Still no progress regarding the factory images. Currently I'm stuck with the partitioning in the DTS. The working state using only the "ubi" partition is:
partition@580000 {
label = "ubi";
reg = <0x580000 0x3200000>;
};
partition@3780000 {
label = "ubi1";
reg = <0x3780000 0x3200000>;
read-only;
};
In the working case, I cannot download factory images as they would be written to the ubi1 partition, so I can just use flashing via recovery web interface or initramfs.
What I want to achive when flashing via OEM web interface is selcteding the active ubi partition during bootup depending on the kernel command line arguments, I tried this:
partition@580000 {
label = "ubi";
reg = <0x580000 0x3200000>;
compatible = "linux,ubi";
openwrt,cmdline-match = "bootpart=ubi0";
};
partition@3780000 {
label = "ubi1";
reg = <0x3780000 0x3200000>;
compatible = "linux,ubi";
openwrt,cmdline-match = "bootpart=ubi1";
read-only;
};
But it results in this error:
[ 1.002302] VFS: Cannot open root device "(null)" or unknown-block(0,0): error -6
[ 1.009823] Please append a correct "root=" boot option; here are the available partitions:
OpenWrt is booting when changing label="ubi1" to label="ubi" and writing to the second partition, but then it's quite strange behaviour. Looks like no access to the U-Boot environment is present and ethernet doesn't work.
U-Boot environment:
MT7981> printenv
FW_RESET_FLAG=0
baudrate=115200
boot_by_part=if itest.s ${mupgrade_en} == 1; then aup;fi;if itest.s ${bootpart} == 0; then run set_act1; run ub0; else run set_act2; run ub1; fi
boot_by_tryactive=if itest.s ${sw_tryactive} == 0; then setenv sw_tryactive 2; setenv sw_active 1; saveenv; run ub0; else setenv sw_tryactive 2; setenv sw_active 2; saveenv; run ub1; fi
boot_rd_auto_sw_img=if itest.s ${sw_tryactive} == 2; then run boot_by_part; else run boot_by_tryactive; fi
bootargs=console=ttyS0,115200n1 loglevel=8 earlycon=uart8250,mmio32,0x11002000 bootpart=ubi0
bootdelay=2
bootfile=openwrt-mediatek-filogic-dlink_aquila-pro-ai-m30-a1-initramfs-kernel.bin
bootmenu_0=Startup system (Default)=run boot_rd_auto_sw_img
bootmenu_1=Upgrade firmware=mtkupgrade fw
bootmenu_2=Upgrade ATF BL2=mtkupgrade bl2
bootmenu_3=Upgrade ATF FIP=mtkupgrade fip
bootmenu_4=Http Upgrade=uip main; reset
bootmenu_5=Upgrade single image=mtkupgrade simg
bootmenu_6=Load image=mtkload
bootpart=0
con=0
en_wdt=wdt on 30
ethact=ethernet@15100000
ethaddr=be:e4:d5:0b:05:0d
fdtcontroladdr=5ff35220
fileaddr=46000000
filesize=7a73c0
fw_ver_a=1.01.05
fw_ver_b=1.01.05
i=7
ipaddr=192.168.200.1
loadaddr=0x46000000
mtdids=nmbm0=nmbm0
mtdparts=nmbm0:1024k(bl2),512k(u-boot-env),2048k(factory),2048k(fip),51200k(ubi),51200k(ubi1),256k(Odm),512k(Config1),512k(Config2),5120k(Storage)
mupgrade_en=1
netmask=255.255.255.0
power_on_rst_recov=setexpr i 8;setexpr con 1;while itest ${con} -gt 0; do if gpio input 0; then gpio toggle 5; else setexpr con 0; fi; sleep 1; if itest ${i} -eq 0; then setexpr con 0; else setexpr i ${i} - 1; fi;done;if itest ${i} -gt 0; then if itest ${i} -lt 4; then setenv FW_RESET_FLAG 1; saveenv; echo set FW_RESET_FLAG to 1; gpio toggle 5;sleep 0.2; gpio toggle 5;sleep 0.2; gpio toggle 5;sleep 0.2; gpio toggle 5;sleep 0.2; gpio toggle 5;sleep 0.2; gpio toggle 5; fi;else uip main;fi
serverip=192.168.200.2
set_act1=if itest.s ${sw_active} != 1; then setenv sw_active 1; saveenv; fi
set_act2=if itest.s ${sw_active} != 2; then setenv sw_active 2; saveenv; fi
stderr=serial@11002000
stdin=serial@11002000
stdout=serial@11002000
sw_active=2
sw_tryactive=2
ub0=setenv bootpart 0; mtkboardboot; run ub0to1; uip main; reset
ub0to1=setenv bootpart 1; mtkboardboot
ub1=setenv bootpart 1; mtkboardboot; run ub1to0; uip main; reset
ub1to0=setenv bootpart 0; mtkboardboot
Environment size: 2376/262140 bytes