STM32F1 DFU CubeMX and Example Code from STM32Cube_FW_F1_V1.4.0 repo
Hi
When creating a project with CubeMX and selecting DFU as FS class for the USB IP one gets presented with a skeleton set of empty functions as interface.
Within the file /Src/usbd_dfu_if.c are the following functions:
In STM32Cube_FW_F1_V1.4.0 one can find these functions for the DFU standalon example within
The erase function there is implemented as:
Because I have created a bootloader I didn’t use the predefined adresses USBD_DFU_APP_END_ADD USBD_DFU_APP_DEFAULT_ADD but my own Adresses taking the offset of my application into account.
But the function is silly an seemingly untested. The parameter “Add” is not used at all.
The effect is, that for every page (1024 bytes) to be programmed the whole flash memory from APPLICATION_ADDRESS onwarts gets erased. After the download with dfu-util has finished there are only FFs in the memory.
The correct or at least functioning implemetation is as follows:
By the way I have a question too:
Can someone tell me how to avoid it, that the programming of my application with an offset via openocd and debugger do not erase the bootloader first?
Dieter