Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mediatek: Add a second u-boot for Redmi AX6S #14770

Closed
wants to merge 3 commits into from
Closed

Conversation

981213
Copy link
Member

@981213 981213 commented Mar 2, 2024

The vendor u-boot knows nothing about UBI, and we used to have a fixed-size kernel partition for vendor u-boot and UBI for rootfs. However, that fixed partition becomes too small eventually, and expanding it requires complicated procedure.

This commit changed the flash layout and added a second u-boot where the kernel supposed to be.
Now the vendor u-boot chainloads our mainline u-boot, and our u-boot reads kernel+rootfs from UBI, verifies it, and boot into OpenWrt.

Converting from old layout:

  1. prepare a tftp server at 192.168.1.254 to serve the sysupgrade image:
    openwrt-mediatek-mt7622-xiaomi_redmi-router-ax6s-squashfs-sysupgrade.itb

  2. upload the ubi-loader.itb to OpenWrt /tmp, and flash it to the old kernel partition:
    mtd -r write openwrt-mediatek-mt7622-xiaomi_redmi-router-ax6s-ubi-loader.itb

  3. The router should reboot and flash the sysupgrade image via TFTP.

Flashing from vendor firmware should go like this:

  1. set environment to boot from the first firmware partition
  2. flash ubi-loader.itb into the first firmware
  3. reboot, and u-boot should tftp & flash OpenWrt from 192.168.1.254 like mentioned above.

Help wanted:
This entire PR is made on a different board with a Xiaomi u-boot dump. It's not tested on a real Redmi-AX6S.
It would be great if someone with serial console access can:

  1. Test this PR.
  2. write a new flash instruction for flashing from vendor firmware.

@981213 981213 added work in progress pull request the author is still working on RFC pull request ready for comments RFT pull request ready for testing labels Mar 2, 2024
@github-actions github-actions bot added core packages pull request/issue for core (in-tree) packages target/mediatek pull request/issue for mediatek target labels Mar 2, 2024
@remittor
Copy link
Contributor

remittor commented Mar 2, 2024

@981213

3. The router should reboot and flash the sysupgrade image via TFTP.

What kind of image is this? How to create it?

@981213
Copy link
Member Author

981213 commented Mar 2, 2024

@remittor

What kind of image is this? How to create it?

It's openwrt-mediatek-mt7622-xiaomi_redmi-router-ax6s-squashfs-sysupgrade.itb built in OpenWrt.
Step 1 asked for a TFTP server with this file on it at 192.168.1.254.

@@ -9,7 +9,8 @@ case "$(board_name)" in
uci set system.@system[0].compat_version="1.1"
uci commit system
;;
linksys,e8450-ubi)
linksys,e8450-ubi|\
xiaomi,redmi-router-ax6s)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's a chance to remove support for this device and add a new one redmi,ax6s instead. I remember Redmi is a standalone brand. It's not a series of Xiaomi.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DragonBluep
You are in vain trying to use marketing names.
Each Xiaomi router has a sticker on which the model name is written.
AX6S = RB03
AX3200 = RB01

Here's a look at ipq806x-based devices: https://github.com/openwrt/openwrt/tree/main/target/linux/ipq806x/files/arch/arm/boot/dts
It is not the marketing name of the router that is used, but the model name.

The marketing name must be indicated here:
DEVICE_ALT1_MODEL :=

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name should be vendor,model. I think we should keep Xiaomi as it's the actual vendor.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are in vain trying to use marketing names.
Each Xiaomi router has a sticker on which the model name is written.
AX6S = RB03
AX3200 = RB01

So the correct model should be xxx,rb03. Sadly, there are no Xiaomi devices using the correct model name.

The name should be vendor,model. I think we should keep Xiaomi as it's the actual vendor.

At least Xiaomi devices have the MI logo but Redmi devices have the Redmi logo. Anyway, they still share the same official site. Their relationship is more like Mercury and TP-Link.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DragonBluep

So the correct model should be xxx,rb03

Yes. I believe that developers should use precise notations, and not those that marketers force.

Sadly, there are no Xiaomi devices using the correct model name.

You are not right. Each firmware image for an Asus router has the exact model name in the header.
Likewise, in every firmware image for a Xiaomi router, the header contains the exact name of the model.

@remittor
Copy link
Contributor

remittor commented Mar 2, 2024

  • prepare a tftp server at 192.168.1.254 to serve the sysupgrade image:
    openwrt-mediatek-mt7622-xiaomi_redmi-router-ax6s-squashfs-sysupgrade.itb
  • upload the ubi-loader.itb to OpenWrt /tmp, and flash it to the old kernel partition:
    mtd -r write /tmp/openwrt-mediatek-mt7622-xiaomi_redmi-router-ax6s-ubi-loader.itb kernel
  • The router should reboot and flash the sysupgrade image via TFTP.

I checked this installation method. It works!

