jiuweiljp 发表于 2024-1-4 00:51:51

大容量Nand Flash 光猫固件备份方法

本帖最后由 jiuweiljp 于 2024-1-4 01:05 编辑

使用条件:
   1、有usb接口并且能驱动U pan的无视这个方法;
   2、光猫不能telnet,并没有tftp或者wget、chmod命令也可以不用看;

正文如下
手上有一个闲置的中兴光猫F657GV9,焊接TTL线后启动信息如下(可无视):
U-Boot 2013.04 (Sep 11 2021 - 00:00:57)

CPU: ZX279127S@A9,1000MHZ
Board: ZXIC zx279127sevb
127s product_vid = 158
DRAM:256 MiB
127s product_vid = 158
,10000000,50000000
cpuid=27912710
127s pinmux: 3f7ffffa3ffffeff19ff05556be1b
127s product_vid = 158
bootsel=3
NAND:
Manu ID: 0x2c, Chip ID: 0x24 (Micron SPI NAND MT29F2G01ABAGDWB256MiB 3,3V)
256 MiB
<nand_read_skip_bad_,447>!mtdpart=0x1,offset=0x0,mtdpartoffset=0x180000,mtdPartsize=0x80000,length=0x20000
In:    serial
Out:   serial
Err:   serial
clk_pll env is not setted, core clk won't change
Net:   enter ref_clk_set.. mode = 0 .
enter pll_cfg_fractional
ref_clk_set success!
gpon serdes init
addr 0x9400002c before value is 11000013
addr 0x9400004c after value is 11003ff3
eth0
sec mode!

Hit 1 to upgrade software version
Hit any key to stop autoboot:0
addr=1200000
addr=4200000
select=0x0
search=0x2
<nand_read_skip_bad_,447>!mtdpart=0x6,offset=0x0,mtdpartoffset=0x200000,mtdPartsize=0x200000,length=0x1000
tmp=0x00000000, value=0
select=0x0
search=0x2
search->result.entry=1200240
<nand_read_skip_bad_,447>!mtdpart=0x2,offset=0x0,mtdpartoffset=0x1200000,mtdPartsize=0x3000000,length=0x23e0000
RSA Verify OK

---mtdparts_init--current_mtd_partnum=0-
dev id: type = 2, num = 0, size = 0xffffffff, mtd_id = single part
part: name = rootfs0, size = 0x023c0000, offset = 0x01220000
part: name = rootfs1, size = 0x023c0000, offset = 0x04220000

--- jffs2_part_info: partition number 0 for device nand0 (single part)
jffs2_part_info:rootfs0,1220000
### JFFS2 loading '0uImage' to 0x44000000
Scanning JFFS2 FS: ..................... done.
### JFFS2 load complete: 4344391 bytes loaded to 0x44000000
127s product_vid = 158
<nand_read_skip_bad_,447>!mtdpart=0x0,offset=0x0,mtdpartoffset=0x0,mtdPartsize=0x180000,length=0x100000
lseek=0x42080800
cmdline=U-Boot V1.0.0P1N1 20210911001937
output gpio:58, value=1, 0
output gpio:59, value=1, 0
## Booting kernel from Legacy Image at 44000000 ...
   Image Name:   Linux Kernel Image
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    4344327 Bytes = 4.1 MiB
   Load Address: 40008000
   Entry Point:40008000
   Verifying Checksum ... OK
   Loading Kernel Image ... OK
OK
----------------------
|-->setup versioninfo tag...

Starting kernel ...根据启动信息可以得知
cpu(ZX279127S@A9,1000MHZ)后面再吐槽它,内存(DRAM: 256 MiB),闪存用的美光(Micron SPI NAND MT29F2G01ABAGDWB 256MiB 3,3V)其实这个光猫也有USB接口,我测量过没有5V输出,如果想USB好用需要补元件。

