Offset of program Flash = Systick irq don't work
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
to create the code of my app in ahttp://www.st.com/en/evaluation-tools/b-l475e-iot01a.html
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 &sharpdefine 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
load
♯ 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.
continue
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
http://www.st.com/en/development-tools/stm32cubeprog.html
). 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
https://community.st.com/0D50X00009XkfHiSAJ
, 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.
#bootloader