blue_st_sdk.firmware_upgrade.utils package

Submodules

blue_st_sdk.firmware_upgrade.utils.firmware_file module

firmware_file

The firmware_file module is responsible for handling a firmware file.

class blue_st_sdk.firmware_upgrade.utils.firmware_file.FirmwareFile(filename)[source]
__init__(filename)[source]

Constructor.

Args:
filename (str): File name of the firmware file.
Raises:
OSError if the file is not found or is inaccessible.
close()[source]

Close the firmware file.

Raises:
OSError if the file is not found or is inaccessible.
get_crc_32()[source]

Getting the 32 bit CRC of the firmware file.

The file size must be multiple of 32 bits.

Raises:
ValueError if the firmware file can not be read properly.
Returns:
int: The CRC of the firmware file.
get_size()[source]

Get the firmware size in bytes.

Returns:
int: The firmware size in bytes.
get_type()[source]

Get the firmware type.

Returns:
blue_st_sdk.firmware_upgrade.utils.firmware_file.FirmwareType: The firmware type.
open()[source]

Open the firmware file.

Raises:
OSError if the file is not found or is inaccessible.
Returns:
file: The file descriptor of the firmware file.
class blue_st_sdk.firmware_upgrade.utils.firmware_file.FirmwareType[source]

Bases: enum.Enum

Firmware type.

Currently only BIN format is handled.

BIN = 1
UNKNOWN = 0

blue_st_sdk.firmware_upgrade.utils.stm32crc32 module

firmware_file

The firmware_file module is responsible for handling a firmware file.

class blue_st_sdk.firmware_upgrade.utils.stm32crc32.STM32Crc32[source]

Bases: object

Computes the CRC32 by using the same algorithm implemented by STM32 chips.

The algorithm works on unsigned integer 32 numbers, hence the buffer must have a length multiple of 4.

CRC_TABLE = [0, 79764919, 159529838, 222504665, 319059676, 398814059, 445009330, 507990021, 638119352, 583659535, 797628118, 726387553, 890018660, 835552979, 1015980042, 944750013]

Nibble lookup table for 0x04C11DB7 polynomial.

INITIAL_VALUE = 4294967295

Initial value of the CRC.

__init__()[source]

Constructor.

get_value()[source]

Get the CRC value.

Returns:
int: The value of the current CRC.
reset()[source]

Reset the CRC to the initial value.

update(data)[source]

Update the value of the CRC.

Size of data in bytes must be multiple of 4.

Args:
data (bytearray): Data to compute the CRC value of.
Raises:
ValueError if the length of the data is not multiple of 4.

Module contents