cancel
Showing results for 
Search instead for 
Did you mean: 

Project with own bootloader goes into "b Infinite_Loop" when an timer interrupt occure.

sde c.1
Senior II

Hi,

i have written a custom bootloader + end user application for STM32G030K8.

When i run the bootloader seperately , then the bootload code works as expected

When i run the user application from addres 0x0800000 then the code works fine.

But after i make the changes to be able to build and debug bootloader + enduser application, some things go wrong...

  • changes made are

1) in end user applications system_stm32g0xx.c , i have changed the vect tab offset

#define VECT_TAB_OFFSET     0x00005800U 

2) in end user applications STM32G030K8TX_FLASH.ld , i have changed the origin FLASH  (rx)  : ORIGIN = 0x8005800,  LENGTH = 40K

3) in bootloader applications STM32G030K8TX_FLASH.ld , i have changed the length

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

(2 k is used to write data to flash)

  • in debug settings

0693W00000Hrh7iQAB.pngwhen i run the debugger with above settings , the debugger starts at in main(void) from the end user application? I expect the debugger would start in main of the bootloader.

But when i press the reset chip button, 0693W00000Hrh9FQAR.pngthen the debugger jumps to the first line of the bootloader (as expected).

At this point the debugger start running the bootload program, and jumps to the end user main loop as designed, so the bootloader does what i need to do.

In the end user application main loop i can step everything until the first timer 16 interrupt is fired, when that happens then the code is running in the b infinite_loop...

/**
 * @brief  This is the code that gets called when the processor receives an
 *         unexpected interrupt.  This simply enters an infinite loop, preserving
 *         the system state for examination by a debugger.
 *
 * @param  None
 * @retval None
*/
  .section .text.Default_Handler,"ax",%progbits
Default_Handler:
Infinite_Loop:
  b Infinite_Loop
  .size Default_Handler, .-Default_Handler

It seems that the interrupt vector is at a wrong address . what did i miss?

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
sde c.1
Senior II

Found the issue , it seems that i needed to uncomment this line in system_stm32g0xx.c

/* #define USER_VECT_TAB_ADDRESS */

When this line is uncommented , then the VTOR registry will be updated with the VECT_TAB_OFFSET value.

I have created bootloader and user applications before in the G4 series, in those projects i did not need to uncomment this line.

Anyway, glad i have found it.

View solution in original post

1 REPLY 1
sde c.1
Senior II

Found the issue , it seems that i needed to uncomment this line in system_stm32g0xx.c

/* #define USER_VECT_TAB_ADDRESS */

When this line is uncommented , then the VTOR registry will be updated with the VECT_TAB_OFFSET value.

I have created bootloader and user applications before in the G4 series, in those projects i did not need to uncomment this line.

Anyway, glad i have found it.