platform.sh 3.8 KB

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