Skip to content

CalculateChecksum fails for addresses close to the upper end of the program memory range #6

Closed
@bessman

Description

@bessman

CalculateChecksum checks address validity incorrectly 1:

if ( IsLegalRange(pCommand->address, pCommand->address+pCommand->dataLength-1))

Compare with the equivalent check in ReadFlash 2:

if (IsLegalRange(pCommand->address, pCommand->address+pCommand->dataLength/2)

WriteFlash also checks address validity in the same way as ReadFlash 3.

CalculateChecksum's validity constraint is tighter than that of ReadFlash and WriteFlash. As a result, addresses close to the upper end of the program memory range are readable/writable, but not checksummable.

In practice, this does not affect us because the PSLab's firmware currently does not write anything to the affected addresses.

Footnotes

  1. https://github.com/fossasia/pslab-bootloader/blob/5e1616dc1366fb7e08c73000c62aba77432c1327/src/mcc_generated_files/boot/boot_process.c#L445

  2. https://github.com/fossasia/pslab-bootloader/blob/5e1616dc1366fb7e08c73000c62aba77432c1327/src/mcc_generated_files/boot/boot_process.c#L403

  3. https://github.com/fossasia/pslab-bootloader/blob/5e1616dc1366fb7e08c73000c62aba77432c1327/src/mcc_generated_files/boot/boot_process.c#L354

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions