openwrt/target/linux/mediatek
Roland Reinl 70610a5240
Some checks are pending
Build Kernel / Build all affected Kernels (push) Waiting to run
mediatek: Fix U-Boot variables handling for D-Link M30 A1
I think I implemented the U-Boot handling incorrectly on M30 (saw the issue while porting M60 to OpenWrt). Maybe someone with more U-Boot experience can have a look at it.
What I understood until now:

Before flashing, `sw_tryactive` must be set to 0 because OpenWrt runs on partition 0

During reset after flashing, U-Boot executes the following line:
`boot_rd_auto_sw_img=if itest.s ${sw_tryactive} == 2; then run boot_by_part; else run boot_by_tryactive; fi`

As `sw_tryactive` was set to 0 before flashing, `boot_by_tryactive` will be executed:
`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`

As `sw_tryactive` was set to 0 before flashing, `sw_active` will be set to 1 and `ub0` will be executed:
`ub0=setenv bootpart 0; mtkboardboot; run ub0to1; uip main; reset`

If the OpenWrt boot is successful, `ub0to1` and `uip` main will never be executed. Only in case OpenWrt cannot be loaded, `mtkboardboot` will return and the fallback `ub0to1` is executed.

Conclusion: It's sufficient to set `sw_tryacitve` to 0 before flashing, the added code in `target/linux/mediatek/filogic/base-files/etc/init.d/bootcount` is useless.
In the worst case (/proc/cmdline doesn't contain `bootpart=ubi0` as expected), the bootpart variable would be set to 1 and causes starting the firmware from the second partition instead of the one on the first partition.

Signed-off-by: Roland Reinl <reinlroland+github@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/17298
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
2025-01-04 22:32:26 +01:00
..
base-files mediatek: update openembed som7981 support 2024-12-22 18:19:16 +01:00
dts mediatek: Fix primary MAC of D-Link M60 2025-01-01 17:28:01 +01:00
files/drivers treewide: remove THIS_MODULE assignment 2024-11-10 02:16:31 +01:00
files-6.6 linux: replace u-boot,env with nvmem,layout 2024-12-27 13:34:58 +01:00
filogic mediatek: Fix U-Boot variables handling for D-Link M30 A1 2025-01-04 22:32:26 +01:00
image mediatek: append metadata to factory-uboot.bin for WSR devices 2025-01-04 18:55:31 +01:00
mt7622 mediatek: mt7622: sync buffalo.sh with ramips/mt7621 2025-01-04 18:55:31 +01:00
mt7623 kernel: filter out compiler opts from config 2024-11-17 14:55:16 +01:00
mt7629 kernel: filter out compiler opts from config 2024-11-17 14:55:16 +01:00
patches-6.6 kernel: bump 6.6 to 6.6.69 2025-01-02 20:56:33 +01:00
Makefile mediatek: change the the default SUBTARGET to filogic 2024-10-02 15:12:18 +02:00
modules.mk mediatek: mt7623: build mt6577_auxadc driver into kernel 2022-12-05 23:14:36 +00:00