Loading...
 

Zephyr project on STM32

   Zephyr Workbench, a VSCode extension to manage Zephyr on STM32.
It enables users to easily create, develop, and debug Zephyr applications.
Main features:
  • Install host dependencies.
  • Import toolchain and SDK.
  • Create, configure, build and manage apps.
  • Debug STM32.
You can directly download it from the VSCode marketplace
For more details, visit the Zephyr Workbench

System Workbench for STM32


Bootloader, linker and application start address

Hello everyone,

I have a problem setting the start address of an application.
I am using an STM32F429 with 2MB of Flash.

In the flash there is a custom bootloader (@0x8000000) that will performs some basic operations, then it will jump at a specified address (e.g. 0x8030000).

The source code of custom bootloader is not accessible.
The generation of the elf file is successful and the map file seems correct (also using objdump).
However when loaded, it meets an hard fault and it does not start.

In main.c file, I execute:
1) HAL_Init();
2) SystemClock_Config()
3) Interrupt Vector remap (I copy g_pfnVectors into a variable, disable irq, make SCB->VTOR poit to the variable, re-enable irq)
4)SystemCoreClockUpdate()


In the linker script of my application, I defined the memory layout like this:
*********************************************************
MEMORY
{
bootloader (rx)  : ORIGIN = 0x08000000, LENGTH = 192K
flash (rx)  : ORIGIN = 0x08030000, LENGTH = 2048K - 192K
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 192K
}
************************************************************

while the sections like this:

************************************************************
SECTIONS
{
.bootloader :
{
. = ALIGN(4);
KEEP(*(.bootloader))
FILL(0xFFFFFF)
. = ALIGN(4);
} >bootloader


/* Reset and ISR vectors */
.isr_vector :
{
isr_vector_start = .;
KEEP(*(.isr_vector))
} >flash
....
************************************************************



Do you have any idea? Could you please help me?
Thanks in advance.


Hello,

thank you for your reply.

Yes, I am sure.
I haven’t specified that I load the bootloader (custom, closed, just .hex file) through openocd, while the application is loaded with a software (custom and closed) that allows me to specify the address in the flash where the application is copied.
I observed with ST-Link Utility the whole flash before and after writing the binary of the application: the .bin file I generate does not overlap the bootloader in the flash memory.


Hi

For relocation of the application I do the change in LinkerScript.ld in MEMORY section as you did.
Also I change in system_stm32xxxx.c, system_stm32l4xx.c for example, the line

#define VECT_TAB_OFFSET offset

where offset would be 0x30000 in your case.

Nothing else and no change within the application at all.

This works, but overwrites the bootloader.. So I have to flash the bootloader thereafter.

Dieter

Thank you for your help Dieter, however it still does not work.

For the linker, I used the configuration posted above.
Then, I opened the file “system_stm32f4xx.c” and changed the line from

  1. define VECT_TAB_OFFSET 0x00

to

  1. define VECT_TAB_OFFSET 0x30000


But no results.
Before doing this I erase the whole flash, then loaded the bootlader (.hex) file with openocd and finally loaded the application binary with the software setting the start address as in the linker script.
If it may helps, the bootloader (.hex file) is generated with Keil, while my application with Eclipse, Ac6 Tool and SW4STM32.

Do you have any other idea?
Would you advise to create a simpler custom bootloader? If so, do you have any resources on how I can build that?

Thank you
a.


Thank you very much Dieter.
I’ll try building the bootloader and see if I can find any error.


Do somebody know how to avoid stlink erase bootloader?

 

Newest Forum Posts

  1. reservation car service Seattle by Jamesprede, 2025-05-01 10:06
  2. Last day: drone bonus by Danielrug, 2025-04-19 16:55
  3. SPI on Nucleo_STMH533RE by higginsa1, 2025-03-25 07:37
  4. SPI on Nucleo_STMH533RE by royjamil, 2025-03-23 11:31
  5. SPI on Nucleo_STMH533RE by higginsa1, 2025-03-23 09:33
  6. Configuring DMA for ADC in SW? by sam.hodgson, 2025-03-04 12:58
  7. Insightful Perspectives on This Subject by davidsycle, 2025-03-04 05:45
  8. Build a project in "release" mode by info@creosrl.it, 2025-02-20 18:12
  9. Build a project in "release" mode by info@creosrl.it, 2025-02-20 17:05
  10. Build a project in "release" mode by tang, 2025-02-20 10:36

Last-Modified Blogs