platform.sh 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. PART_NAME=firmware
  2. REQUIRE_IMAGE_METADATA=1
  3. RAMFS_COPY_BIN='fw_printenv fw_setenv'
  4. RAMFS_COPY_DATA='/etc/fw_env.config /var/lock/fw_printenv.lock'
  5. platform_check_image() {
  6. case "$(board_name)" in
  7. asus,rt-ac42u |\
  8. asus,rt-ac58u)
  9. local ubidev=$(nand_find_ubi $CI_UBIPART)
  10. local asus_root=$(nand_find_volume $ubidev jffs2)
  11. [ -n "$asus_root" ] || return 0
  12. cat << EOF
  13. jffs2 partition is still present.
  14. There's probably no space left
  15. to install the filesystem.
  16. You need to delete the jffs2 partition first:
  17. # ubirmvol /dev/ubi0 --name=jffs2
  18. Once this is done. Retry.
  19. EOF
  20. return 1
  21. ;;
  22. zte,mf286d)
  23. CI_UBIPART="rootfs"
  24. local mtdnum="$( find_mtd_index $CI_UBIPART )"
  25. [ ! "$mtdnum" ] && return 1
  26. ubiattach -m "$mtdnum" || true
  27. local ubidev="$( nand_find_ubi $CI_UBIPART )"
  28. local ubi_rootfs=$(nand_find_volume $ubidev ubi_rootfs)
  29. local ubi_rootfs_data=$(nand_find_volume $ubidev ubi_rootfs_data)
  30. [ -n "$ubi_rootfs" ] || [ -n "$ubi_rootfs_data" ] || return 0
  31. cat << EOF
  32. ubi_rootfs partition is still present.
  33. You need to delete the stock partition first:
  34. # ubirmvol /dev/ubi0 -N ubi_rootfs
  35. Please also delete ubi_rootfs_data, if exist:
  36. # ubirmvol /dev/ubi0 -N ubi_rootfs_data
  37. Once this is done. Retry.
  38. EOF
  39. return 1
  40. ;;
  41. esac
  42. return 0;
  43. }
  44. askey_do_upgrade() {
  45. local tar_file="$1"
  46. local board_dir=$(tar tf $tar_file | grep -m 1 '^sysupgrade-.*/$')
  47. board_dir=${board_dir%/}
  48. tar Oxf $tar_file ${board_dir}/root | mtd write - rootfs
  49. nand_do_upgrade "$1"
  50. }
  51. zyxel_do_upgrade() {
  52. local tar_file="$1"
  53. local board_dir=$(tar tf $tar_file | grep -m 1 '^sysupgrade-.*/$')
  54. board_dir=${board_dir%/}
  55. tar Oxf $tar_file ${board_dir}/kernel | mtd write - kernel
  56. if [ -n "$UPGRADE_BACKUP" ]; then
  57. tar Oxf $tar_file ${board_dir}/root | mtd -j "$UPGRADE_BACKUP" write - rootfs
  58. else
  59. tar Oxf $tar_file ${board_dir}/root | mtd write - rootfs
  60. fi
  61. }
  62. platform_do_upgrade_mikrotik_nand() {
  63. local fw_mtd=$(find_mtd_part kernel)
  64. fw_mtd="${fw_mtd/block/}"
  65. [ -n "$fw_mtd" ] || return
  66. local board_dir=$(tar tf "$1" | grep -m 1 '^sysupgrade-.*/$')
  67. board_dir=${board_dir%/}
  68. [ -n "$board_dir" ] || return
  69. local kernel_len=$(tar xf "$1" ${board_dir}/kernel -O | wc -c)
  70. [ -n "$kernel_len" ] || return
  71. tar xf "$1" ${board_dir}/kernel -O | ubiformat "$fw_mtd" -y -S $kernel_len -f -
  72. CI_KERNPART="none"
  73. nand_do_upgrade "$1"
  74. }
  75. platform_do_upgrade() {
  76. case "$(board_name)" in
  77. 8dev,jalapeno |\
  78. aruba,ap-303 |\
  79. aruba,ap-303h |\
  80. aruba,ap-365 |\
  81. avm,fritzbox-7530 |\
  82. avm,fritzrepeater-1200 |\
  83. avm,fritzrepeater-3000 |\
  84. buffalo,wtr-m2133hp |\
  85. cilab,meshpoint-one |\
  86. edgecore,ecw5211 |\
  87. edgecore,oap100 |\
  88. engenius,eap2200 |\
  89. glinet,gl-ap1300 |\
  90. luma,wrtq-329acn |\
  91. mobipromo,cm520-79f |\
  92. netgear,wac510 |\
  93. p2w,r619ac-64m |\
  94. p2w,r619ac-128m |\
  95. qxwlan,e2600ac-c2)
  96. nand_do_upgrade "$1"
  97. ;;
  98. glinet,gl-b2200)
  99. CI_KERNPART="0:HLOS"
  100. CI_ROOTPART="rootfs"
  101. CI_DATAPART="rootfs_data"
  102. emmc_do_upgrade "$1"
  103. ;;
  104. alfa-network,ap120c-ac)
  105. part="$(awk -F 'ubi.mtd=' '{printf $2}' /proc/cmdline | sed -e 's/ .*$//')"
  106. if [ "$part" = "rootfs1" ]; then
  107. fw_setenv active 2 || exit 1
  108. CI_UBIPART="rootfs2"
  109. else
  110. fw_setenv active 1 || exit 1
  111. CI_UBIPART="rootfs1"
  112. fi
  113. nand_do_upgrade "$1"
  114. ;;
  115. asus,map-ac2200)
  116. CI_KERNPART="linux"
  117. nand_do_upgrade "$1"
  118. ;;
  119. asus,rt-ac42u |\
  120. asus,rt-ac58u)
  121. CI_KERNPART="linux"
  122. nand_do_upgrade "$1"
  123. ;;
  124. cellc,rtl30vw)
  125. CI_UBIPART="ubifs"
  126. askey_do_upgrade "$1"
  127. ;;
  128. compex,wpj419)
  129. nand_do_upgrade "$1"
  130. ;;
  131. linksys,ea6350v3 |\
  132. linksys,ea8300 |\
  133. linksys,mr8300)
  134. platform_do_upgrade_linksys "$1"
  135. ;;
  136. meraki,mr33)
  137. CI_KERNPART="part.safe"
  138. nand_do_upgrade "$1"
  139. ;;
  140. mikrotik,cap-ac|\
  141. mikrotik,hap-ac2|\
  142. mikrotik,lhgg-60ad|\
  143. mikrotik,sxtsq-5-ac)
  144. [ "$(rootfs_type)" = "tmpfs" ] && mtd erase firmware
  145. default_do_upgrade "$1"
  146. ;;
  147. mikrotik,hap-ac3)
  148. platform_do_upgrade_mikrotik_nand "$1"
  149. ;;
  150. netgear,rbr50 |\
  151. netgear,rbs50 |\
  152. netgear,srr60 |\
  153. netgear,srs60)
  154. platform_do_upgrade_netgear_orbi_upgrade "$1"
  155. ;;
  156. openmesh,a42 |\
  157. openmesh,a62 |\
  158. plasmacloud,pa1200 |\
  159. plasmacloud,pa2200)
  160. PART_NAME="inactive"
  161. platform_do_upgrade_dualboot_datachk "$1"
  162. ;;
  163. teltonika,rutx10 |\
  164. zte,mf286d)
  165. CI_UBIPART="rootfs"
  166. nand_do_upgrade "$1"
  167. ;;
  168. zyxel,nbg6617)
  169. zyxel_do_upgrade "$1"
  170. ;;
  171. *)
  172. default_do_upgrade "$1"
  173. ;;
  174. esac
  175. }
  176. platform_copy_config() {
  177. case "$(board_name)" in
  178. glinet,gl-b2200)
  179. emmc_copy_config
  180. ;;
  181. esac
  182. return 0;
  183. }