I couldn’t find online a working bootloader implementation of STM32f103C8 based on generated files from CubeMX, i’ve started porting the F4 DFU to F1, there are two applications:
0x08000000 - DFU Bootloader
0x08008000 - Application
Jump between the address works perfectly, CRC works well, at the init of DFU bootloader i check the CRC at certain address if it matches the application that starts from 0x08008000.
Correctly the main issue is with the implementation of “MEM_If_Write_FS”, this is the code:
uint16_t MEM_If_Write_FS(uint8_t *src, uint8_t *dest, uint32_t Len)
/* USER CODE BEGIN 3 */
uint32_t i = 0;
for(i = 0; i < Len; i+=4)
/* Device voltage range supposed to be 2.7V to 3.6V, the operation will
be done by byte */
if(HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, (uint32_t)(dest+i), *(uint32_t*)(src+i)) == HAL_OK)
/* Check the written value */
if(*(uint32_t *)(src + i) != *(uint32_t*)(dest+i))
/* Flash content doesn’t match SRAM content */
/* Error occurred while writing data in Flash memory */
/* USER CODE END 3 */
When i try to load the app through dfu-util on linux the app freezes on:
Download from image offset 00000000 to memory 08008000-080083ff, size 1024
Poll timeout 50 ms
Poll timeout 0 ms
And on the debugger i get “Flash content doesn’t match SRAM content” on the “MEM_If_Write_FS”.
Is there any way to solve this issue?