mtd Usage: mtd [ ...] [ ...] [:...] The device is in the format of mtdX (eg: mtd4) or its label. mtd recognizes these commands: unlock unlock the device refresh refresh mtd partition erase erase all data on device verify |- verify (use - for stdin) to device write |- write (use - for stdin) to device jffs2write append to the jffs2 partition on the device resetbc reset the uboot boot counter fixseama fix the checksum in a seama header on first boot fixwrg fix the checksum in a wrg header on first boot Following options are available: -q quiet mode (once: no [w] on writing, twice: no status messages) -n write without first erasing the blocks -r reboot after successful command -f force write without trx checks -e erase before executing the command -d directory for jffs2write, defaults to "tmp" -j integrate into jffs2 data when writing an image -s skip the first n bytes when appending data to the jffs2 partiton, defaults to "0" -p write beginning at partition offset -l the length of data that we want to dump -c datasize amount of data to be used for checksum calculation (for fixtrx / fixseama / fixwrg / fixwrgg) -t write TP-Link recovery-flag to (for write) Example: To write linux.trx to mtd4 labeled as linux and reboot afterwards mtd -r write linux.trx linux root@OpenWrt-wt1520:~# cat /proc/mtd dev: size erasesize name mtd0: 00030000 00001000 "u-boot" mtd1: 00010000 00001000 "u-boot-env" mtd2: 00010000 00001000 "factory" mtd3: 007b0000 00001000 "firmware" mtd4: 00156849 00001000 "kernel" mtd5: 006597b7 00001000 "rootfs" mtd6: 003c3000 00001000 "rootfs_data" BusyBox v1.31.1 () built-in shell (ash) _______ ________ __ | |.-----.-----.-----.| | | |.----.| |_ | - || _ | -__| || | | || _|| _| |_______|| __|_____|__|__||________||__| |____| |__| W I R E L E S S F R E E D O M ----------------------------------------------------- OpenWrt SNAPSHOT, r14553-7dc78d1d28 [11:36:04:364] U-Boot 1.1.3 (Sep 13 2012 - 16:39:43) [11:36:04:369] [11:36:04:373] Board: Ralink APSoC DRAM: 32 MB [11:36:04:378] relocate_code Pointer at: 81fb4000 [11:36:04:385] spi_wait_nsec: 42 [11:36:04:388] spi device id: ef 40 17 0 0 (40170000) [11:36:04:395] find flash: W25Q64BV [11:36:04:401] raspi_read: from:30000 len:1000 [11:36:04:408] .*** Warning - bad CRC, using default environment [11:36:04:421] [11:36:04:422] ============================================ [11:36:04:430] Ralink UBoot Version: 4.0.1.0 [11:36:04:436] -------------------------------------------- [11:36:04:444] ASIC 5350_MP (Port5<->None) [11:36:04:449] DRAM_CONF_FROM: Boot-Strapping [11:36:04:455] DRAM_TYPE: SDRAM [11:36:04:458] DRAM_SIZE: 256 Mbits [11:36:04:462] DRAM_WIDTH: 16 bits [11:36:04:465] DRAM_TOTAL_WIDTH: 16 bits [11:36:04:470] TOTAL_MEMORY_SIZE: 32 MBytes [11:36:04:475] Flash component: SPI Flash [11:36:04:480] Date:Sep 13 2012 Time:16:39:43 [11:36:04:486] ============================================ [11:36:04:494] icache: sets:256, ways:4, linesz:32 ,total:32768 [11:36:04:502] dcache: sets:128, ways:4, linesz:32 ,total:16384 [11:36:04:512] [11:36:04:512] ##### The CPU freq = 360 MHZ #### [11:36:04:518] estimate memory size =32 Mbytes [11:36:04:528] [11:36:04:529] Please choose the operation: [11:36:04:534] 1: Load system code to SDRAM via TFTP. [11:36:04:542] 2: Load system code then write to Flash via TFTP. [11:36:04:551] 3: Boot system code via Flash (default). [11:36:04:559] 4: Entr boot command line interface. [11:36:04:566] 7: Load Boot Loader code then write to Flash via Serial. [11:36:04:577] 9: Load Boot Loader code then write to Flash via TFTP. [11:36:05:586] <0x08><0x08><0x08> 4 <0x08><0x08><0x08> 3 <0x08><0x08><0x08> 2 <0x08><0x08><0x08> 1 <0x08><0x08><0x08> 0 [11:36:09:596] [11:36:09:596] 3: System Boot system code via Flash. [11:36:09:601] ## Booting image at bc050000 ... [11:36:09:606] raspi_read: from:50000 len:40 [11:36:09:611] . Image Name: MIPS OpenWrt Linux-5.4.67 [11:36:09:618] Created: 2020-09-25 2:31:36 UTC [11:36:09:626] Image Type: MIPS Linux Kernel Image (lzma compressed) [11:36:09:636] Data Size: 1402889 Bytes = 1.3 MB [11:36:09:643] Load Address: 80000000 [11:36:09:648] Entry Point: 80000000 [11:36:09:652] raspi_read: from:50040 len:156809 [11:36:09:659] ...................... Verifying Checksum ... OK [11:36:11:162] Uncompressing Kernel Image ... OK [11:36:14:176] No initrd [11:36:14:182] ## Transferring control to Linux (at address 80000000) ... [11:36:14:193] ## Giving linux memsize in MB, 32 [11:36:14:198] [11:36:14:198] Starting kernel ... [11:36:14:198] [11:36:14:204] [ 0.000000] Linux version 5.4.67 (johndoe@jd-ubuntu) (gcc version 8.4.0 (OpenWrt GCC 8.4.0 r13903-f206461153)) #0 Fri Sep 25 02:31:36 2020 [11:36:14:225] [ 0.000000] SoC Type: Ralink RT5350 id:1 rev:3 [11:36:14:233] [ 0.000000] printk: bootconsole [early0] enabled [11:36:14:243] [ 0.000000] CPU0 revision is: 0001964c (MIPS 24KEc) [11:36:14:254] [ 0.000000] MIPS: machine is Nexx WT1520 (8M) [11:36:14:264] [ 0.000000] Initrd not found or empty - disabling initrd [11:36:14:276] [ 0.000000] Primary instruction cache 32kB, VIPT, 4-way, linesize 32 bytes. [11:36:14:290] [ 0.000000] Primary data cache 16kB, 4-way, VIPT, no aliases, linesize 32 bytes [11:36:14:305] [ 0.000000] Zone ranges: [11:36:14:309] [ 0.000000] Normal [mem 0x0000000000000000-0x0000000001ffffff] [11:36:14:321] [ 0.000000] Movable zone start for each node [11:36:14:330] [ 0.000000] Early memory node ranges [11:36:14:337] [ 0.000000] node 0: [mem 0x0000000000000000-0x0000000001ffffff] [11:36:14:350] [ 0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x0000000001ffffff] [11:36:14:373] [ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 8128 [11:36:14:386] [ 0.000000] Kernel command line: console=ttyS0,57600 rootfstype=squashfs,jffs2 [11:36:14:402] [ 0.000000] Dentry cache hash table entries: 4096 (order: 2, 16384 bytes, linear) [11:36:14:416] [ 0.000000] Inode-cache hash table entries: 2048 (order: 1, 8192 bytes, linear) [11:36:14:431] [ 0.000000] Writing ErrCtl register=00049b0e [11:36:14:440] [ 0.000000] Readback ErrCtl register=00049b0e [11:36:14:448] [ 0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off [11:36:14:464] [ 0.000000] Memory: 26856K/32768K available (3479K kernel code, 170K rwdata, 492K rodata, 1228K init, 186K bss, 5912K reserved, 0K cma-reserved) [11:36:14:492] [ 0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1 [11:36:14:504] [ 0.000000] NR_IRQS: 256 [11:36:14:512] [ 0.000000] random: get_random_bytes called from 0x8040d9ac with crng_init=0 [11:36:14:526] [ 0.000000] CPU Clock: 360MHz [11:36:14:533] [ 0.000000] clocksource: systick: mask: 0xffff max_cycles: 0xffff, max_idle_ns: 583261500 ns [11:36:14:550] [ 0.000000] systick: running - mult: 214748, shift: 32 [11:36:14:560] [ 0.000000] clocksource: MIPS: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 10618113593 ns [11:36:14:577] [ 0.000018] sched_clock: 32 bits at 180MHz, resolution 5ns, wraps every 11930464253ns [11:36:14:624] [ 0.015721] Calibrating delay loop... 239.10 BogoMIPS (lpj=478208) [11:36:14:638] [ 0.059904] pid_max: default: 32768 minimum: 301 [11:36:14:647] [ 0.069413] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes, linear) [11:36:14:661] [ 0.083925] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes, linear) [11:36:14:685] [ 0.108620] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns [11:36:14:706] [ 0.128025] futex hash table entries: 256 (order: -1, 3072 bytes, linear) [11:36:14:719] [ 0.141591] pinctrl core: initialized pinctrl subsystem [11:36:14:730] [ 0.153266] NET: Registered protocol family 16 [11:36:14:809] [ 0.231950] rt2880_gpio 10000600.gpio: registering 22 gpios [11:36:14:820] [ 0.243117] rt2880_gpio 10000600.gpio: registering 22 irq handlers [11:36:14:837] [ 0.257215] workqueue: max_active 576 requested for napi_workq is out of range, clamping between 1 and 512 [11:36:14:864] [ 0.286953] clocksource: Switched to clocksource MIPS [11:36:14:879] [ 0.299932] NET: Registered protocol family 2 [11:36:14:890] [ 0.310338] tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 4096 bytes, linear) [11:36:14:905] [ 0.327073] TCP established hash table entries: 1024 (order: 0, 4096 bytes, linear) [11:36:14:921] [ 0.342308] TCP bind hash table entries: 1024 (order: 0, 4096 bytes, linear) [11:36:14:935] [ 0.356295] TCP: Hash tables configured (established 1024 bind 1024) [11:36:14:948] [ 0.369318] UDP hash table entries: 256 (order: 0, 4096 bytes, linear) [11:36:14:960] [ 0.382396] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes, linear) [11:36:14:974] [ 0.396906] NET: Registered protocol family 1 [11:36:14:990] [ 0.413224] rt-timer 10000100.timer: maximum frequency is 3662Hz [11:36:15:008] [ 0.431491] workingset: timestamp_bits=30 max_order=13 bucket_order=0 [11:36:15:035] [ 0.458645] squashfs: version 4.0 (2009/01/31) Phillip Lougher [11:36:15:050] [ 0.470268] jffs2: version 2.2 (NAND) (SUMMARY) (LZMA) (RTIME) (CMODE_PRIORITY) (c) 2001-2006 Red Hat, Inc. [11:36:15:105] [ 0.528185] Serial: 8250/16550 driver, 2 ports, IRQ sharing disabled [11:36:15:122] [ 0.543482] printk: console [ttyS0] disabled [11:36:15:132] [ 0.552108] 10000c00.uartlite: ttyS0 at MMIO 0x10000c00 (irq = 20, base_baud = 2500000) is a Palmchip BK-3103 [11:36:15:148] [ 0.571868] printk: console [ttyS0] enabled [11:36:15:158] [ 0.571868] printk: console [ttyS0] enabled [11:36:15:166] [ 0.588434] printk: bootconsole [early0] disabled [11:36:15:176] [ 0.588434] printk: bootconsole [early0] disabled [11:36:15:200] [ 0.623846] spi spi0.0: force spi mode3 [11:36:15:222] [ 0.645078] spi-nor spi0.0: s25fl064k (8192 Kbytes) [11:36:15:232] [ 0.655035] 4 fixed-partitions partitions found on MTD device spi0.0 [11:36:15:245] [ 0.667782] Creating 4 MTD partitions on "spi0.0": [11:36:15:255] [ 0.677420] 0x000000000000-0x000000030000 : "u-boot" [11:36:15:266] [ 0.689630] 0x000000030000-0x000000040000 : "u-boot-env" [11:36:15:279] [ 0.702617] 0x000000040000-0x000000050000 : "factory" [11:36:15:292] [ 0.715210] 0x000000050000-0x000000800000 : "firmware" [11:36:15:314] [ 0.737217] 2 uimage-fw partitions found on MTD device firmware [11:36:15:327] [ 0.749205] Creating 2 MTD partitions on "firmware": [11:36:15:337] [ 0.759210] 0x000000000000-0x000000156849 : "kernel" [11:36:15:348] [ 0.771546] 0x000000156849-0x0000007b0000 : "rootfs" [11:36:15:360] [ 0.783909] mtd: device 5 (rootfs) set to be root filesystem [11:36:15:377] [ 0.800238] 1 squashfs-split partitions found on MTD device rootfs [11:36:15:390] [ 0.812805] 0x0000003ed000-0x0000007b0000 : "rootfs_data" [11:36:15:404] [ 0.827235] libphy: Fixed MDIO Bus: probed [11:36:15:422] [ 0.845433] rt3050-esw 10110000.esw: link changed 0x00 [11:36:15:437] [ 0.860124] mtk_soc_eth 10100000.ethernet eth0: mediatek frame engine at 0xb0100000, irq 5 [11:36:15:454] [ 0.877891] rt2880_wdt 10000120.watchdog: Initialized [11:36:15:468] [ 0.891408] NET: Registered protocol family 10 [11:36:15:488] [ 0.911833] Segment Routing with IPv6 [11:36:15:501] [ 0.919596] NET: Registered protocol family 17 [11:36:15:505] [ 0.928774] 8021q: 802.1Q VLAN Support v1.8 [11:36:15:531] [ 0.954139] VFS: Mounted root (squashfs filesystem) readonly on device 31:5. [11:36:15:558] [ 0.981183] Freeing unused kernel memory: 1228K [11:36:15:569] [ 0.990324] This architecture does not have kernel memory protection. [11:36:15:581] [ 1.003222] Run /sbin/init as init process [11:36:16:047] [ 1.471010] random: fast init done [11:36:18:815] [ 4.238784] init: Console is alive [11:36:18:823] [ 4.246567] init: - watchdog - [11:36:21:932] [ 7.356919] kmodloader: loading kernel modules from /etc/modules-boot.d/* [11:36:22:395] [ 7.820094] kmodloader: done loading kernel modules from /etc/modules-boot.d/* [11:36:22:421] [ 7.845716] init: - preinit - [11:36:24:475] [ 9.900574] random: procd: uninitialized urandom read (4 bytes read) [11:36:24:589] [ 10.014234] random: jshn: uninitialized urandom read (4 bytes read) [11:36:24:757] [ 10.182146] random: jshn: uninitialized urandom read (4 bytes read) [11:36:27:265] [ 12.690362] rt3050-esw 10110000.esw: link changed 0x00 [11:36:27:499] Press the [f] key and hit [enter] to enter failsafe mode [11:36:27:510] Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level [11:36:31:678] - failsafe button reset was pressed - [11:36:31:707] - failsafe - [11:36:33:300] Waiting for kernel randomness to be initialised... [11:36:35:336] [ 20.763112] random: crng init done [11:36:35:343] [ 20.769995] random: 3 urandom warning(s) missed due to ratelimiting [11:36:35:359] Generating 1024 bit rsa key, this may take a while... [11:36:39:267] Public key portion is: