cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F746 bootloader question

JChen.24
Associate III

Hi,

I am using STM32F746NG.

In the app link file, I set flash to 0x08010000.

MEMORY

{

 RAM  (xrw)  : ORIGIN = 0x20000000,  LENGTH = 320K

 FLASH  (rx)  : ORIGIN = 0x8010000,  LENGTH = 960K /*1024-64K*/

}

In the boot link file, I set flash to 0x08000000.

MEMORY

{

 RAM  (xrw)  : ORIGIN = 0x20000000,  LENGTH = 320K

 FLASH  (rx)  : ORIGIN = 0x8000000,  LENGTH = 64K

/* FLASH  (rx)  : ORIGIN = 0x8000000,  LENGTH = 1024K*/

}

My jump functions looks like:

#define APP_ADDRESS   (uint32_t)0x08010000  

void Bootloader_JumpToApplication(void)

{

 uint32_t JumpAddress = *(__IO uint32_t*)(APP_ADDRESS + 4);

 aFunction Jump = (aFunction)JumpAddress;

 

 HAL_RCC_DeInit();

 HAL_DeInit();

 

 SysTick->CTRL = 0;

 SysTick->LOAD = 0;

 SysTick->VAL = 0;

 

 RCC->CIR = 0x00000000; // disable all interrupts

 SCB->VTOR = APP_ADDRESS;

 

 __set_MSP(*(__IO uint32_t*)APP_ADDRESS);

 Jump() ; //argc, argv); this Jump to the startup assembly reset handler

}

After the jump function, the app does not run.

I see the app.bin file begins with:

00 00 05 20 01 29 04 08

from list file I see the Reset_Handler is at 8042900(the .bin file shows 08042901):

08042900 <Reset_Handler>:

 

 .section .text.Reset_Handler

 .weak Reset_Handler

 .type Reset_Handler, %function

Reset_Handler:

 ldr  r0, =_estack

 8042900: 480d   ldr r0, [pc, #52] ; (8042938 <LoopForever+0x2>)

 mov  sp, r0     /* set stack pointer */

 8042902: 4685   mov sp, r0

/* Call the clock system intitialization function.*/

 bl SystemInit

 8042904: f7d5 f8be bl 8017a84 <SystemInit>

Any thoughts on how to troubleshoot?

I also notice the boot.bin and app.bin has the same first 4 bytes: 20050000. as shown in the app list file:

08042936 <LoopForever>:

 

LoopForever:

  b LoopForever

 8042936: e7fe   b.n 8042936 <LoopForever>

 ldr  r0, =_estack

 8042938: 20050000 .word 0x20050000

 ldr r0, =_sdata

 804293c: 20000000 .word 0x20000000

 ldr r1, =_edata

 8042940: 200009ac .word 0x200009ac

1 REPLY 1

The odd address indicates executable Thumb code, so is expected.

You should step into the app code.

Perhaps if you loader sets up USART and GPIO/LEDs you can use those to checkpoint execution.

Make sure the code in SystemInit() sets the SCB->VTOR correctly, or remove it as you've set it before transferring control.

You might also skip setting the clocks and PLLs, etc, that you have already running in the loader.

Make sure your Hard Fault and Error Handlers output actionable data rather than silent while(1) loops.

Watch you start up code doesn't touch external memory which you haven't already initialized.

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