I am having trouble building a DSP image to run DSP code from flash. The boot order we are using is a small AIS script that only sets the PINMUX Registers and jumps to ARM code, a small ARM boot code that remains in supervisor mode to wake the DSP, and an initial DSP hardware setup program that turns everything on. Memory space and power consumption are not an issue for us.
The ARM boot, DSP hardware initialization, and a secondary DSP application are all built as separate images using the settings following. The initial jump from AIS to ARM to DSP hardware initialization works fine. I can also see the jump from the DSP initialization to the DSP application. If the application is simple enough, it loads from flash and works. If there are global or static variables, it seems that the code does not work. I am having trouble tracing exactly where the problem occurs.
We are using a simple assembly jump instruction to get to the rest of the DSP application code. The problem comes with the initialization that is created by the compile and link process.
Build environment:
Code Composer Studio v 5.1.0.09000
ARM Compiler/Linker: TMS470 - TI v4.9.1
DSP Compiler/Linker: C6000 - TI v7.3.1
Output format for all projects: eabi (ELF)
I have built the image independently on the command line using the included "build.bat" file, as well as the project build feature in the CCS IDE with the following post build steps.
"${CG_TOOL_ROOT}/bin/hex470.exe" -b -o "${BuildArtifactFileBaseName}.bin" "${BuildArtifactFileName}"
"${CG_TOOL_ROOT}/bin/hex6x.exe" -b -o "${BuildArtifactFileBaseName}.bin" "${BuildArtifactFileName}"
COMPILE COMMAND FORMAT: "C:/ti/ccsv5/tools/compiler/c6000/bin/cl6x" -mv6740 -g --include_path="C:/ti/ccsv5/tools/compiler/c6000/include" --display_error_number --diag_warning=225 --abi=eabi --preproc_with_compile --preproc_dependency="wdt.pp" "../wdt.c"
LINK COMMAND: "C:/ti/ccsv5/tools/compiler/c6000/bin/cl6x" -mv6740 -g --display_error_number --diag_warning=225 --abi=eabi -z -m"DSP.map" --warn_sections -i"C:/ti/ccsv5/tools/compiler/c6000/lib" -i"C:/ti/ccsv5/tools/compiler/c6000/include" --reread_libs --rom_model -o "DSP.out" "./wdt.obj" "./timer.obj" "./led.obj" "./gpio.obj" "./DSP_LED_wdt_manual_blink.obj" "./DSP_LED_wdt_blink.obj" "./DSP_LED_blink.obj" -l"libc.a" "../DSP_linker.cmd"
3513.DspConstInitializationProblem.zip
The sample code is designed to service a hardware watch dog timer (WDT) through a GPIO pin. We have a breakout board that brings all of the signals for our OMAP out of the board and provides power. It has a toggle switch that disables the WDT for debugging. If I load the code in RAM using the CCS interface, it runs correctly. If I build the code to run in flash memory, it does not.
What is Code Composer doing that I am missing? I thought that the global variables were initialized by the auto_initialization sequence, since I can see the .neardata and .fardata copy tables in the map file. The ".const" section is the only addition to the output text from hex6x.exe. ".const" is listed as an automatically generated section in the Hex Conversion Utility Description section (11.5) of the TMS320C6000 Assembly Language Tools v7.3 (spru186V).
The gpio code uses three "static const" variables, two with function scope, and one with file scope. If I compile the files as they are, the GPIO functions do not work. The system will run the lights until I enable the WDT, at which point it fails to service it and is reset. If I simply take away the "const" modifier from the "bit_mask" function scope "static const" variable, the system seems to work fine, toggling the lights even while the WDT is enabled. That is with the file scope "static const" and the function scope "static const *" variables left with their "const" keywords.
How do I initialize these function scope constant variables?
Do I need to write a loader function for the generated .const section if we have function level "const"?
Is there any way to avoid moving all function level "const" to the file scope? We are trying to follow MISRA2004, and it prefers we place variables used in only one function into the function they are used in.
Also, this is minor compared to the other questions, and may even be a code composer question, but why are the map files different when I build in CCS and run the batch file? The files are the same byte size and their functionality from flash is the same, but the symbol placement is different for the two binary files.
I realize the code is not optimized or cleaned, but we are collaborating and this is the basic format of what we will use. I would greatly appreciate it if someone could please help explain what else I have to put into the linker file (or which boot/init functions to call) to properly use this code from within flash memory.