uboot-mediatek: fixes for OpenWrt One
authorDaniel Golle <[email protected]>
Tue, 7 May 2024 19:46:06 +0000 (20:46 +0100)
committerDaniel Golle <[email protected]>
Wed, 8 May 2024 01:13:37 +0000 (02:13 +0100)
 - sync filenames with image name changes
 - make sure device never ends up on U-Boot shell no matter what ever goes
   wrong during default boot.
 - reorder environment with _bootmenu_update_title last, so truncation
   will not go unnoticed.
 - unify environment with other mtk devices.

package/boot/uboot-mediatek/patches/453-add-openwrt-one.patch

index 3c3155809a386edc742eb7c6edb8422833a43e55..b15c1051915dce2c8b6dc6d838e40e9f9079ca70 100644 (file)
@@ -1,7 +1,5 @@
-Index: u-boot-2024.01/arch/arm/dts/openwrt-one.dts
-===================================================================
 --- /dev/null
-+++ u-boot-2024.01/arch/arm/dts/openwrt-one.dts
++++ b/arch/arm/dts/openwrt-one.dts
 @@ -0,0 +1,203 @@
 +// SPDX-License-Identifier: GPL-2.0
 +/*
@@ -206,10 +204,8 @@ Index: u-boot-2024.01/arch/arm/dts/openwrt-one.dts
 +&watchdog {
 +      status = "disabled";
 +};
-Index: u-boot-2024.01/configs/mt7981_openwrt-one-nor_defconfig
-===================================================================
 --- /dev/null
-+++ u-boot-2024.01/configs/mt7981_openwrt-one-nor_defconfig
++++ b/configs/mt7981_openwrt-one-nor_defconfig
 @@ -0,0 +1,1811 @@
 +#
 +# Automatically generated file; DO NOT EDIT.
@@ -2022,10 +2018,8 @@ Index: u-boot-2024.01/configs/mt7981_openwrt-one-nor_defconfig
 +# CONFIG_TOOLS_MKEFICAPSULE is not set
 +# CONFIG_FSPI_CONF_HEADER is not set
 +# CONFIG_TOOLS_MKFWUMDATA is not set
-Index: u-boot-2024.01/configs/mt7981_openwrt-one-spi-nand_defconfig
-===================================================================
 --- /dev/null
-+++ u-boot-2024.01/configs/mt7981_openwrt-one-spi-nand_defconfig
++++ b/configs/mt7981_openwrt-one-spi-nand_defconfig
 @@ -0,0 +1,1815 @@
 +#
 +# Automatically generated file; DO NOT EDIT.
@@ -3842,15 +3836,9 @@ Index: u-boot-2024.01/configs/mt7981_openwrt-one-spi-nand_defconfig
 +# CONFIG_TOOLS_MKEFICAPSULE is not set
 +# CONFIG_FSPI_CONF_HEADER is not set
 +# CONFIG_TOOLS_MKFWUMDATA is not set
-Index: u-boot-2024.01/openwrt-one-nor_env
-===================================================================
 --- /dev/null
-+++ u-boot-2024.01/openwrt-one-nor_env
++++ b/openwrt-one-nor_env
 @@ -0,0 +1,44 @@
-+_bootmenu_update_title=setenv _bootmenu_update_title ; setenv bootmenu_title "$bootmenu_title       \e[33m$ver\e[0m"
-+_firstboot=setenv _firstboot ; run _switch_to_menu ; run _init_env ; bootmenu
-+_init_env=setenv _init_env ; echo Initialize Env ; run ubi_create_env ; saveenv 
-+_switch_to_menu=setenv _switch_to_menu ; setenv bootdelay 3 ; setenv bootmenu_delay 3 ; setenv bootmenu_0 $bootmenu_0d ; setenv bootmenu_0d ; run _bootmenu_update_title
 +bl2_mtd_write=mtd erase bl2-nor &&  mtd write bl2-nor $loadaddr 0x0 0x40000
 +bl2_tftp_write=tftpboot $loadaddr $bootfile_bl2_nor && run bl2_mtd_write
 +bootcmd=run check_button ; run led_start ; mtd read recovery ${loadaddr} ; bootm ; run led_loop_error
@@ -3869,8 +3857,8 @@ Index: u-boot-2024.01/openwrt-one-nor_env
 +bootmenu_confirm_return=askenv - Press ENTER to return to menu ; bootmenu 60
 +bootmenu_default=0
 +bootmenu_delay=0
-+bootmenu_title=      \e[0 ;34m( ( ( \e[1 ;39mOpenWrt\e[0 ;34m ) ) )  \e[0 ;36m[SPI-NOR]\e[0m
-+check_button=if button front ; then run usb_recovery ; run led_loop_error ; fi ; 
++bootmenu_title=      \e[0;34m( ( ( \e[1;39mOpenWrt\e[0;34m ) ) )  \e[0;36m[SPI-NOR]\e[0m
++check_button=if button front ; then run usb_recovery ; run led_loop_error ; fi
 +fip_mtd_write=mtd erase fip-nor && mtd write fip-nor $loadaddr
 +fip_tftp_write=tftpboot $loadaddr $bootfile_fip_nor && run fip_mtd_write
 +ipaddr=192.168.11.11
@@ -3881,7 +3869,7 @@ Index: u-boot-2024.01/openwrt-one-nor_env
 +led_start=led green off ; led red off; led white on
 +loadaddr=0x46000000
 +preboot=run led_boot
-+recoverfile_bl2=openwrt-mediatek-filogic-openwrt_one-spim-nand-preloader.bin
++recoverfile_bl2=openwrt-mediatek-filogic-openwrt_one-snand-preloader.bin
 +recoverfile_ubi=openwrt-mediatek-filogic-openwrt_one-factory.ubi
 +recovery_write_bl2=mtd erase bl2 && for offset in 0x0 0x40000 0x80000; do mtd write bl2 $loadaddr $offset 0x40000 ; done
 +recovery_write_ubi=mtd erase ubi && mtd write ubi $loadaddr 0 ${filesize}
@@ -3891,64 +3879,68 @@ Index: u-boot-2024.01/openwrt-one-nor_env
 +usb_recovery=run led_start ; usb start && run usb_recovery_bl2 && run usb_recovery_ubi && run led_loop_done
 +usb_recovery_bl2=fatload usb 0:1 ${loadaddr} ${recoverfile_bl2} && run recovery_write_bl2
 +usb_recovery_ubi=fatload usb 0:1 ${loadaddr} ${recoverfile_ubi} && run recovery_write_ubi
-Index: u-boot-2024.01/openwrt-one-spi-nand_env
-===================================================================
---- /dev/null
-+++ u-boot-2024.01/openwrt-one-spi-nand_env
-@@ -0,0 +1,56 @@
-+_bootargs=root=/dev/fit0
 +_bootmenu_update_title=setenv _bootmenu_update_title ; setenv bootmenu_title "$bootmenu_title       \e[33m$ver\e[0m"
 +_firstboot=setenv _firstboot ; run _switch_to_menu ; run _init_env ; bootmenu
-+_init_env=setenv _init_env ; echo Initialize Env ; run ubi_create_env ; saveenv 
++_init_env=setenv _init_env ; echo Initialize Env ; run ubi_create_env ; saveenv
 +_switch_to_menu=setenv _switch_to_menu ; setenv bootdelay 3 ; setenv bootmenu_delay 3 ; setenv bootmenu_0 $bootmenu_0d ; setenv bootmenu_0d ; run _bootmenu_update_title
-+bl2_mtd_write=mtd erase bl2 && mtd write bl2 $loadaddr
-+bl2_tftp_write=tftpboot $loadaddr $bootfile_bl2 && run bl2_mtd_write
-+bootcmd=run check_buttons ; run led_start ; run production_boot ; run recovery_boot
+--- /dev/null
++++ b/openwrt-one-spi-nand_env
+@@ -0,0 +1,58 @@
++ipaddr=192.168.11.11
++serverip=192.168.11.23
++loadaddr=0x46000000
++console=earlycon=uart8250,mmio32,0x11002000 console=ttyS0
++bootcmd=run check_buttons ; run led_start ; run boot_production ; run boot_recovery
 +bootconf=config-1
 +bootdelay=0
 +bootfile=openwrt-mediatek-filogic-openwrt_one-initramfs.itb
-+bootfile_bl2=openwrt-mediatek-filogic-openwrt_one-spim-nand-preloader.bin
-+bootfile_fip=openwrt-mediatek-filogic-openwrt_one-spim-nand-bl31-uboot.fip
++bootfile_bl2=openwrt-mediatek-filogic-openwrt_one-snand-preloader.bin
++bootfile_fip=openwrt-mediatek-filogic-openwrt_one-snand-bl31-uboot.fip
 +bootfile_upg=openwrt-mediatek-filogic-openwrt_one-squashfs-sysupgrade.itb
-+bootmenu_0=Initialize environment.=run _firstboot
-+bootmenu_0d=Run default boot command.=run bootcmd
-+bootmenu_1=Boot system via TFTP.=run tftp_boot ; run bootmenu_confirm_return
-+bootmenu_2=Boot production system from NAND.=run production_boot ; run bootmenu_confirm_return
-+bootmenu_3=Boot recovery system from NAND.=run recovery_boot ; run bootmenu_confirm_return
-+bootmenu_4=Load production system via TFTP then write to NAND.=run production_tftp_boot ; run bootmenu_confirm_return
-+bootmenu_5=Load recovery system via TFTP then write to NAND.=run recovery_tftp_write ; run bootmenu_confirm_return
-+bootmenu_6=\e[31mLoad BL31+U-Boot FIP via TFTP then write to NAND.\e[0m=run fip_tftp_write ; run bootmenu_confirm_return
-+bootmenu_7=\e[31mLoad bl2 preloader via TFTP then write to NAND.\e[0m=run bl2_tftp_write ; run bootmenu_confirm_return
-+bootmenu_8=Reboot.=reset
-+bootmenu_9=Reset all settings to factory defaults.=run factory_reset ; reset
 +bootmenu_confirm_return=askenv - Press ENTER to return to menu ; run led_boot ; bootmenu 60
 +bootmenu_default=0
 +bootmenu_delay=0
-+bootmenu_title=      \e[0 ;34m( ( ( \e[1 ;39mOpenWrt\e[0 ;34m ) ) )  \e[0 ;36m[SPI-NAND]\e[0m
-+check_buttons=if button front ; then run recovery_boot ; run tftp_boot ; run led_loop_error ; else if button back ; then ; run usb_recover ; run led_loop_error ; fi ; fi
-+console=earlycon=uart8250,mmio32,0x11002000 console=ttyS0
-+factory_reset=ubi part ubi ; mw $loadaddr 0x0 0x800 ; ubi write $loadaddr ubootenv 0x800 && ubi write $loadaddr ubootenv2 0x800
-+fip_mtd_write=ubi check fip && ubi remove fip && ubi create fip $filesize static 2 && ubi write $loadaddr fip $filesize
-+fip_tftp_write=tftpboot $loadaddr $bootfile_fip && run fip_mtd_write && run factory_reset
-+ipaddr=192.168.11.11
++bootmenu_title=      \e[0;34m( ( ( \e[1;39mOpenWrt\e[0;34m ) ) )  \e[0;36m[SPI-NAND]\e[0m
++bootmenu_0=Initialize environment.=run _firstboot
++bootmenu_0d=Run default boot command.=run boot_default
++bootmenu_1=Boot system via TFTP.=run boot_tftp ; run bootmenu_confirm_return
++bootmenu_2=Boot production system from NAND.=run boot_production ; run bootmenu_confirm_return
++bootmenu_3=Boot recovery system from NAND.=run boot_recovery ; run bootmenu_confirm_return
++bootmenu_4=Load production system via TFTP then write to NAND.=noboot=1 ; replacevol=1 ; run boot_tftp_production ; noboot= ; replacevol= ; run bootmenu_confirm_return
++bootmenu_5=Load recovery system via TFTP then write to NAND.=noboot=1 ; replacevol=1 ; run boot_tftp_recovery ; noboot= ; replacevol= ; run bootmenu_confirm_return
++bootmenu_6=\e[31mLoad BL31+U-Boot FIP via TFTP then write to NAND.\e[0m=run boot_tftp_write_fip ; run bootmenu_confirm_return
++bootmenu_7=\e[31mLoad BL2 preloader via TFTP then write to NAND.\e[0m=run boot_tftp_write_bl2 ; run bootmenu_confirm_return
++bootmenu_8=Reboot.=reset
++bootmenu_9=Reset all settings to factory defaults.=run reset_factory ; reset
++boot_default=run bootcmd ; run boot_recovery ; replacevol=1 ; run boot_tftp_forever
++boot_production=led white on ; run ubi_read_production && bootm $loadaddr#$bootconf ; led white off
++boot_recovery=led green on ; run ubi_read_recovery && bootm $loadaddr#$bootconf ; led green off
++boot_tftp=run led_start ; tftpboot $loadaddr $bootfile && bootm $loadaddr#$bootconf
++boot_tftp_forever=led green off ; led white off ; led red on ; while true ; do run boot_tftp_recovery ; led red off ; sleep 1 ; done
++boot_tftp_production=tftpboot $loadaddr $bootfile_upg && test $replacevol = 1 && iminfo $loadaddr && run ubi_write_production ; if test $noboot = 1 ; then else bootm $loadaddr#$bootconf ; fi
++boot_tftp_recovery=tftpboot $loadaddr $bootfile && test $replacevol = 1 && iminfo $loadaddr && run ubi_write_recovery ; if test $noboot = 1 ; then else bootm $loadaddr#$bootconf ; fi
++boot_tftp=tftpboot $loadaddr $bootfile && bootm $loadaddr#$bootconf
++boot_tftp_write_fip=tftpboot $loadaddr $bootfile_fip && run ubi_write_fip && run reset_factory
++boot_tftp_write_bl2=tftpboot $loadaddr $bootfile_bl2 && run snand_write_bl2
++check_buttons=if button front ; then run boot_recovery ; run boot_tftp ; run led_loop_error ; else if button back ; then ; run usb_recover ; run led_loop_error ; fi ; fi
 +led_boot=led green on ; led white on ; led red on
 +led_done=led green on ; led white off ; led red off
 +led_loop_error=led white off ; led green off ; while true ; do led red on ; sleep 1 ; led red off ; sleep 1 ; done
 +led_start=led white on ; led green off ; led red off
-+loadaddr=0x46000000
 +preboot=run led_boot
-+production_boot=led white on ; run ubi_read_production && bootm $loadaddr#$bootconf ; led white off
-+production_tftp_boot=tftpboot $loadaddr $bootfile_upg && iminfo $loadaddr && run production_write_ubi
-+production_write_ubi=ubi check fit && ubi remove fit ; run ubi_remove_rootfs ; ubi create fit $filesize dynamic && ubi write $loadaddr fit $filesize
-+recovery_boot=led green on ; run ubi_read_recovery && bootm $loadaddr#$bootconf ; led green off
-+recovery_tftp_write=tftpboot $loadaddr $bootfile && iminfo $loadaddr && run recovery_ubi_write
-+recovery_ubi_write=ubi check recovery && ubi remove recovery ; ubi create recovery $filesize dynamic && ubi write $loadaddr recovery $filesize
-+serverip=192.168.11.23
-+tftp_boot=run led_start ; tftpboot $loadaddr $bootfile && bootm $loadaddr#$bootconf
-+ubi_create_env=ubi check ubootenv || ubi create ubootenv 0x100000 dynamic 0
++reset_factory=mw $loadaddr 0xff 0x1f000 ; ubi write $loadaddr ubootenv 0x1f000 ; ubi write $loadaddr ubootenv2 0x1f000 ; ubi remove rootfs_data
++snand_write_bl2=mtd erase bl2 && for offset in 0x0 0x40000 0x80000 0xc0000 ; do mtd write bl2 $loadaddr $offset 0x40000 ; done
++ubi_create_env=ubi check ubootenv || ubi create ubootenv 0x1f000 dynamic ; ubi check ubootenv2 || ubi create ubootenv2 0x1f000 dynamic
 +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
 +ubi_read_production=ubi read $loadaddr fit && iminfo $loadaddr && run ubi_prepare_rootfs
 +ubi_read_recovery=ubi check recovery && ubi read $loadaddr recovery
 +ubi_remove_rootfs=ubi check rootfs_data && ubi remove rootfs_data
 +usb_recover=run led_start ; usb start && run usb_recover_production && run led_loop_done
-+usb_recover_production=fatload usb 0:1 ${loadaddr} ${bootfile_upg} && iminfo $loadaddr && run production_write_ubi
++usb_recover_production=fatload usb 0:1 ${loadaddr} ${bootfile_upg} && iminfo $loadaddr && run ubi_write_production
++ubi_write_fip=run ubi_remove_rootfs ; ubi check fip && ubi remove fip ; ubi create fip $filesize static && ubi write $loadaddr fip $filesize
++ubi_write_production=ubi check fit && ubi remove fit ; run ubi_remove_rootfs ; ubi create fit $filesize dynamic && ubi write $loadaddr fit $filesize
++ubi_write_recovery=ubi check recovery && ubi remove recovery ; run ubi_remove_rootfs ; ubi create recovery $filesize dynamic && ubi write $loadaddr recovery $filesize
++_init_env=setenv _init_env ; run ubi_create_env ; saveenv ; saveenv
++_firstboot=setenv _firstboot ; run _switch_to_menu ; run _init_env ; bootmenu
++_switch_to_menu=setenv _switch_to_menu ; setenv bootdelay 3 ; setenv bootmenu_delay 3 ; setenv bootmenu_0 $bootmenu_0d ; setenv bootmenu_0d ; run _bootmenu_update_title
++_bootmenu_update_title=setenv _bootmenu_update_title ; setenv bootmenu_title "$bootmenu_title       \e[33m$ver\e[0m"