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.

Overlaying code using CCS DSK V2.21



Hello all:

I am working on a project that has grown too large to fit in the 2407A internal flash. We have added an external flash chip (connected via the SPI port) and I would like to overlay routines from there to the internal 2407 Code Ram located at 0x8700.

I have the mechanism working to actually load code from external to internal RAM, but have run into an issue.

I have one project that compiles the code required to be in external flash and programs the external flash (called INIT), and a second project that has all the other code and can load the external routines in as needed (called WORKING)

The problem is, the loader places dependent routines (subroutines called from the overlayed code) in different places in the 2 projects so when I run the WORKING, and call a routine from an overlayed code, it goes to the wrong address.

I found the order of the sections in the SECTIONS paragraph (.text, .cinit, .switch etc...) in the linker command file matters, and I also found I can select a "link order" in the project build options too.

Does anyone know how I can use the build output from one project to make the linker place routines in identical locations in a different project. For example, if I build WORKING first, is there a way I can use the map file, or even the absolute lister output, to make the linker place the routines in INIT in the same places?

This isn't just a problem in the code, but memory variables are ending up in different places too.

As a stopgap measure, I am making an external program to create a CMD file that will place each memory variable in a specific place by creating a single MEMORY and SECTIONS directive for each variable.

I am considering doing that for each routine that exists in both projects too (this means putting each routine in it's own C file so I get a separate .obj file for each one.)

This is a really sucky approach,  and I am hoping for something much more automated. Both to make my  life easier, and to eliminate errors caused by me forgetting something.

Any help I can get to help me think outside the box, or help me better use the available tools will be appreciated.

Thanks for your help.

 

Mark.

 

  • Your problems arise because you are managing these overlays with separate executables (AKA .out files).  You don't have to do it that way.

    The linker supports overlaying sections at the same run address, while also giving those sections separate load addresses.  See the description of the UNION directive, and copy tables feature, in this application note on the linker http://www-s.ti.com/sc/techlit/spraa46 .

    These techniques enable you to set up and manage an overlay all from within the same executable.  That will solve your problems with symbols.

    Thanks and regards,

    -George