How to push code to SRAM rather than FLASH

Sysprogs forums Forums VisualGDB How to push code to SRAM rather than FLASH

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #36590
    Sherlock
    Participant

    Can 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.

     

    #36591
    bflannery
    Participant

    When 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.
    #36593
    Sherlock
    Participant

    I 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.
    #36595
    Sherlock
    Participant

    It’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.

     

    #36596
    Sherlock
    Participant

    OK 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.
    #36598
    Sherlock
    Participant

    OK 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:

    image

    and

    image

    There might now be a way to define two configurations…

     

    • This reply was modified 2 weeks, 6 days ago by Sherlock.
    • This reply was modified 2 weeks, 6 days ago by Sherlock.
    • This reply was modified 2 weeks, 6 days ago by Sherlock.
    #36602
    Sherlock
    Participant

    The 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.
    #36607
    bflannery
    Participant
    #36609
    Sherlock
    Participant

    Thank 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.
    #36614
    bflannery
    Participant

    Yes it uses the Advanced CMake project type.

    #36615
    Sherlock
    Participant

    Hi, 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?

    #36618
    bflannery
    Participant

    Right click on the target you want to load (within the solution explorer) and click “Set as Startup Target” it should be the first option.

    The one that is bolded is the current startup target.

    • This reply was modified 2 weeks, 5 days ago by bflannery.
Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.