Sysprogs forums › Forums › VisualGDB › How to push code to SRAM rather than FLASH
Tagged: sram debug flash linker
- This topic has 11 replies, 2 voices, and was last updated 2 weeks, 5 days ago by
bflannery.
-
AuthorPosts
-
April 23, 2025 at 15:09 #36590
Sherlock
ParticipantCan any community member shed light on how to do this?
I gather I should add a second linker script (which I can create by creating a new empty project and specifying SRAM as target and then copying this script into my project, that gives me two scrips to choose from for linking, a “flash” one and a “sram” one). but what else must I do?
I cant see any project options/settings that let me tell the system to push the code to SRAM as opposed to FLASH.
My projects are STM32 F4 Nucleo projects FYI.
Thank you.
April 23, 2025 at 15:32 #36591bflannery
ParticipantWhen you create your project you can specify generically whether you want your program to execute from FLASH or SRAM.
If you want the option to choose simply add another executable target and differentiate them by name. Then you could right click on the one you want to use and press “Set as startup target”. Assuming you are using cmake this can be done just by making two calls to add_bsp_based_executable with different NAME values. You can also specify the linkerscript via LINKER_SCRIPT within that call.
Don’t forget to relocate your vector table in the SRAM version of your executable.
-
This reply was modified 3 weeks ago by
bflannery.
April 24, 2025 at 08:22 #36593Sherlock
ParticipantI see, OK that’s an idea for me to ponder.
I’m wondering if I can somehow define a VS build configuration for this, like we have “Debug” and “Release” already defined, we can add more and I’ve done this on large C# applications but not with VisualGDB.
I’d have
Debug – FLASH, Debug – SRAM, Release – FLASH, Release – SRAM for example.
-
This reply was modified 2 weeks, 6 days ago by
Sherlock.
April 24, 2025 at 08:38 #36595Sherlock
ParticipantIt’s confusing, I’d assumed that if I created a new simple blinker project but specified SRAM rather than FLASH when creating the project, then it would just work and publish the code to RAM and be debuggable etc.
But that’s not true, it’s looking like one cannot do this without some additional manual steps or editing and I can’t find any documentation about this.
April 24, 2025 at 08:45 #36596Sherlock
ParticipantOK I was wrong, there’s a small misleading thing in the UI where it says
Program FLASH memory: Always Never If rebuilt since last load
(That probably should say: Publish to memory:… and not be hard coded as FLASH).
I’d set that to “Never” but that was an error, if I create the project to target SRAM then I should leave the above option set (i.e do not set it to “Never”).
I did this and it publishes it to SRAM, I debugged he code and looked at the assembly and it is indeed in RAM and not FLASH.
I’m going to compare two projects and see what differs between an initial choice of FLASH and SRAM then I might be able to make these distinct configurations…
-
This reply was modified 2 weeks, 6 days ago by
Sherlock.
April 24, 2025 at 08:55 #36598Sherlock
ParticipantOK I got it, when we create two new identical projects but choose SRAM for one and FLASH for the other when creating the projects, only two files contain differences:
and
There might now be a way to define two configurations…
April 24, 2025 at 09:20 #36602Sherlock
ParticipantThe file stm32.props is referenced by the VS build settings and so that can easily be made part of a build configuration, but the file stm32.xml is not something I can find referenced anywhere…
OK it is referenced, the various .vgdbsettings files refer to stm32.xml and so I think this can be done with a bit of experimentation.
Perhaps there’s a case here for Sysprogs to expose this a build time option?
-
This reply was modified 2 weeks, 6 days ago by
Sherlock.
April 24, 2025 at 09:51 #36607bflannery
ParticipantI made a CMAKE example for you.
https://github.com/pseudotronics/visualgdbexamples/tree/main/DualTargetsExample
April 24, 2025 at 12:39 #36609Sherlock
ParticipantThank you Mr Flannery!
I’ve only ever used MSBuild based projects, so perhaps I need to move away from that.
Is that kind of project created using the “Advanced CMake” option when I create a new project?
-
This reply was modified 2 weeks, 6 days ago by
Sherlock.
April 24, 2025 at 14:50 #36614bflannery
ParticipantYes it uses the Advanced CMake project type.
April 24, 2025 at 16:21 #36615Sherlock
ParticipantHi, so if one is in VS with that solution open, how does one choose which of the two ways to publish the code to the board?
April 25, 2025 at 06:36 #36618 -
This reply was modified 3 weeks ago by
-
AuthorPosts
- You must be logged in to reply to this topic.