cancel
Showing results for 
Search instead for 
Did you mean: 

Problem! flash loader doesn't work after I jump to bootloader in stm32f446rc

gabriel23
Associate II
Posted on May 10, 2018 at 19:06

Hello, I have a board with stm32f446rc processor and I don't get to connect bootloader with stm32 flashloader.

Following below this function used to access the bootloader on chip. I am using USART1 (PA9,PA10)  to connect RS232.

void JumpToBootloader(void) {

void (*SysMemBootJump)(void);

/**

* Step: Set system memory address.

*

* For STM32F446, system memory is on 0x1FFF 0000

* For other families, check AN2606 document table 110 with descriptions of memory addresses

*/

volatile uint32_t addr = 0x1FFF0000;

/**

* Step: Disable RCC, set it to default (after reset) settings

* Internal clock, no PLL, etc.

*/

RCC_DeInit();

__HAL_RCC_SYSCFG_CLK_ENABLE();

/**

* Step: Disable systick timer and reset it to default values

*/

SysTick->CTRL = 0;

SysTick->LOAD = 0;

SysTick->VAL = 0;

/**

* Step: Disable all interrupts

*/

__disable_irq();

__DSB();

/**

* Step: Remap system memory to address 0x0000 0000 in address space

* For each family registers may be different.

* Check reference manual for each family.

*

* For STM32F4xx, MEMRMP register in SYSCFG is used (bits[1:0])

* For STM32F0xx, CFGR1 register in SYSCFG is used (bits[1:0])

* For others, check family reference manual

*/

__HAL_SYSCFG_REMAPMEMORY_SYSTEMFLASH(); //Call HAL macro to do this for you

/**

* Step: Set jump memory location for system memory

* Use address with 4 bytes offset which specifies jump location where program starts

*/

/* Remap is bot visible at once. Execute some unrelated command! */

__DSB();

__ISB();

SysMemBootJump = (void (*)(void)) (*((uint32_t *)(addr + 4)));

/**

* Step: Set main stack pointer.

* This step must be done last otherwise local variables in this function

* don't have proper value since stack pointer is located on different position

*

* Set direct address location which specifies stack pointer in SRAM location

*/

__set_MSP(*(uint32_t *)addr);

/**

* Step: Actually call our function to jump to set location

* This will start system memory execution

*/

SysMemBootJump();

/**

* Step: Connect USB<->UART converter to dedicated USART pins and test

* and test with bootloader works with STM32 Flash Loader Demonstrator software

*/

while(1);

}
5 REPLIES 5
Posted on May 10, 2018 at 19:12

Does it work when you reset with BOOT0=High?

Use a debugger and step into the ROM and get a better understanding about what is actually happening.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Pavel A.
Evangelist III
Posted on May 11, 2018 at 16:01

volatile uint32_t addr = 0x1FFF0000;

You've forgotten to set bit 0 in the jump address. It is required for the thumb instruction set.

- pa

Posted on May 11, 2018 at 15:12

Thank you Clive,

so I tried to put in bootloader mode with BOOT0=HIGH, but it didn't work communication between board and stm32 loader.

I don't know what is happening.

Posted on May 11, 2018 at 15:40

The loader is going to be highly sensitive to transitions on any of the pins/interfaces where valid activity might be expected. This might take precedence over your signalling on PA9/PA10 later.

Review board design and pin usage.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on May 11, 2018 at 16:03

>>You've forgotten to set bit 0 in the jump address. It is required for the thumb instruction set.

Yeah, that's not how it works in this context, it is a table full of addresses, not the address it is calling. The address of the ROM Vector Table is correct.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..