Checksums stored or exchanged by the firmware.
More...
|
| #define | PBL_CRC32_RESIDUE 0x2144DF1CU |
| | CRC-32 of a message with its little-endian CRC-32 appended, when the message is intact.
|
| |
|
| uint8_t | pbl_crc8 (uint8_t crc, const void *data, size_t len) |
| | CRC-8/OPENSAFETY.
|
| |
| uint8_t | pbl_crc8_reversed (uint8_t crc, const void *data, size_t len) |
| | pbl_crc8() consuming data from its last byte to its first.
|
| |
| uint32_t | pbl_crc32 (uint32_t crc, const void *data, size_t len) |
| | CRC-32/ISO-HDLC, as used by zlib and PNG.
|
| |
| void | pbl_crc32_legacy_init (struct pbl_crc32_legacy *ctx) |
| | Start a legacy checksum.
|
| |
| void | pbl_crc32_legacy_update (struct pbl_crc32_legacy *ctx, const void *data, size_t len) |
| | Feed data to a legacy checksum.
|
| |
| uint32_t | pbl_crc32_legacy_finish (struct pbl_crc32_legacy *ctx) |
| | Finish a legacy checksum.
|
| |
| uint32_t | pbl_crc32_legacy (const void *data, size_t len) |
| | Legacy checksum of a single buffer.
|
| |
Checksums stored or exchanged by the firmware.
The software implementations are always built. Buffers of at least CONFIG_CRC_HW_MIN_LEN bytes are offloaded to a hardware CRC unit when a driver provides one (see CRC).
Every function takes the running value and returns the updated one, so data can be fed in chunks:
uint32_t crc =
pbl_crc32(0, &hdr,
sizeof(hdr));
uint32_t pbl_crc32(uint32_t crc, const void *data, size_t len)
CRC-32/ISO-HDLC, as used by zlib and PNG.
◆ pbl_crc32_legacy
Running state of the legacy checksum.
The legacy checksum is the CRC-32/MPEG-2 computed by the STM32F2/F4 CRC unit over little-endian 32-bit words, MSB first: the checksum of bytes A B C D E F G H is the CRC of D C B A H G F E. A trailing partial word is zero-padded at the front, so bytes 1 2 3 4 5 6 are checksummed as 4 3 2 1 0 0 5 6. It persists in on-flash and on-wire formats.
Running state of the legacy checksum.
Definition crc.h:85
uint32_t pbl_crc32_legacy_finish(struct pbl_crc32_legacy *ctx)
Finish a legacy checksum.
void pbl_crc32_legacy_update(struct pbl_crc32_legacy *ctx, const void *data, size_t len)
Feed data to a legacy checksum.
void pbl_crc32_legacy_init(struct pbl_crc32_legacy *ctx)
Start a legacy checksum.
| Data Fields |
|
uint8_t |
accumulated_length |
Number of valid bytes in accumulator. |
|
uint8_t |
accumulator[3] |
Bytes of an incomplete word, pending until the next update or finish. |
|
uint32_t |
reg |
CRC register. |
◆ PBL_CRC32_RESIDUE
| #define PBL_CRC32_RESIDUE 0x2144DF1CU |
CRC-32 of a message with its little-endian CRC-32 appended, when the message is intact.
◆ pbl_crc32()
| uint32_t pbl_crc32 |
( |
uint32_t |
crc, |
|
|
const void * |
data, |
|
|
size_t |
len |
|
) |
| |
CRC-32/ISO-HDLC, as used by zlib and PNG.
Compatible with zlib's crc32().
- Parameters
-
| crc | Running value, 0 to start. |
| data | Data to checksum. |
| len | Length of data in bytes. |
- Returns
- Updated CRC.
◆ pbl_crc32_legacy()
Legacy checksum of a single buffer.
- Parameters
-
| data | Data to checksum. |
| len | Length of data in bytes. |
- Returns
- Checksum.
◆ pbl_crc32_legacy_finish()
Finish a legacy checksum.
Pads and consumes any trailing partial word.
- Parameters
-
- Returns
- Checksum of all data fed since pbl_crc32_legacy_init().
◆ pbl_crc32_legacy_init()
Start a legacy checksum.
- Parameters
-
◆ pbl_crc32_legacy_update()
| void pbl_crc32_legacy_update |
( |
struct pbl_crc32_legacy * |
ctx, |
|
|
const void * |
data, |
|
|
size_t |
len |
|
) |
| |
Feed data to a legacy checksum.
- Parameters
-
| ctx | Checksum state. |
| data | Data to checksum. |
| len | Length of data in bytes. |
◆ pbl_crc8()
| uint8_t pbl_crc8 |
( |
uint8_t |
crc, |
|
|
const void * |
data, |
|
|
size_t |
len |
|
) |
| |
CRC-8/OPENSAFETY.
Polynomial 0x2F, zero initial value, no reflection and no final XOR.
- Parameters
-
| crc | Running value, 0 to start. |
| data | Data to checksum. |
| len | Length of data in bytes. |
- Returns
- Updated CRC.
◆ pbl_crc8_reversed()
| uint8_t pbl_crc8_reversed |
( |
uint8_t |
crc, |
|
|
const void * |
data, |
|
|
size_t |
len |
|
) |
| |
pbl_crc8() consuming data from its last byte to its first.
- Parameters
-
| crc | Running value, 0 to start. |
| data | Data to checksum. |
| len | Length of data in bytes. |
- Returns
- Updated CRC.