使用工具软件打开光猫telnet并登录后查看mtd信息
/ # cat /proc/mtd
dev:    size   erasesizename
mtd0: 10000000 00020000 "whole flash"
mtd1: 00200000 00020000 "u-boot"
mtd2: 00200000 00020000 "others"
mtd3: 00200000 00020000 "parameter tags"
mtd4: 00200000 00020000 "wlan"
mtd5: 00800000 00020000 "usercfg"
mtd6: 00200000 00020000 "middleware"
mtd7: 03000000 00020000 "kernel1"
mtd8: 03000000 00020000 "kernel2"
mtd9: 01000000 00020000 "framework1"
mtd10: 01000000 00020000 "framework2"
mtd11: 01800000 00020000 "preplugin_data"
mtd12: 05600000 00020000 "plugin_data"
mtd13: 02fe0000 00020000 "rootfs"可以看见有一个MTD0它就是一个完整的nand flash影像把它拷贝出来就是一个完整且连续的flash备份,有人会说下面不是有MTD1-13,分别拷贝不方便点吗?
1、mtd1-13 加起来是超过256MB的;
2、你不知道它mtd1-13在flash存储地址是不是按1-13这个编号连续分布的;

我查过启动信息如下:(我没看出来有MTD地址分布信息)
/opt/cu/apps # ./busybox1 dmesg
NET: Registered protocol family 24
p p t p driver version 0.8.5
127s doesn't have USB3.0,just return -ENODEV
**********TOP_CRM_BASE+0x2c=0x11393ff3******
**********TOP_CRM_BASE+0x2c=0x113f3ff3******
dwc2 9000000.usb: 1792 invalid for host_rx_fifo_size. Check HW configuration.
dwc2 9000000.usb: 1024 invalid for host_nperio_tx_fifo_size. Check HW configuration.
dwc2 9000000.usb: 1024 invalid for max_packet_count. Check HW configuration.
dwc2 9000000.usb: DWC OTG Controller
dwc2 9000000.usb: new USB bus registered, assigned bus number 1
dwc2 9000000.usb: irq 60, io mem 0x00000000
usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
usb usb1: Product: DWC OTG Controller
usb usb1: Manufacturer: Linux 4.1.25 dwc2_hsotg
usb usb1: SerialNumber: 9000000.usb
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 1 port detected
usbcore: registered new interface driver cdc_acm
cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
usbcore: registered new interface driver usbserial
usbcore: registered new interface driver usbserial_generic
usbserial: USB Serial support registered for generic
usbcore: registered new interface driver ch341
usbserial: USB Serial support registered for ch341-uart
usbcore: registered new interface driver cp210x
usbserial: USB Serial support registered for cp210x
usbcore: registered new interface driver pl2303
usbserial: USB Serial support registered for pl2303
mousedev: PS/2 mouse device common for all mice
I2C probe start!
zx_i2c_probe i2c-1 i2c-1->clk is ccdce7c0 ,clk rate is 100000000
I2C probe successed!
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
zx tempsensor: zx_bsp_tempsensor.regs = 0xf0500034,&(zx_bsp_tempsensor.regs->cfg)= 0xf0500034
bsp_temp_start,val = 0x2ef
(458):creat proc files for temper sensor!!!
(463):temper sensor is running...
zx tempsensor: work clock 0
zx tempsensor: selector0's int num 27 allocated.
zx tempsensor: selector1's int num 28 allocated.
zx tempsensor: selector2's int num 29 allocated.
Netfilter messages via NETLINK v0.30.
nf_conntrack version 0.5.0 (3372 buckets, 60000 max)
ip_set: protocol 6
gre: GRE over IPv4 demultiplexor driver
ip_tables: (C) 2000-2006 Netfilter Core Team
NET: Registered protocol family 10
ip6_tables: (C) 2000-2006 Netfilter Core Team
sit: IPv6 over IPv4 tunneling driver
NET: Registered protocol family 17
bridge: automatic filtering via arp/ip/ip6tables has been deprecated. Update your scripts to load br_netfilter if you need this.
Bridge firewalling registered
Ebtables v2.0 registered
l2tp_core: L2TP core driver, V2.0
l2tp_ppp: PPPoL2TP kernel driver, V2.0
8021q: 802.1Q VLAN Support v1.8
systools version:v0.7.5
zte--oss cpu usage module init
DPI interface Loaded
e8_init OK!
Registering SWP/SWPB emulation handler
FLowRL module init
DevBw module init
jffs2: notice: (1) jffs2_build_xattr_subsystem: complete building xattr subsystem, 0 of xdatum (0 unchecked, 0 orphan) and 0 of xref (0 dead, 0 orphan) found.
VFS: Mounted root (jffs2 filesystem) readonly on device 31:13.
Freeing unused kernel memory: 212K (c07d3000 - c0808000)
This architecture does not have kernel memory protection.
jffs2: notice: (532) jffs2_build_xattr_subsystem: complete building xattr subsystem, 0 of xdatum (0 unchecked, 0 orphan) and 0 of xref (0 dead, 0 orphan) found.
jffs2: notice: (577) jffs2_build_xattr_subsystem: complete building xattr subsystem, 0 of xdatum (0 unchecked, 0 orphan) and 0 of xref (0 dead, 0 orphan) found.
jffs2: notice: (585) jffs2_build_xattr_subsystem: complete building xattr subsystem, 0 of xdatum (0 unchecked, 0 orphan) and 0 of xref (0 dead, 0 orphan) found.
jffs2: notice: (587) jffs2_build_xattr_subsystem: complete building xattr subsystem, 0 of xdatum (0 unchecked, 0 orphan) and 0 of xref (0 dead, 0 orphan) found.
11930:23:02 [(1348)CheckLogConfFile] CheckLogConfFile%CheckRestartCntConfFile

