cancel
Showing results for 
Search instead for 
Did you mean: 

Software DFU : where are targets and available sectors specified ?

JulienD
Senior
Posted on May 12, 2016 at 17:53

Hi,

I need a custom DFU bootloader. I started from the one given as example with Cube 1.5. It is located in STM32Cube_FW_L1_V1.5.0\Projects\STM32L152D_EVAL\Applications\USB_Device\DFU_Standalone With this, I succeeded in bootloading my own small test application on the device (STM32L152ZDT). Then, I tried to upload a bigger app. The upload is ok but the apps doesn't work. In DFUse demo app, and the hardware bootloader, I can see that there are 1536 available sectors of 256 bytes each which sounds right (1536/4= 384K). On the other hand, with the software bootloader, the number of available sectors shown is 96 which obviously is a wrong value and is really less than what I need to store my app. Another curious thing is that each sector has a size of 1Kb while the reference manual of the microcontroler shows that a sector is 256 bytes. I went through the code but didn't find where those 96 are specified. I found the following constants:

#define USBD_DFU_APP_DEFAULT_ADD 0x08007000 /*ADDR_FLASH_PAGE_14*/
#define USBD_DFU_APP_END_ADD 0x08020000 /*ADDR_FLASH_PAGE_64*/

I changed the second one to

#define USBD_DFU_APP_END_ADD 0x08060000 /*ADDR_FLASH_PAGE_64*/

which suits better the 384K of flash but that did not change what's shown in DFUse app. In fact, the code shows that this variable is used only to erase the flash. In DFUse demo app, if I double click on the target 0 with 96 sectors, I can see that sectors from 0 to 11 are only readable. I suspect that, this is where the bootloader is located but once again, I can't find where this information comes from. My questions are: - Where, in the code of the software bootloader, can I find the definition of the targets, sectors and their characteristics ? - What are the only readable sectors and where are they defined ? Joined : - two captures of DFUse demo app, one with hardware bootloader and one with software bootloader. - code of the demo bootloader. Thanks Julien
1 REPLY 1
JulienD
Senior
Posted on May 12, 2016 at 19:28

Ok, I found that it was on this cabalistic line :

-#define FLASH_DESC_STR ''@Internal Flash /0x08000000/12*01Ka,84*01Kg''

I also discovered that in response on a sector erase the function erases the whole flash except the bootloader. No need to say that this function is called for each sector...