EmbeddedRelated.com
Forums

MPC5566 boot code

Started by matrix13 May 25, 2012
On 29/05/2012 12:34, matrix13 wrote:
>> On 28/05/12 14:45, Rich Webb wrote: >>> On Mon, 28 May 2012 14:09:00 +0200, David Brown >>> <david.brown@removethis.hesbynett.no> wrote: >>> >>>> If I used >>>> the debugger, it ran fine, and it would run fine from flash after > that, >>>> even after a hard reset - but if I powered off the board and started >>> >from flash, it failed. >>> >>> Ah, the unique joys of embedded development. ;-) >>> >> >> True enough. It would be boring if it were easy! >> >> > > Thank you for all your helps. The issue has been resolved. > > There was a small mistake in the start up code generated by Code Warrior. > The internal SRAM size for MPC5566 is of 128KB and its an ECC SRAM. The > start up code was assuming it to be of 64KB and initialized only that much. > Now, this left the rest of the 64KB of internal SRAM uninitialized. > > In my linker code, the stack is defined to be at the last of this 128KB > SRAM. Since the last 64KB is not initialized, ECC errors will be generated > if the stack is accessed. The start up code was accessing the stack which > resulted in a failure and the MCU stopped execution. > > Corrected the internal SRAM initialization code and the MCU booted itself > from Flash (without the debugger). > > From this experience I understood one thing - do not be overly confident on > the tool generated codes. :) >
The pre-generated startup code was originally written for earlier devices, and the CW developers then adapt it for newer devices. This history is one of the reasons why it is often quite bad - it is the product of lots of small changes, rather than a clear design. On the other hand, of course, clear new designs often have new bugs, and if you are using the free "special" edition, then there is a limit to how much one can complain! Still, it is worth filling out a service request highlighting the problem. While I think the startup code is poor and needs re-writing, I think this is mainly a question of time, money and resources - the CW developers I have been in contact with through service requests take a pride in their work, and are trying to make the best tools they can. I think they will appreciate the feedback.