platform.sh 5.0 KB

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