[U-Boot] Download the u-boot from flash back to PC

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.
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?

Hi Rishi,
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.
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?
The only thing that I know of is CONFIG_CMD_SAVES which does a "save S record over serial line" (check common/cmd_load.c). It is likely that your binary U-Boot does noe have this feature though (it is not in config_cmd_default, so the board maintainer has to define it explicitely).
When I needed to do this, I could either attach a BDI3000 which can do a tftp put (remember to create the file on the host first, otherwise it will fail silently!), or I used a linux kernel that was able to read U-Boot through the mtd interface.
If you decide to implement a "tftpput" command, I for one would find this a very nice addition indeed ;)
Cheers Detlev

On Wednesday, June 08, 2011 09:43:36 Detlev Zundel wrote:
If you decide to implement a "tftpput" command, I for one would find this a very nice addition indeed ;)
someone has already posted tftp server support for u-boot. not sure if it's been merged yet, but wolfgang seemed happy with it.
not that it'd help with the OP's current issue ... -mike

Hi Mike,
On Wednesday, June 08, 2011 09:43:36 Detlev Zundel wrote:
If you decide to implement a "tftpput" command, I for one would find this a very nice addition indeed ;)
someone has already posted tftp server support for u-boot. not sure if it's been merged yet, but wolfgang seemed happy with it.
Yes, I know - but that only implemenmts the "receive" operation, i.e. U-Boot receives data.
not that it'd help with the OP's current issue ...
Nope, not at all ;) That's why I said, either a "tftpput" or a "receive" for the tftp server would be nice.
Cheers Detlev

On Wednesday, June 08, 2011 17:42:30 Detlev Zundel wrote:
On Wednesday, June 08, 2011 09:43:36 Detlev Zundel wrote:
If you decide to implement a "tftpput" command, I for one would find this a very nice addition indeed ;)
someone has already posted tftp server support for u-boot. not sure if it's been merged yet, but wolfgang seemed happy with it.
Yes, I know - but that only implemenmts the "receive" operation, i.e. U-Boot receives data.
i thought there was code sitting around for transmitting from u-boot. *shrug* must have remembered wrong. -mike

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.
participants (4)
-
Detlev Zundel
-
Jason
-
Mike Frysinger
-
Rishi Dhupar