application start address

Post here first, or if you can't find a relevant section!
omaroski
Posts: 11
Joined: Mon Apr 03, 2023 5:36 pm

application start address

Post by omaroski »

Hello,

i'm playing with stm32f407g-disc1 evaluation board and exploring the possibility to update firmware via USB host port (the micro USB one) from a USB memory stick.

From AN3990 i understand that i need to flash the smt32f4 mcu with the "firmware upgrade application" and set my application to start from memory address 0x08008000.

I modified "system_stm32f4xx.c" in the firmware upgrade application with:

Code: Select all

#define VECT_TAB_OFFSET  0x8000
as told in AN3990 page 11.

Connecting a usb stick with my image.bin to the micro USB and hitting the reset button i get the blue LED on which turns off after a few seconds and then the green LED turns on signaling my application has been downloaded to stm32f4.

If i check the stm32f4 memory content with CUBEprogrammer i can see that my application is effectively stored at address 0x08008000

The problem is that my application (simple LED blink) never starts, either if i press user button after download or after board hardware reset.

So i'm missing something or have done something wrong.

From this thread i've read about the build_opt.h file:
viewtopic.php?t=1611

i use STM32 core 2.5.0, the build.opt.h file is not generatated when i export the compilation, so i created it manually and added the following:

Code: Select all

-DVECT_TAB_OFFSET=0x00008000U
placed in the sketch folder, restart Arduino IDE 2.0 and exported the compilation.

However still my blink application won't start so there's defintely something wrong i'm doing here :)

Don't know if it helps but looking at my bin files with and without the build_opt.h they look the same in size

Can you help?
Thank you!
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: application start address

Post by fpiSTM »

You should update the linkerscript to change flash start adress
omaroski
Posts: 11
Joined: Mon Apr 03, 2023 5:36 pm

Re: application start address

Post by omaroski »

Thank you for fast reply.

Unfortunately i don't know what linkerscript is and where i can find it. Can you help?
omaroski
Posts: 11
Joined: Mon Apr 03, 2023 5:36 pm

Re: application start address

Post by omaroski »

Ok, i googled a bit and i guess the linker script is stm32_flash.ld where i can find the following:

Code: Select all

MEMORY
{
  FLASH (rx)      : ORIGIN = 0x08000000, LENGTH = 1024K
  RAM (xrw)       : ORIGIN = 0x20000000, LENGTH = 112K
  MEMORY_B1 (rx)  : ORIGIN = 0x60000000, LENGTH = 0K
}
This is from the upgrade application firmware in stm32f4 package.

Should i change the flash to reflect my application start address?
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: application start address

Post by fpiSTM »

I would try this:

Code: Select all

  FLASH (rx)      : ORIGIN = 0x08008000, LENGTH = 1024K - 32k
And check if the system_stm32f4xx.c well apply the VECT_TAB_OFFSET because it is not well managed from my point of view in the template file:
https://github.com/STMicroelectronics/S ... c#L96-L111

Here you have to define USER_VECT_TAB_ADDRESS and update the VECT_TAB_OFFSET value.
omaroski
Posts: 11
Joined: Mon Apr 03, 2023 5:36 pm

Re: application start address

Post by omaroski »

I've been trying to do the same thing with CubeIDE as explained in ST application note and it works fine.
From CubeIDE project i only need to change the following files:

system_stm32f4xx.c

Code: Select all

#define VECT_TAB_OFFSET  0x8000 /*!< Vector Table base offset field. This value must be a multiple of 0x200. */
changed VECT_TAB_OFFSET from 0 to 0x8000

stm32_flash.ld

Code: Select all

/* Specify the memory areas */
MEMORY
{
  FLASH (rx)      : ORIGIN = 0x08008000, LENGTH = 1024K - 32K
  RAM (xrw)       : ORIGIN = 0x20000000, LENGTH = 112K
  MEMORY_B1 (rx)  : ORIGIN = 0x60000000, LENGTH = 0K
}
With Arduino currently i get multiple compiling errors when i have the build_opt.h file with

Code: Select all

-DVECT_TAB_OFFSET = 0x00008000U
in it. I have tried to uninstall and reinstall the stm32 core but still get the errors at compile time.

Even if i want to modify the stm32 core files to make it work i don't know which files to modify cause they look a bit different from the ones i have in CubeIDE.
Searching in in the core files there are two system_stm32f4xx.c:
hardware\stm32\2.5.0\system\STM32F4xx
https://github.com/stm32duino/Arduino_C ... tm32f4xx.c
hardware\stm32\2.5.0\system\Drivers\CMSIS\Device\ST\STM32F4xx\Source\Templates
https://github.com/stm32duino/Arduino_C ... tm32f4xx.c

the ldscript.ld file which i assume is the one in this location for STM32F407G-DISC1 board:
\hardware\stm32\2.5.0\variants\STM32F4xx\F407V(E-G)T_F417V(E-G)T
https://github.com/stm32duino/Arduino_C ... dscript.ld
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: application start address

Post by fpiSTM »

No space in the build_opt.h file
omaroski
Posts: 11
Joined: Mon Apr 03, 2023 5:36 pm

Re: application start address

Post by omaroski »

ok thank you, now it doesn't spit errors at compile anymore.

However i still can't make the application start from different address.

I have the build_opt.h file with vector offset declared

and the linkerscript modified as this:

Code: Select all

MEMORY
{
  CCMRAM    (xrw)    : ORIGIN = 0x10000000,   LENGTH = 64K
  RAM    (xrw)    : ORIGIN = 0x20000000,   LENGTH = LD_MAX_DATA_SIZE
  FLASH    (rx)    : ORIGIN = 0x8000000 + 0x8000, LENGTH = LD_MAX_SIZE - 0x8000
}
in this last piece of code i just replaced LD_FLASH_OFFSET with desired offset.

Can you help? Thank you!
omaroski
Posts: 11
Joined: Mon Apr 03, 2023 5:36 pm

Re: application start address

Post by omaroski »

ok, somehow after trying sooo many times i made it work by coyping the stm32_flash.ld file (attached) to ldscript.ld

Is there a better way of doing it without replacing core files? I'm sure there is but i can't figure it out.
Attachments
stm32_flash.rar
(1.81 KiB) Downloaded 60 times
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: application start address

Post by fpiSTM »

it seems some other stuff are required for your application.
Post Reply

Return to “General discussion”