7.9.6. Moving GEL Initialization to Production Code

Relying on a GEL file to perform tasks such as EMIF initialization is very convenient. However, when the application nears production, the Hardware initialization settings performed by the GEL script need to be moved to the bootload or other initialization code and any intrinsic macros or other debug-oriented constructs need to be removed.

Additional important details:

  • Fortunately the GEL syntax matches standard C syntax, therefore the vast majority of a typical init_emif() or watchdog_disable() routine can be moved to a .c file and linked with the application.

  • Consider creating a separate GEL file that only sets up the memory map via GEL_MapAdd() API to enable CCS debugging, but that no longer performs peripheral settings such as EMIF writes or watchdog disabling.

  • Moving GEL syntax to C doesn’t work for initialized code (for example, in the .text section) and data (for example, in the .const section). Thankfully the debugger lets you know this. At load time CCStudio performs a data verification of any initialized code/data (that is, anything that needs to be loaded) that was written to memory. The data verification fails because the EMIF has not yet been set up.

  • Moving GEL syntax to C works fine for un-initialized data such as heaps. However, you need to ensure the init_emif() C function is called before the heap is used. In a DSP/BIOS application, you can ensure this by plugging the GBL user init function since this gets called early in the code startup sequence.

  • It’s a good idea to add “volatile” qualifiers as follows to ensure that the Codegen Optimizer doesn’t optimize the memory references out.

    *(volatile int *)EMIFA_SDRAMTIM = 0x00000618; /* SDRAM timing (refresh) */

Finally, these tips are useful if you want to stay in a CCStudio build/debug environment but avoid GEL file peripheral settings. When you do reach the production timeframe, you’ll need a smart loader booting from flash or a host machine that sets up EMIF and then copies runtime-critical initialized code/data sections via DMA or memcpy(). Several application notes describe how to achieve this with new Codegen utilities, Hex converters etc.