This is the mail archive of the
insight@sources.redhat.com
mailing list for the Insight project.
Re: downloading elf file via JTAG
On Tue, Mar 13, 2001 at 10:08:02AM -0500, Fernando Nasser wrote:
> Grant Edwards wrote:
> >
> > On Tue, Mar 13, 2001 at 07:41:05AM +0100, karsten@thebox-communications.de wrote:
> >
> > > I have problem with downloading ELF files with Insight 5.0 via
> > > JEENI JTAG interface. I want to download a program that is
> > > linked for address 0x4000000 to another address than this,
> > > because at address 0x40000000 is in RAM and I want it in flash.
> > > A bootloader copies it on reset to 0x40000000. My problem is
> > > that Insight always loads the programm at that address for what
> > > it was compiled for.
> > > Can somebody tell me how I get the program downloaded via JTAG
> > > to another address than specified in the ELF file ?
> >
> > Use objcopy.
> >
> > The --change-addresses option, IIRC.
>
> I guess what Grant is suggesting is:
>
> 1) Make a copy of your object file that has the other (flash)
> address using objcopy
> 2) Use GDB with this file to download the program to flash
I doubt that you can use GDB to download something to flash.
The Jeeni doesn't know that a particular region of memory is
flash and doesn't know the sequence required to write stuff
into flash. I didn't understand that you wanted to use GDB to
write to flash -- what you asked was how to change the download
address. That's easy. Writing to flash is harder. ;)
If what you really want is to write something into flash,
you're going to have to write a program that knows about your
particular type of flash memory. There are two ways of doing
this:
1) Use GDB to download your application program (not the
flash burner, what you want to end up in flash) into it's
executution location in RAM.
Download your flash burning application into another
section of unused RAM. Run the flash-burn program to copy
contents of RAM into flash.
or (this way is cooler)
2) Link an image of the application program (as a block of
data) with the flash-burning program. Then just download
the result using GDB and run it.
There are various ways of getting the image of one program
linked as a data block to another. The easiest is to
convert the "payload" program from ELF to binary format
using objcopy. Then convert it _back_ to ELF format
(again using objcopy) specifying a unique section name
(e.g. ".payload").
In your linker script, suck in the .payload section from the
file you just created and assign some symbols to the start
and size of the .payload section so that the flash-burn app
knows where to copy from.
I generally specify the flash destination as a symbod
defined at link time on the ld command line.
> 3) Exit GDB and reboot your system so the program gets loaded at
> 0x40000000
> 4) Start GDB with the original object file (that has 0x40000000 as load
> addr)
> 5) Connect to the target and debug normally
--
Grant Edwards
grante@visi.com