Linux
如何備份 Linux 核心映像
帶有 ARM926EJ CPU 的板,執行嵌入式 Linux v2.6.26.5,在 NAND 快閃記憶體設備上,NAND 32MiB。Linux 位於 NAND 設備上的 MTD 分區上。
如何從串列介面備份 Linux 核心映像 (SP2Xcybertan_rom_bin)?由於沒有通過 tftp 將文件從電路板傳輸到主機 PC 的 TFTP 選項。我可以將 nand 讀取到某個記憶體地址,將輸出轉儲到終端並保存,然後將十六進制轉換為二進制:
nand read 0x20000000 0x80000 0x0017FF80 md.b 0x20000000 0x0017FF80
從啟動過程日誌:
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.........
環境變數
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
核心(uImage)和romimage(romimg.img)在啟動過程方面有什麼區別?
執行此操作的步驟如下:
首先假設更新uImage是正確的
update.kernel=echo Update kernel && tftpboot 0x20000000 uImage && nand erase 0x80000 0x180000 && nand write.jffs2 20000000 0x80000 0x180000
然後:
nand read <memory offset> <nand start offset> <size> md <memory offset> <size>
所以:
nand read 0x20000000 0x80000 0x180000 md 0x20000000 0x180000
然後,您需要找到一種方法來記錄串列上的輸入並使用腳本對其進行解析以獲取十六進製字節並將它們以二進制形式輸出到文件中。