jffs2: notice: (578) check_node_data: wrong data CRC in data node at 0x006d5d7c: read 0x19d3a03, calculated 0x1e78a0ef.
ubi0: attaching mtd12
ubi0: scanning is finished
ubi0: attached mtd12 (name "plugin_data", size 86 MiB)
ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 126976 bytes
ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 2048
ubi0: VID header offset: 2048 (aligned 2048), data offset: 4096
ubi0: good PEBs: 688, bad PEBs: 0, corrupted PEBs: 0
ubi0: user volume: 1, internal volumes: 1, max. volumes count: 128
ubi0: max/mean erase counter: 14/9, WL threshold: 4096, image sequence number: 2012089330
ubi0: available PEBs: 0, total reserved PEBs: 688, PEBs reserved for bad PEB handling: 16
ubi0: background thread "ubi_bgt0d" started, PID 601
UBIFS (ubi0:0): background thread "ubifs_bgt0_0" started, PID 607
UBIFS (ubi0:0): recovery needed
UBIFS (ubi0:0): recovery completed
UBIFS (ubi0:0): UBIFS: mounted UBI device 0, volume 0, name "plugin_ubifs"
UBIFS (ubi0:0): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
UBIFS (ubi0:0): FS size: 83423232 bytes (79 MiB, 657 LEBs), journal size 4190208 bytes (3 MiB, 33 LEBs)
UBIFS (ubi0:0): reserved for root: 3940284 bytes (3847 KiB)
UBIFS (ubi0:0): media format: w4/r0 (latest is w4/r0), UUID 156BD46D-0725-43B0-AA2C-8A8DCD1D83F4, small LPT model
jffs2: notice: (618) jffs2_build_xattr_subsystem: complete building xattr subsystem, 0 of xdatum (0 unchecked, 0 orphan) and 0 of xref (0 dead, 0 orphan) found.
lo up
mux=3f7ffffa
mux=3ffffeff
mux=19ff0555
mux=6be1b
storage_wakeup_proc_create success!
verinfo=U-Boot V1.0.0P1N1 20210911001937 0x1200000 0x0 0x8f 0x83
can find /usr/java/osgi_verosgi_version_info_get error!
data_in=0x0
data_in=0x0
>>TagaramodInit the typeindex:5
>>TagaramodInit the board_name:F657GV9 ,wan=0x40
pon init
ZX_PA_BUF_BASE0=4dea0000
ZX_VA_BUF_BASE0=cdea0000
ZX_BP_BUFFER_BASE=4dec0000
ZX_DESC_BASE=4ee80000
ZX_TX_UP_DESC_BASE=4ef40000
ZX_TX_DN_DESC_BASE=4ef50000
ZX_BPPE_SW_BASE=4dea0000
ZX_BP_BUFFER_SW_BASE=4dec0000
ZX_DESC_SW_BASE=4ea00000
ZX_TX_UP_DESC_SW_BASE=4eac0000
ZX_BPPE_BASE_127S=4eae0000
ZX_BP_BUFFER_BASE_127S=4eb02000
BP_BUFFER_SIZE_127S=b40000
ZX_VA_TX_DN_DESC_BASE=cef50000
BPPE_POOL_SIZE=1c00
NORMAL_BP_BUFFER_SIZE=fc0000
JUMBO_BP_SIZE=2800
JUMBO_BPPE_POOL_SIZE=0
BP_BUFFER_SIZE=fc0000
lan_up=0, lan_up_port=0
the pon mode is 40
lan_up=0, lan_up_port=0
g_pon_irq=36,d1000000,f0400000,f0500000,f0600000,d0e00000
get npp irq succeed,g_npp_irq:38
get tm irq succeed,g_tm_irq:41 tm_base:0xf4340000
get pp irq succeed,g_pp_irq:37
get idm irq succeed,g_idm_irq:39
enter ref_clk_set.. mode = 0 .
enter pll_cfg_fractional
ref_clk_set success!
serdes band cpu_temper:32 coarse:0x29
band calc fin
pon tm init
enter pon_tm_bppe_pool_init
bppe_va_addr = 0xceae0000
jumbo_bppe_va_addr = 0xceaf0000
BMU_JUMBO_BPPE_SW_PTR=0x0    (JUMBO_BPPE_SW_POOL_SIZE)<<16=0x0
netif_napi_add() called with weight 512 on device pon
DMA_UP_DESC_CNT = 0x0
pon_tm net init ok,272/176
pon_pp init
pon_npp init
idm_status_proc success!
idm_desc_init d0c35000/4c980000
request idm irq succeed
idm net init ok
switch_phy_int_check 0
mac 0 link down
switch_phy_int_check 1
mac 1 link down
switch_phy_int_check 2
mac 2 link down
switch_phy_int_check 3
mac 3 link down
register fpga driver success, major=222
register peripheral success, major = 106
= TM Module SYS FS Init ended successfully =
tm_initModule begin...
enter tm_sdk_init
api lock init!!
tm_initModule end...
hw_power_optx_get_fordg:txdisable=0
Kmodule ZX279511.ko insmod successfully !
bob is not GN25L95: 40
pon up
ethdriver_init....
g_mii_dev_namesw
g_mii_dev_namepon
sw up
zteGpmac_devReg begin...
zteGpmac_devReg end...
enter zteGponCpuTypeAddrSet
*
asicGlbDb, 0x46,0x31007,0x0
zteGpmac_initModule begin...
=== GponMac Supported MaxTcont: 16 MaxPLI: 800B ===
htb debug 1 =====> inCnt =0,outCnt=0
##huoqf zteGponAsicStarttimeChkResultInit write cfg=10
##huoqf zteGponAsicStarttimeChkResultInit read cfg=10
= PON Module Operate ended successfully =
DEbug: GPON PIN_MUX_REG2:(0x19ff0555)
DEbug: GPON GPIO_PDD_REG:(0xfac)
DEbug: GPON GPIO_POSEDGE_REG:(0x4)
DEbug: GPON PIN_MUX_REG3:(0x2be1b)
create zteGpon_rei_task ok!
= GMAC Module SYS FS Init ended successfully =
zteGpmac_initModule end...
gpon_Init ok
gpondrv g_OnuType is 2
11930:23:06 netlink_unicast failedmsgid = 0xa5c2, ptr = bf26dd20, len = 4
omci up
Init switch module
unicnt 4, wancnt 1, wifi cnt 0, all ports 5, portmask 0x0000002f
Onu type is 1,Wan type is 4
switch config GPON HGU mode!
protocol fail, error deal 66
failed
protocol fail, error deal 65
failed
-------chip_tm_init end-----
l2_fast init
set cpu queue rate limit to 8000pps
tm_port_egress_traffic_sharp_set p_port:5 p_ena:1 p_band_width:2048

