Question
Jump to Bootloader issues
Posted on June 06, 2015 at 12:37
Hello everyone,
I am using a stm32L151CB (PID : 0x416) and I am trying to jump to bootloader while inside a program. Here is the function I use :
void
(* sys_mem_boot_jump) (
void
);
void
bootloader_init(u4_t boot_loader_status) {
sys_mem_boot_jump = (
void
(*) (
void
)) (*(( u4_t *)SYS_MEM_ADDRESS));
if
(boot_loader_status == 1) {
RCC_DeInit();
SysTick->CTRL = 0;
SysTick->LOAD = 0;
SysTick->VAL = 0;
__set_PRIMASK(1);
__set_MSP(RAM_MEM_ADDRESS);
sys_mem_boot_jump();
while
(1);
}
}
with :
1.
#define SYS_MEM_ADDRESS 0x1FF00004
2.
#define RAM_MEM_ADDRESS 0x20000800
(from the Application note 2606, Table 68)
The code seems to work because when I try to send 0x7F on the serial port, the Stm32 answer ACK. But after, when I send the first byte of the command (for example 0x21 for the Go command), the device answer NACK. After this NACK, I can send the full command ( 0x21 + 0xDE) and jump to 0x08000000.
The fact that the device answer NACK on the first part of a command don't enable me to use the application Flash Loader demonstrator.
Do you have any idea why the bootloader has such a behavior with the first command?
Thanks,
Romain
#stm32-bootloader