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.

Compiler/TMS320F28069F: Trying to get USB code to run from RAM

Part Number: TMS320F28069F


Tool/software: TI C/C++ Compiler

I am trying to get the code loaded on the TMS320F28069F so that I can copy an image off of a USB stick into the internal flash. I have verified I can get all the code to run, as long as the fat_usbmsc.obj file is compiled into the flash. When, I add that fat_usbmsc.obj(.text) to the ramfuncs in the cmd file, the code will run upto a certain point. 

The code is written to do the following:

1) detect a USB stick; attempt to mountUSBDrive() and spin until STATE_DEVICE_READY is set by mountUSBDrive() routine

2) f_open a path declared in a global string

3) f_read the contents of a file (specified in a second global string) into a RAM buffer

4) delete the internal flash, and copy the contents of the RAM buffer into the internal flash

5) reset and run the new code

As I step through the code, I take an exception and the ISR is stuck on the memcpy when the f_mount() routine calls the f_read() routine.

My theory is that the memcpy routine needs to be moved to ramfuncs as well. Any idea on how I can get the memcpy to compile into the RAM space instead of it being compiled to flash? I tried specifying the string.obj (and tried the string.lib), but the compiler is failing when I add that extra line to the ramfuncs section of the cmd file.

What am I doing wrong?

My cmd file looks like this:

ramfuncs : {
fat_usbmsc.obj(.text)
*(ramfuncs)
}
LOAD = FLASHD,
RUN = RAML0 | RAML1,
LOAD_START(_RamfuncsLoadStart),
LOAD_END(_RamfuncsLoadEnd),
RUN_START(_RamfuncsRunStart),
LOAD_SIZE(_RamfuncsLoadSize),
PAGE = 0

  • Parag Shah said:
    My theory is that the memcpy routine needs to be moved to ramfuncs as well.

    Whether that theory is correct is beyond my expertise.  It does not appeal to my intuition.  So far as the compiler is concerned, it makes no difference whether memcpy is in flash or RAM.  Though it probably makes a difference in execution speed.  But, for now, I'll presume your theory is correct.

    Parag Shah said:
    Any idea on how I can get the memcpy to compile into the RAM space instead of it being compiled to flash?

    Add a line similar this one to the ramfuncs part of the linker command file ...

        --library=rts2800_fpu32.lib<memcpy.obj>(.text)
    

    Change the library name to the one you use.  This syntax is explained in the section titled Specifying Library or Archive Members as Input to Output Sections in the C2000 assembly language tools manual.

    Thanks and regards,

    -George