platform.sh 3.7 KB

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