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.

TMS320F28335-Q1: Firmware does not work after flashing to device

Part Number: TMS320F28335-Q1
Other Parts Discussed in Thread: TMDSCNCD28335, C2000WARE

Tool/software:

I developed a firmware on TMDSCNCD28335 with CCS v12.3. It works well if we use the RAM linker command file on CCS debugger. If I changes to use the flash linker command file F28335 and set the --ramfunc option on, it does not run well after flashing the firmware to device. However, if I turns off the --ramfunc option, the firmware works well after flashing. If I look at the map file when turning on the --ramfunc option, I find that the obj file where the main function is included gets mapped twice in RAM as highlighted below:

SECTION ALLOCATION MAP

output attributes/
section page origin length input sections
-------- ---- ---------- ---------- ----------------
.TI.ramfunc
* 0 00320000 0000065c RUN ADDR = 00008000
00320000 00000365 DSP2833x_DefaultIsr.obj (.TI.ramfunc:retain)
00320365 000000d9 DSP2833x_SysCtrl.obj (.TI.ramfunc)
0032043e 000000a0 SmartBit_2833xSci_int_1.obj (.TI.ramfunc:retain)
003204de 00000074 DSP2833x_CpuTimers.obj (.TI.ramfunc)
00320552 00000074 SmartBit_2833xSci_int_1.obj (.TI.ramfunc)
003205c6 00000048 DSP2833x_Sci.obj (.TI.ramfunc)
0032060e 00000028 DSP2833x_PieCtrl.obj (.TI.ramfunc)
00320636 00000022 DSP2833x_PieVect.obj (.TI.ramfunc)
00320658 00000004 DSP2833x_usDelay.obj (.TI.ramfunc)

It seems like this is why it makes the firmware not working. My question is how can I get rid of one of them? This firmware is modified from the example routines for SCI communication from TI. 

Thanks in advance for any help.

Weiliang

  • Weiliang,

    If you find the function SmartBit_2833xSci_int_1(), then it should have a #pragma like this above it: to assign it to the section >TI.ramfunc

    #ifdef __cplusplus
    #pragma CODE_SECTION(".TI.ramfunc");
    #else
    #pragma CODE_SECTION(SmartBit_2833x..., ".TI.ramfunc");
    #endif

    Since you are also showing a "retain" section as well, I think you may find an additional #pragma retain in your code; this is needed in case of conditional linking, but I doubt you have that in your .cmd file.  I would try to remove this extra pragma, and see if this cleans things up.

    Best,

    Matthew

  • Hi Matthew,

    Thanks for your reply and helping me to understand this problem. But in my code I did not have the #pragma as you pointed out, and neither my code nor linker file has the #pragma to define the retain section as well. All I did was that I turned on the option of --ramfunc in my CCS project property C2000 Compiler->Advanced Options->Runtime Model Options. Look like the retain section was added by the compiler automatically in compilation. In this case, how can I get rid of this retain section?

    Best Regards,

    Weiliang 

  • Weilang,

    I need to check with our compiler team how the "runtime model option" can/should be used.  I am only familiar with manual pragma insertion for code section/data sections that need to be loaded to flash and ran from RAM. 

    In the meantime, please take a look at this example in C2000Ware(C:\ti\c2000\C2000Ware_5_04_00_00\device_support\f2833x\examples\flash_f28335), that has the correct .cmd and #pragma, and memcopy functions inserted manually.  Since flash size is >> that RAM size, applications will typically only copy/run the most time critical functions from RAM.

    Best,

    Matthew

  • All I did was that I turned on the option of --ramfunc in my CCS project property C2000 Compiler->Advanced Options->Runtime Model Options.

    That is the same as putting every function in the program in the section .TI.ramfunc.  I can't think of any good reason to do that.  I'm surprised the link worked.

    Thanks and regards,

    -George

  • Matthew,

    This helps a lot. This solved my problem. I though the linker would insert the memory copying function if I turned on the --ramfunc option in CCS. It seemed like it did not and I have to add it to my main function. 

    I am curious that (1) What is the --ramfunc option used for in CCS and (2) What is the function of table(BINIT) used for in linker? For (1) I tried turning on the --ramfunc in CCS and add the memory copy function in my Main function. It turned out it did not work. 

    Best Regards,

    Weiliang

  • George,

    Thanks for replying. The linker does work in this case, but the standalone firmware does not work, though. My understanding is that the linker just uses this option to configure the load and run addresses in flash and RAM. If I do not have the memory copy function in main, when the runtime support routine transfers its control to main at RAM, there is nothing over there to take the control.

    Best Regards,

    Weiliang

  • I think the ramfunc option might be useful if the code was separated into different projects, then you could have contents of a certain project all be part of -ramfunc switch.  Just a thought, I have not used this switch as I mentioned above.

    The BINIT (boot init) is an alternative method to the memcopy function, basically by adding a section to binit, the tools will take care of the memory copy as part of the boot initialization, before control of the MCU is handed over to your "main" function.  This post gives the syntax for that option.

    https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1224756/tmdscncd28379d-system-clock-and-flash-setting/4627567?tisearch=e2e-sitesearch&keymatch=binit#4627567

    Best,

    Matthew 

  • Matthew,

    Thanks for the information about how to use the table(BINIT). I did try using table(BINIT) without using the memory copy function in my firmware without success. After reading the post you referred, I found I put the .binit section in wrong memory ( I put it to RAM instead of flash). Now I understand why it did not work.

    Best Regards,

    Weiliang

  • With regard to the option --ramfunc you said ...

     My understanding is that the linker just uses this option to configure the load and run addresses in flash and RAM.

    That's incorrect.  The --ramfunc option, applied at the level of a CCS project, causes every function to be in the section .TI.ramfunc.  For more detail, search for --ramfunc in the C28x compiler manual.  Arranging for .TI.ramfunc to have separate load and run addresses happens in the linker command file.  For an example, please search the article Linker Command File Primer for the sub-part titled Load at One Address, Run from a Different Address.  Most (or all?) of the linker command files supplied with C2000Ware configure .TI.ramfunc with similar code.

    If I do not have the memory copy function in main, when the runtime support routine transfers its control to main at RAM, there is nothing over there to take the control.

    This is yet another reason to not apply --ramfunc to the entire project.  System startup code, along with the code that copies from flash to RAM, cannot itself be in .TI.ramfunc.

    Thanks and regards,

    -George

  • George,

    Thanks for the explanation and clarification about using the --ramfunc option. This helps me understand better of using the option.

    Best Regards,

    Weiliang