[U-Boot] Download the u-boot from flash back to PC
Jason
u-boot at lakedaemon.net
Wed Jun 8 17:35:18 CEST 2011
On Wed, Jun 08, 2011 at 09:25:42AM -0400, Rishi Dhupar wrote:
> I have a board which has a version of u-boot on it that I would like
> to save before overwriting. I did not flash this version so I do not
> have the source code for it.
funny how often that happens... :-(
> I am trying to figure out is there away to essentially do a 'tftp get'
> of the u-boot.bin that was originally written to flash. I do not see
> any methods to "read" data from U-boot back to the PC. Is there any
> method to do this?
Here's what I've done in the past.
WARNING: read everything _before_ you start!
1.) On the device, in U-Boot, zero out some memory (1MB at 0x0800000)
$ mw.b 0x0800000 0x00 0x100000
2.) Read the bootloader into RAM at 0x0800000, size 1MB, offset into
nand, 0x300.
$ nand read 0x0800000 0x300 0x100000
3.) close your minicom/screen/whatever that you are using to talk to the
serial port. On your desktop, run the following:
$ printf "md.b 0x0800000 0x100000\r\r" | \
socat - /dev/ttyUSB0,raw,echo=0,crnl >u-boot.ascii 2>&1
This will take a while (10 - 20 minutes!), in another terminal, setup a
watch:
$ watch -n3 "ls -l u-boot.ascii"
4.) prep the ascii file for conversion to binary.
a.) remove the first and last lines
b.) start the address numbers (first column) at 0, eg
$ sed -i.bak -r -e 's/^008/000/' -e 's/^009/001/' u-boot.ascii
5.) Convert ascii to binary
$ xxd -r u-boot.ascii u-boot.bin
Notes: Obviously, your addresses and sizes are going to be different,
you may need to use 'sudo socat' for step 3. This is from memory, I
just did it a week ago though. You could always replace xxd with some
sort of sed/awk script.
hth,
Jason.
More information about the U-Boot
mailing list