Capacity=256000tm_port_egress_traffic_sharp_set p_port:6 p_ena:1 p_band_width:2048

Capacity=256000 reg hff
reg get statistics
Init switch module Success
bsp_i2c_probe 0x50 success!
vendor name = ZTE_PX20+_G
optical PN(0x60) =
optical PN(0x28) = ZX279511
tdm: exports duplicate symbol tdm_ch_close (owned by kernel)
udpwatchd inited!
kudpinited!
Init codec v2.3(2019-05-17)!
idm0 up
idm1 up
redirusb_init,no usb dev!
random: dbus-uuidgen urandom read with 47 bits of entropy available
gpondrvCfgXGRegInfoAdapter not support now!
=== GponMac Supported MaxTcont: 8 MaxPLI: 1536B ===
htb debug 1 =====> inCnt =0,outCnt=0
IPv6: ADDRCONF(NETDEV_UP): br0: link is not ready
br0 up
ethdrv_dev_ioctl,brdev_set.port_id 0 ,brdev_set.name eth0 ,brdev_set.flag 0
eth0 up
ethdrv_dev_ioctl,brdev_set.port_id 1 ,brdev_set.name eth1 ,brdev_set.flag 0
eth1 up
ethdrv_dev_ioctl,brdev_set.port_id 2 ,brdev_set.name eth2 ,brdev_set.flag 0
eth2 up
ethdrv_dev_ioctl,brdev_set.port_id 3 ,brdev_set.name eth3 ,brdev_set.flag 0
eth3 up
tm_port_egress_traffic_sharp_set p_port:3 p_ena:0 p_band_width:0

