U-boot 2022.07 vs 2023.04 on Acer W6/W6m

I have 4 Acer W6/W6m units that I have flashed onto OpenWRT FW. Of those 4 units, 2 have U-boot version 2022.07 and the other 2 have 2023.04. Now; I've noticed some interesting differences that in my opinion warrant being documented for each U-boot version.

  • First is that the newer bootloader version is not compatible with flash instructions for W6 the part that needs to be added is setenv ipaddr -- it needs to be undefined; otherwise, after flashing with initramfs and performing subsequent sysupgrade, it fails to autoboot because both slots being marked invalid (neither has valid signature). When setenv ipaddr is undefined, it will fail into normal bootcmd autoboot, which does not are about that, unlike mtkautoboot.

  • Second thing I noticed, but this time with the older U-boot version, is that it flip-flops between kernel/kernel1 and rootfs/rootfs1 on each reboot, even though the other bootslot is zeroed out in eMMC. Also, what cat /proc/cmdline boot_param.boot_image_slot=x reports is always the opposite of what U-boot initially tries to boot from.

Demonstration of the first issue (if I go by the OpenWRT wiki provided flash procedure):

> F0: 102B 0000
> FA: 1040 0000
> FA: 1040 0000 [0200]
> F9: 103F 0000
> F3: 1006 0033 [0200]
> F3: 4001 00E0 [0200]
> F3: 0000 0000
> V0: 0000 0000 [0001]
> 00: 0000 0000
> BP: 2400 0041 [0000]
> G0: 1190 0000
> EC: 0000 0000 [2000]
> T0: 0000 0275 [010F]
> Jump to BL
> 
> 
> 
> U-Boot 2023.04 (Jan 15 2024 - 14:30:51 +0800), Build: jenkins-YX6ES_mesh-187
> 
> CPU:   MediaTek MT7986
> Model: mt7986-rfb
>        (mediatek,mt7986-emmc-rfb)
> DRAM: 1 GiB
> Core:  70 devices, 20 uclasses, devicetree: separate
> MMC: mmc@11230000: 0
> OK
> In:    serial@11002000
> Out:   serial@11002000
> Err:   serial@11002000
> Net:   eth0: ethernet@15100000
> 
>   *** U-Boot Boot Menu ***
> 
>       1. Startup system (Default)
>       2. Upgrade firmware
>       3. Upgrade ATF BL2
>       4. Upgrade ATF FIP
>       5. Upgrade U-boot only
>       6. Upgrade partition table
>       7. Upgrade single image
>       8. Load image
>       9. Start Web failsafe
>       0. U-Boot console
> 
> 
>   Press UP/DOWN to move, ENTER to select, ESC to quit
> Image slot 0 was marked invalid.
> Image slot 1 was marked invalid.
> 
> Web failsafe UI started
> URL: http://192.168.1.1/
> 
> Press Ctrl+C to exit

Here it will remain stuck preventing autoboot unless another input from the serial console over UART. If I flash with modified method this can be remedied, my exact procedure:

mmc dev 0
mmc erase 0x4400 0x220000
setenv bootcmd 'mmc read 0x40000000 0x00004400 0x0010000; fdt addr $(fdtcontroladdr); fdt rm /signature; bootm 0x40000000';
setenv dual_boot.slot_0_invalid 1
setenv dual_boot.slot_1_invalid 1
setenv bootmenu_default 0
setenv ipaddr
setenv serverip
setenv bootmenu_delay 3
setenv bootdelay 0
saveenv
setenv serverip 192.168.1.66; setenv ipaddr 192.168.1.1; tftpboot 0x46000000 initramfs.bin; fdt addr $(fdtcontroladdr); fdt rm /signature; bootm

Then SCP into the router; upload sysupgrade.bin; perform sysupgrade with
sysupgrade -n sysupgrade.bin over serial console. When I use the modified method:

