いつもと順番が逆だけどstock戻しのメモ
導入時にinitramfsイメージでFlash内部全く触らず一度ブートする関係上、バックアップを取ってそれを基に戻すことも可能であるが、公式アップデート用FWから戻せるかどうかのテスト
- 公式FWをdecryptしてtar形式を出す
- デバイスにアップロード
- sysupgrade用スクリプトを2つロード
- stockの書き込みに使用するUBIパーティションを明示して(OpenWrtではrootfsを本来とは別のパーティションのUBIに投入するよう構成した為、明示無しではそちらに書き込まれてしまう)
nand_do_flash_fileを実行 - 書き込み完了後
rebootで再起動 - ブートローダでOS 2組のkernel/rootfs比較が行われ、CRC32不一致となるのでimage0からimage1へのコピーが行われる
- image0のstockを使用してブート
root@OpenWrt:/tmp# . /lib/upgrade/common.sh
root@OpenWrt:/tmp# . /lib/upgrade/nand.sh
root@OpenWrt:/tmp# CI_UBIPART="ubi_kernel" nand_do_flash_file wsr_3000ax4p_jp_121.dec
verifying sysupgrade tar file integrity
[74454.150629] block ubiblock1_1: released
Volume ID 0, size 28 LEBs (3555328 bytes, 3.3 MiB), LEB size 126976 bytes (124.0 KiB), dynamic, name "kernel", alignment 1
[74454.512668] block ubiblock1_1: created from ubi1:1(rootfs)
Volume ID 1, size 125 LEBs (15872000 bytes, 15.1 MiB), LEB size 126976 bytes (124.0 KiB), dynamic, name "rootfs", alignment 1
Set volume size to 3809280
Volume ID 2, size 30 LEBs (3809280 bytes, 3.6 MiB), LEB size 126976 bytes (124.0 KiB), dynamic, name "rootfs_data", alignment 1
root@OpenWrt:/tmp# ubinfo -a
UBI version: 1
Count of UBI devices: 2
UBI control device major/minor: 10:256
Present UBI devices: ubi0, ubi1
ubi0
Volumes count: 2
Logical eraseblock size: 126976 bytes, 124.0 KiB
Total amount of logical eraseblocks: 352 (44695552 bytes, 42.6 MiB)
Amount of available logical eraseblocks: 0 (0 bytes)
Maximum count of volumes 128
Count of bad physical eraseblocks: 0
Count of reserved physical eraseblocks: 19
Current maximum erase counter value: 7
Minimum input/output unit size: 2048 bytes
Character device major/minor: 250:0
Present volumes: 0, 1
Volume ID: 0 (on ubi0)
Type: dynamic
Alignment: 1
Size: 37 LEBs (4698112 bytes, 4.4 MiB)
State: OK
Name: rootfs
Character device major/minor: 250:1
-----------------------------------
Volume ID: 1 (on ubi0)
Type: dynamic
Alignment: 1
Size: 290 LEBs (36823040 bytes, 35.1 MiB)
State: OK
Name: rootfs_data
Character device major/minor: 250:2
===================================
ubi1
Volumes count: 3
Logical eraseblock size: 126976 bytes, 124.0 KiB
Total amount of logical eraseblocks: 208 (26411008 bytes, 25.1 MiB)
Amount of available logical eraseblocks: 0 (0 bytes)
Maximum count of volumes 128
Count of bad physical eraseblocks: 0
Count of reserved physical eraseblocks: 19
Current maximum erase counter value: 7
Minimum input/output unit size: 2048 bytes
Character device major/minor: 249:0
Present volumes: 0, 1, 2
Volume ID: 0 (on ubi1)
Type: dynamic
Alignment: 1
Size: 28 LEBs (3555328 bytes, 3.3 MiB)
State: OK
Name: kernel
Character device major/minor: 249:1
-----------------------------------
Volume ID: 1 (on ubi1)
Type: dynamic
Alignment: 1
Size: 125 LEBs (15872000 bytes, 15.1 MiB)
State: OK
Name: rootfs
Character device major/minor: 249:2
-----------------------------------
Volume ID: 2 (on ubi1)
Type: dynamic
Alignment: 1
Size: 30 LEBs (3809280 bytes, 3.6 MiB)
State: OK
Name: rootfs_data
Character device major/minor: 249:3
root@OpenWrt:/tmp# reboot
root@OpenWrt:/tmp# [74479.597873] mt7530-mdio mdio-bus:1f lan1: left allmulticast mode
[74479.603904] mt7530-mdio mdio-bus:1f lan1: left promiscuous mode
[74479.609964] br-lan: port 1(lan1) entered disabled state
[74479.624271] mt7530-mdio mdio-bus:1f lan2: left allmulticast mode
[74479.630290] mt7530-mdio mdio-bus:1f lan2: left promiscuous mode
[74479.636313] br-lan: port 2(lan2) entered disabled state
[74479.650241] mt7530-mdio mdio-bus:1f lan3: left allmulticast mode
[74479.656393] mtk_soc_eth 15100000.ethernet eth0: left allmulticast mode
[74479.662917] mt7530-mdio mdio-bus:1f lan3: left promiscuous mode
[74479.668912] br-lan: port 3(lan3) entered disabled state
[74480.177936] mtk_soc_eth 15100000.ethernet eth0: Link is Down
[74484.255697] reboot: Restarting system
F0: 102B 0000
FA: 1040 0000
FA: 1040 0000 [0200]
F9: 0000 0000
V0: 0000 0000 [0001]
00: 0000 0000
BP: 2400 0041 [0000]
G0: 1190 0000
EC: 0000 0000 [1000]
T0: 0000 024B [010F]
Jump to BL
NOTICE: BL2: v2.7(release):9818265ce7-dirty
NOTICE: BL2: Built : 06:51:45, May 6 2023
NOTICE: WDT: disabled
NOTICE: EMI: Using DDR4 settings
[TxChooseVref] Worse bit 3, Min win 24, Win sum 406, Final Vref 38
NOTICE: EMI: Detected DRAM size: 512MB
NOTICE: EMI: complex R/W mem test passed
NOTICE: CPU: MT7981 (1300MHz)
NOTICE: SPI_NAND parses attributes from parameter page.
NOTICE: SPI_NAND Detected ID 0xef
NOTICE: Page size 2048, Block size 131072, size 134217728
NOTICE: Initializing NMBM ...
NOTICE: Signature found at block 1023 [0x07fe0000]
NOTICE: First info table with writecount 0 found in block 960
NOTICE: Second info table with writecount 0 found in block 963
NOTICE: NMBM has been successfully attached in read-only mode
NOTICE: BL2: Booting BL31
NOTICE: BL31: v2.7(release):9818265ce7-dirty
NOTICE: BL31: Built : 06:51:47, May 6 2023
U-Boot 2022.10 (May 06 2023 - 06:51:01 +0000)
CPU: MediaTek MT7981
Model: mt7981-rfb
DRAM: 512 MiB
Core: 32 devices, 12 uclasses, devicetree: separate
Initializing NMBM ...
spi-nand: spi_nand spi_nand@0: Winbond SPI NAND was found.
spi-nand: spi_nand spi_nand@0: 128 MiB, block size: 128 KiB, page size: 2048, OOB size: 64
Could not find a valid device for nmbm0
Signature found at block 1023 [0x07fe0000]
First info table with writecount 0 found in block 960
Second info table with writecount 0 found in block 963
NMBM has been successfully attached
Loading Environment from MTD... OK
In: serial@11002000
Out: serial@11002000
Err: serial@11002000
*** U-Boot Boot Menu ***
Press UP/DOWN to move, ENTER to select, ESC/CTRL+C to quit
1. Startup system (Default)
2. Upgrade firmware
3. Upgrade ATF BL2
4. Upgrade ATF FIP
5. Upgrade single image
6. Load image
0. U-Boot console
***ubi_boot_image: boot_select = 0.... ***
ubi0: attaching mtd6
ubi0: scanning is finished
ubi0: attached mtd6 (name "ubi", size 26 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: 208, bad PEBs: 0, corrupted PEBs: 0
ubi0: user volume: 3, internal volumes: 1, max. volumes count: 128
ubi0: max/mean erase counter: 7/5, WL threshold: 4096, image sequence number: 2002301422
ubi0: available PEBs: 2, total reserved PEBs: 206, PEBs reserved for bad PEB handling: 19
Reading from volume 'kernel' to 0x46000000, size 0x0 ... OK
Reading from volume 'rootfs' to 0x46364000, size 0x0 ... OK
ubi0: detaching mtd6
ubi0: mtd6 is detached
ubi0: attaching mtd7
ubi0: scanning is finished
ubi0: attached mtd7 (name "Kernel2", size 26 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: 208, bad PEBs: 0, corrupted PEBs: 0
ubi0: user volume: 3, internal volumes: 1, max. volumes count: 128
ubi0: max/mean erase counter: 5/3, WL threshold: 4096, image sequence number: 1193052006
ubi0: available PEBs: 0, total reserved PEBs: 208, PEBs reserved for bad PEB handling: 19
Reading from volume 'kernel' to 0x47287000, size 0x0 ... OK
Reading from volume 'rootfs' to 0x476e3000, size 0x0 ... OK
ret0=0 ret1=0 kernel1_crc=700b1e07 rootfs1_crc=3fd24b4d kernel2_crc=7fc17418 rootfs2_crc=51dd723f -
***copy image direction: copy image0 to image1 ***
UBI partition 'Kernel2' already selected
kernel_data is 46000000 rootfs_data is 46364000 kernel_size is 3555328 rootfs_size is 15872000 ---
Remove UBI volume rootfs_data (id 2)
Remove UBI volume kernel (id 0)
Creating static volume kernel of size 3555328
Updating volume 'kernel' from 0x46000000, size 0x364000 ... OK
Remove UBI volume rootfs (id 1)
Creating static volume rootfs of size 15872000
Updating volume 'rootfs' from 0x46364000, size 0xf23000 ... OK
Creating dynamic volume rootfs_data of size -1
ubi0: detaching mtd7
ubi0: mtd7 is detached
ubi0: attaching mtd6
ubi0: scanning is finished
ubi0: attached mtd6 (name "ubi", size 26 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: 208, bad PEBs: 0, corrupted PEBs: 0
ubi0: user volume: 3, internal volumes: 1, max. volumes count: 128
ubi0: max/mean erase counter: 7/5, WL threshold: 4096, image sequence number: 2002301422
ubi0: available PEBs: 2, total reserved PEBs: 206, PEBs reserved for bad PEB handling: 19
No size specified -> Using max size (3555328)
Read 3555328 bytes from volume kernel to 0000000046000000
## Loading kernel from FIT Image at 46000000 ...
Using 'config-1' configuration
Trying 'kernel-1' kernel subimage
Description: ARM64 OpenWrt Linux-5.4.238
Type: Kernel Image
Compression: lzma compressed
Data Start: 0x460000e8
Data Size: 3498774 Bytes = 3.3 MiB
Architecture: AArch64
OS: Linux
Load Address: 0x48080000
Entry Point: 0x48080000
Hash algo: crc32
Hash value: 76639287
Hash algo: sha1
Hash value: ef0c9a323ad3a62a142acf3dbb79366a17e631c3
Verifying Hash Integrity ... crc32+ sha1+ OK
## Loading fdt from FIT Image at 46000000 ...
Using 'config-1' configuration
Trying 'fdt-1' fdt subimage
Description: ARM64 OpenWrt mt7981-spim-nand-gsw-dual-gmac-wan-p0 device tree blob
Type: Flat Device Tree
Compression: uncompressed
Data Start: 0x46356558
Data Size: 18483 Bytes = 18 KiB
Architecture: AArch64
Hash algo: crc32
Hash value: b5898151
Hash algo: sha1
Hash value: 01f7bfec87d15d00d12052b441fd3abe3d3d9216
Verifying Hash Integrity ... crc32+ sha1+ OK
Booting using the fdt blob at 0x46356558
Uncompressing Kernel Image
Loading Device Tree to 000000005f7f1000, end 000000005f7f8832 ... OK
Starting kernel ...
[ 0.000000] Booting Linux on physical CPU 0x0000000000 [0x410fd034]
[ 0.000000] Linux version 5.4.238 (wenfang@1c30f36eaf34) (gcc version 8.4.0 (OpenWrt GCC 8.4.0 r16490-cb0975a9bb)) #0 SMP Fri May 31 11:54:03
2024
[ 0.000000] Machine model: MediaTek MT7981 GSW DualGMAC
[ 0.000000] earlycon: uart8250 at MMIO32 0x0000000011002000 (options '')
[ 0.000000] printk: bootconsole [uart8250] enabled
...