This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Running FLASH API from RAM

Hello,

I am using the 035 FLASH API to erase/program FLASH. Currently the library is running out  of FLASH and I'd like to run it out of RAM. I am struggling with the linker command file syntax to make this happen. I added the .ram_code section shown below, however, I get a "no matching section" warning. Can anyone steer me in the right direction?

Thanks,

Walt

MEMORY

{

     VECTORS (X) : origin=0x00000000 length=0x00000020

     FLASH0 (RX) : origin=0x00000020 length=0x0007FFE0

     FLASH1 (RX) : origin=0x00080000 length=0x00080000

     FLASH2 (RX) : origin=0x00100000 length=0x00080000

     FLASH3 (RX) : origin=0x00180000 length=0x00080000

     STACKS (RW) : origin=0x08000000 length=0x00001300

     RAM (RW) : origin=0x08001300 length=0x00026D00

 

}

 

 

SECTIONS

{

     .intvecs : {} > VECTORS

     .text : {} > FLASH0 | FLASH1 | FLASH2 | FLASH3

     .const : {} > FLASH0 | FLASH1 | FLASH2 | FLASH3

     .cinit : {} > FLASH0 | FLASH1 | FLASH2 | FLASH3

     .pinit : {} > FLASH0 | FLASH1 | FLASH2 | FLASH3

     .bss : {} > RAM

     .data : {} > RAM

 

 

     .ram_code: 

     { 

          pf035a_api.lib(.text)

          pf035a_api_eabi.lib(.text)

          pf035a_api_tiabi.lib(.text)

     }

     load = FLASH0,

     run = RAM,

     LOAD_START(_Flash_API_LoadStart),

     RUN_START(_Flash_API_RunStart),

    SIZE(_Flash_API_LoadSize)

 

  • Hi Walt,

    I have forwarded your query to our Expert team members, will get back to you asap.


    Regards

    Hari

     

     

  • Thanks Hari!

  • Hello Walt,

     

    Here is an example command linker file that would put the Flash API in flash but run it from RAM.  Your code would still be responsible to copy the code from Flash into RAM, but it defines the FlashApi_xxx symbols to know where the Load and Run locations are.

     

    /****************************************************************************/
    /* LINKER COMMAND FILE                                                                             */
    /****************************************************************************/

    /****************************************************************************/
    /* OPTIONS                                                                  */
    /****************************************************************************/
    -stack  0x800           /* SOFTWARE STACK SIZE                             

    /****************************************************************************/
    /* SPECIFY THE SYSTEM MEMORY MAP                                            */
    /****************************************************************************/
    MEMORY
    {
        FLASH       (RX)  :  origin=0x00000000   length=0x00007FFF
        VECTORS     (RWX) :  origin=0x08000000   length=0x00000100
        RAM         (RWX) :  origin=0x08000100   length=0x0000B700
        STACKS      (RW)  :  origin=0x0800B800   length=0x00000800
       

    /****************************************************************************************/


    /****************************************************************************************/
    /* SPECIFY THE SECTIONS ALLOCATION INTO MEMORY                                          */
    /****************************************************************************************/
    SECTIONS
    {
        .intvecs : {} > VECTORS     /* INTERRUPT VECTORS                 */
        .flashapi : load = FLASH, run = RAM, LOAD_START(FlashApi_LoadStart), LOAD_END(FlashApi_LoadEnd), LOAD_SIZE(FlashApi_LoadSize), RUN_START(FlashApi_RunStart), RUN_END(FlashApi_RunEnd), RUN_SIZE(FlashApi_RunSize),
        {
            pf035a_api_eabi.lib (.text)
        }
        .text    : {} > FLASH
        .data     : {} > RAM
        .const   : {} > FLASH
        .cinit   : {} > FLASH
        .bss     : {} > RAM
        .stack   : {} > STACKS
    }

     

    and here is some example code to copy the library to RAM

    main()
    {

        load((char *)&FlashApi_LoadStart,
            (char *)&FlashApi_RunStart),
            (unsigned int)&FlashApi_LoadSize);

    ...
    }


    void load(char *load,char *start, unsigned int size)
    do
      { 
       *start = *load;
    start++;
    load++;
      } while (--size);
    }

     

  • Hi John,

    Thanks, that works perfectly.

    Walt

     

  • excellent answer, perfectly solve my problem