453-add-openwrt-one.patch 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  1. --- /dev/null
  2. +++ b/arch/arm/dts/openwrt-one.dts
  3. @@ -0,0 +1,203 @@
  4. +// SPDX-License-Identifier: GPL-2.0
  5. +/*
  6. + * Copyright (c) 2024 John Crispin <[email protected]>
  7. + */
  8. +
  9. +/dts-v1/;
  10. +#include "mt7981.dtsi"
  11. +#include <dt-bindings/gpio/gpio.h>
  12. +#include <dt-bindings/input/input.h>
  13. +
  14. +/ {
  15. + #address-cells = <1>;
  16. + #size-cells = <1>;
  17. + model = "OpenWrt One";
  18. + compatible = "openwrt,one", "mediatek,mt7981";
  19. + chosen {
  20. + stdout-path = &uart0;
  21. + tick-timer = &timer0;
  22. + };
  23. +
  24. + memory@40000000 {
  25. + device_type = "memory";
  26. + reg = <0x40000000 0x10000000>;
  27. + };
  28. +
  29. + keys {
  30. + compatible = "gpio-keys";
  31. +
  32. + user {
  33. + label = "front";
  34. + gpios = <&gpio 0 GPIO_ACTIVE_LOW>;
  35. + linux,code = <BTN_0>;
  36. + };
  37. +
  38. + reset {
  39. + label = "back";
  40. + gpios = <&gpio 1 GPIO_ACTIVE_LOW>;
  41. + linux,code = <BTN_1>;
  42. + };
  43. + };
  44. +
  45. + leds {
  46. + compatible = "gpio-leds";
  47. +
  48. + red {
  49. + label = "red";
  50. + gpios = <&gpio 9 GPIO_ACTIVE_HIGH>;
  51. + };
  52. +
  53. + white {
  54. + label = "white";
  55. + gpios = <&gpio 13 GPIO_ACTIVE_HIGH>;
  56. + };
  57. +
  58. + green {
  59. + label = "green";
  60. + gpios = <&gpio 15 GPIO_ACTIVE_HIGH>;
  61. + };
  62. + };
  63. +};
  64. +
  65. +&uart0 {
  66. + status = "okay";
  67. +};
  68. +
  69. +&eth {
  70. + status = "okay";
  71. + mediatek,gmac-id = <1>;
  72. + phy-mode = "gmii";
  73. + phy-handle = <&phy0>;
  74. +
  75. + phy0: eth-phy@0 {
  76. + compatible = "ethernet-phy-ieee802.3-c22";
  77. + reg = <0>;
  78. + };
  79. +};
  80. +
  81. +&pinctrl {
  82. + spi_flash_pins: spi0-pins-func-1 {
  83. + mux {
  84. + function = "flash";
  85. + groups = "spi0", "spi0_wp_hold";
  86. + };
  87. +
  88. + conf-pu {
  89. + pins = "SPI0_CS", "SPI0_HOLD", "SPI0_WP";
  90. + drive-strength = <MTK_DRIVE_8mA>;
  91. + bias-pull-up = <MTK_PUPD_SET_R1R0_11>;
  92. + };
  93. +
  94. + conf-pd {
  95. + pins = "SPI0_CLK", "SPI0_MOSI", "SPI0_MISO";
  96. + drive-strength = <MTK_DRIVE_8mA>;
  97. + bias-pull-down = <MTK_PUPD_SET_R1R0_11>;
  98. + };
  99. + };
  100. +
  101. + spi2_flash_pins: spi2-spi2-pins {
  102. + mux {
  103. + function = "spi";
  104. + groups = "spi2", "spi2_wp_hold";
  105. + };
  106. +
  107. + conf-pu {
  108. + pins = "SPI2_CS", "SPI2_HOLD", "SPI2_WP";
  109. + drive-strength = <MTK_DRIVE_8mA>;
  110. + bias-pull-down = <MTK_PUPD_SET_R1R0_00>;
  111. + };
  112. +
  113. + conf-pd {
  114. + pins = "SPI2_CLK", "SPI2_MOSI", "SPI2_MISO";
  115. + drive-strength = <MTK_DRIVE_8mA>;
  116. + bias-pull-down = <MTK_PUPD_SET_R1R0_00>;
  117. + };
  118. + };
  119. +};
  120. +
  121. +&spi0 {
  122. + #address-cells = <1>;
  123. + #size-cells = <0>;
  124. + pinctrl-names = "default";
  125. + pinctrl-0 = <&spi_flash_pins>;
  126. + status = "okay";
  127. + must_tx;
  128. + enhance_timing;
  129. + dma_ext;
  130. + ipm_design;
  131. + support_quad;
  132. + tick_dly = <2>;
  133. + sample_sel = <0>;
  134. +
  135. + spi_nand@0 {
  136. + compatible = "spi-nand";
  137. + reg = <0>;
  138. + spi-max-frequency = <52000000>;
  139. +
  140. + partitions {
  141. + compatible = "fixed-partitions";
  142. + #address-cells = <1>;
  143. + #size-cells = <1>;
  144. +
  145. + partition@0 {
  146. + label = "bl2";
  147. + reg = <0x0 0x100000>;
  148. + };
  149. +
  150. + partition@200000 {
  151. + label = "ubi";
  152. + reg = <0x100000 0x7f00000>;
  153. + };
  154. + };
  155. + };
  156. +};
  157. +
  158. +&spi2 {
  159. + #address-cells = <1>;
  160. + #size-cells = <0>;
  161. + pinctrl-names = "default";
  162. + pinctrl-0 = <&spi2_flash_pins>;
  163. + status = "okay";
  164. + must_tx;
  165. + enhance_timing;
  166. + dma_ext;
  167. + ipm_design;
  168. + tick_dly = <2>;
  169. + sample_sel = <0>;
  170. +
  171. + spi_nor@0 {
  172. + compatible = "jedec,spi-nor";
  173. + reg = <0>;
  174. + spi-max-frequency = <5000000>;
  175. +
  176. + partitions {
  177. + compatible = "fixed-partitions";
  178. + #address-cells = <1>;
  179. + #size-cells = <1>;
  180. +
  181. + partition@00000 {
  182. + label = "bl2-nor";
  183. + reg = <0x00000 0x0040000>;
  184. + };
  185. +
  186. + partition@40000 {
  187. + label = "factory";
  188. + reg = <0x40000 0x00C0000>;
  189. + };
  190. +
  191. + partition@100000 {
  192. + label = "fip-nor";
  193. + reg = <0x100000 0x0080000>;
  194. + };
  195. +
  196. + partition@180000 {
  197. + label = "recovery";
  198. + reg = <0x180000 0xc80000>;
  199. + };
  200. + };
  201. + };
  202. +};
  203. +
  204. +&watchdog {
  205. + status = "disabled";
  206. +};
  207. --- /dev/null
  208. +++ b/configs/mt7981_openwrt-one-nor_defconfig
  209. @@ -0,0 +1,128 @@
  210. +CONFIG_ARM=y
  211. +CONFIG_SYS_HAS_NONCACHED_MEMORY=y
  212. +CONFIG_POSITION_INDEPENDENT=y
  213. +CONFIG_ARCH_MEDIATEK=y
  214. +CONFIG_TEXT_BASE=0x41e00000
  215. +CONFIG_SYS_MALLOC_F_LEN=0x4000
  216. +CONFIG_NR_DRAM_BANKS=1
  217. +CONFIG_ENV_SIZE=0x8000
  218. +CONFIG_DEFAULT_DEVICE_TREE="openwrt-one"
  219. +CONFIG_OF_LIBFDT_OVERLAY=y
  220. +CONFIG_TARGET_MT7981=y
  221. +CONFIG_RESET_BUTTON_LABEL="back"
  222. +CONFIG_DEBUG_UART_BASE=0x11002000
  223. +CONFIG_DEBUG_UART_CLOCK=40000000
  224. +CONFIG_SYS_LOAD_ADDR=0x46000000
  225. +CONFIG_DEBUG_UART=y
  226. +CONFIG_FIT=y
  227. +CONFIG_SPI_BOOT=y
  228. +CONFIG_AUTOBOOT_MENU_SHOW=y
  229. +CONFIG_USE_PREBOOT=y
  230. +CONFIG_DEFAULT_FDT_FILE="openwrt-one"
  231. +CONFIG_SYS_CBSIZE=512
  232. +CONFIG_SYS_PBSIZE=1049
  233. +CONFIG_LOGLEVEL=7
  234. +CONFIG_LOG=y
  235. +CONFIG_BOARD_LATE_INIT=y
  236. +CONFIG_HUSH_PARSER=y
  237. +CONFIG_SYS_PROMPT="OpenWrt One> "
  238. +CONFIG_SYS_MAXARGS=16
  239. +CONFIG_CMD_CPU=y
  240. +CONFIG_CMD_LICENSE=y
  241. +# CONFIG_BOOTM_NETBSD is not set
  242. +# CONFIG_BOOTM_PLAN9 is not set
  243. +# CONFIG_BOOTM_RTEMS is not set
  244. +# CONFIG_BOOTM_VXWORKS is not set
  245. +# CONFIG_CMD_BOOTEFI_BOOTMGR is not set
  246. +CONFIG_CMD_BOOTMENU=y
  247. +CONFIG_CMD_ASKENV=y
  248. +CONFIG_CMD_ERASEENV=y
  249. +CONFIG_CMD_ENV_FLAGS=y
  250. +CONFIG_CMD_STRINGS=y
  251. +# CONFIG_CMD_UNLZ4 is not set
  252. +# CONFIG_CMD_UNZIP is not set
  253. +CONFIG_CMD_DM=y
  254. +CONFIG_CMD_GPIO=y
  255. +CONFIG_CMD_PWM=y
  256. +CONFIG_CMD_MTD=y
  257. +CONFIG_CMD_PCI=y
  258. +CONFIG_CMD_SF_TEST=y
  259. +CONFIG_CMD_USB=y
  260. +CONFIG_CMD_DHCP=y
  261. +CONFIG_CMD_TFTPSRV=y
  262. +CONFIG_CMD_RARP=y
  263. +CONFIG_CMD_PING=y
  264. +CONFIG_CMD_CDP=y
  265. +CONFIG_CMD_SNTP=y
  266. +CONFIG_CMD_DNS=y
  267. +CONFIG_CMD_LINK_LOCAL=y
  268. +CONFIG_CMD_PXE=y
  269. +CONFIG_CMD_CACHE=y
  270. +CONFIG_CMD_PSTORE=y
  271. +CONFIG_CMD_PSTORE_MEM_ADDR=0x42ff0000
  272. +CONFIG_CMD_UUID=y
  273. +CONFIG_CMD_HASH=y
  274. +CONFIG_CMD_SMC=y
  275. +CONFIG_CMD_FAT=y
  276. +CONFIG_CMD_FS_GENERIC=y
  277. +CONFIG_CMD_FS_UUID=y
  278. +CONFIG_CMD_UBI=y
  279. +CONFIG_CMD_UBI_RENAME=y
  280. +CONFIG_ENV_OVERWRITE=y
  281. +CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
  282. +CONFIG_SYS_RELOC_GD_ENV_ADDR=y
  283. +CONFIG_USE_DEFAULT_ENV_FILE=y
  284. +CONFIG_DEFAULT_ENV_FILE="openwrt-one-nor_env"
  285. +CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
  286. +CONFIG_VERSION_VARIABLE=y
  287. +CONFIG_NET_RANDOM_ETHADDR=y
  288. +CONFIG_REGMAP=y
  289. +CONFIG_SYSCON=y
  290. +CONFIG_BUTTON=y
  291. +CONFIG_BUTTON_GPIO=y
  292. +CONFIG_CLK=y
  293. +CONFIG_GPIO_HOG=y
  294. +CONFIG_LED=y
  295. +CONFIG_LED_BLINK=y
  296. +CONFIG_LED_GPIO=y
  297. +# CONFIG_MMC is not set
  298. +CONFIG_MTD=y
  299. +CONFIG_DM_MTD=y
  300. +# CONFIG_MTD_RAW_NAND is not set
  301. +CONFIG_MTD_SPI_NAND=y
  302. +CONFIG_DM_SPI_FLASH=y
  303. +CONFIG_SPI_FLASH_SFDP_SUPPORT=y
  304. +CONFIG_SPI_FLASH_EON=y
  305. +CONFIG_SPI_FLASH_GIGADEVICE=y
  306. +CONFIG_SPI_FLASH_ISSI=y
  307. +CONFIG_SPI_FLASH_MACRONIX=y
  308. +CONFIG_SPI_FLASH_SPANSION=y
  309. +CONFIG_SPI_FLASH_STMICRO=y
  310. +CONFIG_SPI_FLASH_WINBOND=y
  311. +CONFIG_SPI_FLASH_XMC=y
  312. +CONFIG_SPI_FLASH_XTX=y
  313. +CONFIG_SPI_FLASH_MTD=y
  314. +CONFIG_UBI_SILENCE_MSG=y
  315. +CONFIG_PHY_FIXED=y
  316. +CONFIG_MEDIATEK_ETH=y
  317. +CONFIG_PHY=y
  318. +CONFIG_PHY_MTK_TPHY=y
  319. +CONFIG_PINCTRL=y
  320. +CONFIG_PINCONF=y
  321. +CONFIG_PINCTRL_MT7981=y
  322. +CONFIG_POWER_DOMAIN=y
  323. +CONFIG_MTK_POWER_DOMAIN=y
  324. +CONFIG_DM_PWM=y
  325. +CONFIG_PWM_MTK=y
  326. +CONFIG_DM_SERIAL=y
  327. +CONFIG_MTK_SERIAL=y
  328. +CONFIG_SPI=y
  329. +CONFIG_DM_SPI=y
  330. +CONFIG_MTK_SPIM=y
  331. +CONFIG_USB=y
  332. +CONFIG_USB_XHCI_HCD=y
  333. +CONFIG_USB_XHCI_MTK=y
  334. +CONFIG_USB_STORAGE=y
  335. +CONFIG_UBIFS_SILENCE_MSG=y
  336. +CONFIG_HEXDUMP=y
  337. +CONFIG_LMB_MAX_REGIONS=64
  338. --- /dev/null
  339. +++ b/configs/mt7981_openwrt-one-spi-nand_defconfig
  340. @@ -0,0 +1,129 @@
  341. +CONFIG_ARM=y
  342. +CONFIG_SYS_HAS_NONCACHED_MEMORY=y
  343. +CONFIG_POSITION_INDEPENDENT=y
  344. +CONFIG_ARCH_MEDIATEK=y
  345. +CONFIG_TEXT_BASE=0x41e00000
  346. +CONFIG_SYS_MALLOC_F_LEN=0x4000
  347. +CONFIG_NR_DRAM_BANKS=1
  348. +CONFIG_DEFAULT_DEVICE_TREE="openwrt-one"
  349. +CONFIG_OF_LIBFDT_OVERLAY=y
  350. +CONFIG_TARGET_MT7981=y
  351. +CONFIG_RESET_BUTTON_LABEL="back"
  352. +CONFIG_DEBUG_UART_BASE=0x11002000
  353. +CONFIG_DEBUG_UART_CLOCK=40000000
  354. +CONFIG_SYS_LOAD_ADDR=0x46000000
  355. +CONFIG_DEBUG_UART=y
  356. +CONFIG_FIT=y
  357. +CONFIG_SPI_BOOT=y
  358. +CONFIG_AUTOBOOT_MENU_SHOW=y
  359. +CONFIG_USE_PREBOOT=y
  360. +CONFIG_DEFAULT_FDT_FILE="openwrt-one"
  361. +CONFIG_SYS_CBSIZE=512
  362. +CONFIG_SYS_PBSIZE=1049
  363. +CONFIG_LOGLEVEL=7
  364. +CONFIG_LOG=y
  365. +CONFIG_BOARD_LATE_INIT=y
  366. +CONFIG_HUSH_PARSER=y
  367. +CONFIG_SYS_PROMPT="OpenWrt One> "
  368. +CONFIG_SYS_MAXARGS=16
  369. +CONFIG_CMD_CPU=y
  370. +CONFIG_CMD_LICENSE=y
  371. +# CONFIG_BOOTM_NETBSD is not set
  372. +# CONFIG_BOOTM_PLAN9 is not set
  373. +# CONFIG_BOOTM_RTEMS is not set
  374. +# CONFIG_BOOTM_VXWORKS is not set
  375. +# CONFIG_CMD_BOOTEFI_BOOTMGR is not set
  376. +CONFIG_CMD_BOOTMENU=y
  377. +CONFIG_CMD_ASKENV=y
  378. +CONFIG_CMD_ERASEENV=y
  379. +CONFIG_CMD_ENV_FLAGS=y
  380. +CONFIG_CMD_STRINGS=y
  381. +# CONFIG_CMD_UNLZ4 is not set
  382. +# CONFIG_CMD_UNZIP is not set
  383. +CONFIG_CMD_DM=y
  384. +CONFIG_CMD_GPIO=y
  385. +CONFIG_CMD_PWM=y
  386. +CONFIG_CMD_MTD=y
  387. +CONFIG_CMD_PCI=y
  388. +CONFIG_CMD_SF_TEST=y
  389. +CONFIG_CMD_USB=y
  390. +CONFIG_CMD_DHCP=y
  391. +CONFIG_CMD_TFTPSRV=y
  392. +CONFIG_CMD_RARP=y
  393. +CONFIG_CMD_PING=y
  394. +CONFIG_CMD_CDP=y
  395. +CONFIG_CMD_SNTP=y
  396. +CONFIG_CMD_DNS=y
  397. +CONFIG_CMD_LINK_LOCAL=y
  398. +CONFIG_CMD_PXE=y
  399. +CONFIG_CMD_CACHE=y
  400. +CONFIG_CMD_PSTORE=y
  401. +CONFIG_CMD_PSTORE_MEM_ADDR=0x42ff0000
  402. +CONFIG_CMD_UUID=y
  403. +CONFIG_CMD_HASH=y
  404. +CONFIG_CMD_SMC=y
  405. +CONFIG_CMD_FAT=y
  406. +CONFIG_CMD_FS_GENERIC=y
  407. +CONFIG_CMD_FS_UUID=y
  408. +CONFIG_CMD_UBI=y
  409. +CONFIG_CMD_UBI_RENAME=y
  410. +CONFIG_ENV_OVERWRITE=y
  411. +CONFIG_ENV_IS_IN_UBI=y
  412. +CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
  413. +CONFIG_ENV_UBI_PART="ubi"
  414. +CONFIG_ENV_UBI_VOLUME="ubootenv"
  415. +CONFIG_ENV_UBI_VOLUME_REDUND="ubootenv2"
  416. +CONFIG_SYS_RELOC_GD_ENV_ADDR=y
  417. +CONFIG_USE_DEFAULT_ENV_FILE=y
  418. +CONFIG_DEFAULT_ENV_FILE="openwrt-one-spi-nand_env"
  419. +CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
  420. +CONFIG_VERSION_VARIABLE=y
  421. +CONFIG_NET_RANDOM_ETHADDR=y
  422. +CONFIG_REGMAP=y
  423. +CONFIG_SYSCON=y
  424. +CONFIG_BUTTON=y
  425. +CONFIG_BUTTON_GPIO=y
  426. +CONFIG_CLK=y
  427. +CONFIG_GPIO_HOG=y
  428. +CONFIG_LED=y
  429. +CONFIG_LED_BLINK=y
  430. +CONFIG_LED_GPIO=y
  431. +# CONFIG_MMC is not set
  432. +CONFIG_MTD=y
  433. +CONFIG_DM_MTD=y
  434. +# CONFIG_MTD_RAW_NAND is not set
  435. +CONFIG_MTD_SPI_NAND=y
  436. +CONFIG_DM_SPI_FLASH=y
  437. +CONFIG_SPI_FLASH_SFDP_SUPPORT=y
  438. +CONFIG_SPI_FLASH_EON=y
  439. +CONFIG_SPI_FLASH_GIGADEVICE=y
  440. +CONFIG_SPI_FLASH_ISSI=y
  441. +CONFIG_SPI_FLASH_MACRONIX=y
  442. +CONFIG_SPI_FLASH_SPANSION=y
  443. +CONFIG_SPI_FLASH_STMICRO=y
  444. +CONFIG_SPI_FLASH_WINBOND=y
  445. +CONFIG_SPI_FLASH_XMC=y
  446. +CONFIG_SPI_FLASH_XTX=y
  447. +CONFIG_SPI_FLASH_MTD=y
  448. +CONFIG_PHY_FIXED=y
  449. +CONFIG_MEDIATEK_ETH=y
  450. +CONFIG_PHY=y
  451. +CONFIG_PHY_MTK_TPHY=y
  452. +CONFIG_PINCTRL=y
  453. +CONFIG_PINCONF=y
  454. +CONFIG_PINCTRL_MT7981=y
  455. +CONFIG_POWER_DOMAIN=y
  456. +CONFIG_MTK_POWER_DOMAIN=y
  457. +CONFIG_DM_PWM=y
  458. +CONFIG_PWM_MTK=y
  459. +CONFIG_DM_SERIAL=y
  460. +CONFIG_MTK_SERIAL=y
  461. +CONFIG_SPI=y
  462. +CONFIG_DM_SPI=y
  463. +CONFIG_MTK_SPIM=y
  464. +CONFIG_USB=y
  465. +CONFIG_USB_XHCI_HCD=y
  466. +CONFIG_USB_XHCI_MTK=y
  467. +CONFIG_USB_STORAGE=y
  468. +CONFIG_HEXDUMP=y
  469. +CONFIG_LMB_MAX_REGIONS=64
  470. --- /dev/null
  471. +++ b/openwrt-one-nor_env
  472. @@ -0,0 +1,46 @@
  473. +bl2_mtd_write=mtd erase bl2-nor && mtd write bl2-nor $loadaddr 0x0 0x40000
  474. +bl2_tftp_write=tftpboot $loadaddr $bootfile_bl2_nor && run bl2_mtd_write
  475. +bootcmd=run check_button ; run led_start ; mtd read recovery ${loadaddr} ; bootm ; run led_loop_error
  476. +bootconf=config-1
  477. +bootdelay=0
  478. +bootfile=openwrt-mediatek-filogic-openwrt_one-initramfs.itb
  479. +bootfile_bl2_nor=openwrt-mediatek-filogic-openwrt_one-nor-preloader.bin
  480. +bootfile_fip_nor=openwrt-mediatek-filogic-openwrt_one-nor-bl31-uboot.fip
  481. +bootmenu_0=Initialize environment.=run _firstboot
  482. +bootmenu_0d=Run default boot command.=run bootcmd
  483. +bootmenu_1=Boot system via TFTP.=run tftp_boot ; run bootmenu_confirm_return
  484. +bootmenu_2=Unlock NOR. (Make sure the NOR/WP jumper is populated)=sf probe 1:0 && sf protect unlock 0x0 0x1000000 ; run bootmenu_confirm_return
  485. +bootmenu_3=Load BL31+U-Boot FIP via TFTP then write to NOR.=run fip_tftp_write ; run bootmenu_confirm_return
  486. +bootmenu_4=Load BL2 preloader via TFTP then write to NOR.=run bl2_tftp_write ; run bootmenu_confirm_return
  487. +bootmenu_5=Load recovery system via TFTP then write to NOR.=run tftp_write ; run bootmenu_confirm_return
  488. +bootmenu_6=Lock NOR. (Remove jumper afterwards)=sf probe 1:0 && sf protect lock 0x0 0x1000000 ; run bootmenu_confirm_return
  489. +bootmenu_7=Reboot.=reset
  490. +bootmenu_confirm_return=askenv - Press ENTER to return to menu ; bootmenu 60
  491. +bootmenu_default=0
  492. +bootmenu_delay=0
  493. +bootmenu_title= ( ( ( OpenWrt ) ) ) [SPI-NOR]
  494. +check_button=if button front ; then run usb_recovery ; run led_loop_error ; fi
  495. +fip_mtd_write=mtd erase fip-nor && mtd write fip-nor $loadaddr
  496. +fip_tftp_write=tftpboot $loadaddr $bootfile_fip_nor && run fip_mtd_write
  497. +ipaddr=192.168.11.11
  498. +led_done=led green off ; led white on
  499. +led_loop_done=led white off ; led green on ; echo done ; while true ; do sleep 1 ; done
  500. +led_loop_error=led white off ; led green off ; while true ; do led red on ; sleep 1 ; led red off ; sleep 1 ; done
  501. +led_boot=led green on ; led white on ; led red on
  502. +led_start=led green off ; led red off; led white on
  503. +loadaddr=0x46000000
  504. +preboot=run led_boot
  505. +recoverfile_bl2=openwrt-mediatek-filogic-openwrt_one-snand-preloader.bin
  506. +recoverfile_ubi=openwrt-mediatek-filogic-openwrt_one-factory.ubi
  507. +recovery_write_bl2=mtd erase bl2 && for offset in 0x0 0x40000 0x80000; do mtd write bl2 $loadaddr $offset 0x40000 ; done
  508. +recovery_write_ubi=mtd erase ubi && mtd write ubi $loadaddr 0 ${filesize}
  509. +serverip=192.168.11.23
  510. +tftp_boot=run led_start ; tftpboot $loadaddr $bootfile && bootm $loadaddr#$bootconf
  511. +tftp_write=run led_start ; tftpboot $loadaddr $bootfile && mtd erase recovery 0x0 ${filesize} && mtd write recovery $loadaddr 0x0 ${filesize}
  512. +usb_recovery=run led_start ; usb start && run usb_recovery_bl2 && run usb_recovery_ubi && run led_loop_done
  513. +usb_recovery_bl2=fatload usb 0:1 ${loadaddr} ${recoverfile_bl2} && run recovery_write_bl2
  514. +usb_recovery_ubi=fatload usb 0:1 ${loadaddr} ${recoverfile_ubi} && run recovery_write_ubi
  515. +_bootmenu_update_title=setenv _bootmenu_update_title ; setenv bootmenu_title "$bootmenu_title $ver"
  516. +_firstboot=setenv _firstboot ; run _switch_to_menu ; run _init_env ; bootmenu
  517. +_init_env=setenv _init_env ; echo Initialize Env ; run ubi_create_env ; saveenv
  518. +_switch_to_menu=setenv _switch_to_menu ; setenv bootdelay 3 ; setenv bootmenu_delay 3 ; setenv bootmenu_0 $bootmenu_0d ; setenv bootmenu_0d ; run _bootmenu_update_title
  519. --- /dev/null
  520. +++ b/openwrt-one-spi-nand_env
  521. @@ -0,0 +1,59 @@
  522. +ipaddr=192.168.11.11
  523. +serverip=192.168.11.23
  524. +loadaddr=0x46000000
  525. +console=earlycon=uart8250,mmio32,0x11002000 console=ttyS0
  526. +bootcmd=run check_buttons ; run led_start ; run boot_calibration ; run boot_production ; run boot_recovery
  527. +bootconf=config-1
  528. +bootdelay=0
  529. +bootfile=openwrt-mediatek-filogic-openwrt_one-initramfs.itb
  530. +bootfile_bl2=openwrt-mediatek-filogic-openwrt_one-snand-preloader.bin
  531. +bootfile_fip=openwrt-mediatek-filogic-openwrt_one-snand-bl31-uboot.fip
  532. +bootfile_upg=openwrt-mediatek-filogic-openwrt_one-squashfs-sysupgrade.itb
  533. +bootmenu_confirm_return=askenv - Press ENTER to return to menu ; run led_boot ; bootmenu 60
  534. +bootmenu_default=0
  535. +bootmenu_delay=0
  536. +bootmenu_title= ( ( ( OpenWrt ) ) ) [SPI-NAND]
  537. +bootmenu_0=Initialize environment.=run _firstboot
  538. +bootmenu_0d=Run default boot command.=run boot_default
  539. +bootmenu_1=Boot system via TFTP.=run boot_tftp ; run bootmenu_confirm_return
  540. +bootmenu_2=Boot production system from NAND.=run boot_production ; run bootmenu_confirm_return
  541. +bootmenu_3=Boot recovery system from NAND.=run boot_recovery ; run bootmenu_confirm_return
  542. +bootmenu_4=Load production system via TFTP then write to NAND.=noboot=1 ; replacevol=1 ; run boot_tftp_production ; noboot= ; replacevol= ; run bootmenu_confirm_return
  543. +bootmenu_5=Load recovery system via TFTP then write to NAND.=noboot=1 ; replacevol=1 ; run boot_tftp_recovery ; noboot= ; replacevol= ; run bootmenu_confirm_return
  544. +bootmenu_6=Load BL31+U-Boot FIP via TFTP then write to NAND.=run boot_tftp_write_fip ; run bootmenu_confirm_return
  545. +bootmenu_7=Load BL2 preloader via TFTP then write to NAND.=run boot_tftp_write_bl2 ; run bootmenu_confirm_return
  546. +bootmenu_8=Reboot.=reset
  547. +bootmenu_9=Reset all settings to factory defaults.=run reset_factory ; reset
  548. +boot_default=run bootcmd ; run boot_recovery ; replacevol=1 ; run boot_tftp_forever
  549. +boot_calibration=ubi read $loadaddr calibration && bootm $loadaddr#$bootconf
  550. +boot_production=led white on ; run ubi_read_production && bootm $loadaddr#$bootconf ; led white off
  551. +boot_recovery=led green on ; run ubi_read_recovery && bootm $loadaddr#$bootconf ; led green off
  552. +boot_tftp=run led_start ; tftpboot $loadaddr $bootfile && bootm $loadaddr#$bootconf
  553. +boot_tftp_forever=led green off ; led white off ; led red on ; while true ; do run boot_tftp_recovery ; led red off ; sleep 1 ; done
  554. +boot_tftp_production=tftpboot $loadaddr $bootfile_upg && test $replacevol = 1 && iminfo $loadaddr && run ubi_write_production ; if test $noboot = 1 ; then else bootm $loadaddr#$bootconf ; fi
  555. +boot_tftp_recovery=tftpboot $loadaddr $bootfile && test $replacevol = 1 && iminfo $loadaddr && run ubi_write_recovery ; if test $noboot = 1 ; then else bootm $loadaddr#$bootconf ; fi
  556. +boot_tftp=tftpboot $loadaddr $bootfile && bootm $loadaddr#$bootconf
  557. +boot_tftp_write_fip=tftpboot $loadaddr $bootfile_fip && run ubi_write_fip && run reset_factory
  558. +boot_tftp_write_bl2=tftpboot $loadaddr $bootfile_bl2 && run snand_write_bl2
  559. +check_buttons=if button front ; then run boot_recovery ; run boot_tftp ; run led_loop_error ; else if button back ; then ; run usb_recover ; run led_loop_error ; fi ; fi
  560. +led_boot=led green on ; led white on ; led red on
  561. +led_done=led green on ; led white off ; led red off
  562. +led_loop_error=led white off ; led green off ; while true ; do led red on ; sleep 1 ; led red off ; sleep 1 ; done
  563. +led_start=led white on ; led green off ; led red off
  564. +preboot=run led_boot
  565. +reset_factory=mw $loadaddr 0xff 0x1f000 ; ubi write $loadaddr ubootenv 0x1f000 ; ubi write $loadaddr ubootenv2 0x1f000 ; ubi remove rootfs_data
  566. +snand_write_bl2=mtd erase bl2 && for offset in 0x0 0x40000 0x80000 0xc0000 ; do mtd write bl2 $loadaddr $offset 0x40000 ; done
  567. +ubi_create_env=ubi check ubootenv || ubi create ubootenv 0x1f000 dynamic ; ubi check ubootenv2 || ubi create ubootenv2 0x1f000 dynamic
  568. +ubi_prepare_rootfs=if ubi check rootfs_data ; then else if env exists rootfs_data_max ; then ubi create rootfs_data $rootfs_data_max dynamic || ubi create rootfs_data - dynamic ; else ubi create rootfs_data - dynamic ; fi ; fi
  569. +ubi_read_production=ubi read $loadaddr fit && iminfo $loadaddr && run ubi_prepare_rootfs
  570. +ubi_read_recovery=ubi check recovery && ubi read $loadaddr recovery
  571. +ubi_remove_rootfs=ubi check rootfs_data && ubi remove rootfs_data
  572. +usb_recover=run led_start ; usb start && run usb_recover_production && run led_loop_done
  573. +usb_recover_production=fatload usb 0:1 ${loadaddr} ${bootfile_upg} && iminfo $loadaddr && run ubi_write_production
  574. +ubi_write_fip=run ubi_remove_rootfs ; ubi check fip && ubi remove fip ; ubi create fip $filesize static && ubi write $loadaddr fip $filesize
  575. +ubi_write_production=ubi check fit && ubi remove fit ; run ubi_remove_rootfs ; ubi create fit $filesize dynamic && ubi write $loadaddr fit $filesize
  576. +ubi_write_recovery=ubi check recovery && ubi remove recovery ; run ubi_remove_rootfs ; ubi create recovery $filesize dynamic && ubi write $loadaddr recovery $filesize
  577. +_init_env=setenv _init_env ; run ubi_create_env ; saveenv ; saveenv
  578. +_firstboot=setenv _firstboot ; run _switch_to_menu ; run _init_env ; bootmenu
  579. +_switch_to_menu=setenv _switch_to_menu ; setenv bootdelay 3 ; setenv bootmenu_delay 3 ; setenv bootmenu_0 $bootmenu_0d ; setenv bootmenu_0d ; run _bootmenu_update_title
  580. +_bootmenu_update_title=setenv _bootmenu_update_title ; setenv bootmenu_title "$bootmenu_title $ver"