uart logs ``` Writing to NAND... OK Booting System 0

NAND read: device 0 offset 0x2c0000, size 0x2000
8192 bytes read: OK
[do_read_image_blks] This is a FIT image,img_size = 0x3d2f4
[do_read_image_blks] img_blks = 0x7b
[do_read_image_blks] img_align_size = 0x3d800

NAND read: device 0 offset 0x2c0000, size 0x3d800
251904 bytes read: OK
bootm flag=0, states=70f

Loading kernel from FIT Image at 4007ff28 ...

Using 'config-1' configuration
Trying 'kernel-1' kernel subimage
Description: ARM64 OpenWrt Linux-u-boot
Type: Kernel Image
Compression: lzma compressed
Data Start: 0x40080010
Data Size: 248944 Bytes = 243.1 KiB
Architecture: AArch64
OS: Linux
Load Address: 0x41e00000
Entry Point: 0x41e00000
Hash algo: crc32
Hash value: af7aac32
Hash algo: sha1
Hash value: b0d0fb46f431b9166b99110be6937f1c63437e07
Verifying Hash Integrity ... crc32+ sha1+ OK
Uncompressing Kernel Image ... OK

Starting kernel ...

[ATF][ 4.128532]save kernel info
[ATF][ 4.131468]Kernel_EL2
[ATF][ 4.134139]Kernel is 64Bit
[ATF][ 4.137227]pc=0x41e00000, r0=0x0, r1=0x0
INFO: BL3-1: Preparing for EL3 exit to normal world, Kernel
INFO: BL3-1: Next image address = 0x41e00000
INFO: BL3-1: Next image spsr = 0x3c9
[ATF][ 4.154341]el3_exi▒serial_mtk serial@11002000: pinctrl_select_state_full: uclass_get_device_by_phandle_id: err=-19

U-Boot 2024.01-OpenWrt-r25402-012be0468c (Mar 02 2024 - 14:26:04 +0000)

CPU: MediaTek MT7622
Model: Xiaomi Redmi Router AX6S
DRAM: 256 MiB
Core: 37 devices, 16 uclasses, devicetree: separate
Loading Environment from nowhere... OK
In: serial@11002000
Out: serial@11002000
Err: serial@11002000
reset button found
Net:
Warning: ethernet@1b100000 (eth0) using random MAC address - 82:00:b1:12:21:f7
eth0: ethernet@1b100000
Autoboot in 0 seconds
SPI-NAND: Failed to enable quad spi
SPI-NAND: F50L1G41LB (128MB)
Volume fit not found!
Using ethernet@1b100000 device
TFTP from server 192.168.1.254; our IP address is 192.168.1.1
Filename 'openwrt-mediatek-mt7622-xiaomi_redmi-router-ax6s-squashfs-sysupgrade.itb'.
Load address: 0x46000000
Loading: #################################################################
#################################################################
3.5 MiB/s
done
Bytes transferred = 23344234 (164346a hex)

Checking Image at 46000000 ...

FIT image found
FIT description: ARM64 OpenWrt FIT (Flattened Image Tree)
Image 0 (kernel-1)
Description: ARM64 OpenWrt Linux-6.1.79
Type: Kernel Image
Compression: gzip compressed
Data Start: 0x46001000
Data Size: 5741058 Bytes = 5.5 MiB
Architecture: AArch64
OS: Linux
Load Address: 0x44000000
Entry Point: 0x44000000
Hash algo: crc32
Hash value: e23dade2
Hash algo: sha1
Hash value: e0dce2b6eb043363ccb7f35fbce0430c731f04d8
Image 1 (fdt-1)
Description: ARM64 OpenWrt xiaomi_redmi-router-ax6s device tree blob
Type: Flat Device Tree
Compression: uncompressed
Data Start: 0x4657b000
Data Size: 29363 Bytes = 28.7 KiB
Architecture: AArch64
Hash algo: crc32
Hash value: 00555340
Hash algo: sha1
Hash value: a83482eaf9594aa02c025fc9c06d91d0f06600fa
Image 2 (rootfs-1)
Description: ARM64 OpenWrt xiaomi_redmi-router-ax6s rootfs
Type: Filesystem Image
Compression: uncompressed
Data Start: 0x46583000
Data Size: 17563648 Bytes = 16.8 MiB
Hash algo: crc32
Hash value: c9045516
Hash algo: sha1
Hash value: 99dce000889bafec32f5c7a958314428cf81fac3
Default Configuration: 'config-1'
Configuration 0 (config-1)
Description: OpenWrt xiaomi_redmi-router-ax6s
Kernel: kernel-1
FDT: fdt-1
Loadables: rootfs-1

Checking hash(es) for FIT Image at 46000000 ...

Hash(es) for Image 0 (kernel-1): crc32+ sha1+
Hash(es) for Image 1 (fdt-1): crc32+ sha1+
Hash(es) for Image 2 (rootfs-1): crc32+ sha1+
Remove UBI volume rootfs_data (id 1)
Creating dynamic volume fit of size 23344234
23344234 bytes written to volume fit
No size specified -> Using max size (71995392)
Creating dynamic volume rootfs_data of size 71995392
resetting ...

F0: 102B 0000
F6: 0000 0000
V0: 0000 0000 [0001]
00: 0000 0000
BP: 0000 0041 [0000]
G0: 0190 0000
T0: 0000 036E [000F]
Jump to BL

UNIVPLL_CON0 = 0xFE000000!!!
mt_pll_init: Set pll frequency for 25M crystal
RAM_CONSOLE preloader last status: 0x0 0x0 0x0 0x0 0x0 0x0
[PMIC_WRAP]wrap_init pass,the return value=0.
[pmic_init] Preloader Start..................
[pmic_init] MT6380 CHIP Code, reg_val = 0, 1:E2 0:E3
[pmic_init] Done...................
Chip part number:7622B
MT7622 Version: 1.2.8, (iPA)
SSC OFF
mt_pll_post_init: mt_get_cpu_freq = 1350000Khz
mt_pll_post_init: mt_get_mem_freq = 1600000Khz
mt_pll_post_init: mt_get_bus_freq = 279980Khz
[PLFM] Init I2C: OK(0)

[BLDR] Build Time: 20210316-161525
==== Dump RGU Reg ========
RGU MODE: 14
RGU LENGTH: FFE0
RGU STA: 40000000
RGU INTERVAL: FFF
RGU SWSYSRST: 8000
==== Dump RGU Reg End ====
RGU: g_rgu_satus:2
mtk_wdt_mode_config mode value=10, tmp:22000010
PL RGU RST: ??
SW reset with bypass power key flag
Find bypass powerkey flag
WDT NONRST=0x20000000
WDT IRQ_EN=0x340003
RGU mtk_wdt_init:MTK_WDT_DEBUG_CTL(590200F3)
[EMI] MDL number = 2
[EMI] DRAMC calibration start

[DDR] Gating glitch patched (0<cnt<=6)
[EMI] DRAMC calibration end

[EMI]rank size auto detect
[EMI]start_addr[0x40000000]=0x12345678, test_addr[0x48000000]= 0xEDCBA987
[EMI]start_addr[0x40000000]=0xEDCBA987, test_addr[0x50000000]= 0xEDCBA987
[EMI]rank0 size: 0x10000000
[MEM] complex R/W mem test pass
RAM_CONSOLE wdt status (0x2)=0x2
mtk_snand_get_device_info
2-Recognize NAND: ID [C8 1 ], Device Name [F50L1G41LB], Page Size [2048]B Spare Size [64]B Total Size [128]MB
[BBT] BMT.v2 is found at 0x3FF
[PLFM] Init Boot Device: OK(0)

[PART] blksz: 2048B
[PART] [0x0000000000000000-0x000000000007FFFF] "PRELOADER" (256 blocks)
[PART] [0x0000000000080000-0x00000000000BFFFF] "tee1" (128 blocks)
[PART] [0x00000000000C0000-0x000000000013FFFF] "lk" (256 blocks)

Device APC domain init setup:

Domain Setup (0x0)
Domain Setup (0x0)
Device APC domain after setup:
Domain Setup (0x0)
Domain Setup (0x0)
[PART] Image with part header
[PART] name : U-Boot
[PART] addr : 41E00000h mode : -1
[PART] size : 356560
[PART] magic: 58881688h

[PART] load "lk" from 0x00000000000C0200 (dev) to 0x41E00000 (mem) [SUCCESS]
[PART] load speed: 16581KB/s, 356560 bytes, 21ms
load lk (ret=0)
[PART] Image with part header
[PART] name : atf
[PART] addr : FFFFFFFFh mode : -1
[PART] size : 57936
[PART] magic: 58881688h

[PART] load "tee1" from 0x0000000000080200 (dev) to 0x43000DC0 (mem) [SUCCESS]
[PART] load speed: 14144KB/s, 57936 bytes, 4ms
load tee1 (ret=0)
[BLDR] bldr load tee part ret=0x0, addr=0x43001000
[BLDR] boot part. not found
[BLDR] part_load_images ret=0x0
[BLDR] Others, jump to ATF

[BLDR] jump to 0x41E00000
[BLDR] <0x41E00000>=0xEA00000F
[BLDR] <0x41E00004>=0xE59FF014

U-Boot 2014.04-rc1 (Sep 03 2021 - 08:42:53)

auto detection g_total_rank_size = 0x F000000
DRAM: 240 MiB
Turn on power orange!
NAND: Recognize SNAND: ID [c8 1 ], Device Name [F50L1G41LB], Page Size [2048]B Spare Size [64]B Total Size [128]MB
[mtk_snand] probe successfully!
[BBT] BMT.v2 is found at 0x3ff
128 MiB
In: serial
Out: serial
Err: serial
Net: mtk_eth
Uip activated

*** U-Boot SPI NAND ***

 1. Load firmware 0 and bootup.
 2. Load firmware 1 and bootup.
 3. Load firmware selected by Xiaoqiang and bootup.
 U-Boot console

trigger button release!
Press UP/DOWN to move or Press 1~3 to choose, ENTER to select
Erasing NAND...
[mtk_nand_erase_hw] mtk_nand_erase_hw @4249, ret:0x40. page:0x280
Erasing at 0x140000 -- 100% complete.
Writing to NAND... OK
Booting System 0

NAND read: device 0 offset 0x2c0000, size 0x2000
8192 bytes read: OK
[do_read_image_blks] This is a FIT image,img_size = 0x3d2f4
[do_read_image_blks] img_blks = 0x7b
[do_read_image_blks] img_align_size = 0x3d800

NAND read: device 0 offset 0x2c0000, size 0x3d800
251904 bytes read: OK
bootm flag=0, states=70f

Loading kernel from FIT Image at 4007ff28 ...

Using 'config-1' configuration
Trying 'kernel-1' kernel subimage
Description: ARM64 OpenWrt Linux-u-boot
Type: Kernel Image
Compression: lzma compressed
Data Start: 0x40080010
Data Size: 248944 Bytes = 243.1 KiB
Architecture: AArch64
OS: Linux
Load Address: 0x41e00000
Entry Point: 0x41e00000
Hash algo: crc32
Hash value: af7aac32
Hash algo: sha1
Hash value: b0d0fb46f431b9166b99110be6937f1c63437e07
Verifying Hash Integrity ... crc32+ sha1+ OK
Uncompressing Kernel Image ... OK

Starting kernel ...

[ATF][ 4.128802]save kernel info
[ATF][ 4.131738]Kernel_EL2
[ATF][ 4.134409]Kernel is 64Bit
[ATF][ 4.137497]pc=0x41e00000, r0=0x0, r1=0x0
INFO: BL3-1: Preparing for EL3 exit to normal world, Kernel
INFO: BL3-1: Next image address = 0x41e00000
INFO: BL3-1: Next image spsr = 0x3c9
[ATF][ 4.154611]el3_exi▒serial_mtk serial@11002000: pinctrl_select_state_full: uclass_get_device_by_phandle_id: err=-191

U-Boot 2024.01-OpenWrt-r25402-012be0468c (Mar 02 2024 - 14:26:04 +0000)

CPU: MediaTek MT7622
Model: Xiaomi Redmi Router AX6S
DRAM: 256 MiB
Core: 37 devices, 16 uclasses, devicetree: separate
Loading Environment from nowhere... OK
In: serial@11002000
Out: serial@11002000
Err: serial@11002000
reset button found
Net:
Warning: ethernet@1b100000 (eth0) using random MAC address - 5a:54:cf:1f:7e:6d
eth0: ethernet@1b100000
Autoboot in 0 seconds
SPI-NAND: Failed to enable quad spi
SPI-NAND: F50L1G41LB (128MB)
No size specified -> Using max size (23363584)
Read 23363584 bytes from volume fit to 0000000046000000

Checking Image at 46000000 ...

FIT image found
FIT description: ARM64 OpenWrt FIT (Flattened Image Tree)
Image 0 (kernel-1)
Description: ARM64 OpenWrt Linux-6.1.79
Type: Kernel Image
Compression: gzip compressed
Data Start: 0x46001000
Data Size: 5741058 Bytes = 5.5 MiB
Architecture: AArch64
OS: Linux
Load Address: 0x44000000
Entry Point: 0x44000000
Hash algo: crc32
Hash value: e23dade2
Hash algo: sha1
Hash value: e0dce2b6eb043363ccb7f35fbce0430c731f04d8
Image 1 (fdt-1)
Description: ARM64 OpenWrt xiaomi_redmi-router-ax6s device tree blob
Type: Flat Device Tree
Compression: uncompressed
Data Start: 0x4657b000
Data Size: 29363 Bytes = 28.7 KiB
Architecture: AArch64
Hash algo: crc32
Hash value: 00555340
Hash algo: sha1
Hash value: a83482eaf9594aa02c025fc9c06d91d0f06600fa
Image 2 (rootfs-1)
Description: ARM64 OpenWrt xiaomi_redmi-router-ax6s rootfs
Type: Filesystem Image
Compression: uncompressed
Data Start: 0x46583000
Data Size: 17563648 Bytes = 16.8 MiB
Hash algo: crc32
Hash value: c9045516
Hash algo: sha1
Hash value: 99dce000889bafec32f5c7a958314428cf81fac3
Default Configuration: 'config-1'
Configuration 0 (config-1)
Description: OpenWrt xiaomi_redmi-router-ax6s
Kernel: kernel-1
FDT: fdt-1
Loadables: rootfs-1

Checking hash(es) for FIT Image at 46000000 ...

Hash(es) for Image 0 (kernel-1): crc32+ sha1+
Hash(es) for Image 1 (fdt-1): crc32+ sha1+
Hash(es) for Image 2 (rootfs-1): crc32+ sha1+

Loading kernel from FIT Image at 46000000 ...

Using 'config-1' configuration
Trying 'kernel-1' kernel subimage
Description: ARM64 OpenWrt Linux-6.1.79
Type: Kernel Image
Compression: gzip compressed
Data Start: 0x46001000
Data Size: 5741058 Bytes = 5.5 MiB
Architecture: AArch64
OS: Linux
Load Address: 0x44000000
Entry Point: 0x44000000
Hash algo: crc32
Hash value: e23dade2
Hash algo: sha1
Hash value: e0dce2b6eb043363ccb7f35fbce0430c731f04d8
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 xiaomi_redmi-router-ax6s device tree blob
Type: Flat Device Tree
Compression: uncompressed
Data Start: 0x4657b000
Data Size: 29363 Bytes = 28.7 KiB
Architecture: AArch64
Hash algo: crc32
Hash value: 00555340
Hash algo: sha1
Hash value: a83482eaf9594aa02c025fc9c06d91d0f06600fa
Verifying Hash Integrity ... crc32+ sha1+ OK
Booting using the fdt blob at 0x4657b000
Working FDT set to 4657b000

Loading loadables from FIT Image at 46000000 ...

Trying 'rootfs-1' loadables subimage
Description: ARM64 OpenWrt xiaomi_redmi-router-ax6s rootfs
Type: Filesystem Image
Compression: uncompressed
Data Start: 0x46583000
Data Size: 17563648 Bytes = 16.8 MiB
Hash algo: crc32
Hash value: c9045516
Hash algo: sha1
Hash value: 99dce000889bafec32f5c7a958314428cf81fac3
Verifying Hash Integrity ... crc32+ sha1+ OK
Uncompressing Kernel Image
Loading Device Tree to 000000004f7ee000, end 000000004f7f82b2 ... OK
Working FDT set to 4f7ee000

Starting kernel ...

[ 0.000000] Booting Linux on physical CPU 0x0000000000 [0x410fd034]
[ 0.000000] Linux version 6.1.79 (user@debian) (aarch64-openwrt-linux-musl-gcc (OpenWrt GCC 12.3.0 r25402-012be0468c) 12.3.0, GNU ld (GNU Binutils) 2.40.0) #0 SMP Sat Mar 2 14:26:04 2024
[ 0.000000] Machine model: Xiaomi Redmi Router AX6S
[ 0.000000] earlycon: uart8250 at MMIO32 0x0000000011002000 (options '')
[ 0.000000] printk: bootconsole [uart8250] enabled
[ 0.000000] Zone ranges:
[ 0.000000] DMA [mem 0x0000000040000000-0x000000004fffffff]
[ 0.000000] DMA32 empty
[ 0.000000] Normal empty
[ 0.000000] Movable zone start for each node
[ 0.000000] Early memory node ranges
[ 0.000000] node 0: [mem 0x0000000040000000-0x0000000042ffffff]
[ 0.000000] node 0: [mem 0x0000000043000000-0x000000004302ffff]
[ 0.000000] node 0: [mem 0x0000000043030000-0x000000004fffffff]
[ 0.000000] Initmem setup node 0 [mem 0x0000000040000000-0x000000004fffffff]
[ 0.000000] psci: probing for conduit method from DT.
[ 0.000000] psci: PSCIv0.2 detected in firmware.
[ 0.000000] psci: Using standard PSCI v0.2 function IDs
[ 0.000000] psci: Trusted OS migration not required
[ 0.000000] percpu: Embedded 18 pages/cpu s33896 r8192 d31640 u73728
[ 0.000000] pcpu-alloc: s33896 r8192 d31640 u73728 alloc=18*4096
[ 0.000000] pcpu-alloc: [0] 0 [0] 1
[ 0.000000] Detected VIPT I-cache on CPU0
[ 0.000000] CPU features: kernel page table isolation disabled by kernel configuration
[ 0.000000] CPU features: detected: ARM erratum 843419
[ 0.000000] alternatives: applying boot alternatives
[ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 64512
[ 0.000000] Kernel command line: earlycon=uart8250,mmio32,0x11002000 swiotlb=512 ubi.block=0,fit root=/dev/fit0
[ 0.000000] Dentry cache hash table entries: 32768 (order: 6, 262144 bytes, linear)
[ 0.000000] Inode-cache hash table entries: 16384 (order: 5, 131072 bytes, linear)
[ 0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[ 0.000000] Memory: 243496K/262144K available (8768K kernel code, 910K rwdata, 2480K rodata, 448K init, 310K bss, 18648K reserved, 0K cma-reserved)
[ 0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=2, Nodes=1
[ 0.000000] rcu: Hierarchical RCU implementation.
[ 0.000000] Tracing variant of Tasks RCU enabled.
[ 0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 10 jiffies.
[ 0.000000] NR_IRQS: 64, nr_irqs: 64, preallocated irqs: 0
[ 0.000000] Root IRQ handler: gic_handle_irq
[ 0.000000] GIC: Using split EOI/Deactivate mode
[ 0.000000] rcu: srcu_init: Setting srcu_struct sizes based on contention.
[ 0.000000] arch_timer: cp15 timer(s) running at 12.50MHz (phys).
[ 0.000000] clocksource: arch_sys_counter: mask: 0xffffffffffffff max_cycles: 0x2e2049cda, max_idle_ns: 440795202628 ns
[ 0.000000] sched_clock: 56 bits at 13MHz, resolution 80ns, wraps every 4398046511080ns
[ 0.008250] Calibrating delay loop (skipped), value calculated using timer frequency.. 25.00 BogoMIPS (lpj=125000)
[ 0.018647] pid_max: default: 32768 minimum: 301
[ 0.023535] Mount-cache hash table entries: 512 (order: 0, 4096 bytes, linear)
[ 0.030792] Mountpoint-cache hash table entries: 512 (order: 0, 4096 bytes, linear)
[ 0.039693] cblist_init_generic: Setting adjustable number of callback queues.
[ 0.046957] cblist_init_generic: Setting shift to 1 and lim to 1.
[ 0.053195] rcu: Hierarchical SRCU implementation.
[ 0.058004] rcu: Max phase no-delay instances is 1000.
[ 0.063598] smp: Bringing up secondary CPUs ...
[ 0.068511] Detected VIPT I-cache on CPU1
[ 0.068601] CPU1: Booted secondary processor 0x0000000001 [0x410fd034]
[ 0.068660] smp: Brought up 1 node, 2 CPUs
[ 0.083334] SMP: Total of 2 processors activated.
[ 0.088050] CPU features: detected: 32-bit EL0 Support
[ 0.093207] CPU features: detected: CRC32 instructions
[ 0.098385] CPU features: emulated: Privileged Access Never (PAN) using TTBR0_EL1 switching
[ 0.106772] CPU: All CPU(s) started at EL2
[ 0.110876] alternatives: applying system-wide alternatives
[ 0.120752] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[ 0.130644] futex hash table entries: 512 (order: 3, 32768 bytes, linear)
[ 0.137589] pinctrl core: initialized pinctrl subsystem
[ 0.143705] NET: Registered PF_NETLINK/PF_ROUTE protocol family
[ 0.149921] DMA: preallocated 128 KiB GFP_KERNEL pool for atomic allocations
[ 0.157025] DMA: preallocated 128 KiB GFP_KERNEL|GFP_DMA pool for atomic allocations
[ 0.164823] DMA: preallocated 128 KiB GFP_KERNEL|GFP_DMA32 pool for atomic allocations
[ 0.173158] thermal_sys: Registered thermal governor 'fair_share'
[ 0.173162] thermal_sys: Registered thermal governor 'bang_bang'
[ 0.179273] thermal_sys: Registered thermal governor 'step_wise'
[ 0.185307] thermal_sys: Registered thermal governor 'user_space'
[ 0.191387] ASID allocator initialised with 65536 entries
[ 0.203276] pstore: Registered ramoops as persistent store backend
[ 0.209481] ramoops: using 0x10000@0x42ff0000, ecc: 0
[ 0.232911] cryptd: max_cpu_qlen set to 1000
[ 0.237975] SCSI subsystem initialized
[ 0.241852] libata version 3.00 loaded.
[ 0.246798] clocksource: Switched to clocksource arch_sys_counter
[ 0.253604] NET: Registered PF_INET protocol family
[ 0.258605] IP idents hash table entries: 4096 (order: 3, 32768 bytes, linear)
[ 0.266319] tcp_listen_portaddr_hash hash table entries: 256 (order: 0, 4096 bytes, linear)
[ 0.274715] Table-perturb hash table entries: 65536 (order: 6, 262144 bytes, linear)
[ 0.282504] TCP established hash table entries: 2048 (order: 2, 16384 bytes, linear)
[ 0.290299] TCP bind hash table entries: 2048 (order: 4, 65536 bytes, linear)
[ 0.297521] TCP: Hash tables configured (established 2048 bind 2048)
[ 0.303956] UDP hash table entries: 256 (order: 1, 8192 bytes, linear)
[ 0.310528] UDP-Lite hash table entries: 256 (order: 1, 8192 bytes, linear)
[ 0.317635] NET: Registered PF_UNIX/PF_LOCAL protocol family
[ 0.323333] PCI: CLS 0 bytes, default 64
[ 0.328286] workingset: timestamp_bits=46 max_order=16 bucket_order=0
[ 0.338429] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[ 0.344289] jffs2: version 2.2 (NAND) (SUMMARY) (LZMA) (RTIME) (CMODE_PRIORITY) (c) 2001-2006 Red Hat, Inc.
[ 0.386999] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 251)
[ 0.395007] mt7622-pinctrl 10211000.pinctrl: invalid group "pwm_ch7_2" for function "pwm"
[ 0.406593] mt-pmic-pwrap 10001000.pwrap: unexpected interrupt int=0x1
[ 0.421553] Serial: 8250/16550 driver, 16 ports, IRQ sharing enabled
[ 0.430150] printk: console [ttyS0] disabled
[ 0.454610] 11002000.serial: ttyS0 at MMIO 0x11002000 (irq = 118, base_baud = 1562500) is a ST16650V2
[ 0.463934] printk: console [ttyS0] enabled
[ 0.463934] printk: console [ttyS0] enabled
[ 0.472305] printk: bootconsole [uart8250] disabled
[ 0.472305] printk: bootconsole [uart8250] disabled
[ 0.483080] mtk_rng 1020f00.rng: registered RNG driver
[ 0.488946] random: crng init done
[ 0.491785] loop: module loaded
[ 0.495710] Loading iSCSI transport class v2.0-870.
[ 0.501856] mtk-ecc 1100e000.ecc: probed
[ 0.507016] spi-nand spi0.0: ESMT SPI NAND was found.
[ 0.512074] spi-nand spi0.0: 128 MiB, block size: 128 KiB, page size: 2048, OOB size: 64
[ 0.520194] mtk-snand 1100d00.spi: ECC strength: 4 bits per 512 bytes
[ 0.528053] [BBT] BMT.v2 is found at 0x3ff
[ 0.532363] 10 fixed-partitions partitions found on MTD device spi0.0
[ 0.538830] OF: Bad cell count for /spi@1100d000/flash@0/partitions
[ 0.545102] OF: Bad cell count for /spi@1100d000/flash@0/partitions
[ 0.551558] Creating 10 MTD partitions on "spi0.0":
[ 0.556430] 0x000000000000-0x000000080000 : "Preloader"
[ 0.562568] 0x000000080000-0x0000000c0000 : "ATF"
[ 0.567829] 0x0000000c0000-0x000000140000 : "u-boot"
[ 0.573594] 0x000000140000-0x000000180000 : "u-boot-env"
[ 0.579465] 0x000000180000-0x0000001c0000 : "bdata"
[ 0.584880] 0x0000001c0000-0x000000240000 : "factory"
[ 0.590868] OF: Bad cell count for /spi@1100d000/flash@0/partitions
[ 0.597370] 0x000000240000-0x000000280000 : "crash"
[ 0.602813] 0x000000280000-0x0000002c0000 : "crash_log"
[ 0.608694] 0x0000002c0000-0x000000340000 : "ubi-loader"
[ 0.614852] 0x000000340000-0x0000075c0000 : "ubi"
[ 0.745494] ubi0: default fastmap pool size: 45
[ 0.750033] ubi0: default fastmap WL pool size: 22
[ 0.754815] ubi0: attaching mtd9
[ 1.008094] ubi0: scanning is finished
[ 1.015941] ubi0: attached mtd9 (name "ubi", size 114 MiB)
[ 1.021444] ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 126976 bytes
[ 1.028315] ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 2048
[ 1.035095] ubi0: VID header offset: 2048 (aligned 2048), data offset: 4096
[ 1.042051] ubi0: good PEBs: 916, bad PEBs: 0, corrupted PEBs: 0
[ 1.048055] ubi0: user volume: 3, internal volumes: 1, max. volumes count: 128
[ 1.055269] ubi0: max/mean erase counter: 2/0, WL threshold: 4096, image sequence number: 1708331108
[ 1.064395] ubi0: available PEBs: 1, total reserved PEBs: 915, PEBs reserved for bad PEB handling: 19
[ 1.073615] ubi0: background thread "ubi_bgt0d" started, PID 249
[ 1.080112] block ubiblock0_0: created from ubi0:0(rootfs)
[ 1.085593] ubiblock: device ubiblock0_0 (rootfs) set to be root filesystem

</details>

@remittor
Copy link
Contributor

remittor commented Mar 2, 2024

This new way of arranging the kernel and rootfs completely breaks facinstall and XMiR-Patcher work.
I'll have to modify them now.

And it’s probably worth adding the following lines to simplify the initial flash firmware:

  ARTIFACTS += factory.bin
  ARTIFACT/factory.bin := uboot-bin xiaomi_redmi-router-ax6s-ubi-loader | lzma | uboot-fit lzma | pad-to 512k | append-image-stage sysupgrade.itb

@981213
Copy link
Member Author

981213 commented Mar 2, 2024

I checked this installation method. It works!

Thanks!

  ARTIFACTS += factory.bin
  ARTIFACT/factory.bin := uboot-bin xiaomi_redmi-router-ax6s-ubi-loader | lzma | uboot-fit lzma | pad-to 512k | append-image-stage sysupgrade.itb

Does appending a sysupgrade.itb really work? I think if we do append-ubi instead, we can write the entire factory.bin to the first firmware partition.

@remittor
Copy link
Contributor

remittor commented Mar 2, 2024

Does appending a sysupgrade.itb really work?

I don't know yet.
Now I'll try to fix facinstall and roll back to the stock firmware. And then I will check this factory image.

@remittor
Copy link
Contributor

remittor commented Mar 2, 2024

Does appending a sysupgrade.itb really work?

I tried to flash OpenWRT under the stock firmware:

uart logs root@XiaoQiang:/# mtd -r write /tmp/factory.bin firmware

Unlocking firmware ...

Writing from /tmp/factory.bin to firmware ...
Rebooting ...
...
[ 1503.282795] SQUASHFS error: xz decompression failed, data probably corrupt
[ 1503.289741] SQUASHFS error: squashfs_read_data failed to read block 0xf20342
[ 1503.296817] SQUASHFS error: Unable to read metadata cache entry [f20342]
[ 1503.303631] SQUASHFS error: Unable to read directory block [f20342:0]
[ 1503.310360] ipaccount: ifname [br-miot] event[17]
[ 1503.313332] SQUASHFS error: Unable to read metadata cache entry [f20342]
[ 1503.313334] SQUASHFS error: Unable to read directory block [f20342:0]
[ 1503.318701] VFS: brelse: Trying to free free buffer
[ 1503.318714] ------------[ cut here ]------------
[ 1503.318720] WARNING: at fs/buffer.c:1207
[ 1503.318901] CPU: 0 PID: 22352 Comm: which Not tainted 4.4.198 #0
[ 1503.318904] Hardware name: Mi Router RB03 (MediaTek MT7622 + MT7915E + MT7975 + MT7531B, 256MB DDR3, 128MB SPI NAND flash, AX3200 board) (DT)
[ 1503.318907] task: ffffffc00c089800 task.stack: ffffffc005794000
[ 1503.318915] PC is at __brelse+0x3c/0x48
[ 1503.318918] LR is at __brelse+0x3c/0x48
[ 1503.318920] pc : [] lr : [] pstate: 80000145
[ 1503.318922] sp : ffffffc0057977d0
[ 1503.318925] x29: ffffffc0057977d0 x28: 0000000000000000
[ 1503.318928] x27: 0000000000000400 x26: ffffffc00e701300
[ 1503.318931] x25: 0000000000f1e25c x24: ffffff80087a3648
[ 1503.318934] x23: ffffff80087a35c8 x22: ffffffc00c5fd9c0
[ 1503.318938] x21: ffffffc00c5a6618 x20: ffffff80087a3648
[ 1503.318941] x19: 0000000000000010 x18: 0000000000000001
[ 1503.318944] x17: 0000007f82c2ec10 x16: ffffff800815f818
[ 1503.318947] x15: 0000007f82e1d030 x14: ffffffc00c5fd958
[ 1503.318950] x13: ffffffc00c5fd8f0 x12: ffffffc00c5e5d68
[ 1503.318953] x11: ffffffc00c5e5d00 x10: ffffff800882d000
[ 1503.318957] x9 : 00000000000008de x8 : ffffff800883109f
[ 1503.318960] x7 : 0000000000000000 x6 : 0000000000000015
[ 1503.318962] x5 : 000000000002fdf0 x4 : 0000000000000000
[ 1503.318966] x3 : 0000000000000140 x2 : 0000000000001579
[ 1503.318968] x1 : ffffffc00c089800 x0 : 0000000000000027
[ 1503.319590] Call trace:
[ 1503.319634] [] __brelse+0x3c/0x48
[ 1503.319637] [] bh_lru_install+0x124/0x138
[ 1503.319640] [] __find_get_block+0xe4/0x100
[ 1503.319644] [] __getblk_gfp+0x24/0x50
[ 1503.319648] [] squashfs_bio_submit+0x124/0x418
[ 1503.319651] [] squashfs_process_blocks+0x164/0x370
[ 1503.319653] [] squashfs_bio_submit+0x308/0x418
[ 1503.319656] [] __squashfs_read_data+0x154/0x1c8
[ 1503.319659] [] squashfs_read_data+0x10/0x18
[ 1503.319662] [] squashfs_cache_get+0x198/0x2b0
[ 1503.319665] [] squashfs_read_metadata+0x4c/0x118
[ 1503.319668] [] squashfs_lookup+0x1e8/0x350
[ 1503.319672] [] lookup_real+0x34/0x58
[ 1503.319676] [] __lookup_hash+0x34/0x48
[ 1503.319679] [] walk_component+0x100/0x308
[ 1503.319682] [] path_lookupat+0xa4/0x120
[ 1503.319686] [] filename_lookup+0x8c/0xf0
[ 1503.319689] [] user_path_at_empty+0x48/0x58
[ 1503.319693] [] SyS_faccessat+0xac/0x1f0
[ 1503.319698] [] el0_svc_naked+0x24/0x28
[ 1503.319740] VFS: brelse: Trying to free free buffer

F0: 102B 0000
F6: 0000 0000
V0: 0000 0000 [0001]
00: 0000 0000
BP: 0000 0041 [0000]
G0: 0190 0000
T0: 0000 036E [000F]
Jump to BL

UNIVPLL_CON0 = 0xFE000000!!!
mt_pll_init: Set pll frequency for 25M crystal
RAM_CONSOLE preloader last status: 0x0 0x0 0x0 0x0 0x0 0x0
[PMIC_WRAP]wrap_init pass,the return value=0.
[pmic_init] Preloader Start..................
[pmic_init] MT6380 CHIP Code, reg_val = 0, 1:E2 0:E3
[pmic_init] Done...................
Chip part number:7622B
MT7622 Version: 1.2.8, (iPA)
SSC OFF
mt_pll_post_init: mt_get_cpu_freq = 1350000Khz
mt_pll_post_init: mt_get_mem_freq = 1600000Khz
mt_pll_post_init: mt_get_bus_freq = 279980Khz
[PLFM] Init I2C: OK(0)

[BLDR] Build Time: 20210316-161525
==== Dump RGU Reg ========
RGU MODE: 14
RGU LENGTH: FFE0
RGU STA: 40000000
RGU INTERVAL: FFF
RGU SWSYSRST: 8000
==== Dump RGU Reg End ====
RGU: g_rgu_satus:2
mtk_wdt_mode_config mode value=10, tmp:22000010
PL RGU RST: ??
SW reset with bypass power key flag
Find bypass powerkey flag
WDT NONRST=0x20000000
WDT IRQ_EN=0x300002
RGU mtk_wdt_init:MTK_WDT_DEBUG_CTL(590200F3)
[EMI] MDL number = 2
[EMI] DRAMC calibration start

[DDR] Gating glitch patched (0<cnt<=6)
[EMI] DRAMC calibration end

[EMI]rank size auto detect
[EMI]start_addr[0x40000000]=0x12345678, test_addr[0x48000000]= 0xEDCBA987
[EMI]start_addr[0x40000000]=0xEDCBA987, test_addr[0x50000000]= 0xEDCBA987
[EMI]rank0 size: 0x10000000
[MEM] complex R/W mem test pass
RAM_CONSOLE wdt status (0x2)=0x2
mtk_snand_get_device_info
2-Recognize NAND: ID [C8 1 ], Device Name [F50L1G41LB], Page Size [2048]B Spare Size [64]B Total Size [128]MB
[BBT] BMT.v2 is found at 0x3FF
[PLFM] Init Boot Device: OK(0)

[PART] blksz: 2048B
[PART] [0x0000000000000000-0x000000000007FFFF] "PRELOADER" (256 blocks)
[PART] [0x0000000000080000-0x00000000000BFFFF] "tee1" (128 blocks)
[PART] [0x00000000000C0000-0x000000000013FFFF] "lk" (256 blocks)

Device APC domain init setup:

Domain Setup (0x0)
Domain Setup (0x0)
Device APC domain after setup:
Domain Setup (0x0)
Domain Setup (0x0)
[PART] Image with part header
[PART] name : U-Boot
[PART] addr : 41E00000h mode : -1
[PART] size : 356560
[PART] magic: 58881688h

[PART] load "lk" from 0x00000000000C0200 (dev) to 0x41E00000 (mem) [SUCCESS]
[PART] load speed: 16581KB/s, 356560 bytes, 21ms
load lk (ret=0)
[PART] Image with part header
[PART] name : atf
[PART] addr : FFFFFFFFh mode : -1
[PART] size : 57936
[PART] magic: 58881688h

[PART] load "tee1" from 0x0000000000080200 (dev) to 0x43000DC0 (mem) [SUCCESS]
[PART] load speed: 14144KB/s, 57936 bytes, 4ms
load tee1 (ret=0)
[BLDR] bldr load tee part ret=0x0, addr=0x43001000
[BLDR] boot part. not found
[BLDR] part_load_images ret=0x0
[BLDR] Others, jump to ATF

[BLDR] jump to 0x41E00000
[BLDR] <0x41E00000>=0xEA00000F
[BLDR] <0x41E00004>=0xE59FF014

U-Boot 2014.04-rc1 (Sep 03 2021 - 08:42:53)

auto detection g_total_rank_size = 0x F000000
DRAM: 240 MiB
Turn on power orange!
NAND: Recognize SNAND: ID [c8 1 ], Device Name [F50L1G41LB], Page Size [2048]B Spare Size [64]B Total Size [128]MB
[mtk_snand] probe successfully!
[BBT] BMT.v2 is found at 0x3ff
128 MiB
In: serial
Out: serial
Err: serial
Net: mtk_eth
Uip activated

*** U-Boot SPI NAND ***

 1. Load firmware 0 and bootup.
 2. Load firmware 1 and bootup.
 3. Load firmware selected by Xiaoqiang and bootup.
 U-Boot console

trigger button release!
Press UP/DOWN to move or Press 1~3 to choose, ENTER to select
Erasing NAND...
[mtk_nand_erase_hw] mtk_nand_erase_hw @4249, ret:0x40. page:0x280
Erasing at 0x140000 -- 100% complete.
Writing to NAND... OK
Booting System 0

NAND read: device 0 offset 0x2c0000, size 0x2000
8192 bytes read: OK
[do_read_image_blks] This is a FIT image,img_size = 0x3d2f4
[do_read_image_blks] img_blks = 0x7b
[do_read_image_blks] img_align_size = 0x3d800

NAND read: device 0 offset 0x2c0000, size 0x3d800
251904 bytes read: OK
bootm flag=0, states=70f

Loading kernel from FIT Image at 4007ff28 ...

Using 'config-1' configuration
Trying 'kernel-1' kernel subimage
Description: ARM64 OpenWrt Linux-u-boot
Type: Kernel Image
Compression: lzma compressed
Data Start: 0x40080010
Data Size: 248944 Bytes = 243.1 KiB
Architecture: AArch64
OS: Linux
Load Address: 0x41e00000
Entry Point: 0x41e00000
Hash algo: crc32
Hash value: af7aac32
Hash algo: sha1
Hash value: b0d0fb46f431b9166b99110be6937f1c63437e07
Verifying Hash Integrity ... crc32+ sha1+ OK
Uncompressing Kernel Image ... OK

Starting kernel ...

[ATF][ 4.128443]save kernel info
[ATF][ 4.131379]Kernel_EL2
[ATF][ 4.134049]Kernel is 64Bit
[ATF][ 4.137137]pc=0x41e00000, r0=0x0, r1=0x0
INFO: BL3-1: Preparing for EL3 exit to normal world, Kernel
INFO: BL3-1: Next image address = 0x41e00000
INFO: BL3-1: Next image spsr = 0x3c9
[ATF][ 4.154251]el3_exi▒serial_mtk serial@11002000: pinctrl_select_state_full: uclass_get_device_by_phandle_id: err=-19

U-Boot 2024.01-OpenWrt-r25402-012be0468c (Mar 02 2024 - 14:26:04 +0000)

CPU: MediaTek MT7622
Model: Xiaomi Redmi Router AX6S
DRAM: 256 MiB
Core: 37 devices, 16 uclasses, devicetree: separate
Loading Environment from nowhere... OK
In: serial@11002000
Out: serial@11002000
Err: serial@11002000
reset button found
Net:
Warning: ethernet@1b100000 (eth0) using random MAC address - de:ea:29:7b:db:54
eth0: ethernet@1b100000
Autoboot in 0 seconds
SPI-NAND: Failed to enable quad spi
SPI-NAND: F50L1G41LB (128MB)
Volume fit not found!
Using ethernet@1b100000 device
TFTP from server 192.168.1.254; our IP address is 192.168.1.1
Filename 'openwrt-mediatek-mt7622-xiaomi_redmi-router-ax6s-squashfs-sysupgrade.itb'.
Load address: 0x46000000
Loading: *
ARP Retry count exceeded; starting again
MT7622>

Is there a sign of a completed firmware installation somewhere in the loader's nvram parameters?

Volume fit not found!
It seems that to create a -factory.bin image, I need to create a ubinized image in advance that will contain all the necessary volumes...

@remittor
Copy link
Contributor

remittor commented Mar 2, 2024

structure of ubi:

root@OpenWrt:/# ubinfo /dev/ubi0 -a
ubi0
Volumes count:                           3
Logical eraseblock size:                 126976 bytes, 124.0 KiB
Total amount of logical eraseblocks:     916 (116310016 bytes, 110.9 MiB)
Amount of available logical eraseblocks: 1 (126976 bytes, 124.0 KiB)
Maximum count of volumes                 128
Count of bad physical eraseblocks:       0
Count of reserved physical eraseblocks:  19
Current maximum erase counter value:     2
Minimum input/output unit size:          2048 bytes
Character device major/minor:            250:0
Present volumes:                         0, 1, 2

Volume ID:   0 (on ubi0)
Type:        dynamic
Alignment:   1
Size:        377 LEBs (47869952 bytes, 45.6 MiB)
State:       OK
Name:        data
Character device major/minor: 250:1
-----------------------------------
Volume ID:   1 (on ubi0)
Type:        dynamic
Alignment:   1
Size:        329 LEBs (41775104 bytes, 39.8 MiB)
State:       OK
Name:        rootfs_data
Character device major/minor: 250:2
-----------------------------------
Volume ID:   2 (on ubi0)
Type:        dynamic
Alignment:   1
Size:        184 LEBs (23363584 bytes, 22.2 MiB)
State:       OK
Name:        fit
Character device major/minor: 250:3

Storage info:

root@OpenWrt:/# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root                16.8M     16.8M         0 100% /rom
tmpfs                   119.1M    976.0K    118.2M   1% /tmp
/dev/ubi0_1              35.1M    232.0K     33.0M   1% /overlay
overlayfs:/overlay       35.1M    232.0K     33.0M   1% /
tmpfs                   512.0K         0    512.0K   0% /dev

data volume is unclear where it came from.

Creating dynamic volume fit of size 23344234
23344234 bytes written to volume fit
No size specified -> Using max size (41775104)
Creating dynamic volume rootfs_data of size 41775104
resetting ...

@rany2
Copy link
Contributor

rany2 commented Mar 2, 2024

@Remitor I was able to flash from stock by first flashing the initramfs recovery image and then doing the sysupgrade from there.

@981213
Copy link
Member Author

981213 commented Mar 3, 2024

data volume is unclear where it came from.

There shouldn't be a data volume at all. That's strange.

@remittor
Copy link
Contributor

remittor commented Mar 3, 2024

There shouldn't be a data volume at all. That's strange.

I dumped this volume and found configs from the stock firmware inside. And I don’t understand how this happened.

Then I downloaded the -recovery.itb image using the stock bootloader:

setenv ipaddr 192.168.1.1
setenv serverip 192.168.1.254
setenv bootfile recovery.itb
tftpboot

I waited for the download and ran the following commands:

ubirmvol /dev/ubi0 -N data
ubirmvol /dev/ubi0 -N rootfs_data
reboot

After this, the system loading stopped at this point:

uart logs Booting System 0

NAND read: device 0 offset 0x2c0000, size 0x2000
8192 bytes read: OK
[do_read_image_blks] This is a FIT image,img_size = 0x3d2f4
[do_read_image_blks] img_blks = 0x7b
[do_read_image_blks] img_align_size = 0x3d800

NAND read: device 0 offset 0x2c0000, size 0x3d800
251904 bytes read: OK
bootm flag=0, states=70f

Loading kernel from FIT Image at 4007ff28 ...

Using 'config-1' configuration
Trying 'kernel-1' kernel subimage
Description: ARM64 OpenWrt Linux-u-boot
Type: Kernel Image
Compression: lzma compressed
Data Start: 0x40080010
Data Size: 248944 Bytes = 243.1 KiB
Architecture: AArch64
OS: Linux
Load Address: 0x41e00000
Entry Point: 0x41e00000
Hash algo: crc32
Hash value: af7aac32
Hash algo: sha1
Hash value: b0d0fb46f431b9166b99110be6937f1c63437e07
Verifying Hash Integrity ... crc32+ sha1+ OK
Uncompressing Kernel Image ... OK

Starting kernel ...

[ATF][ 4.128548]save kernel info
[ATF][ 4.131484]Kernel_EL2
[ATF][ 4.134154]Kernel is 64Bit
[ATF][ 4.137243]pc=0x41e00000, r0=0x0, r1=0x0
INFO: BL3-1: Preparing for EL3 exit to normal world, Kernel
INFO: BL3-1: Next image address = 0x41e00000
INFO: BL3-1: Next image spsr = 0x3c9
[ATF][ 4.154356]el3_exi▒serial_mtk serial@11002000: pinctrl_select_state_full: uclass_get_device_by_phandle_id: err=-19

U-Boot 2024.01-OpenWrt-r25402-012be0468c (Mar 02 2024 - 14:26:04 +0000)

CPU: MediaTek MT7622
Model: Xiaomi Redmi Router AX6S
DRAM: 256 MiB
Core: 37 devices, 16 uclasses, devicetree: separate
Loading Environment from nowhere... OK
In: serial@11002000
Out: serial@11002000
Err: serial@11002000
reset button found
Net:
Warning: ethernet@1b100000 (eth0) using random MAC address - 4e:bb:f3:38:e2:9b
eth0: ethernet@1b100000
Autoboot in 0 seconds
SPI-NAND: Failed to enable quad spi
SPI-NAND: F50L1G41LB (128MB)
No size specified -> Using max size (23363584)
Read 23363584 bytes from volume fit to 0000000046000000

Checking Image at 46000000 ...

FIT image found
FIT description: ARM64 OpenWrt FIT (Flattened Image Tree)
Image 0 (kernel-1)
Description: ARM64 OpenWrt Linux-6.1.79
Type: Kernel Image
Compression: gzip compressed
Data Start: 0x46001000
Data Size: 5741058 Bytes = 5.5 MiB
Architecture: AArch64
OS: Linux
Load Address: 0x44000000
Entry Point: 0x44000000
Hash algo: crc32
Hash value: e23dade2
Hash algo: sha1
Hash value: e0dce2b6eb043363ccb7f35fbce0430c731f04d8
Image 1 (fdt-1)
Description: ARM64 OpenWrt xiaomi_redmi-router-ax6s device tree blob
Type: Flat Device Tree
Compression: uncompressed
Data Start: 0x4657b000
Data Size: 29363 Bytes = 28.7 KiB
Architecture: AArch64
Hash algo: crc32
Hash value: 00555340
Hash algo: sha1
Hash value: a83482eaf9594aa02c025fc9c06d91d0f06600fa
Image 2 (rootfs-1)
Description: ARM64 OpenWrt xiaomi_redmi-router-ax6s rootfs
Type: Filesystem Image
Compression: uncompressed
Data Start: 0x46583000
Data Size: 17563648 Bytes = 16.8 MiB
Hash algo: crc32
Hash value: c9045516
Hash algo: sha1
Hash value: 99dce000889bafec32f5c7a958314428cf81fac3
Default Configuration: 'config-1'
Configuration 0 (config-1)
Description: OpenWrt xiaomi_redmi-router-ax6s
Kernel: kernel-1
FDT: fdt-1
Loadables: rootfs-1

Checking hash(es) for FIT Image at 46000000 ...

Hash(es) for Image 0 (kernel-1): crc32+ sha1+
Hash(es) for Image 1 (fdt-1): crc32+ sha1+
Hash(es) for Image 2 (rootfs-1): crc32+ sha1+

Loading kernel from FIT Image at 46000000 ...

Using 'config-1' configuration
Trying 'kernel-1' kernel subimage
Description: ARM64 OpenWrt Linux-6.1.79
Type: Kernel Image
Compression: gzip compressed
Data Start: 0x46001000
Data Size: 5741058 Bytes = 5.5 MiB
Architecture: AArch64
OS: Linux
Load Address: 0x44000000
Entry Point: 0x44000000
Hash algo: crc32
Hash value: e23dade2
Hash algo: sha1
Hash value: e0dce2b6eb043363ccb7f35fbce0430c731f04d8
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 xiaomi_redmi-router-ax6s device tree blob
Type: Flat Device Tree
Compression: uncompressed
Data Start: 0x4657b000
Data Size: 29363 Bytes = 28.7 KiB
Architecture: AArch64
Hash algo: crc32
Hash value: 00555340
Hash algo: sha1
Hash value: a83482eaf9594aa02c025fc9c06d91d0f06600fa
Verifying Hash Integrity ... crc32+ sha1+ OK
Booting using the fdt blob at 0x4657b000
Working FDT set to 4657b000

Loading loadables from FIT Image at 46000000 ...

Trying 'rootfs-1' loadables subimage
Description: ARM64 OpenWrt xiaomi_redmi-router-ax6s rootfs
Type: Filesystem Image
Compression: uncompressed
Data Start: 0x46583000
Data Size: 17563648 Bytes = 16.8 MiB
Hash algo: crc32
Hash value: c9045516
Hash algo: sha1
Hash value: 99dce000889bafec32f5c7a958314428cf81fac3
Verifying Hash Integrity ... crc32+ sha1+ OK
Uncompressing Kernel Image
Loading Device Tree to 000000004f7ee000, end 000000004f7f82b2 ... OK
Working FDT set to 4f7ee000

Starting kernel ...

[ 0.000000] Booting Linux on physical CPU 0x0000000000 [0x410fd034]
[ 0.000000] Linux version 6.1.79 (user@debian) (aarch64-openwrt-linux-musl-gcc (OpenWrt GCC 12.3.0 r25402-012be0468c) 12.3.0, GNU ld (GNU Binutils) 2.40.0) #0 SMP Sat Mar 2 14:26:04 2024
[ 0.000000] Machine model: Xiaomi Redmi Router AX6S
[ 0.000000] earlycon: uart8250 at MMIO32 0x0000000011002000 (options '')
[ 0.000000] printk: bootconsole [uart8250] enabled
[ 0.000000] Zone ranges:
[ 0.000000] DMA [mem 0x0000000040000000-0x000000004fffffff]
[ 0.000000] DMA32 empty
[ 0.000000] Normal empty
[ 0.000000] Movable zone start for each node
[ 0.000000] Early memory node ranges
[ 0.000000] node 0: [mem 0x0000000040000000-0x0000000042ffffff]
[ 0.000000] node 0: [mem 0x0000000043000000-0x000000004302ffff]
[ 0.000000] node 0: [mem 0x0000000043030000-0x000000004fffffff]
[ 0.000000] Initmem setup node 0 [mem 0x0000000040000000-0x000000004fffffff]
[ 0.000000] psci: probing for conduit method from DT.
[ 0.000000] psci: PSCIv0.2 detected in firmware.
[ 0.000000] psci: Using standard PSCI v0.2 function IDs
[ 0.000000] psci: Trusted OS migration not required
[ 0.000000] percpu: Embedded 18 pages/cpu s33896 r8192 d31640 u73728
[ 0.000000] pcpu-alloc: s33896 r8192 d31640 u73728 alloc=184096
[ 0.000000] pcpu-alloc: [0] 0 [0] 1
[ 0.000000] Detected VIPT I-cache on CPU0
[ 0.000000] CPU features: kernel page table isolation disabled by kernel configuration
[ 0.000000] CPU features: detected: ARM erratum 843419
[ 0.000000] alternatives: applying boot alternatives
[ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 64512
[ 0.000000] Kernel command line: earlycon=uart8250,mmio32,0x11002000 swiotlb=512 ubi.block=0,fit root=/dev/fit0
[ 0.000000] Dentry cache hash table entries: 32768 (order: 6, 262144 bytes, linear)
[ 0.000000] Inode-cache hash table entries: 16384 (order: 5, 131072 bytes, linear)
[ 0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[ 0.000000] Memory: 243496K/262144K available (8768K kernel code, 910K rwdata, 2480K rodata, 448K init, 310K bss, 18648K reserved, 0K cma-reserved)
[ 0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=2, Nodes=1
[ 0.000000] rcu: Hierarchical RCU implementation.
[ 0.000000] Tracing variant of Tasks RCU enabled.
[ 0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 10 jiffies.
[ 0.000000] NR_IRQS: 64, nr_irqs: 64, preallocated irqs: 0
[ 0.000000] Root IRQ handler: gic_handle_irq
[ 0.000000] GIC: Using split EOI/Deactivate mode
[ 0.000000] rcu: srcu_init: Setting srcu_struct sizes based on contention.
[ 0.000000] arch_timer: cp15 timer(s) running at 12.50MHz (phys).
[ 0.000000] clocksource: arch_sys_counter: mask: 0xffffffffffffff max_cycles: 0x2e2049cda, max_idle_ns: 440795202628 ns
[ 0.000000] sched_clock: 56 bits at 13MHz, resolution 80ns, wraps every 4398046511080ns
[ 0.008250] Calibrating delay loop (skipped), value calculated using timer frequency.. 25.00 BogoMIPS (lpj=125000)
[ 0.018648] pid_max: default: 32768 minimum: 301
[ 0.023534] Mount-cache hash table entries: 512 (order: 0, 4096 bytes, linear)
[ 0.030792] Mountpoint-cache hash table entries: 512 (order: 0, 4096 bytes, linear)
[ 0.039687] cblist_init_generic: Setting adjustable number of callback queues.
[ 0.046953] cblist_init_generic: Setting shift to 1 and lim to 1.
[ 0.053190] rcu: Hierarchical SRCU implementation.
[ 0.057999] rcu: Max phase no-delay instances is 1000.
[ 0.063596] smp: Bringing up secondary CPUs ...
[ 0.068509] Detected VIPT I-cache on CPU1
[ 0.068598] CPU1: Booted secondary processor 0x0000000001 [0x410fd034]
[ 0.068656] smp: Brought up 1 node, 2 CPUs
[ 0.083329] SMP: Total of 2 processors activated.
[ 0.088046] CPU features: detected: 32-bit EL0 Support
[ 0.093202] CPU features: detected: CRC32 instructions
[ 0.098379] CPU features: emulated: Privileged Access Never (PAN) using TTBR0_EL1 switching
[ 0.106765] CPU: All CPU(s) started at EL2
[ 0.110869] alternatives: applying system-wide alternatives
[ 0.120726] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[ 0.130618] futex hash table entries: 512 (order: 3, 32768 bytes, linear)
[ 0.137565] pinctrl core: initialized pinctrl subsystem
[ 0.143680] NET: Registered PF_NETLINK/PF_ROUTE protocol family
[ 0.149902] DMA: preallocated 128 KiB GFP_KERNEL pool for atomic allocations
[ 0.157006] DMA: preallocated 128 KiB GFP_KERNEL|GFP_DMA pool for atomic allocations
[ 0.164804] DMA: preallocated 128 KiB GFP_KERNEL|GFP_DMA32 pool for atomic allocations
[ 0.173134] thermal_sys: Registered thermal governor 'fair_share'
[ 0.173138] thermal_sys: Registered thermal governor 'bang_bang'
[ 0.179250] thermal_sys: Registered thermal governor 'step_wise'
[ 0.185283] thermal_sys: Registered thermal governor 'user_space'
[ 0.191363] ASID allocator initialised with 65536 entries
[ 0.203249] pstore: Registered ramoops as persistent store backend
[ 0.209454] ramoops: using 0x10000@0x42ff0000, ecc: 0
[ 0.232864] cryptd: max_cpu_qlen set to 1000
[ 0.237926] SCSI subsystem initialized
[ 0.241799] libata version 3.00 loaded.
[ 0.246744] clocksource: Switched to clocksource arch_sys_counter
[ 0.253550] NET: Registered PF_INET protocol family
[ 0.258552] IP idents hash table entries: 4096 (order: 3, 32768 bytes, linear)
[ 0.266265] tcp_listen_portaddr_hash hash table entries: 256 (order: 0, 4096 bytes, linear)
[ 0.274662] Table-perturb hash table entries: 65536 (order: 6, 262144 bytes, linear)
[ 0.282450] TCP established hash table entries: 2048 (order: 2, 16384 bytes, linear)
[ 0.290245] TCP bind hash table entries: 2048 (order: 4, 65536 bytes, linear)
[ 0.297466] TCP: Hash tables configured (established 2048 bind 2048)
[ 0.303903] UDP hash table entries: 256 (order: 1, 8192 bytes, linear)
[ 0.310475] UDP-Lite hash table entries: 256 (order: 1, 8192 bytes, linear)
[ 0.317582] NET: Registered PF_UNIX/PF_LOCAL protocol family
[ 0.323279] PCI: CLS 0 bytes, default 64
[ 0.328250] workingset: timestamp_bits=46 max_order=16 bucket_order=0
[ 0.338409] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[ 0.344270] jffs2: version 2.2 (NAND) (SUMMARY) (LZMA) (RTIME) (CMODE_PRIORITY) (c) 2001-2006 Red Hat, Inc.
[ 0.386270] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 251)
[ 0.394286] mt7622-pinctrl 10211000.pinctrl: invalid group "pwm_ch7_2" for function "pwm"
[ 0.405843] mt-pmic-pwrap 10001000.pwrap: unexpected interrupt int=0x1
[ 0.420782] Serial: 8250/16550 driver, 16 ports, IRQ sharing enabled
[ 0.429431] printk: console [ttyS0] disabled
[ 0.453899] 11002000.serial: ttyS0 at MMIO 0x11002000 (irq = 118, base_baud = 1562500) is a ST16650V2
[ 0.463225] printk: console [ttyS0] enabled
[ 0.463225] printk: console [ttyS0] enabled
[ 0.471598] printk: bootconsole [uart8250] disabled
[ 0.471598] printk: bootconsole [uart8250] disabled
[ 0.482325] mtk_rng 1020f000.rng: registered RNG driver
[ 0.486938] random: crng init done
[ 0.494152] loop: module loaded
[ 0.497545] Loading iSCSI transport class v2.0-870.
[ 0.503118] mtk-ecc 1100e000.ecc: probed
[ 0.508279] spi-nand spi0.0: ESMT SPI NAND was found.
[ 0.513336] spi-nand spi0.0: 128 MiB, block size: 128 KiB, page size: 2048, OOB size: 64
[ 0.521463] mtk-snand 1100d000.spi: ECC strength: 4 bits per 512 bytes
[ 0.529362] [BBT] BMT.v2 is found at 0x3ff
[ 0.533620] 10 fixed-partitions partitions found on MTD device spi0.0
[ 0.540089] OF: Bad cell count for /spi@1100d000/flash@0/partitions
[ 0.546359] OF: Bad cell count for /spi@1100d000/flash@0/partitions
[ 0.552805] Creating 10 MTD partitions on "spi0.0":
[ 0.557684] 0x000000000000-0x000000080000 : "Preloader"
[ 0.563809] 0x000000080000-0x0000000c0000 : "ATF"
[ 0.569066] 0x0000000c0000-0x000000140000 : "u-boot"
[ 0.574833] 0x000000140000-0x000000180000 : "u-boot-env"
[ 0.580715] 0x000000180000-0x0000001c0000 : "bdata"
[ 0.586115] 0x0000001c0000-0x000000240000 : "factory"
[ 0.592075] OF: Bad cell count for /spi@1100d000/flash@0/partitions
[ 0.598588] 0x000000240000-0x000000280000 : "crash"
[ 0.604032] 0x000000280000-0x0000002c0000 : "crash_log"
[ 0.609818] 0x0000002c0000-0x000000340000 : "ubi-loader"
[ 0.615945] 0x000000340000-0x0000075c0000 : "ubi"
[ 0.745017] ubi0: default fastmap pool size: 45
[ 0.749559] ubi0: default fastmap WL pool size: 22
[ 0.754342] ubi0: attaching mtd9
[ 1.006921] ubi0: scanning is finished
[ 1.014590] ubi0: attached mtd9 (name "ubi", size 114 MiB)
[ 1.020087] ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 126976 bytes
[ 1.026958] ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 2048
[ 1.033738] ubi0: VID header offset: 2048 (aligned 2048), data offset: 4096
[ 1.040694] ubi0: good PEBs: 916, bad PEBs: 0, corrupted PEBs: 0
[ 1.046691] ubi0: user volume: 1, internal volumes: 1, max. volumes count: 128
[ 1.053908] ubi0: max/mean erase counter: 2/0, WL threshold: 4096, image sequence number: 896530323
[ 1.062950] ubi0: available PEBs: 707, total reserved PEBs: 209, PEBs reserved for bad PEB handling: 19
[ 1.072345] ubi0: background thread "ubi_bgt0d" started, PID 244
[ 1.072786] block ubiblock0_2: created from ubi0:2(fit)
[ 1.220004] mtk_soc_eth 1b100000.ethernet eth0: mediatek frame engine at 0xffffffc009400000, irq 123
[ 1.229790] i2c_dev: i2c /dev entries driver
[ 1.235266] mtk-wdt 10212000.watchdog: Watchdog enabled (timeout=31 sec, nowayout=0)
[ 1.245056] NET: Registered PF_INET6 protocol family
[ 1.250678] Segment Routing with IPv6
[ 1.254351] In-situ OAM (IOAM) with IPv6
[ 1.258324] NET: Registered PF_PACKET protocol family
[ 1.263387] bridge: filtering via arp/ip/ip6tables is no longer available by default. Update your scripts to load br_netfilter if you need this.
[ 1.276511] 8021q: 802.1Q VLAN Support v1.8
[ 1.282098] pstore: Using crash dump compression: deflate
[ 1.300835] mtk-pcie 1a143000.pcie: host bridge /pcie@1a143000 ranges:
[ 1.307413] mtk-pcie 1a143000.pcie: Parsing ranges property...
[ 1.313248] mtk-pcie 1a143000.pcie: MEM 0x0020000000..0x0027ffffff -> 0x0020000000
[ 1.583124] mtk-pcie 1a143000.pcie: PCI host bridge to bus 0000:00
[ 1.589333] pci_bus 0000:00: root bus resource [bus 00-ff]
[ 1.594819] pci_bus 0000:00: root bus resource [mem 0x20000000-0x27ffffff]
[ 1.601701] pci_bus 0000:00: scanning bus
[ 1.605752] pci 0000:00:00.0: [14c3:3258] type 01 class 0x060400
[ 1.611803] pci 0000:00:00.0: reg 0x10: [mem 0x00000000-0x1ffffffff 64bit pref]
[ 1.621147] pci_bus 0000:00: fixups for bus
[ 1.625333] pci 0000:00:00.0: scanning [bus 00-00] behind bridge, pass 0
[ 1.632043] pci 0000:00:00.0: bridge configuration invalid ([bus 00-00]), reconfiguring
[ 1.640064] pci 0000:00:00.0: scanning [bus 00-00] behind bridge, pass 1
[ 1.646889] pci_bus 0000:01: scanning bus
[ 1.651046] pci 0000:01:00.0: [14c3:7915] type 00 class 0x000280
[ 1.657245] pci 0000:01:00.0: reg 0x10: [mem 0x00000000-0x000fffff 64bit pref]
[ 1.664575] pci 0000:01:00.0: reg 0x18: [mem 0x00000000-0x00003fff 64bit pref]
[ 1.671922] pci 0000:01:00.0: reg 0x20: [mem 0x00000000-0x00000fff 64bit pref]
[ 1.679908] pci 0000:01:00.0: supports D1 D2
[ 1.684174] pci 0000:01:00.0: PME# supported from D0 D1 D2 D3hot D3cold
[ 1.690818] pci 0000:01:00.0: PME# disabled
[ 1.695334] pci 0000:01:00.0: 2.000 Gb/s available PCIe bandwidth, limited by 2.5 GT/s PCIe x1 link at 0000:00:00.0 (capable of 4.000 Gb/s with 5.0 GT/s PCIe x1 link)
[ 1.737022] pci_bus 0000:01: fixups for bus
[ 1.741214] pci_bus 0000:01: bus scan returning with max=01
[ 1.746823] pci_bus 0000:01: busn_res: [bus 01-ff] end is updated to 01
[ 1.753458] pci_bus 0000:00: bus scan returning with max=01
[ 1.759078] pci 0000:00:00.0: BAR 0: no space for [mem size 0x200000000 64bit pref]
[ 1.766752] pci 0000:00:00.0: BAR 0: failed to assign [mem size 0x200000000 64bit pref]
[ 1.774749] pci 0000:00:00.0: BAR 8: assigned [mem 0x20000000-0x201fffff]
[ 1.781541] pci 0000:01:00.0: BAR 0: assigned [mem 0x20000000-0x200fffff 64bit pref]
[ 1.789366] pci 0000:01:00.0: BAR 2: assigned [mem 0x20100000-0x20103fff 64bit pref]
[ 1.797194] pci 0000:01:00.0: BAR 4: assigned [mem 0x20104000-0x20104fff 64bit pref]
[ 1.805013] pci 0000:00:00.0: PCI bridge to [bus 01]
[ 1.809980] pci 0000:00:00.0: bridge window [mem 0x20000000-0x201fffff]
[ 1.816878] pcieport 0000:00:00.0: assign IRQ: got 127
[ 1.822018] pcieport 0000:00:00.0: enabling device (0000 -> 0002)
[ 1.828129] pcieport 0000:00:00.0: enabling bus mastering
[ 1.833568] mtk-pcie 1a143000.pcie: msi#0 address_hi 0x0 address_lo 0x44e7d0c0
[ 1.840947] pcieport 0000:00:00.0: PME: Signaling with IRQ 127
[ 1.846846] pcieport 0000:00:00.0: saving config space at offset 0x0 (reading 0x325814c3)
[ 1.855018] pcieport 0000:00:00.0: saving config space at offset 0x4 (reading 0x100006)
[ 1.863023] pcieport 0000:00:00.0: saving config space at offset 0x8 (reading 0x6040000)
[ 1.871112] pcieport 0000:00:00.0: saving config space at offset 0xc (reading 0x10000)
[ 1.879027] pcieport 0000:00:00.0: saving config space at offset 0x10 (reading 0xc)
[ 1.886675] pcieport 0000:00:00.0: saving config space at offset 0x14 (reading 0x0)
[ 1.894328] pcieport 0000:00:00.0: saving config space at offset 0x18 (reading 0x40010100)
[ 1.902590] pcieport 0000:00:00.0: saving config space at offset 0x1c (reading 0x4200000)
[ 1.910764] pcieport 0000:00:00.0: saving config space at offset 0x20 (reading 0x20102000)
[ 1.919028] pcieport 0000:00:00.0: saving config space at offset 0x24 (reading 0x0)
[ 1.926677] pcieport 0000:00:00.0: saving config space at offset 0x28 (reading 0x0)
[ 1.934330] pcieport 0000:00:00.0: saving config space at offset 0x2c (reading 0x0)
[ 1.941983] pcieport 0000:00:00.0: saving config space at offset 0x30 (reading 0x0)
[ 1.949636] pcieport 0000:00:00.0: saving config space at offset 0x34 (reading 0x50)
[ 1.957376] pcieport 0000:00:00.0: saving config space at offset 0x38 (reading 0x0)
[ 1.965025] pcieport 0000:00:00.0: saving config space at offset 0x3c (reading 0x2017f)
[ 1.973679] mtk_hsdma 1b007000.dma-controller: MediaTek HSDMA driver registered
[ 1.981870] FIT: Detected U-Boot 2024.01-OpenWrt-r25402-012be0468c
[ 1.988065] FIT: Selected configuration: "config-1" (OpenWrt xiaomi_redmi-router-ax6s)
[ 1.995986] FIT: kernel sub-image 0x00001000..0x0057aa01 "kernel-1" (ARM64 OpenWrt Linux-6.1.79)
[ 2.005739] FIT: flat_dt sub-image 0x0057b000..0x005822b2 "fdt-1" (ARM64 OpenWrt xiaomi_redmi-router-ax6s device tree blob)
[ 2.017746] FIT: filesystem sub-image 0x00583000..0x01642fff "rootfs-1" (ARM64 OpenWrt xiaomi_redmi-router-ax6s rootfs)
[ 2.029528] block ubiblock0_2: mapped 1 uImage.FIT filesystem sub-image as /dev/fit0
[ 2.078856] mt7530-mdio mdio-bus:00: configuring for fixed/2500base-x link mode
[ 2.088014] mt7530-mdio mdio-bus:00: Link is Up - 2.5Gbps/Full - flow control rx/tx
[ 2.097499] mt7530-mdio mdio-bus:00 wan (uninitialized): PHY [mt7530-0:01] driver [MediaTek MT7531 PHY] (irq=129)
[ 2.118075] mt7530-mdio mdio-bus:00 lan1 (uninitialized): PHY [mt7530-0:02] driver [MediaTek MT7531 PHY] (irq=130)
[ 2.138326] mt7530-mdio mdio-bus:00 lan2 (uninitialized): PHY [mt7530-0:03] driver [MediaTek MT7531 PHY] (irq=131)
[ 2.158496] mt7530-mdio mdio-bus:00 lan3 (uninitialized): PHY [mt7530-0:04] driver [MediaTek MT7531 PHY] (irq=132)
[ 2.169765] device eth0 entered promiscuous mode
[ 2.174402] DSA: tree 0 setup
[ 2.177876] UBI: auto-attach mtd9
[ 2.181186] ubi: mtd9 is already attached to ubi0
[ 2.185880] UBI error: cannot attach mtd9
[ 2.193162] VFS: Mounted root (squashfs filesystem) readonly on device 259:0.
[ 2.200501] Freeing unused kernel memory: 448K
[ 2.226870] Run /sbin/init as init process
[ 2.230962] with arguments:
[ 2.233921] /sbin/init
[ 2.236620] with environment:
[ 2.239769] HOME=/
[ 2.242122] TERM=linux
[ 2.419027] init: Console is alive
[ 2.422548] init: - watchdog -
[ 3.106011] kmodloader: loading kernel modules from /etc/modules-boot.d/

[ 3.149947] usbcore: registered new interface driver usbfs
[ 3.155468] usbcore: registered new interface driver hub
[ 3.160841] usbcore: registered new device driver usb
[ 3.175922] usbcore: registered new interface driver usb-storage
[ 3.182298] kmodloader: done loading kernel modules from /etc/modules-boot.d/*
[ 3.199887] init: - preinit -
[ 3.580478] mtk_soc_eth 1b100000.ethernet eth0: configuring for fixed/2500base-x link mode
[ 3.589013] mtk_soc_eth 1b100000.ethernet eth0: Link is Up - 2.5Gbps/Full - flow control rx/tx
[ 3.596243] mt7530-mdio mdio-bus:00 lan1: configuring for phy/gmii link mode
[ 3.605279] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
Press the [f] key and hit [enter] to enter failsafe mode
Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level
[ 5.739227] mount_root: loading kmods from internal overlay
[ 5.757960] kmodloader: loading kernel modules from //etc/modules-boot.d/*
[ 5.766351] kmodloader: done loading kernel modules from //etc/modules-boot.d/*
[ 5.907987] block: attempting to load /tmp/overlay/upper/etc/config/fstab
[ 5.914886] block: unable to load configuration (fstab: Entry not found)
[ 5.921657] block: attempting to load /tmp/overlay/etc/config/fstab
[ 5.928186] block: unable to load configuration (fstab: Entry not found)
[ 5.934960] block: attempting to load /etc/config/fstab
[ 5.944530] block: unable to load configuration (fstab: Entry not found)
[ 5.951474] block: no usable configuration
[ 5.957275] block: attempting to load /etc/config/fstab
[ 5.962573] block: unable to load configuration (fstab: Entry not found)
[ 5.969447] block: no usable configuration
[ 5.974277] loop0: detected capacity change from 0 to 34304
[ 6.016782] loop0: detected capacity change from 34304 to 0
[ 6.028177] urandom-seed: Seed file not found (/etc/urandom.seed)
[ 6.060549] procd: - early -
[ 6.063504] procd: - watchdog -
[ 6.621794] procd: - watchdog -
[ 6.654748] procd: - ubus -
[ 6.809805] procd: - init -
Please press Enter to activate this console.
[ 7.175239] kmodloader: loading kernel modules from /etc/modules.d/*
[ 7.220371] NET: Registered PF_ALG protocol family
[ 7.234290] Key type dns_resolver registered
[ 7.247132] Key type cifs.idmap registered
[ 7.256011] ntfs: driver 2.1.32 [Flags: R/O MODULE].
[ 7.263209] tun: Universal TUN/TAP device driver, 1.6
[ 7.275433] l2tp_core: L2TP core driver, V2.0
[ 7.280778] l2tp_netlink: L2TP netlink interface
[ 7.286606] sit: IPv6, IPv4 and MPLS over IPv4 tunneling driver
[ 7.295310] gre: GRE over IPv4 demultiplexor driver
[ 7.301350] ip_gre: GRE over IPv4 tunneling driver
[ 7.308409] ip6_gre: GRE over IPv6 tunneling driver
[ 7.315678] GACT probability on
[ 7.320011] Mirror/redirect action on
[ 7.327843] u32 classifier
[ 7.330559] input device check on
[ 7.334211] Actions configured
[ 7.361457] Bridge firewalling registered
[ 7.365895] Loading modules backported from Linux version v6.6.15-0-g51f354b815c4
[ 7.373416] Backport generated by backports.git 193becf2
[ 7.416290] xt_time: kernel timezone is -0000
[ 7.487429] urngd: v1.0.2 started.
[ 7.547286] mt7622-wmac 18000000.wmac: registering led 'mt76-phy0'
[ 7.553960] ieee80211 phy0: Selected rate control algorithm 'minstrel_ht'
[ 7.583955] mt7915e 0000:01:00.0: assign IRQ: got 127
[ 7.589103] mt7915e 0000:01:00.0: enabling device (0000 -> 0002)
[ 7.595194] mt7915e 0000:01:00.0: enabling bus mastering
[ 7.637671] mt7622-wmac 18000000.wmac: HW/SW Version: 0x8a108a10, Build Time: 20190801210006a
[ 7.637671]
[ 7.725681] mtk-pcie 1a143000.pcie: msi#0 address_hi 0x0 address_lo 0x44e7d0c0
[ 7.746177] mt7622-wmac 18000000.wmac: N9 Firmware Version: reserved, Build Time: 20220630094834
[ 7.757390] mt7915e 0000:01:00.0: HW/SW Version: 0x8a108a10, Build Time: 20220929104113a
[ 7.757390]
[ 7.889559] mt7915e 0000:01:00.0: WM Firmware Version: ____000000, Build Time: 20220929104145
[ 7.952370] mt7915e 0000:01:00.0: WA Firmware Version: DEV_000000, Build Time: 20220929104205
[ 8.068621] mt7915e 0000:01:00.0: registering led 'mt76-phy1'
[ 8.132752] PPP generic driver version 2.4.2
[ 8.138373] PPP MPPE Compression module registered
[ 8.144054] NET: Registered PF_PPPOX protocol family
[ 8.150128] PPTP driver version 0.8.5
[ 8.155790] wireguard: WireGuard 1.0.0 loaded. See www.wireguard.com for information.
[ 8.163691] wireguard: Copyright (C) 2015-2019 Jason A. Donenfeld Jason@zx2c4.com. All Rights Reserved.
[ 8.176054] batman_adv: B.A.T.M.A.N. advanced 2024.0-openwrt-2 (compatibility version 15) loaded
[ 8.186465] l2tp_ppp: PPPoL2TP kernel driver, V2.0
[ 8.193989] kmodloader: done loading kernel modules from /etc/modules.d/*
[ 9.334198] mtdblock: MTD device 'bdata' is NAND, please consider using UBI block devices instead.

@981213
Probably in the ubi-loader it is worth adding a check for the presence of volume rootfs_data and if it is not there, then create it.
This functionality will allow you to create a full-fledged -factory.bin image.

@remittor
Copy link
Contributor

remittor commented Mar 3, 2024

@981213

Fixes:
ubi-loader_env

boot_or_recovery=echo "run boot_or_recovery" ; run boot_production ; led $bootled_pwr off ; led $bootled_rec on ; if ubi check fit ; then run boot_tftp_forever ; else run tftp_production ; fi
boot_tftp=tftpboot $loadaddr $bootfile && bootm $loadaddr#$bootconf
boot_tftp_forever=while true ; do run boot_tftp ; sleep 1 ; done
boot_production=echo "run boot_production" ; run ubi_read_production && bootm $loadaddr#$bootconf
ubi_format=echo "run ubi_format" ; ubi detach ; mtd erase ubi && ubi part ubi
ubi_init=echo "run ubi_init" ; ubi part ubi || run ubi_format
ubi_prepare_rootfs=echo "run ubi_prepare_rootfs" ; if ubi check rootfs_data ; then echo "volume rootfs_data already exists"; else if env exists rootfs_data_max ; then ubi create rootfs_data $rootfs_data_max dynamic || ubi create rootfs_data - dynamic ; else ubi create rootfs_data - dynamic ; fi ; fi
ubi_remove_rootfs=echo "run ubi_remove_rootfs" ; ubi check rootfs_data && ubi remove rootfs_data
ubi_write_production=echo "run ubi_write_production" ; ubi check fit && ubi remove fit ; run ubi_remove_rootfs ; ubi create fit $filesize dynamic 2 && ubi write $loadaddr fit $filesize && run ubi_prepare_rootfs
ubi_read_production=echo "run ubi_read_production" ; run ubi_init && run ubi_prepare_rootfs && ubi read $loadaddr fit && iminfo $loadaddr
tftp_production=echo "run tftp_production" ; tftpboot $loadaddr $bootfile_upg && iminfo $loadaddr && run ubi_write_production && reset

image maker

  ARTIFACTS += factory.bin
  ARTIFACT/factory.bin := uboot-bin xiaomi_redmi-router-ax6s-ubi-loader | lzma | uboot-fit lzma | pad-to 512k | \
    ubinize-image fit sysupgrade.itb

now volume rootfs_data is created in its absence:

uart logs U-Boot 2024.01-OpenWrt-r25402-012be0468c (Mar 02 2024 - 14:26:04 +0000)

CPU: MediaTek MT7622
Model: Xiaomi Redmi Router AX6S
DRAM: 256 MiB
Core: 37 devices, 16 uclasses, devicetree: separate
Loading Environment from nowhere... OK
In: serial@11002000
Out: serial@11002000
Err: serial@11002000
reset button found
Net:
Warning: ethernet@1b100000 (eth0) using random MAC address - aa:57:a3:b1:e1:80
eth0: ethernet@1b100000
Autoboot in 0 seconds
run boot_or_recovery
run boot_production
run ubi_read_production
run ubi_init
SPI-NAND: Failed to enable quad spi
SPI-NAND: F50L1G41LB (128MB)
UBI: EOF marker found, PEBs from 186 will be erased
run ubi_prepare_rootfs
No size specified -> Using max size (89645056)
Creating dynamic volume rootfs_data of size 89645056
No size specified -> Using max size (23363584)
Read 23363584 bytes from volume fit to 0000000046000000

Checking Image at 46000000 ...

FIT image found
FIT description: ARM64 OpenWrt FIT (Flattened Image Tree)
Image 0 (kernel-1)
Description: ARM64 OpenWrt Linux-6.1.79
Type: Kernel Image
Compression: gzip compressed
Data Start: 0x46001000
Data Size: 5741058 Bytes = 5.5 MiB
Architecture: AArch64
OS: Linux
Load Address: 0x44000000
Entry Point: 0x44000000
Hash algo: crc32
Hash value: e23dade2
Hash algo: sha1
Hash value: e0dce2b6eb043363ccb7f35fbce0430c731f04d8
Image 1 (fdt-1)
Description: ARM64 OpenWrt xiaomi_redmi-router-ax6s device tree blob
Type: Flat Device Tree
Compression: uncompressed
Data Start: 0x4657b000
Data Size: 29363 Bytes = 28.7 KiB
Architecture: AArch64
Hash algo: crc32
Hash value: 00555340
Hash algo: sha1
Hash value: a83482eaf9594aa02c025fc9c06d91d0f06600fa
Image 2 (rootfs-1)
Description: ARM64 OpenWrt xiaomi_redmi-router-ax6s rootfs
Type: Filesystem Image
Compression: uncompressed
Data Start: 0x46583000
Data Size: 17563648 Bytes = 16.8 MiB
Hash algo: crc32
Hash value: 55fa7d42
Hash algo: sha1
Hash value: b9d93bb1102a03f88522e56bf12222a5a452bc8d
Default Configuration: 'config-1'
Configuration 0 (config-1)
Description: OpenWrt xiaomi_redmi-router-ax6s
Kernel: kernel-1
FDT: fdt-1
Loadables: rootfs-1

Checking hash(es) for FIT Image at 46000000 ...

Hash(es) for Image 0 (kernel-1): crc32+ sha1+
Hash(es) for Image 1 (fdt-1): crc32+ sha1+
Hash(es) for Image 2 (rootfs-1): crc32+ sha1+

Loading kernel from FIT Image at 46000000 ...

Using 'config-1' configuration
Trying 'kernel-1' kernel subimage
Description: ARM64 OpenWrt Linux-6.1.79
Type: Kernel Image
Compression: gzip compressed
Data Start: 0x46001000
Data Size: 5741058 Bytes = 5.5 MiB
Architecture: AArch64
OS: Linux
Load Address: 0x44000000
Entry Point: 0x44000000
Hash algo: crc32
Hash value: e23dade2
Hash algo: sha1
Hash value: e0dce2b6eb043363ccb7f35fbce0430c731f04d8
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 xiaomi_redmi-router-ax6s device tree blob
Type: Flat Device Tree
Compression: uncompressed
Data Start: 0x4657b000
Data Size: 29363 Bytes = 28.7 KiB
Architecture: AArch64
Hash algo: crc32
Hash value: 00555340
Hash algo: sha1
Hash value: a83482eaf9594aa02c025fc9c06d91d0f06600fa
Verifying Hash Integrity ... crc32+ sha1+ OK
Booting using the fdt blob at 0x4657b000
Working FDT set to 4657b000

Loading loadables from FIT Image at 46000000 ...

Trying 'rootfs-1' loadables subimage
Description: ARM64 OpenWrt xiaomi_redmi-router-ax6s rootfs
Type: Filesystem Image
Compression: uncompressed
Data Start: 0x46583000
Data Size: 17563648 Bytes = 16.8 MiB
Hash algo: crc32
Hash value: 55fa7d42
Hash algo: sha1
Hash value: b9d93bb1102a03f88522e56bf12222a5a452bc8d
Verifying Hash Integrity ... crc32+ sha1+ OK
Uncompressing Kernel Image
Loading Device Tree to 000000004f7ee000, end 000000004f7f82b2 ... OK
Working FDT set to 4f7ee000

Starting kernel ...

[ 0.000000] Booting Linux on physical CPU 0x0000000000 [0x410fd034]
[ 0.000000] Linux version 6.1.79 (user@debian) (aarch64-openwrt-linux-musl-gcc (OpenWrt GCC 12.3.0 r25402-012be0468c) 12.3.0, GNU ld (GNU Binutils) 2.40.0) #0 SMP Sat Mar 2 14:26:04 2024
[ 0.000000] Machine model: Xiaomi Redmi Router AX6S
[ 0.000000] earlycon: uart8250 at MMIO32 0x0000000011002000 (options '')
[ 0.000000] printk: bootconsole [uart8250] enabled
[ 0.000000] Zone ranges:
[ 0.000000] DMA [mem 0x0000000040000000-0x000000004fffffff]
[ 0.000000] DMA32 empty
[ 0.000000] Normal empty
[ 0.000000] Movable zone start for each node
[ 0.000000] Early memory node ranges
[ 0.000000] node 0: [mem 0x0000000040000000-0x0000000042ffffff]
[ 0.000000] node 0: [mem 0x0000000043000000-0x000000004302ffff]
[ 0.000000] node 0: [mem 0x0000000043030000-0x000000004fffffff]
[ 0.000000] Initmem setup node 0 [mem 0x0000000040000000-0x000000004fffffff]
[ 0.000000] psci: probing for conduit method from DT.
[ 0.000000] psci: PSCIv0.2 detected in firmware.
[ 0.000000] psci: Using standard PSCI v0.2 function IDs
[ 0.000000] psci: Trusted OS migration not required
[ 0.000000] percpu: Embedded 18 pages/cpu s33896 r8192 d31640 u73728
[ 0.000000] pcpu-alloc: s33896 r8192 d31640 u73728 alloc=184096
[ 0.000000] pcpu-alloc: [0] 0 [0] 1
[ 0.000000] Detected VIPT I-cache on CPU0
[ 0.000000] CPU features: kernel page table isolation disabled by kernel configuration
[ 0.000000] CPU features: detected: ARM erratum 843419
[ 0.000000] alternatives: applying boot alternatives
[ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 64512
[ 0.000000] Kernel command line: earlycon=uart8250,mmio32,0x11002000 swiotlb=512 ubi.block=0,fit root=/dev/fit0
[ 0.000000] Dentry cache hash table entries: 32768 (order: 6, 262144 bytes, linear)
[ 0.000000] Inode-cache hash table entries: 16384 (order: 5, 131072 bytes, linear)
[ 0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[ 0.000000] Memory: 243496K/262144K available (8768K kernel code, 910K rwdata, 2480K rodata, 448K init, 310K bss, 18648K reserved, 0K cma-reserved)
[ 0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=2, Nodes=1
[ 0.000000] rcu: Hierarchical RCU implementation.
[ 0.000000] Tracing variant of Tasks RCU enabled.
[ 0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 10 jiffies.
[ 0.000000] NR_IRQS: 64, nr_irqs: 64, preallocated irqs: 0
[ 0.000000] Root IRQ handler: gic_handle_irq
[ 0.000000] GIC: Using split EOI/Deactivate mode
[ 0.000000] rcu: srcu_init: Setting srcu_struct sizes based on contention.
[ 0.000000] arch_timer: cp15 timer(s) running at 12.50MHz (phys).
[ 0.000000] clocksource: arch_sys_counter: mask: 0xffffffffffffff max_cycles: 0x2e2049cda, max_idle_ns: 440795202628 ns
[ 0.000000] sched_clock: 56 bits at 13MHz, resolution 80ns, wraps every 4398046511080ns
[ 0.008251] Calibrating delay loop (skipped), value calculated using timer frequency.. 25.00 BogoMIPS (lpj=125000)
[ 0.018648] pid_max: default: 32768 minimum: 301
[ 0.023536] Mount-cache hash table entries: 512 (order: 0, 4096 bytes, linear)
[ 0.030794] Mountpoint-cache hash table entries: 512 (order: 0, 4096 bytes, linear)
[ 0.039694] cblist_init_generic: Setting adjustable number of callback queues.
[ 0.046959] cblist_init_generic: Setting shift to 1 and lim to 1.
[ 0.053196] rcu: Hierarchical SRCU implementation.
[ 0.058005] rcu: Max phase no-delay instances is 1000.
[ 0.063603] smp: Bringing up secondary CPUs ...
[ 0.068515] Detected VIPT I-cache on CPU1
[ 0.068605] CPU1: Booted secondary processor 0x0000000001 [0x410fd034]
[ 0.068666] smp: Brought up 1 node, 2 CPUs
[ 0.083339] SMP: Total of 2 processors activated.
[ 0.088055] CPU features: detected: 32-bit EL0 Support
[ 0.093212] CPU features: detected: CRC32 instructions
[ 0.098389] CPU features: emulated: Privileged Access Never (PAN) using TTBR0_EL1 switching
[ 0.106775] CPU: All CPU(s) started at EL2
[ 0.110879] alternatives: applying system-wide alternatives
[ 0.120748] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[ 0.130640] futex hash table entries: 512 (order: 3, 32768 bytes, linear)
[ 0.137586] pinctrl core: initialized pinctrl subsystem
[ 0.143703] NET: Registered PF_NETLINK/PF_ROUTE protocol family
[ 0.149925] DMA: preallocated 128 KiB GFP_KERNEL pool for atomic allocations
[ 0.157028] DMA: preallocated 128 KiB GFP_KERNEL|GFP_DMA pool for atomic allocations
[ 0.164826] DMA: preallocated 128 KiB GFP_KERNEL|GFP_DMA32 pool for atomic allocations
[ 0.173155] thermal_sys: Registered thermal governor 'fair_share'
[ 0.173159] thermal_sys: Registered thermal governor 'bang_bang'
[ 0.179271] thermal_sys: Registered thermal governor 'step_wise'
[ 0.185304] thermal_sys: Registered thermal governor 'user_space'
[ 0.191383] ASID allocator initialised with 65536 entries
[ 0.203271] pstore: Registered ramoops as persistent store backend
[ 0.209476] ramoops: using 0x10000@0x42ff0000, ecc: 0
[ 0.232942] cryptd: max_cpu_qlen set to 1000
[ 0.238000] SCSI subsystem initialized
[ 0.241872] libata version 3.00 loaded.
[ 0.246822] clocksource: Switched to clocksource arch_sys_counter
[ 0.253636] NET: Registered PF_INET protocol family
[ 0.258644] IP idents hash table entries: 4096 (order: 3, 32768 bytes, linear)
[ 0.266362] tcp_listen_portaddr_hash hash table entries: 256 (order: 0, 4096 bytes, linear)
[ 0.274762] Table-perturb hash table entries: 65536 (order: 6, 262144 bytes, linear)
[ 0.282544] TCP established hash table entries: 2048 (order: 2, 16384 bytes, linear)
[ 0.290334] TCP bind hash table entries: 2048 (order: 4, 65536 bytes, linear)
[ 0.297550] TCP: Hash tables configured (established 2048 bind 2048)
[ 0.303987] UDP hash table entries: 256 (order: 1, 8192 bytes, linear)
[ 0.310559] UDP-Lite hash table entries: 256 (order: 1, 8192 bytes, linear)
[ 0.317672] NET: Registered PF_UNIX/PF_LOCAL protocol family
[ 0.323370] PCI: CLS 0 bytes, default 64
[ 0.328285] workingset: timestamp_bits=46 max_order=16 bucket_order=0
[ 0.338415] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[ 0.344277] jffs2: version 2.2 (NAND) (SUMMARY) (LZMA) (RTIME) (CMODE_PRIORITY) (c) 2001-2006 Red Hat, Inc.
[ 0.387315] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 251)
[ 0.395333] mt7622-pinctrl 10211000.pinctrl: invalid group "pwm_ch7_2" for function "pwm"
[ 0.406926] mt-pmic-pwrap 10001000.pwrap: unexpected interrupt int=0x1
[ 0.428547] Serial: 8250/16550 driver, 16 ports, IRQ sharing enabled
[ 0.437183] printk: console [ttyS0] disabled
[ 0.461665] 11002000.serial: ttyS0 at MMIO 0x11002000 (irq = 118, base_baud = 1562500) is a ST16650V2
[ 0.470996] printk: console [ttyS0] enabled
[ 0.470996] printk: console [ttyS0] enabled
[ 0.479369] printk: bootconsole [uart8250] disabled
[ 0.479369] printk: bootconsole [uart8250] disabled
[ 0.490113] mtk_rng 1020f000.rng: registered RNG driver
[ 0.490282] random: crng init done
[ 0.501311] loop: module loaded
[ 0.504658] Loading iSCSI transport class v2.0-870.
[ 0.510341] mtk-ecc 1100e000.ecc: probed
[ 0.515451] spi-nand spi0.0: ESMT SPI NAND was found.
[ 0.520553] spi-nand spi0.0: 128 MiB, block size: 128 KiB, page size: 2048, OOB size: 64
[ 0.528679] mtk-snand 1100d000.spi: ECC strength: 4 bits per 512 bytes
[ 0.536612] [BBT] BMT.v2 is found at 0x3ff
[ 0.541465] 10 fixed-partitions partitions found on MTD device spi0.0
[ 0.547957] OF: Bad cell count for /spi@1100d000/flash@0/partitions
[ 0.554230] OF: Bad cell count for /spi@1100d000/flash@0/partitions
[ 0.560698] Creating 10 MTD partitions on "spi0.0":
[ 0.565570] 0x000000000000-0x000000080000 : "Preloader"
[ 0.571742] 0x000000080000-0x0000000c0000 : "ATF"
[ 0.577016] 0x0000000c0000-0x000000140000 : "u-boot"
[ 0.582795] 0x000000140000-0x000000180000 : "u-boot-env"
[ 0.588679] 0x000000180000-0x0000001c0000 : "bdata"
[ 0.594075] 0x0000001c0000-0x000000240000 : "factory"
[ 0.599995] OF: Bad cell count for /spi@1100d000/flash@0/partitions
[ 0.606434] 0x000000240000-0x000000280000 : "crash"
[ 0.611928] 0x000000280000-0x0000002c0000 : "crash_log"
[ 0.617744] 0x0000002c0000-0x000000340000 : "ubi-loader"
[ 0.623860] 0x000000340000-0x0000075c0000 : "ubi"
[ 0.752772] ubi0: default fastmap pool size: 45
[ 0.757314] ubi0: default fastmap WL pool size: 22
[ 0.762097] ubi0: attaching mtd9
[ 1.016078] ubi0: scanning is finished
[ 1.023821] ubi0: attached mtd9 (name "ubi", size 114 MiB)
[ 1.029322] ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 126976 bytes
[ 1.036190] ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 2048
[ 1.042973] ubi0: VID header offset: 2048 (aligned 2048), data offset: 4096
[ 1.049930] ubi0: good PEBs: 916, bad PEBs: 0, corrupted PEBs: 0
[ 1.055927] ubi0: user volume: 2, internal volumes: 1, max. volumes count: 128
[ 1.063143] ubi0: max/mean erase counter: 1/0, WL threshold: 4096, image sequence number: 1709389564
[ 1.072271] ubi0: available PEBs: 1, total reserved PEBs: 915, PEBs reserved for bad PEB handling: 19
[ 1.081491] ubi0: background thread "ubi_bgt0d" started, PID 245
[ 1.081940] block ubiblock0_0: created from ubi0:0(fit)
[ 1.230082] mtk_soc_eth 1b100000.ethernet eth0: mediatek frame engine at 0xffffffc009400000, irq 123
[ 1.239860] i2c_dev: i2c /dev entries driver
[ 1.245368] mtk-wdt 10212000.watchdog: Watchdog enabled (timeout=31 sec, nowayout=0)
[ 1.255161] NET: Registered PF_INET6 protocol family
[ 1.260788] Segment Routing with IPv6
[ 1.264463] In-situ OAM (IOAM) with IPv6
[ 1.268461] NET: Registered PF_PACKET protocol family
[ 1.273526] bridge: filtering via arp/ip/ip6tables is no longer available by default. Update your scripts to load br_netfilter if you need this.
[ 1.286621] 8021q: 802.1Q VLAN Support v1.8
[ 1.292298] pstore: Using crash dump compression: deflate
[ 1.309422] mtk-pcie 1a143000.pcie: host bridge /pcie@1a143000 ranges:
[ 1.315973] mtk-pcie 1a143000.pcie: Parsing ranges property...
[ 1.321832] mtk-pcie 1a143000.pcie: MEM 0x0020000000..0x0027ffffff -> 0x0020000000
[ 1.593212] mtk-pcie 1a143000.pcie: PCI host bridge to bus 0000:00
[ 1.599414] pci_bus 0000:00: root bus resource [bus 00-ff]
[ 1.604900] pci_bus 0000:00: root bus resource [mem 0x20000000-0x27ffffff]
[ 1.611786] pci_bus 0000:00: scanning bus
[ 1.615838] pci 0000:00:00.0: [14c3:3258] type 01 class 0x060400
[ 1.621884] pci 0000:00:00.0: reg 0x10: [mem 0x00000000-0x1ffffffff 64bit pref]
[ 1.631237] pci_bus 0000:00: fixups for bus
[ 1.635423] pci 0000:00:00.0: scanning [bus 00-00] behind bridge, pass 0
[ 1.642134] pci 0000:00:00.0: bridge configuration invalid ([bus 00-00]), reconfiguring
[ 1.650156] pci 0000:00:00.0: scanning [bus 00-00] behind bridge, pass 1
[ 1.656987] pci_bus 0000:01: scanning bus
[ 1.661139] pci 0000:01:00.0: [14c3:7915] type 00 class 0x000280
[ 1.667343] pci 0000:01:00.0: reg 0x10: [mem 0x00000000-0x000fffff 64bit pref]
[ 1.674675] pci 0000:01:00.0: reg 0x18: [mem 0x00000000-0x00003fff 64bit pref]
[ 1.682013] pci 0000:01:00.0: reg 0x20: [mem 0x00000000-0x00000fff 64bit pref]
[ 1.690005] pci 0000:01:00.0: supports D1 D2
[ 1.694272] pci 0000:01:00.0: PME# supported from D0 D1 D2 D3hot D3cold
[ 1.700917] pci 0000:01:00.0: PME# disabled
[ 1.705434] pci 0000:01:00.0: 2.000 Gb/s available PCIe bandwidth, limited by 2.5 GT/s PCIe x1 link at 0000:00:00.0 (capable of 4.000 Gb/s with 5.0 GT/s PCIe x1 link)
[ 1.747073] pci_bus 0000:01: fixups for bus
[ 1.751262] pci_bus 0000:01: bus scan returning with max=01
[ 1.756872] pci_bus 0000:01: busn_res: [bus 01-ff] end is updated to 01
[ 1.763505] pci_bus 0000:00: bus scan returning with max=01
[ 1.769125] pci 0000:00:00.0: BAR 0: no space for [mem size 0x200000000 64bit pref]
[ 1.776788] pci 0000:00:00.0: BAR 0: failed to assign [mem size 0x200000000 64bit pref]
[ 1.784791] pci 0000:00:00.0: BAR 8: assigned [mem 0x20000000-0x201fffff]
[ 1.791582] pci 0000:01:00.0: BAR 0: assigned [mem 0x20000000-0x200fffff 64bit pref]
[ 1.799408] pci 0000:01:00.0: BAR 2: assigned [mem 0x20100000-0x20103fff 64bit pref]
[ 1.807236] pci 0000:01:00.0: BAR 4: assigned [mem 0x20104000-0x20104fff 64bit pref]
[ 1.815056] pci 0000:00:00.0: PCI bridge to [bus 01]
[ 1.820022] pci 0000:00:00.0: bridge window [mem 0x20000000-0x201fffff]
[ 1.826924] pcieport 0000:00:00.0: assign IRQ: got 127
[ 1.832064] pcieport 0000:00:00.0: enabling device (0000 -> 0002)
[ 1.838175] pcieport 0000:00:00.0: enabling bus mastering
[ 1.843615] mtk-pcie 1a143000.pcie: msi#0 address_hi 0x0 address_lo 0x44e7d0c0
[ 1.850998] pcieport 0000:00:00.0: PME: Signaling with IRQ 127
[ 1.856904] pcieport 0000:00:00.0: saving config space at offset 0x0 (reading 0x325814c3)
[ 1.865076] pcieport 0000:00:00.0: saving config space at offset 0x4 (reading 0x100006)
[ 1.873082] pcieport 0000:00:00.0: saving config space at offset 0x8 (reading 0x6040000)
[ 1.881171] pcieport 0000:00:00.0: saving config space at offset 0xc (reading 0x10000)
[ 1.889085] pcieport 0000:00:00.0: saving config space at offset 0x10 (reading 0xc)
[ 1.896734] pcieport 0000:00:00.0: saving config space at offset 0x14 (reading 0x0)
[ 1.904387] pcieport 0000:00:00.0: saving config space at offset 0x18 (reading 0x40010100)
[ 1.912648] pcieport 0000:00:00.0: saving config space at offset 0x1c (reading 0x4200000)
[ 1.920823] pcieport 0000:00:00.0: saving config space at offset 0x20 (reading 0x20102000)
[ 1.929087] pcieport 0000:00:00.0: saving config space at offset 0x24 (reading 0x0)
[ 1.936735] pcieport 0000:00:00.0: saving config space at offset 0x28 (reading 0x0)
[ 1.944389] pcieport 0000:00:00.0: saving config space at offset 0x2c (reading 0x0)
[ 1.952042] pcieport 0000:00:00.0: saving config space at offset 0x30 (reading 0x0)
[ 1.959695] pcieport 0000:00:00.0: saving config space at offset 0x34 (reading 0x50)
[ 1.967435] pcieport 0000:00:00.0: saving config space at offset 0x38 (reading 0x0)
[ 1.975084] pcieport 0000:00:00.0: saving config space at offset 0x3c (reading 0x2017f)
[ 1.983713] mtk_hsdma 1b007000.dma-controller: MediaTek HSDMA driver registered
[ 1.991847] FIT: Detected U-Boot 2024.01-OpenWrt-r25402-012be0468c
[ 1.998040] FIT: Selected configuration: "config-1" (OpenWrt xiaomi_redmi-router-ax6s)
[ 2.005961] FIT: kernel sub-image 0x00001000..0x0057aa01 "kernel-1" (ARM64 OpenWrt Linux-6.1.79)
[ 2.015713] FIT: flat_dt sub-image 0x0057b000..0x005822b2 "fdt-1" (ARM64 OpenWrt xiaomi_redmi-router-ax6s device tree blob)
[ 2.027724] FIT: filesystem sub-image 0x00583000..0x01642fff "rootfs-1" (ARM64 OpenWrt xiaomi_redmi-router-ax6s rootfs)
[ 2.039490] block ubiblock0_0: mapped 1 uImage.FIT filesystem sub-image as /dev/fit0
[ 2.088692] mt7530-mdio mdio-bus:00: configuring for fixed/2500base-x link mode
[ 2.098024] mt7530-mdio mdio-bus:00: Link is Up - 2.5Gbps/Full - flow control rx/tx
[ 2.107745] mt7530-mdio mdio-bus:00 wan (uninitialized): PHY [mt7530-0:01] driver [MediaTek MT7531 PHY] (irq=129)
[ 2.128658] mt7530-mdio mdio-bus:00 lan1 (uninitialized): PHY [mt7530-0:02] driver [MediaTek MT7531 PHY] (irq=130)
[ 2.148825] mt7530-mdio mdio-bus:00 lan2 (uninitialized): PHY [mt7530-0:03] driver [MediaTek MT7531 PHY] (irq=131)
[ 2.168995] mt7530-mdio mdio-bus:00 lan3 (uninitialized): PHY [mt7530-0:04] driver [MediaTek MT7531 PHY] (irq=132)
[ 2.180276] device eth0 entered promiscuous mode
[ 2.184912] DSA: tree 0 setup
[ 2.188346] UBI: auto-attach mtd9
[ 2.191657] ubi: mtd9 is already attached to ubi0
[ 2.196352] UBI error: cannot attach mtd9
[ 2.204299] VFS: Mounted root (squashfs filesystem) readonly on device 259:0.
[ 2.211649] Freeing unused kernel memory: 448K
[ 2.236936] Run /sbin/init as init process
[ 2.241030] with arguments:
[ 2.243989] /sbin/init
[ 2.246688] with environment:
[ 2.249848] HOME=/
[ 2.252201] TERM=linux
[ 2.431989] init: Console is alive
[ 2.435509] init: - watchdog -
[ 3.124030] kmodloader: loading kernel modules from /etc/modules-boot.d/

[ 3.169652] usbcore: registered new interface driver usbfs
[ 3.175172] usbcore: registered new interface driver hub
[ 3.180564] usbcore: registered new device driver usb
[ 3.195528] usbcore: registered new interface driver usb-storage
[ 3.201942] kmodloader: done loading kernel modules from /etc/modules-boot.d/*
[ 3.215686] init: - preinit -
[ 3.608519] mtk_soc_eth 1b100000.ethernet eth0: configuring for fixed/2500base-x link mode
[ 3.616984] mtk_soc_eth 1b100000.ethernet eth0: Link is Up - 2.5Gbps/Full - flow control rx/tx
[ 3.623496] mt7530-mdio mdio-bus:00 lan1: configuring for phy/gmii link mode
[ 3.635608] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
Press the [f] key and hit [enter] to enter failsafe mode
Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level
[ 5.770580] mount_root: loading kmods from internal overlay
[ 5.790199] kmodloader: loading kernel modules from //etc/modules-boot.d/*
[ 5.799251] kmodloader: done loading kernel modules from //etc/modules-boot.d/*
[ 5.945321] block: attempting to load /tmp/overlay/upper/etc/config/fstab
[ 5.952266] block: unable to load configuration (fstab: Entry not found)
[ 5.959271] block: attempting to load /tmp/overlay/etc/config/fstab
[ 5.965655] block: unable to load configuration (fstab: Entry not found)
[ 5.972596] block: attempting to load /etc/config/fstab
[ 5.982626] block: unable to load configuration (fstab: Entry not found)
[ 5.989409] block: no usable configuration
[ 6.004163] UBIFS (ubi0:1): default file-system created
[ 6.009703] UBIFS (ubi0:1): Mounting in unauthenticated mode
[ 6.015440] UBIFS (ubi0:1): background thread "ubifs_bgt0_1" started, PID 608
[ 6.044514] UBIFS (ubi0:1): UBIFS: mounted UBI device 0, volume 1, name "rootfs_data"
[ 6.052376] UBIFS (ubi0:1): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 6.062305] UBIFS (ubi0:1): FS size: 88248320 bytes (84 MiB, 695 LEBs), max 706 LEBs, journal size 4444160 bytes (4 MiB, 35 LEBs)
[ 6.073966] UBIFS (ubi0:1): reserved for root: 4168186 bytes (4070 KiB)
[ 6.080586] UBIFS (ubi0:1): media format: w5/r0 (latest is w5/r0), UUID 2BFC91A9-2B23-48AF-8272-3004A8D4DBB0, small LPT model
[ 6.092494] block: attempting to load /tmp/ubifs_cfg/upper/etc/config/fstab
[ 6.099599] block: unable to load configuration (fstab: Entry not found)
[ 6.106339] block: attempting to load /tmp/ubifs_cfg/etc/config/fstab
[ 6.112841] block: unable to load configuration (fstab: Entry not found)
[ 6.119605] block: attempting to load /etc/config/fstab
[ 6.124879] block: unable to load configuration (fstab: Entry not found)
[ 6.131622] block: no usable configuration
[ 6.138517] UBIFS (ubi0:1): un-mount UBI device 0
[ 6.143226] UBIFS (ubi0:1): background thread "ubifs_bgt0_1" stops
[ 6.152116] UBIFS (ubi0:1): Mounting in unauthenticated mode
[ 6.157874] UBIFS (ubi0:1): background thread "ubifs_bgt0_1" started, PID 611
[ 6.193750] UBIFS (ubi0:1): UBIFS: mounted UBI device 0, volume 1, name "rootfs_data"
[ 6.201645] UBIFS (ubi0:1): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 6.211567] UBIFS (ubi0:1): FS size: 88248320 bytes (84 MiB, 695 LEBs), max 706 LEBs, journal size 4444160 bytes (4 MiB, 35 LEBs)
[ 6.223218] UBIFS (ubi0:1): reserved for root: 4168186 bytes (4070 KiB)
[ 6.229828] UBIFS (ubi0:1): media format: w5/r0 (latest is w5/r0), UUID 2BFC91A9-2B23-48AF-8272-3004A8D4DBB0, small LPT model
[ 6.272551] block: attempting to load /tmp/overlay/upper/etc/config/fstab
[ 6.279504] block: unable to load configuration (fstab: Entry not found)
[ 6.286278] block: attempting to load /tmp/overlay/etc/config/fstab
[ 6.292915] block: unable to load configuration (fstab: Entry not found)
[ 6.299863] block: attempting to load /etc/config/fstab
[ 6.305199] block: unable to load configuration (fstab: Entry not found)
[ 6.312180] block: no usable configuration
[ 6.318448] block: attempting to load /tmp/ubifs_cfg/upper/etc/config/fstab
[ 6.325463] block: unable to load configuration (fstab: Entry not found)
[ 6.332217] block: attempting to load /tmp/ubifs_cfg/etc/config/fstab
[ 6.338730] block: unable to load configuration (fstab: Entry not found)
[ 6.345466] block: attempting to load /etc/config/fstab
[ 6.350754] block: unable to load configuration (fstab: Entry not found)
[ 6.357516] block: no usable configuration
[ 6.362736] mount_root: overlay filesystem has not been fully initialized yet
[ 6.370108] mount_root: switching to ubifs overlay
[ 6.381229] overlayfs: null uuid detected in lower fs '/', falling back to xino=off,index=off,nfs_export=off.
[ 6.392405] urandom-seed: Seed file not found (/etc/urandom.seed)
[ 6.425899] procd: - early -
[ 6.428881] procd: - watchdog -
[ 6.977529] procd: - watchdog -
[ 7.010912] procd: - ubus -
[ 7.175518] procd: - init -
Please press Enter to activate this console.
[ 7.558581] kmodloader: loading kernel modules from /etc/modules.d/*
[ 7.602560] NET: Registered PF_ALG protocol family
[ 7.618207] Key type dns_resolver registered
[ 7.637451] Key type cifs.idmap registered
[ 7.647436] ntfs: driver 2.1.32 [Flags: R/O MODULE].
[ 7.654723] tun: Universal TUN/TAP device driver, 1.6
[ 7.669971] l2tp_core: L2TP core driver, V2.0
[ 7.675584] l2tp_netlink: L2TP netlink interface
[ 7.681622] sit: IPv6, IPv4 and MPLS over IPv4 tunneling driver
[ 7.690843] gre: GRE over IPv4 demultiplexor driver
[ 7.698614] ip_gre: GRE over IPv4 tunneling driver
[ 7.706896] ip6_gre: GRE over IPv6 tunneling driver
[ 7.714709] GACT probability on
[ 7.719013] Mirror/redirect action on
[ 7.727104] u32 classifier
[ 7.729819] input device check on
[ 7.733471] Actions configured
[ 7.749693] Bridge firewalling registered
[ 7.754327] Loading modules backported from Linux version v6.6.15-0-g51f354b815c4
[ 7.761841] Backport generated by backports.git 193becf2
[ 7.853183] xt_time: kernel timezone is -0000
[ 7.864166] urngd: v1.0.2 started.
[ 7.977294] mt7622-wmac 18000000.wmac: registering led 'mt76-phy0'
[ 7.984013] ieee80211 phy0: Selected rate control algorithm 'minstrel_ht'
[ 8.014246] mt7915e 0000:01:00.0: assign IRQ: got 127
[ 8.019412] mt7915e 0000:01:00.0: enabling device (0000 -> 0002)
[ 8.025506] mt7915e 0000:01:00.0: enabling bus mastering
[ 8.065753] mt7622-wmac 18000000.wmac: HW/SW Version: 0x8a108a10, Build Time: 20190801210006a
[ 8.065753]
[ 8.148002] mtk-pcie 1a143000.pcie: msi#0 address_hi 0x0 address_lo 0x44e7d0c0
[ 8.167584] mt7622-wmac 18000000.wmac: N9 Firmware Version: reserved, Build Time: 20220630094834
[ 8.177928] mt7915e 0000:01:00.0: HW/SW Version: 0x8a108a10, Build Time: 20220929104113a
[ 8.177928]
[ 8.317041] mt7915e 0000:01:00.0: WM Firmware Version: ____000000, Build Time: 20220929104145
[ 8.380041] mt7915e 0000:01:00.0: WA Firmware Version: DEV_000000, Build Time: 20220929104205
[ 8.495217] mt7915e 0000:01:00.0: registering led 'mt76-phy1'
[ 8.560701] PPP generic driver version 2.4.2
[ 8.565878] PPP MPPE Compression module registered
[ 8.571550] NET: Registered PF_PPPOX protocol family
[ 8.577381] PPTP driver version 0.8.5
[ 8.583088] wireguard: WireGuard 1.0.0 loaded. See www.wireguard.com for information.
[ 8.591042] wireguard: Copyright (C) 2015-2019 Jason A. Donenfeld Jason@zx2c4.com. All Rights Reserved.
[ 8.603797] batman_adv: B.A.T.M.A.N. advanced 2024.0-openwrt-2 (compatibility version 15) loaded
[ 8.614614] l2tp_ppp: PPPoL2TP kernel driver, V2.0
[ 8.622991] kmodloader: done loading kernel modules from /etc/modules.d/*
[ 9.771920] mtdblock: MTD device 'bdata' is NAND, please consider using UBI block devices instead.
[ 19.542606] mtk_soc_eth 1b100000.ethernet eth0: Link is Down
[ 19.555892] mtk_soc_eth 1b100000.ethernet eth0: configuring for fixed/2500base-x link mode
[ 19.564798] mtk_soc_eth 1b100000.ethernet eth0: Link is Up - 2.5Gbps/Full - flow control rx/tx
[ 19.569727] mt7530-mdio mdio-bus:00 lan1: configuring for phy/gmii link mode
[ 19.583437] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[ 19.593959] br-lan: port 1(lan1) entered blocking state
[ 19.599240] br-lan: port 1(lan1) entered disabled state
[ 19.610781] device lan1 entered promiscuous mode
[ 19.657983] mt7530-mdio mdio-bus:00 lan2: configuring for phy/gmii link mode
[ 19.670793] br-lan: port 2(lan2) entered blocking state
[ 19.676033] br-lan: port 2(lan2) entered disabled state
[ 19.686444] device lan2 entered promiscuous mode
[ 19.712249] mt7530-mdio mdio-bus:00 lan3: configuring for phy/gmii link mode
[ 19.736548] br-lan: port 3(lan3) entered blocking state
[ 19.741862] br-lan: port 3(lan3) entered disabled state
[ 19.752209] device lan3 entered promiscuous mode
[ 19.772814] mt7530-mdio mdio-bus:00 wan: configuring for phy/gmii link mode
[ 21.578798] br-lan: port 4(wl1-ap0) entered blocking state
[ 21.584303] br-lan: port 4(wl1-ap0) entered disabled state
[ 21.590050] device wl1-ap0 entered promiscuous mode
[ 21.595068] br-lan: port 4(wl1-ap0) entered blocking state
[ 21.600606] br-lan: port 4(wl1-ap0) entered forwarding state
[ 21.609667] br-lan: port 4(wl1-ap0) entered disabled state
[ 22.119449] br-lan: port 5(wl0-ap0) entered blocking state
[ 22.124948] br-lan: port 5(wl0-ap0) entered disabled state
[ 22.130740] device wl0-ap0 entered promiscuous mode
[ 22.135811] br-lan: port 5(wl0-ap0) entered blocking state
[ 22.141351] br-lan: port 5(wl0-ap0) entered forwarding state
[ 22.147186] IPv6: ADDRCONF(NETDEV_CHANGE): br-lan: link becomes ready
[ 22.377671] IPv6: ADDRCONF(NETDEV_CHANGE): wl0-ap0: link becomes ready
[ 22.607586] mt7530-mdio mdio-bus:00 lan2: Link is Up - 1Gbps/Full - flow control rx/tx
[ 22.615578] br-lan: port 2(lan2) entered blocking state
[ 22.620848] br-lan: port 2(lan2) entered forwarding state
[ 22.712213] IPv6: ADDRCONF(NETDEV_CHANGE): wl1-ap0: link becomes ready
[ 22.718981] br-lan: port 4(wl1-ap0) entered blocking state
[ 22.724482] br-lan: port 4(wl1-ap0) entered forwarding state

Now this command works when flashing from stock firmware:
mtd -r write /tmp/factory.bin firmware

@981213 981213 force-pushed the ax6s branch 2 times, most recently from ea350e4 to 4163b02 Compare March 3, 2024 07:48
@remittor
Copy link
Contributor

remittor commented Mar 3, 2024

@981213
This is how you fixed my build option (in my build system the squashfs suffix is disabled):
... | ubinize-image fit squashfs-sysupgrade.itb

And there is another way to fix this situation:

define Device/xiaomi_redmi-router-ax6s
  DEVICE_IMG_NAME = $$(DEVICE_IMG_PREFIX)-$$(2)
...
  ARTIFACTS += factory.bin
  ARTIFACT/factory.bin := uboot-bin xiaomi_redmi-router-ax6s-ubi-loader | lzma | uboot-fit lzma | pad-to 512k | \
    ubinize-image fit sysupgrade.itb

Example:

DEVICE_IMG_NAME = $$(DEVICE_IMG_PREFIX)-$$(2)

@981213
Copy link
Member Author

981213 commented Mar 3, 2024

Removing -squashfs- from image name will cause conflicts when multiple filesystem types are enabled.

@remittor
Copy link
Contributor

remittor commented Mar 3, 2024

Removing -squashfs- from image name will cause conflicts when multiple filesystem types are enabled.

It's understood.
Now my build system will have to be patched or this unnecessary suffix returned. This is sad.

@xabolcs
Copy link
Contributor

xabolcs commented Mar 3, 2024

Offtopic question:
will this U-Boot able to boot a bricked AX3200? Or should I edit it's config?
I found you UART boot compatible BL2, so I need just a working U-Boot for AX3200.

Ontopic question:
I tried this PR but it fails building fitblk:

make[4]: Entering directory '/openwrt/build_dir/target-aarch64_cortex-a53_musl/fitblk'
aarch64-openwrt-linux-musl-gcc -Os -pipe -mcpu=cortex-a53 -fno-caller-saves -fno-plt -fhonour-copts -fmacro-prefix-map=/openwrt/build_dir/target-aarch64_cortex-a53_musl/fitblk=fitblk -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -Wall -Werror -o fitblk fitblk.c -L/openwrt/staging_dir/toolchain-aarch64_cortex-a53_gcc-12.3.0_musl/usr/lib -L/openwrt/staging_dir/toolchain-aarch64_cortex-a53_gcc-12.3.0_musl/lib -fuse-ld=bfd -znow -zrelro
fitblk.c:8:10: fatal error: linux/fitblk.h: No such file or directory
    8 | #include <linux/fitblk.h>
      |          ^~~~~~~~~~~~~~~~
compilation terminated.

Am I missing something? I built the refs/pull/14770/merge commit, not the PR's head.

@rany2
Copy link
Contributor

rany2 commented Mar 3, 2024

@xabolcs did you run defconfig?

@xabolcs
Copy link
Contributor

xabolcs commented Mar 3, 2024

Just a make clean; make menuconfig. I'm trying again, but a make distclean will surely help.

@xabolcs
Copy link
Contributor

xabolcs commented Mar 3, 2024

@xabolcs did you run defconfig?

I'm trying again, but a make distclean will surely help.

Only make distclean helped! Sorry for the noise!

But my original - offtopic - question is still open. 😅

@981213
Copy link
Member Author

981213 commented Mar 4, 2024

@remittor

Now my build system will have to be patched or this unnecessary suffix returned.

I could try building factory.bin in IMAGE instead of ARTIFACTS. Haven't thought of a good way to do that yet.

@xabolcs

will this U-Boot able to boot a bricked AX3200? Or should I edit it's config?

No. The u-boot in this PR is packaged alone into an fit image, and BL2 won't recognize it. For that to work you need to edit the uboot-mediatek Makefile to package u-boot with ATF into an FIP, like what other devices are currently doing.

@danpawlik danpawlik mentioned this pull request Mar 4, 2024
42 tasks
@@ -9,7 +9,8 @@ case "$(board_name)" in
uci set system.@system[0].compat_version="1.1"
uci commit system
;;
linksys,e8450-ubi)
linksys,e8450-ubi|\
xiaomi,redmi-router-ax6s)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DragonBluep

So the correct model should be xxx,rb03

Yes. I believe that developers should use precise notations, and not those that marketers force.

Sadly, there are no Xiaomi devices using the correct model name.

You are not right. Each firmware image for an Asus router has the exact model name in the header.
Likewise, in every firmware image for a Xiaomi router, the header contains the exact name of the model.

+boot_production=run ubi_read_production && bootm $loadaddr#$bootconf
+ubi_format=ubi detach ; mtd erase ubi && ubi part ubi
+ubi_init=ubi part ubi || run ubi_format
+ubi_prepare_rootfs=if ubi check rootfs_data ; then else if env exists rootfs_data_max ; then ubi create rootfs_data $rootfs_data_max dynamic || ubi create rootfs_data - dynamic ; else ubi create rootfs_data - dynamic ; fi ; fi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest adding additional logging:

ubi_prepare_rootfs=echo "run ubi_prepare_rootfs" ; if ubi check rootfs_data ; then echo "volume rootfs_data already exists"; else if env exists rootfs_data_max ; then ubi create rootfs_data $rootfs_data_max dynamic || ubi create rootfs_data - dynamic ; else ubi create rootfs_data - dynamic ; fi ; fi

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really like this kind of verbose logs. As we already have to write an entire script in one line, I think it's better to keep it short for better readability.

Comment on lines +40 to +53
define Build/uboot-bin
cat $(STAGING_DIR_IMAGE)/mt7622_$1-u-boot.bin >> $@
endef

define Build/uboot-fit
$(TOPDIR)/scripts/mkits.sh \
-D $(DEVICE_NAME) -o $@.its -k $@ \
-C $(word 1,$(1)) \
-a 0x41e00000 -e 0x41e00000 \
-c "config-1" \
-A $(LINUX_KARCH) -v u-boot
PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage -f $@.its $@.new
@mv $@.new $@
endef
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These functions need to be moved to the main Makefile, since they are also needed for filogic targets.
Example: openwrt-xiaomi@f10db88

Function uboot-fit needs to be improved (made universal).
Example: openwrt-xiaomi@f10db88

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this kind of standalone utilities need to be included in the main OpenWrt tree. It can be built directly from mainline u-boot and live in a mainline u-boot fork instead.
BTW it'll be more complicated on filogic because the vendor bootchain expects UBI on top of NMBM. Our u-boot knows nothing about NMBM and it shouldn't be directly manipulating the UBI area.

@K900
Copy link
Contributor

K900 commented Mar 8, 2024

This doesn't seem usable on devices with GD5F1GQ5xExxG flash. The existing uboot doesn't know anything about that chip, and adding the ID results in it treating every single block as bad.

@981213
Copy link
Member Author

981213 commented Mar 9, 2024

@K900 I've added support to that flash and it seems fine here. Could you test again with the latest version in my PR?

@rany2
Copy link
Contributor

rany2 commented Mar 9, 2024

@981213 I confirm that the issue is resolved for me.

@edrikk
Copy link

edrikk commented Mar 9, 2024

@981213 Is it possible to build a initramfs-factory.ubi equivalent variant of the firmware similar to what RobiMarko did for AX3600:

https://firmware-selector.openwrt.org/?version=SNAPSHOT&target=qualcommax%2Fipq807x&id=xiaomi_ax3600

This firmware was used to allow a simple means of transitioning from the original 2 data partitions to a single one on that device even from Luci just before support was merged to master. Prior to that (in testing) it was 2 partitions for all the testers. i.e. flash initramfs-factory.ubi, then when the router comes back up flash 'normal' sysupgrade bin.

Separately, if this PR is the path that is going to be taken (vs. the other PR), it would be awesome if the first post could be updated with the commands needed to update directly from openwrt cli.

@rany2
Copy link
Contributor

rany2 commented Mar 9, 2024

@edrikk

Is it possible to build a initramfs-factory.ubi equivalent variant of the firmware similar to what RobiMarko did for AX3600:

It's not possible for AX6S because updating the firmware from the Web UI will not work because of signature checks that aren't defeated yet.

It does build a openwrt-mediatek-mt7622-xiaomi_redmi-router-ax6s-factory.bin which is functionally the same as openwrt-mediatek-mt7622-xiaomi_redmi-router-ax6s-squashfs-factory.bin, so you don't need to setup a TFTP server to flash it if you don't want to. You could from an older OpenWRT do (i.e. kernel size is 4MB, tweak if you used #14768):

mount -o remount,ro /
mount -o remount,ro /overlay
cd /tmp
dd if=factory.bin bs=1M count=4 | mtd write - kernel
dd if=factory.bin bs=1M skip=4 | mtd write - ubi
echo c > /proc/sysrq-trigger

or from the stock firmware do:

mtd -r write factory.bin firmware

Afterwards the sysupgrade images will work as expected.

@edrikk
Copy link

edrikk commented Mar 9, 2024

Fantastic! I would absolutely update the top post with this info as well.
Thank you rany2!

@remittor
Copy link
Contributor

remittor commented Mar 9, 2024

@edrikk
special topic: https://forum.openwrt.org/t/mt7622-re-enable-redmi-ax6s-xiaomi-ax3200-snapshot-builds/190084

@K900
Copy link
Contributor

K900 commented Mar 10, 2024

@K900 I've added support to that flash and it seems fine here. Could you test again with the latest version in my PR?

Weirdly, I made the same change and it didn't work, but I just tried it on latest master and now it does.

@K900
Copy link
Contributor

K900 commented Mar 11, 2024

OK, so I've been running this for a bit and it's been working just fine.

The install process I used is a bit different from what has been documented here I think, so I'll describe it for posterity:

  1. Get serial access
  2. Run a TFTP server in your artifacts directory
  3. From vendor uboot command line, setenv ipaddr 192.168.1.1; setenv serverip 192.168.1.254; tftpboot openwrt-mediatek-mt7622-xiaomi_redmi-router-ax6s-ubi-loader.itb to netboot the second stage loader
  4. Let it fetch, flash and boot the base image
  5. From the booted system, copy the second stage loader image over and mtd write openwrt-mediatek-mt7622-xiaomi_redmi-router-ax6s-ubi-loader.itb ubi-loader to actually write the second stage loader to flash

The nice thing about this approach is that it doesn't actually require any specific firmware or firmware-specific setup, you just need the factory u-boot to be present.

I'm not sure if there's a good way to make the second stage loader write itself to flash so you can just tftpboot it once and have everything set up, but that would make this flow even nicer.

Add support for Xiaomi Redmi AX6S to be used as a second-stage
UBI loader.
The defconfig/env is minimal: Boot fit from UBI. If that failed,
load and boot initramfs image from TFTP.

Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
This patch adds support for GigaDevice GD5F1GQ5UExxG to the
mtk-snfi driver in u-boot.

Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
@981213 981213 removed work in progress pull request the author is still working on RFC pull request ready for comments RFT pull request ready for testing labels Mar 20, 2024
@981213 981213 changed the title [RFT][RFC] mediatek: Add a second u-boot for Redmi AX6S mediatek: Add a second u-boot for Redmi AX6S Mar 20, 2024
@981213 981213 added the work in progress pull request the author is still working on label Mar 20, 2024
The vendor u-boot knows nothing about UBI, and we used to have a
fixed-size kernel partition for vendor u-boot and UBI for rootfs.
However, that fixed partition becomes too small eventually, and
expanding it requires complicated procedure.

This commit changed the flash layout and added a second u-boot
where the kernel supposed to be.
Now the vendor u-boot chainloads our mainline u-boot, and our
u-boot reads kernel+rootfs from UBI, verifies it, and boot
into OpenWrt.

There are two possible ways to convert from the old fw:
Flash the factory image using mtd (provided by @rany2):

mount -o remount,ro /
mount -o remount,ro /overlay
cd /tmp
dd if=factory.bin bs=1M count=4 | mtd write - kernel
dd if=factory.bin bs=1M skip=4 | mtd -r write - ubi

Or, flash the 2nd u-boot via mtd and upload the firmware
to the 2nd u-boot using tftp:

1. prepare a tftp server at 192.168.1.254 to serve the
   sysupgrade image:
   openwrt-mediatek-mt7622-xiaomi_redmi-router-ax6s-squashfs-sysupgrade.itb
2. upload the ubi-loader.itb to OpenWrt /tmp, and flash it to
   the old kernel partition:
   mtd -r write openwrt-mediatek-mt7622-xiaomi_redmi-router-ax6s-ubi-loader.itb
3. The router should reboot and flash the sysupgrade image via TFTP.

Procedure for flashing from vendor firmware shouldn't change.

Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
@981213 981213 removed the work in progress pull request the author is still working on label Mar 20, 2024
@981213
Copy link
Member Author

981213 commented Mar 21, 2024

I've merged this PR into main.

@981213 981213 closed this Mar 21, 2024
@981213 981213 deleted the ax6s branch March 23, 2024 14:20
xabolcs added a commit to xabolcs/openwrt that referenced this pull request Mar 24, 2024
Packaging U-Boot with ATF into a FIP, like the others.

Ref: openwrt#14770 (comment)
Suggested-by: Chuanhong Guo <gch981213@gmail.com>
Signed-off-by: Szabolcs Hubai <szab.hu@gmail.com>
xabolcs added a commit to xabolcs/openwrt that referenced this pull request Mar 24, 2024
Packaging U-Boot with ATF into a FIP, like the others.

Ref: openwrt#14770 (comment)
Suggested-by: Chuanhong Guo <gch981213@gmail.com>
Signed-off-by: Szabolcs Hubai <szab.hu@gmail.com>
xabolcs added a commit to xabolcs/openwrt that referenced this pull request Mar 24, 2024
Packing U-Boot with ATF into a FIP, like the others.

Ref: openwrt#14770 (comment)
Suggested-by: Chuanhong Guo <gch981213@gmail.com>
Signed-off-by: Szabolcs Hubai <szab.hu@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core packages pull request/issue for core (in-tree) packages target/mediatek pull request/issue for mediatek target
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants