445-add-netis-nx31.patch 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. --- /dev/null
  2. +++ b/configs/mt7981_netis_nx31_defconfig
  3. @@ -0,0 +1,106 @@
  4. +CONFIG_ARM=y
  5. +CONFIG_SYS_HAS_NONCACHED_MEMORY=y
  6. +CONFIG_POSITION_INDEPENDENT=y
  7. +CONFIG_ARCH_MEDIATEK=y
  8. +CONFIG_TEXT_BASE=0x41e00000
  9. +CONFIG_SYS_MALLOC_F_LEN=0x4000
  10. +CONFIG_NR_DRAM_BANKS=1
  11. +CONFIG_DEFAULT_DEVICE_TREE="mt7981-netis_nx31"
  12. +CONFIG_OF_LIBFDT_OVERLAY=y
  13. +CONFIG_TARGET_MT7981=y
  14. +CONFIG_SYS_LOAD_ADDR=0x46000000
  15. +CONFIG_PRE_CON_BUF_ADDR=0x4007ef00
  16. +CONFIG_DEBUG_UART_BASE=0x11002000
  17. +CONFIG_DEBUG_UART_CLOCK=40000000
  18. +CONFIG_DEBUG_UART=y
  19. +CONFIG_FIT=y
  20. +CONFIG_BOOTDELAY=30
  21. +CONFIG_AUTOBOOT_KEYED=y
  22. +CONFIG_AUTOBOOT_MENU_SHOW=y
  23. +CONFIG_DEFAULT_FDT_FILE="mediatek/mt7981-netis_nx31.dtb"
  24. +CONFIG_LOGLEVEL=7
  25. +CONFIG_PRE_CONSOLE_BUFFER=y
  26. +CONFIG_LOG=y
  27. +CONFIG_BOARD_LATE_INIT=y
  28. +CONFIG_HUSH_PARSER=y
  29. +CONFIG_SYS_PROMPT="MT7981> "
  30. +CONFIG_CMD_CPU=y
  31. +CONFIG_CMD_LICENSE=y
  32. +CONFIG_CMD_BOOTMENU=y
  33. +CONFIG_CMD_ASKENV=y
  34. +CONFIG_CMD_ERASEENV=y
  35. +CONFIG_CMD_ENV_FLAGS=y
  36. +CONFIG_CMD_STRINGS=y
  37. +CONFIG_CMD_DM=y
  38. +CONFIG_CMD_GPIO=y
  39. +CONFIG_CMD_GPT=y
  40. +CONFIG_CMD_MTD=y
  41. +CONFIG_CMD_PART=y
  42. +CONFIG_CMD_TFTPSRV=y
  43. +CONFIG_CMD_RARP=y
  44. +CONFIG_CMD_CDP=y
  45. +CONFIG_CMD_SNTP=y
  46. +CONFIG_CMD_LINK_LOCAL=y
  47. +CONFIG_CMD_DHCP=y
  48. +CONFIG_CMD_DNS=y
  49. +CONFIG_CMD_PING=y
  50. +CONFIG_CMD_PXE=y
  51. +CONFIG_CMD_CACHE=y
  52. +CONFIG_CMD_PSTORE=y
  53. +CONFIG_CMD_PSTORE_MEM_ADDR=0x42ff0000
  54. +CONFIG_CMD_UUID=y
  55. +CONFIG_CMD_HASH=y
  56. +CONFIG_CMD_SMC=y
  57. +CONFIG_CMD_UBI=y
  58. +CONFIG_CMD_UBI_RENAME=y
  59. +CONFIG_OF_EMBED=y
  60. +CONFIG_ENV_OVERWRITE=y
  61. +CONFIG_ENV_IS_IN_UBI=y
  62. +CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
  63. +CONFIG_ENV_UBI_PART="ubi"
  64. +CONFIG_ENV_UBI_VOLUME="ubootenv"
  65. +CONFIG_ENV_UBI_VOLUME_REDUND="ubootenv2"
  66. +CONFIG_SYS_RELOC_GD_ENV_ADDR=y
  67. +CONFIG_USE_DEFAULT_ENV_FILE=y
  68. +CONFIG_DEFAULT_ENV_FILE="defenvs/netis_nx31_env"
  69. +CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
  70. +CONFIG_VERSION_VARIABLE=y
  71. +CONFIG_NETCONSOLE=y
  72. +CONFIG_USE_IPADDR=y
  73. +CONFIG_IPADDR="192.168.1.1"
  74. +CONFIG_USE_SERVERIP=y
  75. +CONFIG_SERVERIP="192.168.1.254"
  76. +CONFIG_NET_RANDOM_ETHADDR=y
  77. +CONFIG_BUTTON=y
  78. +CONFIG_BUTTON_GPIO=y
  79. +CONFIG_CLK=y
  80. +CONFIG_GPIO_HOG=y
  81. +CONFIG_LED=y
  82. +CONFIG_LED_BLINK=y
  83. +CONFIG_LED_GPIO=y
  84. +# CONFIG_MMC is not set
  85. +CONFIG_MTD=y
  86. +CONFIG_DM_MTD=y
  87. +CONFIG_MTD_SPI_NAND=y
  88. +CONFIG_MTD_UBI_FASTMAP=y
  89. +CONFIG_PHY_FIXED=y
  90. +CONFIG_MEDIATEK_ETH=y
  91. +CONFIG_PHY=y
  92. +CONFIG_PHY_MTK_TPHY=y
  93. +CONFIG_PINCTRL=y
  94. +CONFIG_PINCONF=y
  95. +CONFIG_PINCTRL_MT7981=y
  96. +CONFIG_POWER_DOMAIN=y
  97. +CONFIG_MTK_POWER_DOMAIN=y
  98. +CONFIG_DM_REGULATOR=y
  99. +CONFIG_DM_REGULATOR_FIXED=y
  100. +CONFIG_DM_REGULATOR_GPIO=y
  101. +CONFIG_RAM=y
  102. +CONFIG_DM_SERIAL=y
  103. +CONFIG_SERIAL_RX_BUFFER=y
  104. +CONFIG_MTK_SERIAL=y
  105. +CONFIG_SPI=y
  106. +CONFIG_DM_SPI=y
  107. +CONFIG_MTK_SPIM=y
  108. +CONFIG_ZSTD=y
  109. +CONFIG_HEXDUMP=y
  110. --- /dev/null
  111. +++ b/arch/arm/dts/mt7981-netis_nx31.dts
  112. @@ -0,0 +1,162 @@
  113. +// SPDX-License-Identifier: GPL-2.0
  114. +/*
  115. + * Copyright (c) 2025
  116. + * Author: Mikhail Zhilkin <[email protected]>
  117. + */
  118. +
  119. +/dts-v1/;
  120. +#include "mt7981.dtsi"
  121. +#include <dt-bindings/gpio/gpio.h>
  122. +#include <dt-bindings/input/linux-event-codes.h>
  123. +
  124. +/ {
  125. + #address-cells = <1>;
  126. + #size-cells = <1>;
  127. + model = "netis NX31";
  128. + compatible = "netis,nx31", "mediatek,mt7981";
  129. +
  130. + chosen {
  131. + stdout-path = &uart0;
  132. + tick-timer = &timer0;
  133. + };
  134. +
  135. + memory@40000000 {
  136. + device_type = "memory";
  137. + reg = <0x40000000 0x10000000>;
  138. + };
  139. +
  140. + keys {
  141. + compatible = "gpio-keys";
  142. +
  143. + button-0 {
  144. + label = "mesh";
  145. + linux,code = <BTN_0>;
  146. + gpios = <&gpio 1 GPIO_ACTIVE_LOW>;
  147. + };
  148. +
  149. + button-1 {
  150. + label = "reset";
  151. + linux,code = <KEY_RESTART>;
  152. + gpios = <&gpio 1 GPIO_ACTIVE_LOW>;
  153. + };
  154. + };
  155. +
  156. + leds {
  157. + compatible = "gpio-leds";
  158. +
  159. + led-0 {
  160. + label = "blue:wlan2g";
  161. + gpios = <&gpio 5 GPIO_ACTIVE_LOW>;
  162. + };
  163. +
  164. + led-1 {
  165. + label = "blue:status";
  166. + gpios = <&gpio 7 GPIO_ACTIVE_LOW>;
  167. + };
  168. +
  169. + led-2 {
  170. + label = "blue:wan";
  171. + gpios = <&gpio 8 GPIO_ACTIVE_LOW>;
  172. + };
  173. +
  174. + led-3 {
  175. + label = "blue:wlan5g";
  176. + gpios = <&gpio 34 GPIO_ACTIVE_LOW>;
  177. + };
  178. + };
  179. +};
  180. +
  181. +&uart0 {
  182. + mediatek,force-highspeed;
  183. + status = "okay";
  184. +};
  185. +
  186. +&eth {
  187. + status = "okay";
  188. + mediatek,gmac-id = <0>;
  189. + phy-mode = "2500base-x";
  190. + mediatek,switch = "mt7531";
  191. + reset-gpios = <&gpio 39 GPIO_ACTIVE_HIGH>;
  192. +
  193. + fixed-link {
  194. + speed = <2500>;
  195. + full-duplex;
  196. + };
  197. +};
  198. +
  199. +&pinctrl {
  200. + spi_flash_pins: spi0-pins-func-1 {
  201. + mux {
  202. + function = "flash";
  203. + groups = "spi0", "spi0_wp_hold";
  204. + };
  205. +
  206. + conf-pu {
  207. + pins = "SPI0_CS", "SPI0_HOLD", "SPI0_WP";
  208. + drive-strength = <MTK_DRIVE_8mA>;
  209. + bias-pull-up = <MTK_PUPD_SET_R1R0_11>;
  210. + };
  211. +
  212. + conf-pd {
  213. + pins = "SPI0_CLK", "SPI0_MOSI", "SPI0_MISO";
  214. + drive-strength = <MTK_DRIVE_8mA>;
  215. + bias-pull-down = <MTK_PUPD_SET_R1R0_11>;
  216. + };
  217. + };
  218. +};
  219. +
  220. +&spi0 {
  221. + #address-cells = <1>;
  222. + #size-cells = <0>;
  223. + pinctrl-names = "default";
  224. + pinctrl-0 = <&spi_flash_pins>;
  225. + status = "okay";
  226. + must_tx;
  227. + enhance_timing;
  228. + dma_ext;
  229. + ipm_design;
  230. + support_quad;
  231. + tick_dly = <2>;
  232. + sample_sel = <0>;
  233. +
  234. + spi_nand@0 {
  235. + compatible = "spi-nand";
  236. + reg = <0>;
  237. + spi-max-frequency = <52000000>;
  238. +
  239. + partitions {
  240. + compatible = "fixed-partitions";
  241. + #address-cells = <1>;
  242. + #size-cells = <1>;
  243. +
  244. + partition@0 {
  245. + label = "BL2";
  246. + reg = <0x0 0x100000>;
  247. + };
  248. +
  249. + partition@100000 {
  250. + label = "u-boot-env (unused)";
  251. + reg = <0x100000 0x80000>;
  252. + };
  253. +
  254. + partition@160000 {
  255. + label = "Factory";
  256. + reg = <0x180000 0x200000>;
  257. + };
  258. +
  259. + partition@380000 {
  260. + label = "FIP";
  261. + reg = <0x380000 0x200000>;
  262. + };
  263. +
  264. + partition@580000 {
  265. + label = "ubi";
  266. + reg = <0x580000 0x7a80000>;
  267. + };
  268. + };
  269. + };
  270. +};
  271. +
  272. +&watchdog {
  273. + status = "disabled";
  274. +};
  275. --- /dev/null
  276. +++ b/defenvs/netis_nx31_env
  277. @@ -0,0 +1,57 @@
  278. +ipaddr=192.168.1.1
  279. +serverip=192.168.1.254
  280. +loadaddr=0x46000000
  281. +console=earlycon=uart8250,mmio32,0x11002000 console=ttyS0
  282. +bootcmd=run check_buttons ; if pstore check ; then run boot_recovery ; else run boot_ubi ; fi
  283. +bootconf=config-1
  284. +bootdelay=0
  285. +bootfile=openwrt-mediatek-filogic-netis_nx31-initramfs-recovery.itb
  286. +bootfile_bl2=openwrt-mediatek-filogic-netis_nx31-preloader.bin
  287. +bootfile_fip=openwrt-mediatek-filogic-netis_nx31-bl31-uboot.fip
  288. +bootfile_upg=openwrt-mediatek-filogic-netis_nx31-squashfs-sysupgrade.itb
  289. +bootled_status=blue:status
  290. +bootmenu_confirm_return=askenv - Press ENTER to return to menu ; bootmenu 60
  291. +bootmenu_default=0
  292. +bootmenu_delay=0
  293. +bootmenu_title= ( ( ( OpenWrt ) ) )
  294. +bootmenu_0=Initialize environment.=run _firstboot
  295. +bootmenu_0d=Run default boot command.=run boot_default
  296. +bootmenu_1=Boot system via TFTP.=run boot_tftp ; run bootmenu_confirm_return
  297. +bootmenu_2=Boot production system from NAND.=run boot_production ; run bootmenu_confirm_return
  298. +bootmenu_3=Boot recovery system from NAND.=run boot_recovery ; run bootmenu_confirm_return
  299. +bootmenu_4=Load production system via TFTP then write to NAND.=setenv noboot 1 ; setenv replacevol 1 ; run boot_tftp_production ; setenv noboot ; setenv replacevol ; run bootmenu_confirm_return
  300. +bootmenu_5=Load recovery system via TFTP then write to NAND.=setenv noboot 1 ; setenv replacevol 1 ; run boot_tftp_recovery ; setenv noboot ; setenv replacevol ; run bootmenu_confirm_return
  301. +bootmenu_6=Load BL31+U-Boot FIP via TFTP then write to NAND.=run boot_tftp_write_fip ; run bootmenu_confirm_return
  302. +bootmenu_7=Load BL2 preloader via TFTP then write to NAND.=run boot_tftp_write_bl2 ; run bootmenu_confirm_return
  303. +bootmenu_8=Reboot.=reset
  304. +bootmenu_9=Reset all settings to factory defaults.=run reset_factory ; reset
  305. +boot_first=if button reset ; then led $bootled_status on ; run boot_default ; fi ; bootmenu
  306. +boot_default=if env exists flag_recover ; then else run bootcmd ; fi ; run boot_recovery ; setenv replacevol 1 ; run boot_tftp_forever
  307. +boot_production=led $bootled_status on ; run ubi_read_production && bootm $loadaddr#$bootconf ; led bootled_status off
  308. +boot_recovery=led $bootled_status on ; run ubi_read_recovery && bootm $loadaddr#$bootconf ; led bootled_status off
  309. +boot_ubi=run boot_production ; run boot_recovery ; run boot_tftp_forever
  310. +boot_tftp_forever=led $bootled_status on ; while true ; do run boot_tftp ; sleep 1 ; done
  311. +boot_tftp_production=tftpboot $loadaddr $bootfile_upg && env exists replacevol && iminfo $loadaddr && run ubi_write_production ; if env exists noboot ; then else bootm $loadaddr#$bootconf ; fi
  312. +boot_tftp_recovery=tftpboot $loadaddr $bootfile && env exists replacevol && iminfo $loadaddr && run ubi_write_recovery ; if env exists noboot ; then else bootm $loadaddr#$bootconf ; fi
  313. +boot_tftp=tftpboot $loadaddr $bootfile && bootm $loadaddr#$bootconf
  314. +boot_tftp_write_fip=tftpboot $loadaddr $bootfile_fip && run mtd_write_fip && run reset_factory
  315. +boot_tftp_write_bl2=tftpboot $loadaddr $bootfile_bl2 && run mtd_write_bl2
  316. +check_buttons=if button reset ; then run boot_tftp ; fi
  317. +ethaddr_factory=mtd read Factory 0x40080000 0x1e0000 0x20000 && env readmem -b ethaddr 0x4009ef20 0x6 ; setenv ethaddr_factory
  318. +part_default=production
  319. +part_recovery=recovery
  320. +reset_factory=ubi part ubi ; mw $loadaddr 0x0 0x800 ; ubi write $loadaddr ubootenv 0x800 ; ubi write $loadaddr ubootenv2 0x800
  321. +mtd_write_fip=mtd erase FIP && mtd write FIP $loadaddr
  322. +mtd_write_bl2=mtd erase BL2 && mtd write BL2 $loadaddr
  323. +ubi_create_env=ubi check ubootenv || ubi create ubootenv 0x100000 dynamic || run ubi_format ; ubi check ubootenv2 || ubi create ubootenv2 0x100000 dynamic || run ubi_format
  324. +ubi_format=ubi detach ; mtd erase ubi && ubi part ubi ; reset
  325. +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
  326. +ubi_read_production=ubi read $loadaddr fit && iminfo $loadaddr && run ubi_prepare_rootfs
  327. +ubi_read_recovery=ubi check recovery && ubi read $loadaddr recovery
  328. +ubi_remove_rootfs=ubi check rootfs_data && ubi remove rootfs_data
  329. +ubi_write_production=ubi check fit && ubi remove fit ; run ubi_remove_rootfs ; ubi create fit $filesize dynamic && ubi write $loadaddr fit $filesize
  330. +ubi_write_recovery=ubi check recovery && ubi remove recovery ; run ubi_remove_rootfs ; ubi create recovery $filesize dynamic && ubi write $loadaddr recovery $filesize
  331. +_init_env=setenv _init_env ; run ubi_create_env ; saveenv ; saveenv
  332. +_firstboot=setenv _firstboot ; run ethaddr_factory ; run _switch_to_menu ; run _init_env ; run boot_first
  333. +_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
  334. +_bootmenu_update_title=setenv _bootmenu_update_title ; setenv bootmenu_title "$bootmenu_title $ver"