Jump from custom bootloader to application

Hello, I am trying to build  a custom bootloader which is jumping in the application. In order to do this in a first approach, i wrote a Bootloder which jumps as follows:

For the application I changed the VET_TAB_OFFSET to 0x000A0000UL.

In Keil Settings Target I changed the Read/only Memory Areas:

IROM1 : Start 0x80A000 Size 0x60000

In the Target Options I unchecked Use Memory Layout from Target Dialog

For R/O Base I put 0x080A0000

My scatter file for the application:

LR_IROM1 0x080A0000 0x00060000  {    ; load region size_region
  ER_IROM1 0x080A0000 0x00060000  {  ; load address = execution address
   *.o (RESET, +First)
   *(InRoot$$Sections)
   .ANY (+RO)
   .ANY (+XO)
  }
  RW_IRAM1 0x20000000 0x00020000  {  ; RW data
   .ANY (+RW +ZI)
  }
  RW_IRAM2 0x24000000 0x00080000  {
   .ANY (+RW +ZI)
  }
}

LR_IROM2 0x08100000 0x00100000  {
  ER_IROM2 0x08100000 0x00100000  {  ; load address = execution address
   .ANY (+RO)
  }
}

For the Bootloader

; *************************************************************
; *** Scatter-Loading Description File generated by uVision ***
; *************************************************************

LR_IROM1 0x08000000 0x000A0000  {    ; load region size_region
  ER_IROM1 0x08000000 0x00A0000  {  ; load address = execution address
   *.o (RESET, +First)
   *(InRoot$$Sections)
   .ANY (+RO)
   .ANY (+XO)
  }
  RW_IRAM1 0x20000000 0x00020000  {  ; RW data
   .ANY (+RW +ZI)
  }
  RW_IRAM2 0x24000000 0x00080000  {
   .ANY (+RW +ZI)
  }
}

LR_IROM2 0x08100000 0x00100000  {
  ER_IROM2 0x08100000 0x00100000  {  ; load address = execution address
   .ANY (+RO)
  }
}

I use Keil with the MDK Plus Toolchain on the STM32H753.

I do the jump on the bootloader as follows and nothing happens:

void start_app()
{

	uint32_t JumpAddress = *(volatile uint32_t*) (JUMP_ADDR+4);
	void (*jump_to_application)(void)= (void*) JumpAddress;
	
	

	 HAL_RCC_DeInit();
		__disable_irq();
	__set_MSP(*(__IO uint32_t*) JUMP_ADDR);
	// Disable systick timer and reset it to default values
	SysTick->CTRL = 0;
	SysTick->LOAD = 0;
	SysTick->VAL = 0;
	//__disable_irq();
	//__DSB();
	SCB->VTOR = JUMP_ADDR;
	jump_to_application();
}

What could be the reason?

Parents
  • Hi Jan.

    One situation I have seen was that, if Compiler used no optimization, it actually kept local variables on stack, and when you change MSP then all those variables actually are not there anymore so jump to address which was on stack would be actually jump to unknown (whatever is on the new stack at that location, probably 0).

    Anyways, you should be able to debug your application and will then be able to find out the root cause.

    Best regards, Milorad

Reply
  • Hi Jan.

    One situation I have seen was that, if Compiler used no optimization, it actually kept local variables on stack, and when you change MSP then all those variables actually are not there anymore so jump to address which was on stack would be actually jump to unknown (whatever is on the new stack at that location, probably 0).

    Anyways, you should be able to debug your application and will then be able to find out the root cause.

    Best regards, Milorad

Children
No data