Question
STM32F407 custom bootloader problem
Posted on June 14, 2016 at 14:38
Hello!
I am working in a project that I want to use a custom bootloader for firmware update of stm32f407, I had developed for stm32f107 and all works fine, but for STM32F407 I getting some problems. Below I posted the source code of the bootloader, debugging this code when execute this line ''if (((*(__IO uint32_t*)ApplicationAddress) & 0x2FFE0000 ) == 0x20000000) '' always return 0, I don't know why this occur because in application firmware I defined ''&sharpdefine VECT_TAB_OFFSET 0x8000'' all looks correct but never enter if condition and execute Jump_To_Application. On Flash address (0x80E0000) is located the firmware for update the firmware on address (0x8008000). Bootloader.c &sharpdefine ApplicationAddress (0x8008000) &sharpdefine ApplicationAddress_Firmware (0x80E0000) typedef void (*pFunction)(void); uint32_t JumpAddress; pFunction Jump_To_Application; /*---------------------------------------------------------------------------- Main Thread 'main': Run Network *---------------------------------------------------------------------------*/ int main (void) { uint8_t* App_ptr; SystemClock_Config();//initialize clocks BKP_Init(); if (HAL_RTCEx_BKUPRead(&hrtc, RTC_BKP_DR6) == 0xA5A5){ if (((*(__IO uint32_t*)ApplicationAddress_Firmware) & 0x2FFE0000 ) == 0x20000000) { /* Jump to user application */ JumpAddress = *(__IO uint32_t*) (ApplicationAddress_Firmware + 4); Jump_To_Application = (pFunction) JumpAddress; App_ptr = (uint8_t*)Jump_To_Application; if( (*App_ptr != 0xFF) && (App_ptr) ) { /* Initialise user application's Stack Pointer */ __set_MSP(*(__IO uint32_t*) ApplicationAddress_Firmware); Jump_To_Application(); } } }else{ if (((*(__IO uint32_t*)ApplicationAddress) & 0x2FFE0000 ) == 0x20000000) { /* Jump to user application */ JumpAddress = *(__IO uint32_t*) (ApplicationAddress + 4); Jump_To_Application = (pFunction) JumpAddress; App_ptr = (uint8_t*)Jump_To_Application; if( (*App_ptr != 0xFF) && (App_ptr) ) { /* Initialise user application's Stack Pointer */ __set_MSP(*(__IO uint32_t*) ApplicationAddress); Jump_To_Application(); } } } } Another think is the Scatter file looks good. Bootloader Scatter File ; ************************************************************* ; *** Scatter-Loading Description File generated by uVision *** ; ************************************************************* LR_IROM1 0x08000000 0x00007FFF { ; load region size_region ER_IROM1 0x08000000 0x00007FFF { ; load address = execution address *.o (RESET, +First) *(InRoot$$Sections) .ANY (+RO) } RW_IRAM1 0x20000000 0x00020000 { ; RW data .ANY (+RW +ZI) } RW_IRAM2 0x10000000 UNINIT 0x00010000 { .ANY (+RW +ZI) } } Application Scatter File ; ************************************************************* ; *** Scatter-Loading Description File *** ; ************************************************************* LR_IROM1 0x08008000 0x000D7FFF { ; load region size_region ER_IROM1 0x08008000 0x000D7FFF { ; load address = execution address *.o (RESET, +First) *(InRoot$$Sections) .ANY (+RO) } RW_IRAM1 0x20000000 0x00020000 { ; RW data .ANY (+RW +ZI) } RW_IRAM2 0x10000000 UNINIT 0x00010000 { .ANY (+RW +ZI) } } Thanks, Giovani #stm32-stm32f4-bootloader