Hi, first of all, thanks for your very nice and clean-code bootloader, without the typical 'embedded black magic'.
I tried to port your work to an STM32F0 microcontroller and I discovered an insidious problem, when using ARM Compiler v5.06 for µVision (Keil IDE).
there is a misaligned pointer to received_data (because X_PACKET_DATA_INDEX=2), and this leads to HardFault at HAL_FLASH_Program of flash_write, when it tries to copy the value to the flash by dereferencing the pointer.
I solved the problem by receiving XMODEM header and XMODEM data+crc into two differents uint8_t arrays, one for the header and the other one for data+crc.
Hi, first of all, thanks for your very nice and clean-code bootloader, without the typical 'embedded black magic'. I tried to port your work to an STM32F0 microcontroller and I discovered an insidious problem, when using ARM Compiler v5.06 for µVision (Keil IDE).
In details here: https://github.com/ferenc-nemeth/stm32-bootloader/blob/2e1a7acbb5ea8cad32c769f9cb99047387d2c291/Src/xmodem.c#L206
there is a misaligned pointer to
received_data
(because X_PACKET_DATA_INDEX=2), and this leads to HardFault atHAL_FLASH_Program
offlash_write
, when it tries to copy the value to the flash by dereferencing the pointer.I solved the problem by receiving XMODEM header and XMODEM data+crc into two differents
uint8_t
arrays, one for the header and the other one for data+crc.The modified version of
xmodem_handle_packet
function is available here: https://gist.github.com/lrodorigo/3b975205962e403b50c647728d4cef6fI hope this hint will be useful for you and for other people that are trying to adapt this bootloader to other platforms.