Current section
Files
Jump to
Current section
Files
prebuilt/uboot-env-template.txt
# OpenWrt 24.10 mt7981 OpenWRT One U-Boot default environment.
# Captured 2026-04-08 from a running device after letting U-Boot
# write its compiled-in defaults via saveenv. Used as a base for
# the U-Boot env we bake into the ubootenv UBI volumes so the env
# matches what U-Boot expects (CONFIG_ENV_SIZE=0x1F000) and the
# CRC check passes for U-Boot, boardid, and the Erlang uboot_env
# library all reading from the same volume.
#
# Per-device variables (ethaddr, ipaddr, serverip) are deliberately
# omitted -- those should come from factory data or DHCP, not from
# a baked image.
#
# nerves_fw_* keys are appended at build time by wrap-firmware.sh
# (per-app values from meta.conf) and post-createfs.sh (placeholder
# nerves_fw_active=a only).
boot_calibration=ubi read $loadaddr calibration && bootm $loadaddr#$bootconf
boot_default=run bootcmd ; run boot_recovery ; replacevol=1 ; run boot_tftp_forever
boot_production=led white on ; run boot_active_slot ; echo "[nerves] active slot ${nerves_fw_active} unbootable, trying other slot" ; run nerves_swap_active ; run boot_active_slot ; led white off
boot_active_slot=run nerves_pre_boot ; run ubi_read_production && bootm $loadaddr#$bootconf
nerves_swap_active=if test "${nerves_fw_active}" = "a" ; then setenv nerves_fw_active b ; else setenv nerves_fw_active a ; fi ; saveenv
nerves_pre_boot=if env exists upgrade_available && test "${upgrade_available}" = "1" ; then run nerves_count_attempt ; fi
nerves_count_attempt=if env exists bootcount ; then setexpr bootcount ${bootcount} + 1 ; else setenv bootcount 1 ; fi ; if test ${bootcount} -gt ${bootlimit} ; then echo "[nerves] boot attempts exceeded, rolling back to other slot" ; run nerves_swap_active ; setenv bootcount 0 ; setenv upgrade_available 0 ; fi ; saveenv
bootlimit=3
boot_recovery=led green on ; run ubi_read_recovery && bootm $loadaddr#$bootconf ; led green off
boot_tftp=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_write_bl2=tftpboot $loadaddr $bootfile_bl2 && run snand_write_bl2
boot_tftp_write_fip=tftpboot $loadaddr $bootfile_fip && run ubi_write_fip && run reset_factory
bootcmd=run check_buttons ; run led_start ; run boot_calibration ; run boot_production ; run boot_recovery
bootconf=config-1
bootdelay=3
bootfile=openwrt-mediatek-filogic-openwrt_one-initramfs.itb
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=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=[31mLoad BL31+U-Boot FIP via TFTP then write to NAND.[0m=run boot_tftp_write_fip ; run bootmenu_confirm_return
bootmenu_7=[31mLoad BL2 preloader via TFTP then write to NAND.[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
bootmenu_confirm_return=askenv - Press ENTER to return to menu ; run led_boot ; bootmenu 60
bootmenu_default=0
bootmenu_delay=3
bootmenu_title= [0;34m( ( ( [1;39mOpenWrt[0;34m ) ) ) [0;36m[SPI-NAND][0m [33mU-Boot 2024.10-OpenWrt-r28427-6df0e3d02a (Feb 03 2025 - 23:09:37 +0000)[0m
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
console=earlycon=uart8250,mmio32,0x11002000 console=ttyS0
led_boot=led green on ; led white on ; led red on
led_done=led green on ; led white off ; led red off
led_loop_done=led white off ; led green on ; echo done ; while true ; do sleep 1 ; done
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
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_${nerves_fw_active} && 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
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
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 ubi_write_production