DSPRelated.com
Forums

Re: DSK5510 - same program works from emulator, but not from flash

Started by Jeff Brower May 23, 2008
Arvid Tomayko-Peters-

> I am having a problem running a program from flash memory on the
> DSK5510 and I was hoping someone could give me a pointer (no pun
> intended - really) as to what I might be doing wrong. I am using the
> eDSP DSKAudio4 4-channel audio daughterboard for audio I/O and Code
> Composer 3.2 with DSP/BIOS.
>
> My problem is that the exact same compilation of my software works
> fine when run in Code Composer with the built-in USB emulator, but
> does not work when run from the DSK's flash memory. Flashburn runs and
> verifies. The DSK boots from flash, but freezes when accessing arrays
> in the SDRAM.
>
> My program works perfectly fine when loaded and run through Code
> Composer and the built-in USB emulator, but freezes whenever it
> accesses the DSK's onboard SDRAM when running booted from the flash.
> Oddly, the same program also runs perfectly from the flash when the
> built-in USB emulator is connected to Code Composer and the 'run'
> button is pressed WITHOUT loading a program through the emulator (code
> composer even warns me about this) - it is as if connecting the
> emulator does/sets/resets something that does not get set/reset when
> the DSK boots from the flash. But I can't figure out what it could be!

Based on this clue, my guess would be that your program, when booted from Flash,
omits some initialization that is done in the .gel file that CCS runs on start-up.
Have you gone through the .gel file line-by-line and verified that *everything* (in
particular EMIF init) has corresponding functionality in your boot code?

I have found before that it's sometimes necessary to initialize SDRAM using
application-specific entry-point code that runs prior to DSP/BIOS, CSL, main() or any
other code. In one case, we had to add a loop that read every SDRAM location at
least once to make sure the SDRAM controller and SDRAM devices themselves were
consistently and reliably ready for action, and this had to be done before any other
routines were run (e.g. gblinit, autoinit, userinit, etc).

-Jeff

> If I remove all references of the arrays that live in the SDRAM from
> the program, recompile and re-flashburn, it boots and runs correctly
> from flash without a connection to the computer.
>
> Sometimes, when I have had the DSK powered off for a long time, the
> program will initialize the arrays I am placing in the SDRAM correctly
> at first, and will freeze later - when manipulating them. If I press
> RESET or power cycle the DSK quickly, it tends to crash during the
> initialization of the arrays in the SDRAM - which suggests something
> is persisting through resets - but I don't know what.
>
> I can get other software (Compiled in Code Composer 2.2) that accesses
> the SDRAM (though less of it) to run off the flash memory in the DSK
> fine, just not my software (made in CCS 3.2). I have tried modifying
> my software to use the same amount or less of the SDRAM that the other
> software uses, but it did not work.
>
> I am using flashburn DSK 3.11 from
> http://www.softwaredesignsolutions.com/flashburn.aspx
>
> I have experimented with many of the hex utility's options, such as -
> boot, .SECTIONS, the type of hex file it generates, using image mode,
> and adding boot delays. But nothing worked. I was thinking maybe my
> hex file is too big? It verifies though when I flashburn it.
>
> I thought adding this
>
> EMIF_RSET(EMIRST,0xFFFFu);
>
> might help, but i did not. I also tried putting a loop at the
> beginning of my main() so that the DSP would wait for a while before
> doing anything. That did not help either.
>
> Thanks!
> Arvid
>
>
> Arvid Tomayko-Peters
>
> WEB: http://arvidtp.net
> BAND: http://metropoliscares.com
> PHONE: (401) 490-1320
> AIM: arvthecarve
>
> Have you gone through the .gel file line-by-line and verified that
> *everything* (in
> particular EMIF init) has corresponding functionality in your boot code?
>

Thank you Jeff! That was an excellent suggestion and it worked.

I went through and adapted the emif_init() and OnRestart() functions of the
DSK5510 GEL file to -reg_config lines in my hex conversion utility .cmd
file. Bingo! Not sure I needed to add the OnRestart() function, but i
figured it couldn't hurt.

Here's what I had added:

/*equivalent to GEL file's OnRestart()
Disable interrupts */
-reg_config 0x0003, 0x0800 /* // Set INTM */
-reg_config 0x0000, 0 /* // Clear IER0 */
-reg_config 0x0045, 0 /* // Clear IER1 */

/* Disable each DMA channel
*/
-reg_config 0xC01, 0 /* // DMA0 */
-reg_config 0xC21, 0 /* // DMA1 */
-reg_config 0xC41, 0 /* // DMA2 */
-reg_config 0xC61, 0 /* // DMA3 */
-reg_config 0xC81, 0 /* // DMA4 */
-reg_config 0xCA1, 0 /* // DMA5 */

/* //equivalent to GEL file's init_emif()
//emif setup */
-reg_config 0x800, 0x0221
-reg_config 0x801, 0xFFFF
-reg_config 0x803, 0x3FFF
-reg_config 0x804, 0x5FFF
-reg_config 0x805, 0x5FFF
-reg_config 0x806, 0x1038
-reg_config 0x807, 0x0038
-reg_config 0x808, 0x0038
-reg_config 0x809, 0x1050
-reg_config 0x80A, 0x0050
-reg_config 0x80B, 0x0050
-reg_config 0x80C, 0x1050
-reg_config 0x80D, 0x0050
-reg_config 0x80E, 0x0050
-reg_config 0x80F, 0x2B11
-reg_config 0x810, 0x0578 /* Refresh Period 0x00A8 for 24MHz */
/* 0x0578 for 200MHz */
-reg_config 0x811, 0x0fff
-reg_config 0x813, 0x0535
-reg_config 0x812, 0x0000 /* SDRAM Init */

Thanks!
Arvid