Capacity=200000tm_port_egress_traffic_sharp_set p_port:2 p_ena:0 p_band_width:0

Capacity=200000tm_port_egress_traffic_sharp_set p_port:1 p_ena:0 p_band_width:0

Capacity=200000tm_port_egress_traffic_sharp_set p_port:0 p_ena:0 p_band_width:0

Capacity=200000
switch_phy_int_check 1
pon0 up
set_netdev_type dev (pon0) type (300) vendor name = ZTE_PX20+_G
optical PN(0x60) =
optical PN(0x28) = ZX279511
device eth0 entered promiscuous mode
set_netdev_type dev (eth0) type (800)
device eth1 entered promiscuous mode
set_netdev_type dev (eth1) type (800)
device eth2 entered promiscuous mode
br0: port 3(eth2) entered forwarding state
br0: port 3(eth2) entered forwarding state
IPv6: ADDRCONF(NETDEV_CHANGE): br0: link becomes ready
set_netdev_type dev (eth2) type (800)
device eth3 entered promiscuous mode
set_netdev_type dev (eth3) type (800) set_netdev_type dev (pon0) type (300) set_netdev_type dev (pon0) type (300) set_netdev_type dev (pon0) type (300)
ch:0 pcm mode:G711A_U
Siliconlab chip id error! 0x0
cmd not found
====EVENT_O7_STATE_SAVE OFF====
cmd not found
cmd not found
random: nonblocking pool is initialized
device br0 entered promiscuous mode
tm_port_egress_traffic_sharp_set p_port:5 p_ena:0 p_band_width:0

Capacity=200000tm_port_egress_traffic_sharp_set p_port:6 p_ena:0 p_band_width:0

Capacity=200000
overlayfs: missing 'workdir'
但是将这个mtd0自接考出来是不容易的,因为它的内存也就256MB,临时分区也容不下这个falsh影像
/opt/cu/apps # df
Filesystem         1024-blocks    Used Available Use% Mounted on
/dev/root                49024   37824   1120077% /
/dev/mtdblock3            2048       404      164420% /tagparam
cgroup_root             108016         0    108016   0% /sys/fs/cgroup
none                     21604         0   21604   0% /run
none                      5120         0      5120   0% /run/lock
none                  108016         0    108016   0% /run/shm
tmpfs                  20480       448   20032   2% /var
tmpfs                  81920      2800   79120   3% /upgtempfile
tmpfs                     2048         0      2048   0% /mnt
tmpfs                  15360         4   15356   0% /tmp
/dev/mtdblock5            8192       640      7552   8% /userconfig
/dev/mtdblock6            2048       384      166419% /usr/local/ct
/dev/mtdblock11          24576      6232   1834425% /usr/tmp
/dev/loop0                5376      5376         0 100% /usr/pre_plugin
ubi0_0                   74660      2864   67948   4% /opt/cu/apps
/dev/mtdblock4            2048       436      161221% /wlan
overlay                  74660      2864   67948   4% /CuInform
tmpfs                     5240      24      5216   0% /CuInform/tmp
overlay                  74660      2864   67948   4% /usr/sbin
/dev/mtdblock9            4352      4352         0 100% /opt/cu/framework可以看见也就/upgtempfile 文件夹可用,大小为80MB,远远不能满足需求。

