Steps to convert Coldfire (GNU tools) application to load into flash

Coldfire MCF5475EVB using GNU command line tools - I have a simple application I have written (ELF format) which works when I load it via LogicLoader's 'load elf' command, or through P&E Micro ICDCFZ BDM debugger.

I now want to get that application to be stored in flash and run at startup.

I have a suitable flash programming tool (PROGCFZ) which works.

So, what steps/changes do I need to make? I'm aware my .text section needs to be relocated to the flash memory address, along with the .data section. .bss can remain in RAM I believe.

What else do I need to do? I'd like to write an even simpler application and put that in flash first, before trying it on my application.

Any hints?

Many thanks for your help

David

Reply to
David Hearn
Loading thread data ...

Your flash programming tool should be able to accept hex files in Motorola format (I wonder if it's FreeScale format now?).

You should have a tool or set of tools that convert an elf-format file into hex. IIRC the Gnu toolchain that shipped with VXWorks long ago used "ld" to make an absolutely-located version still in elf format (you have to supply parameters about where flash and RAM are), then there was a utility that converted _that_ into a hex file.

You'll have to dig, but it should be out there.

--
Tim Wescott
Wescott Design Services
 Click to see the full signature
Reply to
Tim Wescott

That .data section is the one to watch. Check what your compiler is doing, but commonly it will put static, initialised, variable data in there. That is, you write something like:

int foo = 5;

void bar(void) { foo++; }

So foo will get put in .data, with a loaded value of 5.

Now you move to flash: what becomes of foo? Can't leave it in flash: it needs to be changeable. Can't *just* put it in RAM either: it will have no value at power-up. What usually happens is, you have the linker build a copy of .data in flash, and the start-up code then copies that into RAM before running main(). Be sure your startup code (usually crt0.s) is doing this.

Reply to
David R Brooks

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.