AnsweredAssumed Answered

Code runs in debug-ram and debug-flash, but not out of flash

Question asked by David Brooks on Oct 16, 2014

Follow-up question to post #443262: I'm converting "C" code from CW V6.4 to V10.4. This code is a Functional Board Tester, not the V10.4 application that actually goes out the door. But I'm using the V10.4 linker file, modified slightly to "talk" to the V6.4 mcf5282_lo.s and sysinit.c files. I think the root of my problem is related to this conversion. The code runs great now on V10.4 when debugging in ram and in flash. But when I disconnect the programmer/debugger (USB Universal FX), the code does not run out of flash on power up or upon hard reset. I've tried everything, but think I am missing something simple. BTW: RCON is pulled to ground with a 1K resistor. Hardware sets the processor for Master Mode and Boot Devcie to Internal 32-bits.The out-the-door application uses MQX, but the Functional Board Tester code does not. Hence the MQX and Kernel references in the LCF. See attached linker file and partial .s19.

 

Since it appears the code wants to run out of External Flash, I changed the LCF to put all code in Extenal Flash. For good measure, I stuffed the appropriate SP and PC at the Reset Vector 0x00000000. This did not help. The code still does not boot up.

Also fixed the following assembly function by commenting out the first statement per Freescale AN4104. The VBR was not being initialized properly due to register_abi. However, this change did not get the code running in Flash either.

 

mcf5xxx_wr_vbr:

_mcfxxx_wr_vbr:

     // move.l 4(sp),d0

     movec d0,VBR

     nop

     rts


UPDATE: This problem is related to A5 Relative Addressing. My application code does not use it. But Standard C Libraries used in my application do use A5. __SDA_BASE is defined in the Linker File. errno cannot be saved since A5 has not been initialized. Documentation suggests that the linker will use this symbol to initialize A5. In my case, it is not. I can do the assignment myself in the startup code, but that does not seem to proper use of the linker. But what do you know, even initializing A5 in startup code does not resolve the bigger issue where

 

     sscanf(inText, "%lf", &inValue);

 

does not return. The system hangs.

 

Any suggestions?


Original Attachment has been moved to: SH_PHFT.Release.Flash---Copy.S19.zip

Original Attachment has been moved to: SH_flash_Lcf---Copy.lcf.txt.zip

Outcomes