> F0: 102B 0000
> FA: 1040 0000
> FA: 1040 0000 [0200]
> F9: 103F 0000
> F3: 1006 0033 [0200]
> F3: 4001 00E0 [0200]
> F3: 0000 0000
> V0: 0000 0000 [0001]
> 00: 0000 0000
> BP: 2400 0041 [0000]
> G0: 1190 0000
> EC: 0000 0000 [2000]
> T0: 0000 0275 [010F]
> Jump to BL
> 
> 
> 
> U-Boot 2023.04 (Jan 15 2024 - 14:30:51 +0800), Build: jenkins-YX6ES_mesh-187
> 
> CPU:   MediaTek MT7986
> Model: mt7986-rfb
>        (mediatek,mt7986-emmc-rfb)
> DRAM: 1 GiB
> Core:  70 devices, 20 uclasses, devicetree: separate
> MMC: mmc@11230000: 0
> OK
> In:    serial@11002000
> Out:   serial@11002000
> Err:   serial@11002000
> Net:   eth0: ethernet@15100000
> 
>   *** U-Boot Boot Menu ***
> 
>       1. Startup system (Default)
>       2. Upgrade firmware
>       3. Upgrade ATF BL2
>       4. Upgrade ATF FIP
>       5. Upgrade U-boot only
>       6. Upgrade partition table
>       7. Upgrade single image
>       8. Load image
>       9. Start Web failsafe
>       0. U-Boot console
> 
> 
>   Press UP/DOWN to move, ENTER to select, ESC to quit
> Image slot 0 was marked invalid.
> Image slot 1 was marked invalid.
> 
> Web failsafe UI started
> URL: http://0.0.0.0/
> 
> Press Ctrl+C to exit
> *** ERROR: `ipaddr' not set
> Hit any key to stop autoboot:  0
> 
> MMC read: dev # 0, block # 17408, count 65536 ... 65536 blocks read: OK
> Working FDT set to 7f7fcda0
> ## Loading kernel from FIT Image at 40000000 ...
>    Using 'config-1' configuration
>    Verifying Hash Integrity ... OK
>    Trying 'kernel-1' kernel subimage
>      Description:  ARM64 OpenWrt Linux-6.12.94
>      Type:         Kernel Image
>      Compression:  lzma compressed
>      Data Start:   0x400000e8
>      Data Size:    4307090 Bytes = 4.1 MiB
>      Architecture: AArch64
>      OS:           Linux
>      Load Address: 0x48000000
>      Entry Point:  0x48000000
>      Hash algo:    crc32
>      Hash value:   d86b7f68
>      Hash algo:    sha1
>      Hash value:   a422b6a6bfff051626511cdaf910bdae50365105
>    Verifying Hash Integrity ... crc32+ sha1+ OK
> ## Loading fdt from FIT Image at 40000000 ...
>    Using 'config-1' configuration
>    Verifying Hash Integrity ... OK
>    Trying 'fdt-1' fdt subimage
>      Description:  ARM64 OpenWrt acer_predator-w6 device tree blob
>      Type:         Flat Device Tree
>      Compression:  uncompressed
>      Data Start:   0x4041babc
>      Data Size:    25747 Bytes = 25.1 KiB
>      Architecture: AArch64
>      Load Address: 0x47000000
>      Hash algo:    crc32
>      Hash value:   cfc56697
>      Hash algo:    sha1
>      Hash value:   d5df932472445be4d13f20941a6aa6009644b615
>    Verifying Hash Integrity ... crc32+ sha1+ OK
>    Loading fdt from 0x4041babc to 0x47000000
>    Booting using the fdt blob at 0x47000000
> Working FDT set to 47000000
>    Uncompressing Kernel Image
>    Loading Device Tree to 000000007f7ef000, end 000000007f7f8492 ... OK
> Working FDT set to 7f7ef000
> 
> Starting kernel ...

Demonstration of the second issue (I have not found a fix for this one):
Before it can make sense here is the map of memory partitions, their GPT names, start addresses and size of each partition;

> root@OpenWrt:~# for n in /sys/class/block/mmcblk0p[0-9]*; do [ -r "$n/start" ] |
> | continue; s=$(cat "$n/start"); z=$(cat "$n/size"); printf "%-5s %-16s %-14s %-
> 14s\n" "p${n##*p}" "$(sed -n 's/^PARTNAME=//p' "$n/uevent")" "$(printf '0x%X' "$
> ((s*512))")" "$(printf '0x%X' "$((z*512))")"; done | sort -V
> p1    gpt              0x0            0x4400
> p2    u-boot-env       0x400000       0x80000
> p3    factory          0x480000       0x200000
> p4    fip              0x680000       0x200000
> p5    kernel           0x880000       0x2000000
> p6    rootfs           0x2880000      0x20000000
> p7    kernel1          0x22880000     0x2000000
> p8    rootfs1          0x24880000     0x20000000
> p9    qcidata          0x44880000     0xA00000
> p10   qcidata1         0x45280000     0xA00000
> p11   rootfs_data      0x45C80000     0x20000000
> p12   user_data        0x65C80000     0x80000000

or;

> MT7986> part list mmc 0
> 
> Partition Map for MMC device 0  --   Partition Type: EFI
> 
> Part    Start LBA       End LBA         Name
>         Attributes
>         Type GUID
>         Partition GUID
>   1     0x00000000      0x00000021      "gpt"
>         attrs:  0x0000000000000000
>         type:   0fc63daf-8483-4772-8e79-3d69d8477de4
>                 (linux)
>         guid:   c2f25d80-045a-11ee-9b88-a81e84c31560
>   2     0x00002000      0x000023ff      "u-boot-env"
>         attrs:  0x0000000000000000
>         type:   0fc63daf-8483-4772-8e79-3d69d8477de4
>                 (linux)
>         guid:   19a4763a-6b19-4a4b-a0c4-8cc34f4c2ab9
>   3     0x00002400      0x000033ff      "factory"
>         attrs:  0x0000000000000000
>         type:   0fc63daf-8483-4772-8e79-3d69d8477de4
>                 (linux)
>         guid:   8142c1b2-1697-41d9-b1bf-a88d76c7213f
>   4     0x00003400      0x000043ff      "fip"
>         attrs:  0x0000000000000000
>         type:   0fc63daf-8483-4772-8e79-3d69d8477de4
>                 (linux)
>         guid:   18de6587-4f17-4e08-a6c9-d9d3d424f4c5
>   5     0x00004400      0x000143ff      "kernel"
>         attrs:  0x0000000000000000
>         type:   0fc63daf-8483-4772-8e79-3d69d8477de4
>                 (linux)
>         guid:   971f7556-ef1a-44cd-8b28-0cf8100b9c7e
>   6     0x00014400      0x001143ff      "rootfs"
>         attrs:  0x0000000000000000
>         type:   0fc63daf-8483-4772-8e79-3d69d8477de4
>                 (linux)
>         guid:   309a3e76-270b-41b2-b5d5-ed8154e7542b
>   7     0x00114400      0x001243ff      "kernel1"
>         attrs:  0x0000000000000000
>         type:   0fc63daf-8483-4772-8e79-3d69d8477de4
>                 (linux)
>         guid:   a975393e-a9bc-491f-8133-aeecf6075307
>   8     0x00124400      0x002243ff      "rootfs1"
>         attrs:  0x0000000000000000
>         type:   0fc63daf-8483-4772-8e79-3d69d8477de4
>                 (linux)
>         guid:   32798804-a1a7-4f95-ad5a-48939498675b
>   9     0x00224400      0x002293ff      "qcidata"
>         attrs:  0x0000000000000000
>         type:   0fc63daf-8483-4772-8e79-3d69d8477de4
>                 (linux)
>         guid:   3c607e69-0038-4195-a819-77157883e2df
>  10     0x00229400      0x0022e3ff      "qcidata1"
>         attrs:  0x0000000000000000
>         type:   0fc63daf-8483-4772-8e79-3d69d8477de4
>                 (linux)
>         guid:   613e2af8-cfe5-4701-8e67-facda9ffdd71
>  11     0x0022e400      0x0032e3ff      "rootfs_data"
>         attrs:  0x0000000000000000
>         type:   0fc63daf-8483-4772-8e79-3d69d8477de4
>                 (linux)
>         guid:   5881ba72-d78f-4cbb-8fef-871aeb4b8eef
>  12     0x0032e400      0x0072e3ff      "user_data"
>         attrs:  0x0000000000000000
>         type:   0fc63daf-8483-4772-8e79-3d69d8477de4
>                 (linux)
>         guid:   e6f92786-dc2f-4b91-b33c-92b3f18c2548

Then we can look into U-boot sequence to map boot slots;

Trying to boot from image slot 0
Reading from 0x880000 to 0x40000000, size 0x200 ... OK
Reading from 0x880000 to 0x40000000, size 0x4222a8 ... OK

... on another boot from the other slot...

Trying to boot from image slot 1
Reading from 0x22880000 to 0x40000000, size 0x200 ... OK
Reading from 0x22880000 to 0x40000000, size 0x4222a8 ... OK

So we can map slot 0 to p5/p6 and slot 1 to p7/p8,
Now onto the actual demonstration here
!Not directly here because of the 32kchar post limit!