以上都是分析,下面是操作步骤:
方法一:采用压缩方法在拷贝flash的时候边拷贝边压缩,然后将压缩后的文件传给电脑:
dd if=/dev/mtd0 | gzip > /upgtempfile/mtd0.gz我使用上述方法临时目录还是无法容纳,只有用更强的压缩方式,linux中有一个.xz文件它使用LZMA的压缩方式,LZMA压缩比相比较zip高不少,但在busybox中的命令xz只能解压这种文件,无法压缩。只能从网上下载完整代码自己编译一个。
/opt/cu/apps # ./xz-v5 -H
Usage: ./xz-v5 ... ...
Compress or decompress FILEs in the .xz format.

Mandatory arguments to long options are mandatory for short options too.

Operation mode:
-z, --compress      force compression
-d, --decompress    force decompression
-t, --test          test compressed file integrity
-l, --list          list information about .xz files

Operation modifiers:
-k, --keep          keep (don't delete) input files
-f, --force         force overwrite of output file and (de)compress links
-c, --stdout      write to standard output and don't delete input files
      --single-stream decompress only the first stream, and silently
                      ignore possible remaining input data
      --no-sparse   do not create sparse files when decompressing
-S, --suffix=.SUF   use the suffix `.SUF' on compressed files
      --files[=FILE]read filenames to process from FILE; if FILE is
                      omitted, filenames are read from the standard input;
                      filenames must be terminated with the newline character
      --files0[=FILE] like --files but use the null character as terminator

Basic file format and compression options:
-F, --format=FMT    file format to encode or decode; possible values are
                      `auto' (default), `xz', `lzma', and `raw'
-C, --check=CHECK   integrity check type: `none' (use with caution),
                      `crc32', `crc64' (default), or `sha256'
      --ignore-checkdon't verify the integrity check when decompressing
-0 ... -9         compression preset; default is 6; take compressor *and*
                      decompressor memory usage into account before using 7-9!
-e, --extreme       try to improve compression ratio by using more CPU time;
                      does not affect decompressor memory requirements
-T, --threads=NUM   use at most NUM threads; the default is 1; set to 0
                      to use as many threads as there are processor cores
      --block-size=SIZE
                      start a new .xz block after every SIZE bytes of input;
                      use this to set the block size for threaded compression
      --block-list=SIZES
                      start a new .xz block after the given comma-separated
                      intervals of uncompressed data
      --flush-timeout=TIMEOUT
                      when compressing, if more than TIMEOUT milliseconds has
                      passed since the previous flush and reading more input
                      would block, all pending data is flushed out
      --memlimit-compress=LIMIT
      --memlimit-decompress=LIMIT
-M, --memlimit=LIMIT
                      set memory usage limit for compression, decompression,
                      or both; LIMIT is in bytes, % of RAM, or 0 for defaults
      --no-adjust   if compression settings exceed the memory usage limit,
                      give an error instead of adjusting the settings downwards

Custom filter chain for compression (alternative for using presets):
--lzma1[=OPTS]      LZMA1 or LZMA2; OPTS is a comma-separated list of zero or
--lzma2[=OPTS]      more of the following options (valid values; default):
                        preset=PRE reset options to a preset (0-9)
                        dict=NUM   dictionary size (4KiB - 1536MiB; 8MiB)
                        lc=NUM   number of literal context bits (0-4; 3)
                        lp=NUM   number of literal position bits (0-4; 0)
                        pb=NUM   number of position bits (0-4; 2)
                        mode=MODEcompression mode (fast, normal; normal)
                        nice=NUM   nice length of a match (2-273; 64)
                        mf=NAME    match finder (hc3, hc4, bt2, bt3, bt4; bt4)
                        depth=NUMmaximum search depth; 0=automatic (default)

--x86[=OPTS]      x86 BCJ filter (32-bit and 64-bit)
--powerpc[=OPTS]    PowerPC BCJ filter (big endian only)
--ia64[=OPTS]       IA-64 (Itanium) BCJ filter
--arm[=OPTS]      ARM BCJ filter (little endian only)
--armthumb[=OPTS]   ARM-Thumb BCJ filter (little endian only)
--sparc[=OPTS]      SPARC BCJ filter
                      Valid OPTS for all BCJ filters:
                        start=NUMstart offset for conversions (default=0)

--delta[=OPTS]      Delta filter; valid OPTS (valid values; default):
                        dist=NUM   distance between bytes being subtracted
                                 from each other (1-256; 1)

Other options:

-q, --quiet         suppress warnings; specify twice to suppress errors too
-v, --verbose       be verbose; specify twice for even more verbose
-Q, --no-warn       make warnings not affect the exit status
      --robot         use machine-parsable messages (useful for scripts)

      --info-memory   display the total amount of RAM and the currently active
                      memory usage limits, and exit
-h, --help          display the short help (lists only the basic options)
-H, --long-help   display this long help and exit
-V, --version       display the version number and exit

With no FILE, or when FILE is -, read standard input.

Report bugs to <lasse.collin@tukaani.org> (in English or Finnish).
XZ Utils home page: <https://tukaani.org/xz/>    到这个地方我走了一段弯路,这里要吐槽这个中兴的这个 ARM cpu (ZX279127S@A9,1000MHZ)TNN的看名字用的是A9并且查看cpu信息用的是ARMv7 指令集,编译好的文件在板子上就是不能跑,查了不短的时间才发现这个cpu要用ARMv5 指令集方式编译才能跑起来,典型的挂羊头卖狗肉。
/opt/cu/apps # cat /proc/cpuinfo
processor       : 0
model name      : ARMv7 Processor rev 1 (v7l)
BogoMIPS      : 1987.37
Features      : half fastmult edsp tls
CPU implementer : 0x41
CPU architecture: 7
CPU variant   : 0x4
CPU part      : 0xc09
CPU revision    : 1

Hardware      : ZTE ZX27912X (Device Tree)
Revision      : 0000
Serial          : 0000000000000000
后面就简单了, 压缩后的文件为76.1 MB (79,894,956 字节)
/opt/cu/apps/busybox1 dd if=/dev/mtd0 |/opt/cu/apps/xz-v5 -M32MB>/upgtempfile/mtd0.xz    (边拷贝边压缩,用-M32MB参数是因为LZMA压缩特别占用内存,如果不限制使用内存,光猫在拷贝过程后期可能因为内存溢出而重启,我这款就重启了2次,后来加了参数就ok了)这个busybox1 文件也是我传到光猫的,光猫内置busybox文件很简化(有tftp及chmod ),但没有包含dd命令

方法二:
在以上过程中我还参考网上信息Linux 下的dd命令使用详解以及dd if=/dev/zero of=的含义发现有另外一种方式使用netcat(简称nc)传数据,这是个非常有名的工具在busybox中集成了它的简化版,busybox windows版本也可以在 https://frippery.org/files/busybox/ 下载到

1、先在windows中执行命令:(接收数据端)
busybox nc -l -p 12345 >mtd02、在光猫中执行命令:(传输数据端)
/opt/cu/apps/busybox1 dd if=/dev/mtd0 | /opt/cu/apps/busybox1 nc 192.168.1.2 12345我这里每秒能传300-400KB的数据,整个传输过程大约需要13分钟。


最后留下文件:
busybox for windows



busybox for Arm 使用静态编译,文件较大,但无需另外的库支撑,直接使用



xz for Arm 使用静态编译,文件较大,但无需另外的库支撑,直接使用


撒大地方 发表于 2024-1-4 17:08:48

大神牛逼

v208cgd 发表于 2024-3-3 17:09:09

感谢!为技术网添砖加瓦!

qq519948746 发表于 2024-3-4 17:41:53

我去 有必要这么麻烦么,光猫都带tftp小型文件传输服务,在dev目录下 执行tftp -pl mtd0 你电脑的IP   在电脑上打开tftp服务端想备份哪个都可以啊

jiuweiljp 发表于 2024-3-10 15:52:19

qq519948746 发表于 2024-3-4 17:41
我去 有必要这么麻烦么,光猫都带tftp小型文件传输服务,在dev目录下 执行tftp -pl mtd0 你电脑的IP   在电 ...

受教了。这个办法好,测试了下每秒约800+KB/S,256MB需要约6分钟。

stanmcquay 发表于 2024-3-11 02:48:49

谢谢楼主分享
页: [1]
查看完整版本: 大容量Nand Flash 光猫固件备份方法