429-add-netcore-n60.patch 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433
  1. --- /dev/null
  2. +++ b/configs/mt7986_netcore_n60_defconfig
  3. @@ -0,0 +1,182 @@
  4. +CONFIG_ARM=y
  5. +CONFIG_POSITION_INDEPENDENT=y
  6. +CONFIG_ARCH_MEDIATEK=y
  7. +CONFIG_TARGET_MT7986=y
  8. +CONFIG_TEXT_BASE=0x41e00000
  9. +CONFIG_SYS_MALLOC_F_LEN=0x4000
  10. +CONFIG_SYS_HAS_NONCACHED_MEMORY=y
  11. +CONFIG_NR_DRAM_BANKS=1
  12. +CONFIG_DEFAULT_DEVICE_TREE="mt7986a-netcore-n60"
  13. +CONFIG_DEFAULT_ENV_FILE="netcore_n60_env"
  14. +CONFIG_DEFAULT_FDT_FILE="mediatek/mt7986a-netcore-n60.dtb"
  15. +CONFIG_OF_LIBFDT_OVERLAY=y
  16. +CONFIG_DEBUG_UART_BASE=0x11002000
  17. +CONFIG_DEBUG_UART_CLOCK=40000000
  18. +CONFIG_DEBUG_UART=y
  19. +CONFIG_SYS_LOAD_ADDR=0x46000000
  20. +CONFIG_SMBIOS_PRODUCT_NAME=""
  21. +CONFIG_AUTOBOOT_KEYED=y
  22. +CONFIG_BOOTDELAY=30
  23. +CONFIG_AUTOBOOT_MENU_SHOW=y
  24. +CONFIG_CFB_CONSOLE_ANSI=y
  25. +CONFIG_BOARD_LATE_INIT=y
  26. +CONFIG_BUTTON=y
  27. +CONFIG_BUTTON_GPIO=y
  28. +CONFIG_GPIO_HOG=y
  29. +CONFIG_CMD_ENV_FLAGS=y
  30. +CONFIG_FIT=y
  31. +CONFIG_FIT_ENABLE_SHA256_SUPPORT=y
  32. +CONFIG_LED=y
  33. +CONFIG_LED_BLINK=y
  34. +CONFIG_LED_GPIO=y
  35. +CONFIG_LOGLEVEL=7
  36. +CONFIG_LOG=y
  37. +CONFIG_SYS_PROMPT="MT7986> "
  38. +CONFIG_CMD_BOOTMENU=y
  39. +CONFIG_CMD_BOOTP=y
  40. +CONFIG_CMD_BUTTON=y
  41. +CONFIG_CMD_CACHE=y
  42. +CONFIG_CMD_CDP=y
  43. +CONFIG_CMD_CPU=y
  44. +CONFIG_CMD_DHCP=y
  45. +CONFIG_CMD_DM=y
  46. +CONFIG_CMD_DNS=y
  47. +CONFIG_CMD_ECHO=y
  48. +CONFIG_CMD_ENV_READMEM=y
  49. +CONFIG_CMD_ERASEENV=y
  50. +CONFIG_CMD_EXT4=y
  51. +CONFIG_CMD_FAT=y
  52. +CONFIG_CMD_FDT=y
  53. +CONFIG_CMD_FS_GENERIC=y
  54. +CONFIG_CMD_FS_UUID=y
  55. +CONFIG_CMD_GPIO=y
  56. +CONFIG_CMD_GPT=y
  57. +CONFIG_CMD_HASH=y
  58. +CONFIG_CMD_ITEST=y
  59. +CONFIG_CMD_LED=y
  60. +CONFIG_CMD_LICENSE=y
  61. +CONFIG_CMD_LINK_LOCAL=y
  62. +# CONFIG_CMD_MBR is not set
  63. +CONFIG_CMD_PCI=y
  64. +CONFIG_CMD_PSTORE=y
  65. +CONFIG_CMD_PSTORE_MEM_ADDR=0x42ff0000
  66. +CONFIG_CMD_SF_TEST=y
  67. +CONFIG_CMD_PING=y
  68. +CONFIG_CMD_PXE=y
  69. +CONFIG_CMD_PWM=y
  70. +CONFIG_CMD_SMC=y
  71. +CONFIG_CMD_TFTPBOOT=y
  72. +CONFIG_CMD_TFTPSRV=y
  73. +CONFIG_CMD_UBI=y
  74. +CONFIG_CMD_UBI_RENAME=y
  75. +CONFIG_CMD_UBIFS=y
  76. +CONFIG_CMD_ASKENV=y
  77. +CONFIG_CMD_PART=y
  78. +CONFIG_CMD_RARP=y
  79. +CONFIG_CMD_SETEXPR=y
  80. +CONFIG_CMD_SLEEP=y
  81. +CONFIG_CMD_SNTP=y
  82. +CONFIG_CMD_SOURCE=y
  83. +CONFIG_CMD_STRINGS=y
  84. +CONFIG_CMD_USB=y
  85. +CONFIG_CMD_UUID=y
  86. +CONFIG_DISPLAY_CPUINFO=y
  87. +CONFIG_DM_MTD=y
  88. +CONFIG_DM_REGULATOR=y
  89. +CONFIG_DM_REGULATOR_FIXED=y
  90. +CONFIG_DM_REGULATOR_GPIO=y
  91. +CONFIG_DM_USB=y
  92. +CONFIG_DM_PWM=y
  93. +CONFIG_PWM_MTK=y
  94. +CONFIG_HUSH_PARSER=y
  95. +CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
  96. +CONFIG_SYS_RELOC_GD_ENV_ADDR=y
  97. +CONFIG_VERSION_VARIABLE=y
  98. +CONFIG_PARTITION_UUIDS=y
  99. +CONFIG_NETCONSOLE=y
  100. +CONFIG_REGMAP=y
  101. +CONFIG_SYSCON=y
  102. +CONFIG_CLK=y
  103. +CONFIG_DM_GPIO=y
  104. +CONFIG_DM_SCSI=y
  105. +CONFIG_AHCI=y
  106. +CONFIG_AHCI_PCI=y
  107. +CONFIG_SCSI_AHCI=y
  108. +CONFIG_SCSI=y
  109. +CONFIG_CMD_SCSI=y
  110. +CONFIG_PHY=y
  111. +CONFIG_PHY_MTK_TPHY=y
  112. +CONFIG_PHY_FIXED=y
  113. +CONFIG_MTK_AHCI=y
  114. +CONFIG_DM_ETH=y
  115. +CONFIG_MEDIATEK_ETH=y
  116. +CONFIG_PCI=y
  117. +# CONFIG_MMC is not set
  118. +# CONFIG_DM_MMC is not set
  119. +CONFIG_MTD=y
  120. +CONFIG_MTD_UBI_FASTMAP=y
  121. +CONFIG_DM_PCI=y
  122. +CONFIG_PCIE_MEDIATEK=y
  123. +CONFIG_PINCTRL=y
  124. +CONFIG_PINCONF=y
  125. +CONFIG_PINCTRL_MT7622=y
  126. +CONFIG_POWER_DOMAIN=y
  127. +CONFIG_PRE_CONSOLE_BUFFER=y
  128. +CONFIG_PRE_CON_BUF_ADDR=0x4007EF00
  129. +CONFIG_MTK_POWER_DOMAIN=y
  130. +CONFIG_RAM=y
  131. +CONFIG_DM_SERIAL=y
  132. +CONFIG_MTK_SERIAL=y
  133. +CONFIG_SPI=y
  134. +CONFIG_DM_SPI=y
  135. +CONFIG_MTK_SPI_NAND=y
  136. +CONFIG_MTK_SPI_NAND_MTD=y
  137. +CONFIG_SYSRESET_WATCHDOG=y
  138. +CONFIG_WDT_MTK=y
  139. +CONFIG_LZO=y
  140. +CONFIG_ZSTD=y
  141. +CONFIG_HEXDUMP=y
  142. +CONFIG_RANDOM_UUID=y
  143. +CONFIG_REGEX=y
  144. +CONFIG_USB=y
  145. +CONFIG_USB_HOST=y
  146. +CONFIG_USB_XHCI_HCD=y
  147. +CONFIG_USB_XHCI_MTK=y
  148. +CONFIG_USB_STORAGE=y
  149. +CONFIG_OF_EMBED=y
  150. +CONFIG_ENV_OVERWRITE=y
  151. +CONFIG_ENV_IS_IN_UBI=y
  152. +CONFIG_ENV_UBI_PART="ubi"
  153. +CONFIG_ENV_SIZE=0x1f000
  154. +CONFIG_ENV_SIZE_REDUND=0x1f000
  155. +CONFIG_ENV_UBI_VOLUME="ubootenv"
  156. +CONFIG_ENV_UBI_VOLUME_REDUND="ubootenv2"
  157. +CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
  158. +CONFIG_NET_RANDOM_ETHADDR=y
  159. +CONFIG_REGMAP=y
  160. +CONFIG_SYSCON=y
  161. +CONFIG_CLK=y
  162. +CONFIG_PHY_FIXED=y
  163. +CONFIG_DM_ETH=y
  164. +CONFIG_MEDIATEK_ETH=y
  165. +CONFIG_PINCTRL=y
  166. +CONFIG_PINCONF=y
  167. +CONFIG_PINCTRL_MT7986=y
  168. +CONFIG_POWER_DOMAIN=y
  169. +CONFIG_MTK_POWER_DOMAIN=y
  170. +CONFIG_DM_REGULATOR=y
  171. +CONFIG_DM_REGULATOR_FIXED=y
  172. +CONFIG_DM_SERIAL=y
  173. +CONFIG_MTK_SERIAL=y
  174. +CONFIG_HEXDUMP=y
  175. +CONFIG_USE_DEFAULT_ENV_FILE=y
  176. +CONFIG_MTD_SPI_NAND=y
  177. +CONFIG_MTK_SPIM=y
  178. +CONFIG_CMD_MTD=y
  179. +CONFIG_CMD_NAND=y
  180. +CONFIG_CMD_NAND_TRIMFFS=y
  181. +CONFIG_LMB_MAX_REGIONS=64
  182. +CONFIG_USE_IPADDR=y
  183. +CONFIG_IPADDR="192.168.1.1"
  184. +CONFIG_USE_SERVERIP=y
  185. +CONFIG_SERVERIP="192.168.1.254"
  186. --- /dev/null
  187. +++ b/arch/arm/dts/mt7986a-netcore-n60.dts
  188. @@ -0,0 +1,185 @@
  189. +// SPDX-License-Identifier: GPL-2.0
  190. +/*
  191. + * Copyright (c) 2021 MediaTek Inc.
  192. + * Author: Sam Shih <[email protected]>
  193. + */
  194. +
  195. +/dts-v1/;
  196. +#include "mt7986.dtsi"
  197. +#include <dt-bindings/gpio/gpio.h>
  198. +#include <dt-bindings/input/linux-event-codes.h>
  199. +
  200. +/ {
  201. + #address-cells = <1>;
  202. + #size-cells = <1>;
  203. + model = "Netcore N60";
  204. + compatible = "mediatek,mt7986", "mediatek,mt7986-rfb";
  205. +
  206. + chosen {
  207. + stdout-path = &uart0;
  208. + tick-timer = &timer0;
  209. + };
  210. +
  211. + memory@40000000 {
  212. + device_type = "memory";
  213. + reg = <0x40000000 0x20000000>;
  214. + };
  215. +
  216. + keys {
  217. + compatible = "gpio-keys";
  218. +
  219. + factory {
  220. + label = "reset";
  221. + linux,code = <KEY_RESTART>;
  222. + gpios = <&gpio 9 GPIO_ACTIVE_LOW>;
  223. + };
  224. +
  225. + wps {
  226. + label = "wps";
  227. + linux,code = <KEY_WPS_BUTTON>;
  228. + gpios = <&gpio 10 GPIO_ACTIVE_LOW>;
  229. + };
  230. + };
  231. +
  232. + leds {
  233. + compatible = "gpio-leds";
  234. +
  235. + status_red {
  236. + label = "red:status";
  237. + gpios = <&gpio 29 GPIO_ACTIVE_LOW>;
  238. + };
  239. +
  240. + status_green {
  241. + label = "green:status";
  242. + gpios = <&gpio 32 GPIO_ACTIVE_LOW>;
  243. + };
  244. + };
  245. +};
  246. +
  247. +&uart0 {
  248. + mediatek,force-highspeed;
  249. + status = "okay";
  250. +};
  251. +
  252. +&uart1 {
  253. + pinctrl-names = "default";
  254. + pinctrl-0 = <&uart1_pins>;
  255. + status = "disabled";
  256. +};
  257. +
  258. +&eth {
  259. + status = "okay";
  260. + mediatek,gmac-id = <0>;
  261. + phy-mode = "2500base-x";
  262. + mediatek,switch = "mt7531";
  263. + reset-gpios = <&gpio 5 GPIO_ACTIVE_HIGH>;
  264. +
  265. + fixed-link {
  266. + speed = <2500>;
  267. + full-duplex;
  268. + };
  269. +};
  270. +
  271. +&pinctrl {
  272. + spi_flash_pins: spi0-pins-func-1 {
  273. + mux {
  274. + function = "flash";
  275. + groups = "spi0", "spi0_wp_hold";
  276. + };
  277. +
  278. + conf-pu {
  279. + pins = "SPI2_CS", "SPI2_HOLD", "SPI2_WP";
  280. + drive-strength = <MTK_DRIVE_8mA>;
  281. + bias-pull-up = <MTK_PUPD_SET_R1R0_00>;
  282. + };
  283. +
  284. + conf-pd {
  285. + pins = "SPI2_CLK", "SPI2_MOSI", "SPI2_MISO";
  286. + drive-strength = <MTK_DRIVE_8mA>;
  287. + bias-pull-down = <MTK_PUPD_SET_R1R0_00>;
  288. + };
  289. + };
  290. +
  291. + spic_pins: spi1-pins-func-1 {
  292. + mux {
  293. + function = "spi";
  294. + groups = "spi1_2";
  295. + };
  296. + };
  297. +
  298. + uart1_pins: spi1-pins-func-3 {
  299. + mux {
  300. + function = "uart";
  301. + groups = "uart1_2";
  302. + };
  303. + };
  304. +
  305. + pwm_pins: pwm0-pins-func-1 {
  306. + mux {
  307. + function = "pwm";
  308. + groups = "pwm0";
  309. + };
  310. + };
  311. +};
  312. +
  313. +&pwm {
  314. + pinctrl-names = "default";
  315. + pinctrl-0 = <&pwm_pins>;
  316. + status = "okay";
  317. +};
  318. +
  319. +&spi0 {
  320. + #address-cells = <1>;
  321. + #size-cells = <0>;
  322. + pinctrl-names = "default";
  323. + pinctrl-0 = <&spi_flash_pins>;
  324. + status = "okay";
  325. + must_tx;
  326. + enhance_timing;
  327. + dma_ext;
  328. + ipm_design;
  329. + support_quad;
  330. + tick_dly = <1>;
  331. + sample_sel = <0>;
  332. +
  333. + spi_nand@1 {
  334. + compatible = "spi-nand";
  335. + reg = <1>;
  336. + spi-max-frequency = <52000000>;
  337. +
  338. + partitions {
  339. + compatible = "fixed-partitions";
  340. + #address-cells = <1>;
  341. + #size-cells = <1>;
  342. +
  343. + partition@0 {
  344. + label = "bl2";
  345. + reg = <0x0 0x100000>;
  346. + };
  347. +
  348. + partition@100000 {
  349. + label = "orig-env";
  350. + reg = <0x100000 0x80000>;
  351. + };
  352. +
  353. + partition@160000 {
  354. + label = "factory";
  355. + reg = <0x180000 0x200000>;
  356. + };
  357. +
  358. + partition@380000 {
  359. + label = "fip";
  360. + reg = <0x380000 0x200000>;
  361. + };
  362. +
  363. + partition@580000 {
  364. + label = "ubi";
  365. + reg = <0x580000 0x7280000>;
  366. + };
  367. + };
  368. + };
  369. +};
  370. +
  371. +&watchdog {
  372. + status = "disabled";
  373. +};
  374. --- /dev/null
  375. +++ b/netcore_n60_env
  376. @@ -0,0 +1,57 @@
  377. +ipaddr=192.168.1.1
  378. +serverip=192.168.1.254
  379. +loadaddr=0x46000000
  380. +console=earlycon=uart8250,mmio32,0x11002000 console=ttyS0
  381. +bootcmd=if pstore check ; then run boot_recovery ; else run boot_ubi ; fi
  382. +bootconf=config-1
  383. +bootdelay=0
  384. +bootfile=openwrt-mediatek-filogic-netcore_n60-initramfs-recovery.itb
  385. +bootfile_bl2=openwrt-mediatek-filogic-netcore_n60-preloader.bin
  386. +bootfile_fip=openwrt-mediatek-filogic-netcore_n60-bl31-uboot.fip
  387. +bootfile_upg=openwrt-mediatek-filogic-netcore_n60-squashfs-sysupgrade.itb
  388. +bootled_pwr=green:status
  389. +bootled_rec=red:status
  390. +bootmenu_confirm_return=askenv - Press ENTER to return to menu ; bootmenu 60
  391. +bootmenu_default=0
  392. +bootmenu_delay=0
  393. +bootmenu_title= ( ( ( OpenWrt ) ) )
  394. +bootmenu_0=Initialize environment.=run _firstboot
  395. +bootmenu_0d=Run default boot command.=run boot_default
  396. +bootmenu_1=Boot system via TFTP.=run boot_tftp ; run bootmenu_confirm_return
  397. +bootmenu_2=Boot production system from NAND.=run boot_production ; run bootmenu_confirm_return
  398. +bootmenu_3=Boot recovery system from NAND.=run boot_recovery ; run bootmenu_confirm_return
  399. +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
  400. +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
  401. +bootmenu_6=Load BL31+U-Boot FIP via TFTP then write to NAND.=run boot_tftp_write_fip ; run bootmenu_confirm_return
  402. +bootmenu_7=Load BL2 preloader via TFTP then write to NAND.=run boot_tftp_write_bl2 ; run bootmenu_confirm_return
  403. +bootmenu_8=Reboot.=reset
  404. +bootmenu_9=Reset all settings to factory defaults.=run reset_factory ; reset
  405. +boot_first=if button reset ; then led $bootled_rec on ; run boot_tftp_recovery ; setenv flag_recover 1 ; run boot_default ; fi ; bootmenu
  406. +boot_default=if env exists flag_recover ; then else run bootcmd ; fi ; run boot_recovery ; setenv replacevol 1 ; run boot_tftp_forever
  407. +boot_production=led $bootled_pwr on ; run ubi_read_production && bootm $loadaddr#$bootconf ; led $bootled_pwr off
  408. +boot_recovery=led $bootled_rec on ; run ubi_read_recovery && bootm $loadaddr#$bootconf ; led $bootled_rec off
  409. +boot_ubi=run boot_production ; run boot_recovery ; run boot_tftp_forever
  410. +boot_tftp_forever=led $bootled_rec on ; while true ; do run boot_tftp_recovery ; sleep 1 ; done
  411. +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
  412. +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
  413. +boot_tftp=tftpboot $loadaddr $bootfile && bootm $loadaddr#$bootconf
  414. +boot_tftp_write_fip=tftpboot $loadaddr $bootfile_fip && run mtd_write_fip && run reset_factory
  415. +boot_tftp_write_bl2=tftpboot $loadaddr $bootfile_bl2 && run mtd_write_bl2
  416. +part_default=production
  417. +part_recovery=recovery
  418. +reset_factory=ubi part ubi ; mw $loadaddr 0x0 0x800 ; ubi write $loadaddr ubootenv 0x800 ; ubi write $loadaddr ubootenv2 0x800
  419. +mtd_write_fip=mtd erase fip && mtd write fip $loadaddr
  420. +mtd_write_bl2=mtd erase bl2 && mtd write bl2 $loadaddr
  421. +ubi_create_env=ubi check ubootenv || ubi create ubootenv 0x100000 dynamic 0 || run ubi_format ; ubi check ubootenv2 || ubi create ubootenv2 0x100000 dynamic 1 || run ubi_format
  422. +ubi_format=ubi detach ; mtd erase ubi && ubi part ubi ; reset
  423. +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
  424. +ubi_read_production=ubi read $loadaddr fit && iminfo $loadaddr && run ubi_prepare_rootfs
  425. +ubi_read_recovery=ubi check recovery && ubi read $loadaddr recovery
  426. +ubi_remove_rootfs=ubi check rootfs_data && ubi remove rootfs_data
  427. +ubi_write_production=ubi check fit && ubi remove fit ; run ubi_remove_rootfs ; ubi create fit $filesize dynamic 2 && ubi write $loadaddr fit $filesize
  428. +ubi_write_recovery=ubi check recovery && ubi remove recovery ; run ubi_remove_rootfs ; ubi create recovery $filesize dynamic 3 && ubi write $loadaddr recovery $filesize
  429. +ethaddr_factory=mtd read factory 0x40080000 0x1fe000 0x1000 && env readmem -b ethaddr 0x40080f20 0x6 ; setenv ethaddr_factory
  430. +_init_env=setenv _init_env ; run ubi_create_env ; saveenv ; saveenv
  431. +_firstboot=setenv _firstboot ; run ethaddr_factory ; run _switch_to_menu ; run _init_env ; run boot_first
  432. +_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
  433. +_bootmenu_update_title=setenv _bootmenu_update_title ; setenv bootmenu_title "$bootmenu_title $ver"