Skip to content

Commit

Permalink
Fix off by one error in SPI bootloader
Browse files Browse the repository at this point in the history
s4 contains the number of bytes copied so far, and s0 contains the number of bytes to copy. When these are equal, we have copied everything and we shouldn't run one more iteration.

If we run the extra iteration and the flash image is being loaded so it lines up with the end of system memory, this causes a write past the end of system memory.
  • Loading branch information
Barabas5532 authored and olofk committed Dec 11, 2024
1 parent 2806f48 commit 9a91980
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion sw/spi_uimage_loader.S
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ copy_to_ram:
addi s4, s4, 4

/* Check if file is completely copied */
bge s0, s4, copy_to_ram
bgt s0, s4, copy_to_ram

/* Jump to entry point */
goto_reset:
Expand Down

0 comments on commit 9a91980

Please sign in to comment.