1

Board with ARM926EJ CPU, running embedded Linux v2.6.26.5, on NAND Flash device, NAND 32MiB. Linux is on MTD partitions on NAND device.

How can I backup Linux kernel image (SP2Xcybertan_rom_bin) from serial interface? Since there is no TFTP option to transfer file from board to host PC via tftp. Can I read nand to some memory address, dump output to terminal and save, then convert hex to binary:

nand read 0x20000000  0x80000  0x0017FF80
md.b 0x20000000 0x0017FF80

From boot process log:

U-Boot 2009.03 (Oct 06 2011 - 20:04:03)

Stack:->21F1EC74 U-Boot code: 21FC4D00->21FF9454  BSS:->21FFFF3B
CPU: PNX8181-2B OM6xxx-ARM926EJ-S(ARMv5TEJ) @ 221MHz(armclk), 110MHz(hclk)
Board: Vega_PNX8181_BaseStation Platform IV (LC)
I2C:   ready
RAM Configuration:
Bank #0: 20000000 32 MB
NAND:  32 MiB
In:    serial
Out:   serial
Err:   serial
Use Full Image's Kernel
Net:   VLAN Mode
L2 switch present
ETN1
Hit any key to stop autoboot:  0 

Loading from NAND 32MiB 3,3V 8-bit, offset 0x80000
   Image Name:   SP2Xcybertan_rom_bin
   Created:      1970-01-01   0:00:-1 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    1572736 Bytes =  1.5 MB
   Load Address: 20008000
   Entry Point:  20008000
## Booting kernel from Legacy Image at 20200000 ...
   Image Name:   SP2Xcybertan_rom_bin
   Created:      1970-01-01   0:00:-1 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    1572736 Bytes =  1.5 MB
   Load Address: 20008000
   Entry Point:  20008000
   Verifying Checksum ... OK
   Loading Kernel Image ... OK
OK

Starting kernel ...
Uncompressing Linux.........

The environment variables

firetux # printenv
baudrate=115200
ethaddr=FF:FF:FF:FF:FF:FF
netmask=255.255.255.0
ipaddr=192.168.1.1
serverip=192.168.1.100
bootfile=firetux.kernel
bootcmd1=setenv bootargs ${bootargs} && nboot 0x20200000 0 ${image_addr} && bootm 0x20200000
bootcmd2=setenv bootargs ${bootargs} && tftpboot 20200000 firetux.kernel && bootm 20200000
phymode=auto
mtdids=nand0=gen_nand
unlock=yes
verify=y
update.uboot=echo Update u-boot && tftpboot 0x20000000 nandboot.flash && nand erase 0x0 0x03ffff && nand write.jffs2 0x20000000 0x0 ${filesize}
update.kernel=echo Update kernel && tftpboot 0x20000000 uImage && nand erase 0x80000 0x180000 && nand write.jffs2 20000000 0x80000 0x180000
update.romimg=echo Update RomImage && tftpboot 0x20000000 romimage.img && nand erase 0x80000 0x13e0000&& nand write.jffs2 20000000 0x80000 ${filesize}
update.halfimg=echo Update HalfImage && tftpboot 0x20000000 recovery.img && nand erase 0x1460000 0x700000&& nand write.jffs2 20000000 0x1460000 ${filesize}
eraseenv=echo Erase Environment && nand erase 0x60000 0x20000
HwModel=Hw_Model=SPA122
bootcmd=run bootcmd1
halfImage=half_image=0
cy_boot_code_ver=1.0.1 (Oct  6 2011 - 20:04:00)
RouterMode=Router_Mode=0
stdin=serial
stdout=serial
stderr=serial
bootcmd=run bootcmd1
image_addr=0x80000
bootargs=console=ttyS1,115200n8 rootfstype=squashfs noalign half_image=0 verify=y Hw_Model=SPA122 Router_Mode=0
ethact=ETN1
bootdelay=3 

What are the difference between kernel(uImage) and romimage (romimg.img) in terms of boot process?

2
  • As with most uboot saving data is hard unless its usb or ftp. The only device I have like this to test with is an old seagate network NAS that I have long since replaced all the software on including the bootloader.
    – jdwolf
    Jan 4, 2018 at 1:07
  • But to answer part of this: uImage is a file that contains some headers and locations to contain the kernel, initram, device tree, etc. Basically everything the linux kernel needs for it to mount a file system. whereas "romimage" is the file system that becomes the fs root and will load system services and the rest of the file system.
    – jdwolf
    Jan 4, 2018 at 1:15

1 Answer 1

2

The steps to do this would be as follows:

First assuming the update uImage is correct

update.kernel=echo Update kernel && tftpboot 0x20000000 uImage && nand erase 0x80000 0x180000 && nand write.jffs2 20000000 0x80000 0x180000

then:

nand read <memory offset> <nand start offset> <size>
md <memory offset> <size>

so:

nand read 0x20000000 0x80000 0x180000
md 0x20000000 0x180000

Then you'd need to find a way to record the input on your serial and parse it with a script to take the hex bytes and output them in binary into a file.

5
  • Got it, thank you. One clarification about updating RomImage: update.romimg=echo Update RomImage && tftpboot 0x20000000 romimage.img && nand erase 0x80000 0x13e0000&& nand write.jffs2 20000000 0x80000 ${filesize} In above command the '0x13e0000' means max size that we need clean out for new RomImage, or an actual size of RomImage? Where the ${filesize} value taken from? If I want to upload new Romimage that have different size(smaller), should I edit size value?
    – minto
    Jan 4, 2018 at 10:15
  • the filesize environment variable is set by the tftpboot command to the number of bytes transferred Jan 4, 2018 at 10:18
  • And 0x13e0000 is partition size assigned to the RomImg, the new Romimg just should not exceed it?
    – minto
    Jan 4, 2018 at 11:15
  • @minto That's correct. Plus romimage can fill up ram as well.
    – jdwolf
    Jan 4, 2018 at 21:04
  • does Linux kernel image and modules need be fully loaded in order to dump romimage? Seems, it's not possible to save it from within U-Boot. I just tried dump romimage output either directly via terminal screen, or use socat to redirect output from serial port to file, but in both cases process goes wrong: it fill huge file and dumping still can't stop, after dumping the actual code it continues to fill the file with empty 'ff' without stopping.
    – minto
    Jan 5, 2018 at 9:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .