5.16. Checksum¶
The chksum
module is part of the foxBMS-Modules
layer.
This section describes the embedded part of the checksum feature in foxBMS. For the buildprocess documentation on the checksum feature, see Build Process.
The chksum
module provides the capability to verify data integrity during
runtime for multiple purposes (e.g., firmware validation and verification of
sent/received data).
5.16.1. Module Files¶
5.16.2. Detailed Description¶
The chksum
module offers 2 possibilities to check data integrity,
Modulo32BitAddition
and a hardware based, slightly modified CRC32
implementation. The following short examples demonstrate the usage of the
chksum
module:
uint32_t chksum = CHK_crc32((uint8_t*)0x08000000, 0x1000) -> hashes 4kB of
code, starting at 0x08000000 using CRC32 algorithm
uint32_t chksum = CHK_modulo32addition((uint8_t*)0x08000000, 0x1000) ->
hashes 4kB of code, starting at 0x08000000 using Modulo32BitAddition
algorithm
During the startup, the CHK_crc32
function is used to verify the integrity
of the flashed firmware image. After the calculation of the CRC32 checksum, it
is compared to a hardcoded value within the flashheader struct. When both
values match, the firmware is valid and execution continues. If both values do
not match, an error is reported.
The flashheader contains the validation and checksum information with memory areas of separate software partitions, it gets generated during compilation by an external checksum tool, written in python. Furthermore it also provides the possibility for software versioning.
5.16.3. Checksum Configuration¶
Enabling/disabling of the checksum verification at startup is set by the following macro:
// deactivating the chechsum
#define BUILD_MODULE_ENABLE_FLASHCHECKSUM 0
// activating the chechsum
#define BUILD_MODULE_ENABLE_FLASHCHECKSUM 1
5.16.4. Checksum Default Configuration¶
The default value enables checksum verification at startup.