AnsweredAssumed Answered

Offset of program Flash = Systick irq don't work

Question asked by Hector Fernandez on Apr 9, 2018
Latest reply on Apr 9, 2018 by Hector Fernandez

I am trying to develop a custom bootloader, using tutorials and examples from everywhere.

Currently I am developing the "App" which is located in a Flash region different from the Bootloader region, so I am forced to push my App program code forward in a different flash position than 0x8000000 (initial flash position).


I am using this tutorial to create the code of my app in a B-L475E-IOT01A evaluation board. So, I started creating the project structure using STM32CubeMX 4.25.0. Then, I changed:

  • In STM32L475VG_FLASH.ld, I modified FLASH section: FLASH (rx)      : ORIGIN = 0x800C000, LENGTH = 976K
  • In system_stm32l4xx.c, I modified #define VECT_TAB_OFFSET  0xC000
  • In the debug configuration, I added this piece of code to the "Startup script":
# Set flash parallelism mode to 32, 16, or 8 bit when using STM32 F2/F4 microcontrollers
# 2=32 bit, 1=16 bit and 0=8 bit parallelism mode
monitor flash set_parallelism_mode 2

# Load the program executable

# Reconfigure vector table offset register to match the application location
set *0xe000ed08 = 0x800C000

# Get the application stack pointer (First entry in the application vector table)
set $sp = *(unsigned int*)0x800C000

# Get the application entry point (Second entry in the application vector table)
set $pc = *(unsigned int*)0x800C004

# Enable Debug connection in low power modes (DBGMCU->CR)
set *0xE0042004 = (*0xE0042004) | 0x7
# Set a breakpoint at main().
tbreak main

# Run to the breakpoint.

In the main.c file, I added a toggle led routine using systicks inside the infinite loop.

The main problem I have with my implementation is that SysTick_Handler() is never called, so systicks counter is never increased.

From 0x08000000 to 0x0800C000 in Flash memory, there is nothing (0xFF according to stm32cubeprogrammer). My code starts in 0x0800C000, where is the vector table.


After doing research, I noticed that if I write the booloader code in the section 0x08000000 to 0x0800C000, the app code and systicks work. So, it means my app code is using the vector table of the bootloader (at 0x00000000 position). But if I erase those flash sectors again, my app don't work correctly.


In other forums and discussions, it is said that it is only necessary to change the STM32L475VG_FLASH.ld file and VECT_TAB_OFFSET constant. So, what am I missing?

According to Jump to custom bootloader SysTick doesn't work, I should disable IRQ. But I can't do it because the code comes from Reset conditions.


I have attached my Atollic Truestudio project too for better feedback.


I am not using the booloader to jump to my program code. I am just using the Atollic Studio debugger (as the tutorials says) to jump to the starting flash position.


Thank you very much.