platform.sh 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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,lbr20 |\
  100. netgear,wac510 |\
  101. p2w,r619ac-64m |\
  102. p2w,r619ac-128m |\
  103. qxwlan,e2600ac-c2 |\
  104. wallys,dr40x9)
  105. nand_do_upgrade "$1"
  106. ;;
  107. glinet,gl-b2200)
  108. CI_KERNPART="0:HLOS"
  109. CI_ROOTPART="rootfs"
  110. CI_DATAPART="rootfs_data"
  111. emmc_do_upgrade "$1"
  112. ;;
  113. alfa-network,ap120c-ac)
  114. part="$(awk -F 'ubi.mtd=' '{printf $2}' /proc/cmdline | sed -e 's/ .*$//')"
  115. if [ "$part" = "rootfs1" ]; then
  116. fw_setenv active 2 || exit 1
  117. CI_UBIPART="rootfs2"
  118. else
  119. fw_setenv active 1 || exit 1
  120. CI_UBIPART="rootfs1"
  121. fi
  122. nand_do_upgrade "$1"
  123. ;;
  124. asus,map-ac2200)
  125. CI_KERNPART="linux"
  126. nand_do_upgrade "$1"
  127. ;;
  128. asus,rt-ac42u |\
  129. asus,rt-ac58u)
  130. CI_KERNPART="linux"
  131. nand_do_upgrade "$1"
  132. ;;
  133. cellc,rtl30vw)
  134. CI_UBIPART="ubifs"
  135. askey_do_upgrade "$1"
  136. ;;
  137. compex,wpj419)
  138. nand_do_upgrade "$1"
  139. ;;
  140. google,wifi)
  141. export_bootdevice
  142. export_partdevice CI_ROOTDEV 0
  143. CI_KERNPART="kernel"
  144. CI_ROOTPART="rootfs"
  145. emmc_do_upgrade "$1"
  146. ;;
  147. linksys,ea6350v3 |\
  148. linksys,ea8300 |\
  149. linksys,mr8300 |\
  150. linksys,whw01 |\
  151. linksys,whw03v2)
  152. platform_do_upgrade_linksys "$1"
  153. ;;
  154. meraki,mr33 |\
  155. meraki,mr74)
  156. CI_KERNPART="part.safe"
  157. nand_do_upgrade "$1"
  158. ;;
  159. mikrotik,cap-ac|\
  160. mikrotik,hap-ac2|\
  161. mikrotik,hap-ac3-lte6-kit|\
  162. mikrotik,lhgg-60ad|\
  163. mikrotik,sxtsq-5-ac|\
  164. mikrotik,wap-ac|\
  165. mikrotik,wap-ac-lte|\
  166. mikrotik,wap-r-ac)
  167. [ "$(rootfs_type)" = "tmpfs" ] && mtd erase firmware
  168. default_do_upgrade "$1"
  169. ;;
  170. mikrotik,hap-ac3)
  171. platform_do_upgrade_mikrotik_nand "$1"
  172. ;;
  173. netgear,rbr40|\
  174. netgear,rbs40|\
  175. netgear,rbr50 |\
  176. netgear,rbs50 |\
  177. netgear,srr60 |\
  178. netgear,srs60)
  179. platform_do_upgrade_netgear_orbi_upgrade "$1"
  180. ;;
  181. openmesh,a42 |\
  182. openmesh,a62 |\
  183. plasmacloud,pa1200 |\
  184. plasmacloud,pa2200)
  185. PART_NAME="inactive"
  186. platform_do_upgrade_dualboot_datachk "$1"
  187. ;;
  188. sony,ncp-hg100-cellular)
  189. sony_emmc_do_upgrade "$1"
  190. ;;
  191. teltonika,rutx10 |\
  192. teltonika,rutx50 |\
  193. zte,mf18a |\
  194. zte,mf282plus |\
  195. zte,mf286d |\
  196. zte,mf287 |\
  197. zte,mf287plus |\
  198. zte,mf287pro |\
  199. zte,mf289f)
  200. CI_UBIPART="rootfs"
  201. nand_do_upgrade "$1"
  202. ;;
  203. zyxel,nbg6617)
  204. zyxel_do_upgrade "$1"
  205. ;;
  206. *)
  207. default_do_upgrade "$1"
  208. ;;
  209. esac
  210. }
  211. platform_copy_config() {
  212. case "$(board_name)" in
  213. glinet,gl-b2200 |\
  214. google,wifi)
  215. emmc_copy_config
  216. ;;
  217. esac
  218. return 0;
  219. }