platform.sh 4.7 KB

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