Topic : Copying inram functions to RAM when no main() is defined?

Forum : ST7/STM8

Original Post
Post Information Post
April 9, 2012 - 8:38pm
Guest

I am trying to copy some inram functions to RAM when no main() function is linked in my project (on an STM8L151C8). The problem is that when no main() function is present in a project, the symbol "__address__functionname" is not defined. It looks like this is a result of the static init section not being linked with the project, because no startup code is being linked with the project.

The reason I do not have a main() function is so that the image I am building can be bundled into a firmware file and downloaded to the device in the field through a custom bootloader. The problem is that when main() is defined, the linker inserts a jump at the reset vector (0x8000) to some startup code, but the reset vector needs to be claimed by my bootloader.

Is there a way I can trick the linker into including the static var init block, while not inserting a jump at 0x8000?

Replies
Post Information Post
+1
0
-1
April 10, 2012 - 7:50pm
Guest

I think I solved this problem already. When no main() is present, no startup code is included. The startup code makes a call to InitData(), which results in the linker including the static init block of data. I copied the startup_STM8.asm file to my project and modified it a bit, and everything looks happy.

+1
0
-1
April 16, 2012 - 11:40am
Raisonance Support Team

Yes, You got it!

The linker requires an "entry point" from which it considers all the other segments are derived.
One of the following symbols must be defined in you project for this purpose:
"STARTUP" is the bare startup (direct jump to "main")
"STARTUP_S" is the startup with only SCI initialization
"STARTUP_V" is the startup with only static data initialization
"STARTUP_S_V" is the startup without any initialization
"STARTUP_VB" is the startup with static data and bit initialization
"STARTUP_S_VB" is the startup with SCI, static data and bit initialization

Best regards,