platform.sh 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. #
  2. # Copyright (C) 2010 OpenWrt.org
  3. #
  4. . /lib/ramips.sh
  5. PART_NAME=firmware
  6. RAMFS_COPY_DATA=/lib/ramips.sh
  7. platform_check_image() {
  8. local board=$(ramips_board_name)
  9. local magic="$(get_magic_long "$1")"
  10. [ "$#" -gt 1 ] && return 1
  11. case "$board" in
  12. 3g150b|\
  13. 3g300m|\
  14. 3g-6200n|\
  15. 3g-6200nl|\
  16. a5-v11|\
  17. ai-br100|\
  18. air3gii|\
  19. all0239-3g|\
  20. all0256n|\
  21. all5002|\
  22. all5003|\
  23. ar725w|\
  24. asl26555|\
  25. awapn2403|\
  26. awm002-evb|\
  27. awm003-evb|\
  28. bc2|\
  29. broadway|\
  30. carambola|\
  31. cf-wr800n|\
  32. cs-qr10|\
  33. d105|\
  34. dap-1350|\
  35. db-wrt01|\
  36. dcs-930|\
  37. dcs-930l-b1|\
  38. dir-300-b1|\
  39. dir-300-b7|\
  40. dir-320-b1|\
  41. dir-600-b1|\
  42. dir-600-b2|\
  43. dir-615-d|\
  44. dir-615-h1|\
  45. dir-620-a1|\
  46. dir-620-d1|\
  47. dir-810l|\
  48. duzun-dm06|\
  49. e1700|\
  50. esr-9753|\
  51. ex2700|\
  52. f7c027|\
  53. firewrt|\
  54. fonera20n|\
  55. freestation5|\
  56. gl-mt300a|\
  57. gl-mt300n|\
  58. gl-mt750|\
  59. hc5*61|\
  60. hg255d|\
  61. hlk-rm04|\
  62. hpm|\
  63. ht-tm02|\
  64. hw550-3g|\
  65. ip2202|\
  66. jhr-n805r|\
  67. jhr-n825r|\
  68. jhr-n926r|\
  69. linkits7688|\
  70. linkits7688d|\
  71. m2m|\
  72. m3|\
  73. m4|\
  74. microwrt|\
  75. miniembplug|\
  76. miniembwifi|\
  77. miwifi-mini|\
  78. miwifi-nano|\
  79. mlw221|\
  80. mlwg2|\
  81. mofi3500-3gn|\
  82. mpr-a1|\
  83. mpr-a2|\
  84. mr-102n|\
  85. mt7628|\
  86. mzk-750dhp|\
  87. mzk-dp150n|\
  88. mzk-ex300np|\
  89. mzk-ex750np|\
  90. mzk-w300nh2|\
  91. mzk-wdpr|\
  92. nbg-419n|\
  93. nw718|\
  94. oy-0001|\
  95. pbr-m1|\
  96. psg1208|\
  97. psg1218|\
  98. psr-680w|\
  99. px-4885|\
  100. re6500|\
  101. rp-n53|\
  102. rt5350f-olinuxino|\
  103. rt5350f-olinuxino-evb|\
  104. rt-g32-b1|\
  105. rt-n10-plus|\
  106. rt-n13u|\
  107. rt-n14u|\
  108. rt-n15|\
  109. rt-n56u|\
  110. rut5xx|\
  111. sap-g3200u3|\
  112. sk-wb8|\
  113. sl-r7205|\
  114. tew-691gr|\
  115. tew-692gr|\
  116. tiny-ac|\
  117. ur-326n4g|\
  118. ur-336un|\
  119. v22rw-2x2|\
  120. vocore|\
  121. w150m|\
  122. w306r-v20|\
  123. w502u|\
  124. wf-2881|\
  125. whr-1166d|\
  126. whr-300hp2|\
  127. whr-600d|\
  128. whr-g300n|\
  129. widora-neo|\
  130. witi|\
  131. wizfi630a|\
  132. wl-330n|\
  133. wl-330n3g|\
  134. wl-341v3|\
  135. wl-351|\
  136. wli-tx4-ag300n|\
  137. wmr-300|\
  138. wnce2001|\
  139. wndr3700v5|\
  140. wr512-3gn|\
  141. wr6202|\
  142. wrh-300cr|\
  143. wrtnode|\
  144. wrtnode2r |\
  145. wrtnode2p |\
  146. wsr-600|\
  147. wt1520|\
  148. wt3020|\
  149. wzr-agl300nh|\
  150. x5|\
  151. x8|\
  152. y1|\
  153. y1s|\
  154. zbt-ape522ii|\
  155. zbt-wa05|\
  156. zbt-we826|\
  157. zbt-wg2626|\
  158. zbt-wg3526|\
  159. zbt-wr8305rt|\
  160. zte-q7|\
  161. youku-yk1)
  162. [ "$magic" != "27051956" ] && {
  163. echo "Invalid image type."
  164. return 1
  165. }
  166. return 0
  167. ;;
  168. ar670w)
  169. [ "$magic" != "6d000080" ] && {
  170. echo "Invalid image type."
  171. return 1
  172. }
  173. return 0
  174. ;;
  175. br-6475nd)
  176. [ "$magic" != "43535953" ] && {
  177. echo "Invalid image type."
  178. return 1
  179. }
  180. return 0
  181. ;;
  182. c20i|\
  183. c50)
  184. [ "$magic" != "03000000" ] && {
  185. echo "Invalid image type."
  186. return 1
  187. }
  188. return 0
  189. ;;
  190. cy-swr1100|\
  191. dir-610-a1|\
  192. dir-645|\
  193. dir-860l-b1)
  194. [ "$magic" != "5ea3a417" ] && {
  195. echo "Invalid image type."
  196. return 1
  197. }
  198. return 0
  199. ;;
  200. wsr-1166)
  201. [ "$magic" != "48445230" ] && {
  202. echo "Invalid image type."
  203. return 1
  204. }
  205. return 0
  206. ;;
  207. ubnt-erx)
  208. nand_do_platform_check "$board" "$1"
  209. return $?;
  210. ;;
  211. esac
  212. echo "Sysupgrade is not yet supported on $board."
  213. return 1
  214. }
  215. platform_nand_pre_upgrade() {
  216. local board=$(ramips_board_name)
  217. case "$board" in
  218. ubnt-erx)
  219. platform_upgrade_ubnt_erx "$ARGV"
  220. ;;
  221. esac
  222. }
  223. platform_pre_upgrade() {
  224. local board=$(ramips_board_name)
  225. case "$board" in
  226. ubnt-erx)
  227. nand_do_upgrade "$ARGV"
  228. ;;
  229. esac
  230. }
  231. platform_do_upgrade() {
  232. local board=$(ramips_board_name)
  233. case "$board" in
  234. *)
  235. default_do_upgrade "$ARGV"
  236. ;;
  237. esac
  238. }
  239. disable_watchdog() {
  240. killall watchdog
  241. ( ps | grep -v 'grep' | grep '/dev/watchdog' ) && {
  242. echo 'Could not disable watchdog'
  243. return 1
  244. }
  245. }
  246. blink_led() {
  247. . /etc/diag.sh; set_state upgrade
  248. }
  249. append sysupgrade_pre_upgrade disable_watchdog
  250. append sysupgrade_pre_upgrade blink_led