Closed exp closed 3 years ago
From my experience this cast looks correct and required. I guess that most USB MCUs tested simply do not have that much space, so the issue never popped up.
Oops - yes, with the shift it will implicitly up-cast the uint8_t to a uint16_t, but no further. Thanks!
When loading the bytes from the USB serial stream that represent the current position in words, BootloaderCDC uses a trick which is too clever for GCC in order to populate a u32 and double the integer value.
In my testing, when the size of the flashed item exceeds 32k, the asm generated by avr-gcc (both v5 and v10) incorrectly manipulates the u32, leading to its upper 2 bytes being set to 0xFF. This then fails the
Address < BOOT_START_ADDR
test inIsPageAddressValid
.This PR adds an explicit u32 cast to the function calls, leading to avr-gcc treating the u32 correctly and populating all 4 bytes.
Disclaimer: I am not familiar with AVR ASM and have based this on functional testing as well as an approximate analysis.