The role of GEL files in TMS320C6000 applications
[Copy link]
GEL (General Extension Language) is an interpreted language similar to C. It can create GEL functions to expand the use of CCS.
GEL is a subset of the C language, however it cannot declare host variables. All variables must be defined in the DSP program and exist in the simulation/actual target board. The only identifiers that are not defined on the target board are GEL functions and their parameters.
GEL functions can be called anywhere a C expression can be typed, either in any dialog box where a C expression can be typed or in other GEL functions. However, recursion is not supported.
You can add commonly used GEL functions to the GEL menu of CCS. At this time, you need to use the menuitem keyword to create a new drop-down menu list (first-level menu) under the GEL menu, and then use hotmenu, dialog and slider to add new menu items (secondary menu) to this menu item.
The GEL function is automatically executed when CCS is started. The GEL function is automatically executed when the environment is set up during SETUP CCS. The StartUp() function is automatically executed. This requires that the GEL file be loaded when each project is created.
CCS provides a series of functions embedded in GEL. Using these functions, users can control the state of the simulation/actual target board, access the memory, and display the results in the output window.
1 Basic functions of GEL files
When CCSStudio is started, the GEL file is loaded into the PC's memory, and the StartUp() function is executed if it is defined. In CCSStudio (V2.3 or earlier), the initialization of the host and target boards is performed in the Startup() function. However, for CCSStudio that supports Connect/Disconnect (V2.4 or later, especially version 3.1), such a GEL file may not be executed correctly because CCSStudio is disconnected from the target processor when it is started. At this time, an error will occur when the Startup() function tries to access the target processor.
Therefore, in versions V2.4 or later, especially when CCS version 3.1 is started, a new callback function OnTargetConnect() is used to perform the initialization of the target processor.
2 GEL callback function
2.1 Startup() function
If the specified GEL file contains a Startup() function, the Startup() function is executed when CCSStudio starts. When CCSStudio that supports Connect/Disconnect is started, the Startup() function does not include code to access the target processor, and the target processor is initialized by the callback function OnTargetConnect().
recommend:
l Establish basic CCSStudio memory mapping relationship (does not require access to the target processor)
Any basic initialization that does not require access to the target processor
Not recommended:
Get_Reset() (This function resets the target processor through the emulator)
l Set breakpoints via GEL_BreakPtAdd()
GEL_TextOUT() and GET_OpenWindow(), because no CCSStudio control window is open when StartUp() is executed
StartUp() function in CCSStudio GEL file that does not support Connect/Disconnect:
/* The StartUp() function is called each time CCS is started. */
/* Customize this function to perform desired initialization. */
StartUp()
{
setup_memory_map();
GEL_Reset(); /* Do not call in StartUp() with CCStudio v2.4 or higher */
init_emif(); /* Do not call in StartUp() with CCStudio v2.4 or higher */
}
StartUp() function in CCSStudio GEL file that supports Connect/Disconnect:
/* The StartUp() function is called each time CCS is started. */
/* Customize this function to perform desired initialization */
/* that will not access the target. */
StartUp()
{
setup_memory_map();
}
2.2 OnTargetConnect() function
The absolute minimum system initialization process ensures that CCSStudio is in a reliable state on the target processor. For example: disable the watchdog clock, DSP reset end
The OnTargetConnect() function is called each time a connection is established with the target processor.
/* OnTargetConnect() is called every time a target is connected.*/
/* Its execution finishes before anything else occurs. Customize*/
/* this function to perform essential target initialization. */
OnTargetConnect()
{
// place critical target initialization steps here
GEL_Reset();
init_emif();
}
For some platforms, you must call GEL_Reset() to put CCSStudio in a "Good" state. You can test to determine whether you need to call GEL_Reset(). You should try to reduce the complexity of GEL startup functions as much as possible - including reducing the number of GEL_Reset() calls.
2.3 OnPreFileLoaded() function
This callback is executed before the program/symbol (.out) file is loaded. It is a good idea to perform additional target processor initialization in this callback to ensure that the program can be loaded and debugged.
/* This function is called automatically when the 'Load Program'*/
/* Menu item is selected. */
OnPreFileLoaded()
{
FlushCache();
IER = 0;
IFR = 0;
init_emif();
}
2.4 OnReset() function
This function is called when the target processor is reset. If you need to restart the program every time with a soft reset, call GEL_Restart() here.
/* This function is called automatically after a SW Reset has been executed.
OnReset(int nErrorCode)
{
init_emif();
}
2.5OnRestart() function
This function is called when the program is reset.
This function is called by CCS when you do Debug->Restart. The goal is to put the C6x into a known good state with respect to cache, edma and interrupts. Failure to do this can cause problems when you restart and run code multiple times .
OnRestart(int nErrorCode )
{
Turn off L2 for all EMIFA CE spaces. App should manage these for coherency
GEL_TextOut("Turn off cache segment\n");
*(int *)0x1848200 = 0; /* MAR0 */
*(int *)0x1848204 = 0; /* MAR1 */
*(int *)0x1848208 = 0; /* MAR2 */
*(int *)0x184820c = 0; /* MAR3 */
/* Disable EDMA events and interrupts and clear any pending events. */
GEL_TextOut("Disable EDMA event\n"); */
*(int *)0x01A0FFA8 = 0; /* CIERH */
*(int *)0x01A0FFB4 = 0; /* EERH */
*(int *)0x01A0FFB8 = 0XFFFFFFFF; /* ECRH */
*(int *)0x01A0FFE8 = 0; /* CIERL */
*(int *)0x01A0FFF4 = 0; /* EERL */
*(int *)0x01A0FFF8 = 0xFFFFFFFF; /* ECRL */
/* Disable other interrupts */
IER = 0;
IFR = 0;
}
3 Memory Map
The CCSStudio memory map tells the debugger which memory areas of the target processor can be accessed and which cannot be accessed. The CCSStudio memory map is usually executed in the StartUp() function.
3.1 GEL_MapAdd() function
This function adds a memory region to the memory map.
3.2 GEL_MapOn() and GEL_MapOff() functions
You can turn memory mapping on or off by calling GEL_MapOn() or GEL_MapOff(). When memory mapping is off, CCSStudio assumes that all memory space can be accessed.
3.3 GEL_MapReset() function
The GEL_MapReset() function clears all memory area mappings. When there is no memory area mapping, the default setting is that all memory area spaces cannot be accessed.
4 Try to avoid using GEL initialization
Consider using GEL_MapAdd() in the GEL file to create a memory map to allow CCSStudio to debug, but do not perform peripheral setup in the GEL file, such as EMIF register initialization and watchdog disabling.
Because GEL syntax is compatible with C, the inif_emif() function can be implemented in a .c file and linked with the application. However, please note the following points:
Use "volatile" to ensure that variables are not optimized away. For example:
*(volatile int *)EMIFA_SDRAMTIM = 0x00000618; /* SDRAM timing (refresh) */ Avoid peripheral settings in the GEL file during compilation and debugging. When the final program is reached, a smart loader software is required to set up the EMIF from the FLASH or host loader, and then copy the program/data through (E)DMA or memcpy().
After loading the GEL file, not all registers are necessarily reset values. Registers that are not assigned values in the main program are not necessarily their power-on reset values. This is because the emulator is added and the GEL file is loaded, which has played a role.
This point must be paid close attention to.
|