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.

Placing C code in particular FLASH location

Hi,

    When I am writting a code in C, how do I make the code reside in a particular location in the memory? What I mean is that, I wan't certain functions (the main function) to reside at memory (FLASH) location 0x0000 onwards & a few functions (may be some bootloader code) at location 0x10000 onwards.

    What I intend to do here is that the application code will always start at address 0x0000 & the bootloader at address 0x10000. I may do the reverse too (app at 0x10000 & bootloader at 0x0000).

    How do I do this?

I remember doing this on some other compiler (while writting asembly codes) by stating ".ORG 0x8000", or something similar.

-

Thanks

-

Regards

Soumyajit

  • Hello Soumyajit,

    I am surprised that the "boot loader" is at 0x10000 and app code at 0x0. The boot loader is supposed to prepare the device for a potential boot image or check the validity of an existing image so that CPU can execute it. Anyways in CCS the change can be done by using the linker cmd file (extension cmd)

    In the file there is a define called APP_BASE and it needs to be changed to the new address
    #define APP_BASE 0x00010000

    Regards
    Amit
  • Hi Amit,
    The purpose of the bootloader planning to be at a higher address other than 0x0000 is that, the app code will activate the bootloader if required. The starting of the app should always contain code that can transfer control to the bootloader depending on some predefined condition. The reason for me thinking like this is that may be the shifting of the vector table is causing some issues, so I thought of trying this out, but I still feel that the bootloader should always be at the beginning of FLASH 0x0000.
    -
    Thanks
    -
    Regards
    Soumyajit
  • Hello Soumyajit,

    Intent is correct but if there is application image in the beginning it would be the classic tedious situation where the ROM would put the Bootloader in the higher region, but would require to be run again to get an application image that is supposed to be the function of the bootloader. Let us continue the debug on the other thread and close this one.

    Regards
    Amit