2
0

platform.sh 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. PART_NAME=firmware
  2. REQUIRE_IMAGE_METADATA=1
  3. RAMFS_COPY_BIN='dumpimage fw_printenv fw_setenv head seq'
  4. RAMFS_COPY_DATA='/etc/fw_env.config /var/lock/fw_printenv.lock'
  5. xiaomi_initramfs_prepare() {
  6. # Wipe UBI if running initramfs
  7. [ "$(rootfs_type)" = "tmpfs" ] || return 0
  8. local rootfs_mtdnum="$( find_mtd_index rootfs )"
  9. if [ ! "$rootfs_mtdnum" ]; then
  10. echo "unable to find mtd partition rootfs"
  11. return 1
  12. fi
  13. local kern_mtdnum="$( find_mtd_index ubi_kernel )"
  14. if [ ! "$kern_mtdnum" ]; then
  15. echo "unable to find mtd partition ubi_kernel"
  16. return 1
  17. fi
  18. ubidetach -m "$rootfs_mtdnum"
  19. ubiformat /dev/mtd$rootfs_mtdnum -y
  20. ubidetach -m "$kern_mtdnum"
  21. ubiformat /dev/mtd$kern_mtdnum -y
  22. }
  23. remove_oem_ubi_volume() {
  24. local oem_volume_name="$1"
  25. local oem_ubivol
  26. local mtdnum
  27. local ubidev
  28. mtdnum=$(find_mtd_index "$CI_UBIPART")
  29. if [ ! "$mtdnum" ]; then
  30. return
  31. fi
  32. ubidev=$(nand_find_ubi "$CI_UBIPART")
  33. if [ ! "$ubidev" ]; then
  34. ubiattach --mtdn="$mtdnum"
  35. ubidev=$(nand_find_ubi "$CI_UBIPART")
  36. fi
  37. if [ "$ubidev" ]; then
  38. oem_ubivol=$(nand_find_volume "$ubidev" "$oem_volume_name")
  39. [ "$oem_ubivol" ] && ubirmvol "/dev/$ubidev" --name="$oem_volume_name"
  40. fi
  41. }
  42. linksys_mx_pre_upgrade() {
  43. local setenv_script="/tmp/fw_env_upgrade"
  44. CI_UBIPART="rootfs"
  45. boot_part="$(fw_printenv -n boot_part)"
  46. if [ -n "$UPGRADE_OPT_USE_CURR_PART" ]; then
  47. if [ "$boot_part" -eq "2" ]; then
  48. CI_KERNPART="alt_kernel"
  49. CI_UBIPART="alt_rootfs"
  50. fi
  51. else
  52. if [ "$boot_part" -eq "1" ]; then
  53. echo "boot_part 2" >> $setenv_script
  54. CI_KERNPART="alt_kernel"
  55. CI_UBIPART="alt_rootfs"
  56. else
  57. echo "boot_part 1" >> $setenv_script
  58. fi
  59. fi
  60. boot_part_ready="$(fw_printenv -n boot_part_ready)"
  61. if [ "$boot_part_ready" -ne "3" ]; then
  62. echo "boot_part_ready 3" >> $setenv_script
  63. fi
  64. auto_recovery="$(fw_printenv -n auto_recovery)"
  65. if [ "$auto_recovery" != "yes" ]; then
  66. echo "auto_recovery yes" >> $setenv_script
  67. fi
  68. if [ -f "$setenv_script" ]; then
  69. fw_setenv -s $setenv_script || {
  70. echo "failed to update U-Boot environment"
  71. return 1
  72. }
  73. fi
  74. }
  75. platform_check_image() {
  76. return 0;
  77. }
  78. platform_pre_upgrade() {
  79. case "$(board_name)" in
  80. xiaomi,ax6000)
  81. xiaomi_initramfs_prepare
  82. ;;
  83. esac
  84. }
  85. platform_do_upgrade() {
  86. case "$(board_name)" in
  87. elecom,wrc-x3000gs2|\
  88. iodata,wn-dax3000gr)
  89. local delay
  90. delay=$(fw_printenv bootdelay)
  91. [ -z "$delay" ] || [ "$delay" -eq "0" ] && \
  92. fw_setenv bootdelay 3
  93. elecom_upgrade_prepare
  94. remove_oem_ubi_volume bt_fw
  95. remove_oem_ubi_volume ubi_rootfs
  96. remove_oem_ubi_volume wifi_fw
  97. nand_do_upgrade "$1"
  98. ;;
  99. glinet,gl-b3000)
  100. glinet_do_upgrade "$1"
  101. ;;
  102. linksys,mr5500|\
  103. linksys,mx2000|\
  104. linksys,mx5500|\
  105. linksys,spnmx56)
  106. linksys_mx_pre_upgrade "$1"
  107. remove_oem_ubi_volume squashfs
  108. nand_do_upgrade "$1"
  109. ;;
  110. xiaomi,ax6000)
  111. # Make sure that UART is enabled
  112. fw_setenv boot_wait on
  113. fw_setenv uart_en 1
  114. # Enforce single partition.
  115. fw_setenv flag_boot_rootfs 0
  116. fw_setenv flag_last_success 0
  117. fw_setenv flag_boot_success 1
  118. fw_setenv flag_try_sys1_failed 8
  119. fw_setenv flag_try_sys2_failed 8
  120. # Kernel and rootfs are placed in 2 different UBI
  121. CI_KERN_UBIPART="ubi_kernel"
  122. CI_ROOT_UBIPART="rootfs"
  123. nand_do_upgrade "$1"
  124. ;;
  125. yuncore,ax830)
  126. CI_UBIPART="rootfs"
  127. remove_oem_ubi_volume ubi_rootfs
  128. remove_oem_ubi_volume bt_fw
  129. remove_oem_ubi_volume wifi_fw
  130. nand_do_upgrade "$1"
  131. ;;
  132. *)
  133. default_do_upgrade "$1"
  134. ;;
  135. esac
  136. }