Skip to content

Instantly share code, notes, and snippets.

@clayface
Last active March 12, 2024 09:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clayface/cc2ef80b845f826d29889fa546195d16 to your computer and use it in GitHub Desktop.
Save clayface/cc2ef80b845f826d29889fa546195d16 to your computer and use it in GitHub Desktop.
dl-wrx36 u-bootenv
#!/bin/sh
fw_setenv active 'recovery'
fw_setenv baudrate '115200'
fw_setenv bootargs 'console=ttyMSM0,115200n8 ubi.mtd=rootfs root=mtd:ubi_rootfs rootfstype=squashfs'
fw_setenv bootcmd 'run bootcounter && run setup && run bootlinux'
fw_setenv bootcount '0'
fw_setenv bootcounter 'if test $bootcount = 0; then setenv bootcount 1 && saveenv;' \
'elif test $bootcount = 1; then setenv bootcount 2 && saveenv;' \
'elif test $bootcount = 2; then setenv bootcount 3 && saveenv;' \
'elif test $bootcount = 3; then run chpart && setenv bootcount 4 && saveenv;' \
'elif test $bootcount = 4; then setenv bootcount 5 && saveenv;' \
'elif test $bootcount = 5; then setenv bootcount 6 && saveenv;' \
'elif test $bootcount = 6; then setenv active recovery && setenv bootcount 0 &&' \
'saveenv && reset; fi'
fw_setenv bootdelay '2'
fw_setenv bootlinux 'ubi read 0x44000000 kernel 0x80000000 &&' \
'bootm 0x44000000#config@rt5010w-d350-rev0'
fw_setenv chpart 'if test $active = 0; then setenv active 1; ' \
'elif test $active = 1; then setenv active 0; fi'
fw_setenv factoryimg 'openwrt-ipq807x-generic-dynalink_dl-wrx36-squashfs-nand-factory.ubi'
fw_setenv mtdids 'nand0=nand0'
fw_setenv mtdparts 'mtdparts=nand0:0x6100000@0x1000000(fs),0x6100000@0x7a00000(fs_1),'
fw_setenv setup 'if test $active = 0; then ubi part fs;' \
'elif test $active = 1; then ubi part fs_1;' \
'else run tftprecover; fi'
fw_setenv stderr 'serial@78B3000'
fw_setenv stdin 'serial@78B3000'
fw_setenv stdout 'serial@78B3000'
fw_setenv tftprecover 'sleep 5; setenv serverip 192.168.1.10 &&' \
'setenv ipaddr 192.168.1.250; tftpboot 0x44000000 ${factoryimg} && nand device 0 &&' \
'nand erase 0x1000000 0x6100000 && nand write $fileaddr 0x1000000 $filesize &&' \
'nand erase 0x7a00000 0x6100000 && nand write $fileaddr 0x7a00000 $filesize &&' \
'setenv active 0 && saveenv && reset'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment