I am new to boot loader program so this question may seem obvious. The main() codes for the STM USB DFU program for the STM32F4 is pasted below. I am a bit confused that I thought the USB DFU boot loader program should resides at address 0x1FFF77DE stated on STM AN2606 Application note. But on this USB DFU example, this program is supposed to be loaded onto memory location 0x8000000 which is usually for application. So if the program below is used to program a user binary, where would the user app go if the USB DFU is already at 0x8000000?
Thanks.
/* Check if the USER Button is pressed */ if(BSP_PB_GetState(BUTTON_USER) == 0x00) { /* Test if user code is programmed starting from USBD_DFU_APP_DEFAULT_ADD address */
if(((*(__IO uint32_t*)USBD_DFU_APP_DEFAULT_ADD) & 0x2FFE0000 ) == 0x20000000) { /* Jump to user application */ JumpAddress = *(__IO uint32_t*) (USBD_DFU_APP_DEFAULT_ADD + 4); JumpToApplication = (pFunction) JumpAddress;
/* Initialize user application's Stack Pointer */ __set_MSP((*(__IO uint32_t*) USBD_DFU_APP_DEFAULT_ADD )); JumpToApplication(); } }
/* Otherwise enters DFU mode to allow user programming his application */ /* Init Device Library */ USBD_Init(&USBD_Device, &DFU_Desc, 0);
/* Add Supported Class */ USBD_RegisterClass(&USBD_Device, USBD_DFU_CLASS);
/* Add DFU Media interface */ USBD_DFU_RegisterMedia(&USBD_Device, &USBD_DFU_Flash_fops);
/* Start Device Process */ USBD_Start(&USBD_Device);
The default app. address is at 0x08008000 so that leaves 32K (0x8000) for the DFU application. The build of the DFU seems like about 13K.
#define USBD_DFU_MAX_ITF_NUM 1 #define USBD_DFU_XFER_SIZE 1024 #define USBD_DFU_APP_DEFAULT_ADD 0x08008000 #define USBD_DFU_MAX_NB_OF_SECTORS 12
Program Size: Code=12564 RO-data=608 RW-data=240 ZI-data=4128 "STM32F446ZE_Nucleo_USBD-FS/\.axf" - 0 Error(s), 0 Warning(s). Build Time Elapsed: 00:00:07