platform.sh 4.8 KB

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