AnsweredAssumed Answered

My own bootloader

Question asked by Peter Janco on Jan 16, 2019
Latest reply on Jan 18, 2019 by Peter Janco

Hi,

I have IMXRT1050-EVKB board with Hyperflash and I want to make my own TFTP bootloader. I am using SDK example "lwip_updecho_bm" as base project for my future bootloader. But I am not able to do jump from bootloader to application. I am not sure, if I have configured memory sections corectly. I will appreciate some help. I prefer to use "manage linker script" instead of manually edited *.ld file.


This is my memory configuration of bootloader project:

 

This is my memory configuration of application project:

 

This is my "jump_to_application" function. I am inspired with this function in "flashloader" project example in SDK:

#define APP_ADDRESS 0x60080000
static void jump_to_application()
{
void (*entry)(void);
uint32_t pc, sp;

sp = *((volatile uint32_t*)APP_ADDRESS);
pc = *((volatile uint32_t *)(APP_ADDRESS + 4));
entry = (void (*)(void))pc;

if((sp == 0x00000000)||(sp == 0xffffffff)||(pc == 0x00000000)||(pc == 0xffffffff))
return;

SCB->VTOR=(uint32_t)(APP_ADDRESS);

__set_MSP(sp);
__set_PSP(sp);

entry();
}

 

First, I erased whole FLASH memory. Then I uploaded application project. Then I uploaded bootloader project. I can see in debug session of bootloader project:

sp = 0x81e00000

pc = 0x60080325

 

So, it is look like the application code is in on the correct position in FLASH. But after I call entry() function, it does not jump into application. Instead of this it jump into begin of bootloader project main() function.

 

I have another question. I can see in generated *.ld file:

__base_FLASH_APP = 0x60080000  ; /* FLASH_APP */  

__top_FLASH_APP = 0x60080000 + 0x3f80000 ; /* 65024K bytes */

 

Is there a way how to use this constants in my code?

Outcomes