cancel
Showing results for 
Search instead for 
Did you mean: 

Jump to Bootloader issues

romain2
Associate III
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
1 REPLY 1
romain2
Associate III
Posted on June 06, 2015 at 17:26

I just found the answer :

It was necessary to de-init USART1 as follow :


void
bootloader_init(u4_t boot_loader_status) {

int
i;

sys_mem_boot_jump = (
void
(*) (
void
)) (*(( u4_t *)SYS_MEM_ADDRESS));

if
(boot_loader_status == 1) {

USART_DeInit(USART1);

RCC_DeInit();

SysTick->CTRL = 0;

SysTick->LOAD = 0;

SysTick->VAL = 0;


__set_PRIMASK(1);


__set_MSP(RAM_MEM_ADDRESS);


sys_mem_boot_jump();


} 

}

Now I can send commands to the device using serial port. But when I try to use the Go command with the adress 0x08000000 the program doesn't restart properly (GPIO don't work for example). I succeed a good restart by sending the adress of the function NVIC_SystemReset() to the Go command. I think that this isn't a good way to do this. I would like to know if there is a better method to restart my program ? Thanks