platform.sh 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  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. 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. omega2|\
  102. omega2p|\
  103. oy-0001|\
  104. pbr-d1|\
  105. pbr-m1|\
  106. psg1208|\
  107. psg1218|\
  108. psr-680w|\
  109. px-4885|\
  110. rb750gr3|\
  111. re6500|\
  112. rp-n53|\
  113. rt5350f-olinuxino|\
  114. rt5350f-olinuxino-evb|\
  115. rt-g32-b1|\
  116. rt-n10-plus|\
  117. rt-n13u|\
  118. rt-n14u|\
  119. rt-n15|\
  120. rt-n56u|\
  121. rut5xx|\
  122. sap-g3200u3|\
  123. sk-wb8|\
  124. sl-r7205|\
  125. tew-691gr|\
  126. tew-692gr|\
  127. tew-714tru|\
  128. timecloud|\
  129. tiny-ac|\
  130. ur-326n4g|\
  131. ur-336un|\
  132. v22rw-2x2|\
  133. vocore|\
  134. vocore2|\
  135. vr500|\
  136. w150m|\
  137. w2914nsv2|\
  138. w306r-v20|\
  139. w502u|\
  140. wf-2881|\
  141. whr-1166d|\
  142. whr-300hp2|\
  143. whr-600d|\
  144. whr-g300n|\
  145. widora-neo|\
  146. witi|\
  147. wizfi630a|\
  148. wl-330n|\
  149. wl-330n3g|\
  150. wl-341v3|\
  151. wl-351|\
  152. wl-wn575a3|\
  153. wli-tx4-ag300n|\
  154. wlr-6000|\
  155. wmr-300|\
  156. wn3000rpv3|\
  157. wnce2001|\
  158. wndr3700v5|\
  159. wr512-3gn|\
  160. wr6202|\
  161. wrh-300cr|\
  162. wrtnode|\
  163. wrtnode2r |\
  164. wrtnode2p |\
  165. wsr-600|\
  166. wt1520|\
  167. wt3020|\
  168. wzr-agl300nh|\
  169. x5|\
  170. x8|\
  171. y1|\
  172. y1s|\
  173. zbt-ape522ii|\
  174. zbt-cpe102|\
  175. zbt-wa05|\
  176. zbt-we826|\
  177. zbt-wg2626|\
  178. zbt-wg3526|\
  179. zbt-wr8305rt|\
  180. zte-q7|\
  181. youku-yk1)
  182. [ "$magic" != "27051956" ] && {
  183. echo "Invalid image type."
  184. return 1
  185. }
  186. return 0
  187. ;;
  188. 3g-6200n|\
  189. 3g-6200nl|\
  190. br-6475nd)
  191. [ "$magic" != "43535953" ] && {
  192. echo "Invalid image type."
  193. return 1
  194. }
  195. return 0
  196. ;;
  197. ar670w)
  198. [ "$magic" != "6d000080" ] && {
  199. echo "Invalid image type."
  200. return 1
  201. }
  202. return 0
  203. ;;
  204. c20i|\
  205. c50|\
  206. mr200)
  207. [ "$magic" != "03000000" ] && {
  208. echo "Invalid image type."
  209. return 1
  210. }
  211. return 0
  212. ;;
  213. cy-swr1100|\
  214. dch-m225|\
  215. dir-610-a1|\
  216. dir-645|\
  217. dir-860l-b1)
  218. [ "$magic" != "5ea3a417" ] && {
  219. echo "Invalid image type."
  220. return 1
  221. }
  222. return 0
  223. ;;
  224. wsr-1166)
  225. [ "$magic" != "48445230" ] && {
  226. echo "Invalid image type."
  227. return 1
  228. }
  229. return 0
  230. ;;
  231. ubnt-erx)
  232. nand_do_platform_check "$board" "$1"
  233. return $?;
  234. ;;
  235. esac
  236. echo "Sysupgrade is not yet supported on $board."
  237. return 1
  238. }
  239. platform_nand_pre_upgrade() {
  240. local board=$(ramips_board_name)
  241. case "$board" in
  242. ubnt-erx)
  243. platform_upgrade_ubnt_erx "$ARGV"
  244. ;;
  245. esac
  246. }
  247. platform_pre_upgrade() {
  248. local board=$(ramips_board_name)
  249. case "$board" in
  250. ubnt-erx)
  251. nand_do_upgrade "$ARGV"
  252. ;;
  253. esac
  254. }
  255. platform_do_upgrade() {
  256. local board=$(ramips_board_name)
  257. case "$board" in
  258. *)
  259. default_do_upgrade "$ARGV"
  260. ;;
  261. esac
  262. }
  263. disable_watchdog() {
  264. killall watchdog
  265. ( ps | grep -v 'grep' | grep '/dev/watchdog' ) && {
  266. echo 'Could not disable watchdog'
  267. return 1
  268. }
  269. }
  270. blink_led() {
  271. . /etc/diag.sh; set_state upgrade
  272. }
  273. append sysupgrade_pre_upgrade disable_watchdog
  274. append sysupgrade_pre_upgrade blink_led