Guest User

Untitled

a guest
Mar 13th, 2021
32
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'Vi▒L▒`.j
  2. -\▒Y▒
  3. %
  4. ###########################################
  5.  
  6. part start mmc ${devnum} 9 mmc_env
  7. mmc dev ${devnum}
  8. setenv loadbootstate " \
  9. echo 'loading env...'; \
  10. mmc read ${ramdisk_addr_r} ${mmc_env} 0x10; \
  11. env import -c ${ramdisk_addr_r} 0x2000;"
  12.  
  13. setenv storebootstate " \
  14. echo 'storing env...'; \
  15. env export -c -s 0x2000 ${ramdisk_addr_r} BOOT_ORDER BOOT_A_LEFT BOOT_B_LEFT MACHINE_ID; \
  16. mmc write ${ramdisk_addr_r} ${mmc_env} 0x10;"
  17.  
  18. run loadbootstate
  19. test -n "${BOOT_ORDER}" || setenv BOOT_ORDER "A B"
  20. test -n "${BOOT_A_LEFT}" || setenv BOOT_A_LEFT 3
  21. test -n "${BOOT_B_LEFT}" || setenv BOOT_B_LEFT 3
  22.  
  23. # HassOS bootargs
  24. setenv bootargs_hassos "zram.enabled=1 zram.num_devices=3 apparmor=1 security=apparmor systemd.machine_id=${MACHINE_ID} cgroup_enable=memory fsck.repair=yes"
  25.  
  26. # HassOS system A/B
  27. setenv bootargs_a "root=PARTUUID=48617373-06 rootfstype=squashfs ro rootwait"
  28. setenv bootargs_b "root=PARTUUID=48617373-08 rootfstype=squashfs ro rootwait"
  29.  
  30. # Load extraargs
  31. fileenv mmc ${devnum}:1 ${ramdisk_addr_r} cmdline.txt cmdline
  32. if test "${board_rev}" = "c"; then
  33. fatload mmc ${devnum}:1 ${fdt_addr_r} meson-g12b-odroid-n2-plus.dtb
  34. else
  35. fatload mmc ${devnum}:1 ${fdt_addr_r} meson-g12b-odroid-n2.dtb
  36. fi
  37.  
  38. # logical volumes get numbered after physical ones.
  39. # 1. boot
  40. # 2. Extended partition
  41. # 3. Overlay
  42. # 4. Data
  43. # 5. KernelA
  44. # 6. SystemA
  45. # 7. KernelB
  46. # 8. SystemB
  47. # 9. BootInfo
  48. setenv bootargs
  49. for BOOT_SLOT in "${BOOT_ORDER}"; do
  50. if test "x${bootargs}" != "x"; then
  51. # skip remaining slots
  52. elif test "x${BOOT_SLOT}" = "xA"; then
  53. if test ${BOOT_A_LEFT} -gt 0; then
  54. setexpr BOOT_A_LEFT ${BOOT_A_LEFT} - 1
  55. PuTTYPuTTY echo "Trying to boot slot A, ${BOOT_A_LEFT} attempts remaining. Loading kernel ..."
  56. if ext4load mmc ${devnum}:5 ${kernel_addr_r} Image; then
  57. setenv bootargs "${bootargs_hassos} ${bootargs_a} rauc.slot=A ${cmdline}"
  58. fi
  59. fi
  60. elif test "x${BOOT_SLOT}" = "xB"; then
  61. if test ${BOOT_B_LEFT} -gt 0; then
  62. setexpr BOOT_B_LEFT ${BOOT_B_LEFT} - 1
  63. echo "Trying to boot slot B, ${BOOT_B_LEFT} attempts remaining. Loading kernel ..."
  64. if ext4load mmc ${devnum}:7 ${kernel_addr_r} Image; then
  65. setenv bootargs "${bootargs_hassos} ${bootargs_b} rauc.slot=B ${cmdline}"
  66. fi
  67. fi
  68. fi
  69. done
  70.  
  71. if test -n "${bootargs}"; then
  72. run storebootstate
  73. else
  74. echo "No valid slot found, resetting tries to 3"
  75. setenv BOOT_A_LEFT 3
  76. setenv BOOT_B_LEFT 3
  77. run storebootstate
  78. reset
  79. fi
  80.  
  81. printenv bootargs
  82. echo "Starting kernel"
  83. booti ${kernel_addr_r} - ${fdt_addr_r}
  84.  
  85. echo "Boot failed, resetting..."
  86. reset
  87.  
RAW Paste Data