platform.sh 4.9 KB

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