setting section / variable address

Sysprogs forums Forums VisualGDB setting section / variable address

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #6462
    sd_tom
    Participant

    I am trying to port some code provided by ST for their Nemo-M1 eval board.   They have build projects for IAR, CooCox, and Keil.  Anyways, in the port i’ve found a section that is compiler specific, and wondering what to do here.   I looked for the general GCC answer and it’s not working either :/

    #if defined (IAR_ARM_CM3)
    /**
    * @brief Flag stored in Flash at address 0x0807F800 in case of IAR.
    */
    const uint16_t nErasedFlag @ (FLASH_PARS_ADDR) =0x0300;
    #elif defined (KEIL)
    /**
    * @brief Flag stored in Flash at address 0x0807F800 in case of Keil.
    */
    const uint16_t nErasedFlag __attribute__((at(FLASH_PARS_ADDR))) =0x0300;
    #elif defined (CooCox)
    /**
    * @brief Flag stored in Flash at address 0x0807F800 in case of CooCox.
    */
    __attribute__ ((section(".SECTION251"))) uint16_t nErasedFlag = 0x0300;
    #elif defined(__GNUC__) /* This is my creation I'm working on*/
    #define nErasedFlag (*((volatile uint16_t *)FLASH_PARS_ADDR)))
    nErasedFlag = 0x0300;
    #endif
    

    Any other gotcha’s?  I am starting from the IAR project (since I use that at work) and moving stuff over.  Is there a different one of the above projects that will be closer to GCC to start?

    • This topic was modified 8 years, 11 months ago by sd_tom.
    #6466
    support
    Keymaster

    There are 2 ways of achieving this:

    An undocumented way that may be broken in the further versions of GCC would look like this:

    extern const int nErasedFlag asm("0x0807F800");

    A classical “supported” approach would be similar to what CooCox version uses: put the variable into a separate section and modify the linker script to place this section at a given address.

    You can read more about this here: http://sysprogs.com/w/forums/topic/bootloader/

    #6506
    sd_tom
    Participant

    to follow up, just to not leaving it hanging is arguments to LD FLAGS

    -Wl,–section-start=.SECTION251=0x0807F800

    vs digging into loader script.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.