Skip to main content
RFlod.2
Senior
August 21, 2026
Solved

STM32G0 Crash when changing bootloader and application adress

  • August 21, 2026
  • 10 replies
  • 103 views

I am trying to jump from bootloader to application at address 0x08004800 i STM32G070 but it crashes.

The same code worked fine jumping to address  0x08007000

Bootloader jump looks like this:

#define BL_FLASH_START	0x08000000
#define BL_FLASH_SIZE 0x4800 // 18 kB reserverade för BL, OBS! Startadress måste vara alignad mot 32 byte, dvs jämnt delbar med 32..
#define BL_FLASH_END (BL_FLASH_START + BL_FLASH_SIZE-4) // 4 byte checksumma
#define APP_FLASH_BANK_SIZE 0xDC00 // 55 kB / appl bank

// Defines för applikationen
#define FLASH_START (BL_FLASH_START + BL_FLASH_SIZE)

.
.
.
.

HW_WD_Trig();



JumpAddress = *(uint32_t*) (FLASH_START + 4);

Jump_To_Application = (pFunction) JumpAddress;



// disable global interrupt

__disable_irq();



JumpAddress = *(uint32_t*) (FLASH_START + 4);

Jump_To_Application = (pFunction) JumpAddress;



/* Initialize user application's Stack Pointer */

__set_MSP(*(uint32_t*) (FLASH_START));

Jump_To_Application();

 

.ld for bor bootloader looks like:

/* Entry Point */
ENTRY(Reset_Handler)

/* Highest address of the user mode stack */
_estack = 0x20004000;    /* end of 16K RAM */

/* Generate a link error if heap and stack don't fit into RAM */
_Min_Heap_Size = 0;      /* required amount of heap  */
_Min_Stack_Size = 0x800; /* required amount of stack */

/* Specify the memory areas */
MEMORY
{
  FLASH (rx)      : ORIGIN = 0x08000000, LENGTH = 18K 
  RAM (xrw)       : ORIGIN = 0x20000000, LENGTH = 16K /* Reservera 16 kB for data after reset 32K    36K*/
  MEMORY_B1 (rx)  : ORIGIN = 0x60000000, LENGTH = 0K
  }

 

 

and .ld for application looks like

/* Entry Point */
ENTRY(Reset_Handler)

/* Highest address of the user mode stack */
_estack = 0x20004000;    /* end of 16 K RAM */

/* Generate a link error if heap and stack don't fit into RAM */
_Min_Heap_Size = 0;      /* required amount of heap  */
_Min_Stack_Size = 0xBB8;    /*0x900; /*required amount of stack */

/* Specify the memory areas */
MEMORY
{
  FLASH (rx)      : ORIGIN = 0x08004800, LENGTH = 55K
  RAM (xrw)       : ORIGIN = 0x20000000, LENGTH = 16K /*32K Rensas vid uppstart   36K*/
  RAM2 (xrw)      : ORIGIN = 0x20004000, LENGTH = 16K /* Rensas inte vid uppstart */
  MEMORY_B1 (rx)  : ORIGIN = 0x60000000, LENGTH = 0K
  }
 

 

 

 

Is there are another restriction than startadress must be dividable by 32 for jump to work?

 

Best answer by RFlod.2

Found it…

 

in system_stm32g0xx.c I had forgot to change the VECT table from 0x7000 to 0x4000:

/************************* Miscellaneous Configuration ************************/
/*!< Uncomment the following line if you need to relocate your vector Table in
     Internal SRAM. */
/* #define VECT_TAB_SRAM */
#define VECT_TAB_OFFSET  0x4000     /*!< Vector Table base offset field.

 

10 replies

waclawek.jan
Super User
August 21, 2026

it crashes

What does it mean? 

JW

RFlod.2
RFlod.2Author
Senior
August 21, 2026

STM32070 restarts

RFlod.2
RFlod.2Author
Senior
August 21, 2026

I changed to 16 kB bootloader, thus application starts at 0x08004000 and it works

waclawek.jan
Super User
August 21, 2026

Are you interested to find out the reason for “not working”?

If yes, I’d recommend to start with disabling the watchdog during debugging, as that may be the secondary reason for the “restart”. If it was so, the primary reason is that the program won’t execute as expected, and with disabled watchdog then you may be able to debug it as usually, i.e. single-step the jump, observe where does it land, observe what in the target program does not work as expected, perhaps look at the interrupts if they execute as intended (and if not check VTOR), etc.

JW

RFlod.2
RFlod.2Author
Senior
August 21, 2026

Hm, seems like it is crashing again….

 

I cannot connect debug to this device. 

waclawek.jan
Super User
August 21, 2026

Well then use whatever debug facilities you have at hand: output to UART, toggling a pin. You have developed your code somehow, after all, and I don’t believe you never wrote a single bug.

Place the debug “printout” or pin toggle at strategical places: before the jump, just after it, in the main loop, in interrupts, wherever you would suspect the problem is.

Or make a modified device where you can use debug - e.g. run your code on a suitable Nucleo board, etc. You’ll have much better life :-)

JW

RFlod.2
RFlod.2Author
Senior
August 21, 2026

I also verifired that the instruction to execute after jump is  Instr: 0800C389 which same as in bin file

 

RFlod.2
RFlod.2AuthorBest answer
Senior
August 21, 2026

Found it…

 

in system_stm32g0xx.c I had forgot to change the VECT table from 0x7000 to 0x4000:

/************************* Miscellaneous Configuration ************************/
/*!< Uncomment the following line if you need to relocate your vector Table in
     Internal SRAM. */
/* #define VECT_TAB_SRAM */
#define VECT_TAB_OFFSET  0x4000     /*!< Vector Table base offset field.

 

waclawek.jan
Super User
August 24, 2026

Thanks for coming back with the solution. Please mark it as such so that the thread is displayed as resolved.

JW