You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1024U is an unsigned int, which is 16-bits wide in the PIC24. Therefore, when eraseAddress is greater than 0xFFFF (the largest value which fits in an unsigned int), the check incorrectly concludes that the address is misaligned.
Defining FLASH_ERASE_PAGE_SIZE_IN_INSTRUCTIONS as 1024UL should fix this.
In practice, the impact of this bug is low; if the entire program area is erased at once, the bug does not trigger. I only noticed it when I tried to erase one page at a time.
EraseFlash
returnsBAD_ADDRESS
when given an address over 0xFFFF. This is due to this check 1:FLASH_ERASE_PAGE_MASK
is 2:and
FLASH_ERASE_PAGE_SIZE_IN_INSTRUCTIONS
is 3:1024U
is an unsigned int, which is 16-bits wide in the PIC24. Therefore, wheneraseAddress
is greater than 0xFFFF (the largest value which fits in an unsigned int), the check incorrectly concludes that the address is misaligned.Defining
FLASH_ERASE_PAGE_SIZE_IN_INSTRUCTIONS
as1024UL
should fix this.In practice, the impact of this bug is low; if the entire program area is erased at once, the bug does not trigger. I only noticed it when I tried to erase one page at a time.
Footnotes
https://github.com/fossasia/pslab-bootloader/blob/5e1616dc1366fb7e08c73000c62aba77432c1327/src/mcc_generated_files/boot/boot_process.c#L282 ↩
https://github.com/fossasia/pslab-bootloader/blob/5e1616dc1366fb7e08c73000c62aba77432c1327/src/mcc_generated_files/boot/boot_process.c#L69 ↩
https://github.com/fossasia/pslab-bootloader/blob/5e1616dc1366fb7e08c73000c62aba77432c1327/src/mcc_generated_files/memory/flash.h#L31 ↩
The text was updated successfully, but these errors were encountered: