As background info, we bypassed the daunting task of building a project by taking an existing example (Example_2806xCpuTimer), gutting it, and adding our code to it. All went well until it became time to run from FLASH.
TI pointed us to spra958l (a .pdf and a collection of example code) to learn how to get our code into FLASH. So far, we have spent more time on this task (without success) than we have on our power converter (running successfully, but under emulation).
I have read most of the document three times (!), and walked through the "nonBIOS" example code for the F28069 for both the RAM and the FLASH examples.
The only difference (nonBIOS RAM versus FLASH) between the spra958l source directories is in DelayUs.asm: a different constant for a NOP delay loop (78 versus 68).
Since the examples' RAM and FLASH .cmd files were so similar, we chose to modify a copy of the example RAM .cmd file to work with our project, and once that was done, to apply the appropriate changes to a copy of the example FLASH .cmd file.
The only change that we ended up making to the FLASH .cmd file was to have .ebss point to L8DPSARAM because our code has some big arrays.
spra958l.pdf's page 14 instructed us to add to the .cmd file a SECTIONS entry for secureRamFuncs. There was already an entry, though some parts varied because the MEMORY names differred between the spra958l.pdf text and the actual example files.
spra958l.pdf's page 14 also instructed us to add to the beginning of our main() some externs, a memcpy() to copy secureRamFuncs_loadsize words of code from secureRamFuncs_loadstart to secureRamFuncs_runstart, and then call InitFlash().
spra958l.pdf told us about CodeBranchStart.asm. We put the example's copy into our source directory, only to find a conflict due to one in the controlSUITE, so we removed it.
spra958l.pdf says that "The codestart section should be placed in memory with the user linker command file." It was unclear how to do so, but our linker output shows a F2806x_CodeStartBranch.obj, so it would appear that it has made it into the code.
Are we done? Apparently not, as the board doesn't run from FLASH, and the linker reports the following two warnings:
=====================================
"C:/ti/ccsv5/tools/compiler/c2000_6.1.4/bin/cl2000" -v28 -ml -mt --cla_support=cla0 --float_support=fpu32 --vcu_support=vcu0 -g --define="_DEBUG" --define="LARGE_MODEL" --quiet --verbose_diagnostics --diag_warning=225 --issue_remarks --output_all_syms --cdebug_asm_data -z --stack_size=0x200 -m"Example_2806xCpuTimer.map" --warn_sections -i"C:/ti/ccsv5/tools/compiler/c2000_6.1.4/lib" -i"C:/ti/ccsv5/tools/compiler/c2000_6.1.4/include" -i"C:/ti/controlSUITE/device_support/f2806x/v130/F2806x_common/lib" -i"C:/ti/controlSUITE/libs/math/IQmath/v15c/lib" -i"C:/ti/controlSUITE/libs/math/FPUfastRTS/v100/lib" --reread_libs --priority --verbose_diagnostics --issue_remarks --xml_link_info="Example_2806xCpuTimer_linkInfo.xml" --entry_point=code_start --rom_model -o "Example_2806xCpuTimer.out" -l"rts2800_fpu32_fast_supplement.lib" -l"rts2800_fpu32.lib" "./src/spi.obj" "./src/sm.obj" "./src/serial.obj" "./src/powertracker.obj" "./src/main.obj" "./src/led.obj" "./src/interrupt.obj" "./src/dsp.obj" "./src/calc.obj" "./src/Passwords.obj" "./F2806x_usDelay.obj" "./F2806x_SysCtrl.obj" "./F2806x_PieVect.obj" "./F2806x_PieCtrl.obj" "./F2806x_GlobalVariableDefs.obj" "./F2806x_DefaultIsr.obj" "./F2806x_CpuTimers.obj" "./F2806x_CodeStartBranch.obj" "./F2806x_Adc.obj" -l"IQmath_fpu32.lib" "../F28069_nonBIOS_flash.cmd" "C:/ti/controlSUITE/device_support/f2806x/v136/F2806x_headers/cmd/F2806x_Headers_nonBIOS.cmd"
warning: creating output section "ramfuncs" without a SECTIONS specification
warning: entry-point symbol other than "_c_int00" specified: "code_start"
'Finished building target: Example_2806xCpuTimer.out'
=====================================
Earlier, we (and from the forums, some others) were told not to worry about the "entry-point symbol" symbol warning, but the other warning was an obvious concern.
After some digging, we looked at the 'init' functions for the DSP in the controlSUITE, and apparently, some of them must be run from RAM, and it became evident that the example files on which we based our work used their own versions of these functions (which apparently must not have the same requirements), ramfuncs is never referenced.
Unfortunately, ramfuncs is never mentioned in spra958l.pdf, and we cannot quite figure out what simple changes (if any) must be made to either our .cmd file, and what simple changes (if any) must be made to our code in order to copy this ramfuncs section from FLASH to RAM (apparently before calling InitFlash, but we are also unsure of that).
After reading nearly one-hundred forum entries, the best-looking resource was provided by another F28069 user, but he was in the forum because he too was unable to get it to work.
Please give us this information, or at least, please point us in the direction of an example that uses the controlSUITE (as do the many example projects available from the Project Explorer).
During the previously mentioned digging through the controlSUITE code whose functions we call, the following discoveries were also made:
=====================================
In F2806x_SysCtrl.c:
// Functions that will be run from RAM need to be assigned to
// a different section. This section will then be mapped to a load and
// run address using the linker cmd file.
//
// *IMPORTANT*
// IF RUNNING FROM FLASH, PLEASE COPY OVER THE SECTION "ramfuncs" FROM FLASH
// TO RAM PRIOR TO CALLING InitSysCtrl(). THIS PREVENTS THE MCU FROM THROWING
// AN EXCEPTION WHEN A CALL TO DELAY_US() IS MADE.
#pragma CODE_SECTION(InitFlash, "ramfuncs");
=====================================
In F2806x_Adc.c:
// NOTE: ADC INIT IS DIFFERENT ON F2806x DEVICES COMPARED TO OTHER 28X DEVICES
//
// *IMPORTANT*
// IF RUNNING FROM FLASH, PLEASE COPY OVER THE SECTION "ramfuncs" FROM FLASH
// TO RAM PRIOR TO CALLING InitSysCtrl(). THIS PREVENTS THE MCU FROM THROWING
// AN EXCEPTION WHEN A CALL TO DELAY_US() IS MADE.
Note that there is no #pragma in F2806x_Adc.c. Why? How does it work?
=====================================
In F2806x_usDelay.asm:
;// *IMPORTANT*
;// IF RUNNING FROM FLASH, PLEASE COPY OVER THE SECTION "ramfuncs" FROM FLASH
;// TO RAM PRIOR TO CALLING InitSysCtrl(). THIS PREVENTS THE MCU FROM THROWING AN EXCEPTION
;// WHEN A CALL TO DELAY_US() IS MADE.
;//
.def _DSP28x_usDelay
.sect "ramfuncs"
=====================================
Should there be a #pragma in F2806x_Adc.c? If not, why not? If yes, should we actually change the controlSUITE code? That does not seem like a good idea.
Is the spra958l .cmd file (that we have slightly modified) compatible with the functions in controlSUITE?
And finally, what is the difference between ramfuncs (in the controlSUITE) and secureRamFuncs (in spra958l)?
Surely, we are not the first team to run into this problem. Please provide us with the necessary information, or point us to a resource that gets us in the right direction.
Thanks -- Mark