c-life_xg1.patch 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. From a3b880a4e8654e86eaf1a8854a07fd90783682ce Mon Sep 17 00:00:00 2001
  2. From: syb999 <[email protected]>
  3. Date: Sun, 4 Sep 2022 18:30:18 +0800
  4. Subject: [PATCH] ramips: add support for C-Life XG1 [WIFI6] (#10057)
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. CPU: MediaTek MT7621AT
  9. Flash: Micron MT29F2G08ABAGAWP 128M
  10. RAM: 256 M
  11. WiFi: MT7915 2.4/5 GHz 2T2R
  12. Ethernet: 10/100/1000 Mbps x3
  13. LED: Status (red / blue / white / green / purple / cyan)
  14. USB: 2.0 x 1
  15. ZigBee/BlueTooth
  16. USB Audio: iec958 x 1
  17. Button: Reset
  18. Power: DC 12V,1.5A
  19. 开启ssh方法:
  20. 打开网页:192.168.10.1,用户路由器底面标注的用户名密码完成登陆。
  21. 然后打开网页:http://192.168.10.1/cgi-bin/luci/admin/mtk/console,在命令行中输入以下命令:
  22. echo -en "root\nroot\n" | passwd
  23. 然后打开网页:http://192.168.10.1/cgi-bin/luci/pti/ssh_open
  24. 即可ssh登陆192.168.10.1,用户名root,密码root
  25. 刷入openwrt:
  26. 开启ssh后,上传breed-mt7621-xiaomi-r3g.bin到路由器/tmp目录。
  27. 然后使用下面命令刷入breed:
  28. mtd -r write /tmp/breed-mt7621-xiaomi-r3g.bin Bootloader
  29. 等待机器重启,等1分钟断开电源。
  30. 按住C-Life XG1机身正面的圆形IoT按钮(gpio 18),通电就能进入breed刷机.
  31. ---
  32. package/boot/uboot-envtools/files/ramips | 1 +
  33. target/linux/ramips/dts/mt7621_c-life_xg1.dts | 160 ++++++++++++++++++
  34. target/linux/ramips/image/mt7621.mk | 17 ++
  35. .../mt7621/base-files/etc/board.d/02_network | 9 +
  36. .../etc/hotplug.d/ieee80211/10_fix_wifi_mac | 6 +
  37. .../mt7621/base-files/lib/upgrade/platform.sh | 1 +
  38. 6 files changed, 194 insertions(+)
  39. create mode 100644 target/linux/ramips/dts/mt7621_c-life_xg1.dts
  40. diff --git a/package/boot/uboot-envtools/files/ramips b/package/boot/uboot-envtools/files/ramips
  41. index 2942fb6af807a..4323a2574c55b 100644
  42. --- a/package/boot/uboot-envtools/files/ramips
  43. +++ b/package/boot/uboot-envtools/files/ramips
  44. @@ -70,6 +70,7 @@
  45. h3c,tx1800-plus|\
  46. h3c,tx1801-plus|\
  47. h3c,tx1806|\
  48. +c-life,xg1|\
  49. jcg,q20|\
  50. linksys,e7350|\
  51. netgear,wax202|\
  52. --- a/target/linux/ramips/dts/mt7621.dtsi
  53. +++ b/target/linux/ramips/dts/mt7621.dtsi
  54. @@ -437,6 +437,13 @@
  55. clock-names = "nfi_clk";
  56. };
  57. + ethsys: ethsys@1e000000 {
  58. + compatible = "mediatek,mt7621-ethsys",
  59. + "syscon";
  60. + reg = <0x1e000000 0x1000>;
  61. + #clock-cells = <1>;
  62. + };
  63. +
  64. ethernet: ethernet@1e100000 {
  65. compatible = "mediatek,mt7621-eth";
  66. reg = <0x1e100000 0x10000>;
  67. @@ -542,6 +549,59 @@
  68. };
  69. };
  70. + hnat: hnat@1e100000 {
  71. + compatible = "mediatek,mtk-hnat_v1";
  72. + ext-devices = "ra0", "rai0", "rax0",
  73. + "apcli0", "apclii0","apclix0";
  74. + reg = <0x1e100000 0x3000>;
  75. +
  76. + resets = <&ethsys 0>;
  77. + reset-names = "mtketh";
  78. +
  79. + mtketh-wan = "wan";
  80. + mtketh-ppd = "lan";
  81. + mtketh-lan = "lan";
  82. + mtketh-max-gmac = <1>;
  83. + mtkdsa-wan-port = <4>;
  84. + };
  85. +
  86. + gsw: gsw@1e110000 {
  87. + compatible = "mediatek,mt753x";
  88. + reg = <0x1e110000 0x8000>;
  89. + interrupt-parent = <&gic>;
  90. + interrupts = <GIC_SHARED 23 IRQ_TYPE_LEVEL_HIGH>;
  91. +
  92. + mediatek,mcm;
  93. + mediatek,mdio = <&mdio>;
  94. + mt7530,direct-phy-access;
  95. +
  96. + resets = <&rstctrl 2>;
  97. + reset-names = "mcm";
  98. + status = "disabled";
  99. +
  100. + port@5 {
  101. + compatible = "mediatek,mt753x-port";
  102. + reg = <5>;
  103. + phy-mode = "rgmii";
  104. +
  105. + fixed-link {
  106. + speed = <1000>;
  107. + full-duplex;
  108. + };
  109. + };
  110. +
  111. + port@6 {
  112. + compatible = "mediatek,mt753x-port";
  113. + reg = <6>;
  114. + phy-mode = "rgmii";
  115. +
  116. + fixed-link {
  117. + speed = <1000>;
  118. + full-duplex;
  119. + };
  120. + };
  121. + };
  122. +
  123. pcie: pcie@1e140000 {
  124. compatible = "mediatek,mt7621-pci";
  125. reg = <0x1e140000 0x100>, /* host-pci bridge registers */
  126. diff --git a/target/linux/ramips/dts/mt7621_c-life_xg1.dts b/target/linux/ramips/dts/mt7621_c-life_xg1.dts
  127. new file mode 100644
  128. index 0000000000000..b3744ff989c06
  129. --- /dev/null
  130. +++ b/target/linux/ramips/dts/mt7621_c-life_xg1.dts
  131. @@ -0,0 +1,160 @@
  132. +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
  133. +
  134. +#include "mt7621.dtsi"
  135. +
  136. +#include <dt-bindings/gpio/gpio.h>
  137. +#include <dt-bindings/input/input.h>
  138. +
  139. +/ {
  140. + compatible = "c-life,xg1", "mediatek,mt7621-soc";
  141. + model = "C-Life XG1";
  142. +
  143. + aliases {
  144. + led-boot = &led_status_red;
  145. + led-failsafe = &led_status_red;
  146. + led-running = &led_status_blue;
  147. + led-upgrade = &led_status_blue;
  148. + label-mac-device = &gmac0;
  149. + };
  150. +
  151. + chosen {
  152. + bootargs = "console=ttyS0,115200";
  153. + };
  154. +
  155. + leds {
  156. + compatible = "gpio-leds";
  157. +
  158. + led_status_red: status_red {
  159. + label = "red:status";
  160. + gpios = <&gpio 14 GPIO_ACTIVE_HIGH>;
  161. + };
  162. +
  163. + led_status_blue: status_blue {
  164. + label = "blue:status";
  165. + gpios = <&gpio 15 GPIO_ACTIVE_LOW>;
  166. + };
  167. + };
  168. +
  169. + keys {
  170. + compatible = "gpio-keys";
  171. +
  172. + reset {
  173. + label = "reset";
  174. + gpios = <&gpio 18 GPIO_ACTIVE_LOW>;
  175. + linux,code = <KEY_RESTART>;
  176. + };
  177. +
  178. + wps {
  179. + label = "wps";
  180. + gpios = <&gpio 17 GPIO_ACTIVE_LOW>;
  181. + linux,code = <KEY_WPS_BUTTON>;
  182. + };
  183. + };
  184. +};
  185. +
  186. +&nand {
  187. + status = "okay";
  188. +
  189. + partitions {
  190. + compatible = "fixed-partitions";
  191. + #address-cells = <1>;
  192. + #size-cells = <1>;
  193. +
  194. + partition@0 {
  195. + label = "Bootloader";
  196. + reg = <0x0 0x80000>;
  197. + };
  198. +
  199. + partition@80000 {
  200. + label = "Nvram";
  201. + reg = <0x80000 0x40000>;
  202. + read-only;
  203. + };
  204. +
  205. + partition@c0000 {
  206. + label = "Bdata";
  207. + reg = <0xc0000 0x40000>;
  208. + read-only;
  209. + };
  210. +
  211. + factory: partition@100000 {
  212. + label = "Factory";
  213. + reg = <0x100000 0x80000>;
  214. + read-only;
  215. + };
  216. +
  217. + partition@180000 {
  218. + label = "crash";
  219. + reg = <0x180000 0x40000>;
  220. + read-only;
  221. + };
  222. +
  223. + partition@1c0000 {
  224. + label = "crash_log";
  225. + reg = <0x1c0000 0x40000>;
  226. + read-only;
  227. + };
  228. +
  229. + partition@200000 {
  230. + label = "kernel";
  231. + reg = <0x200000 0x400000>;
  232. + };
  233. +
  234. + partition@600000 {
  235. + label = "ubi";
  236. + reg = <0x600000 0x7980000>;
  237. + };
  238. + };
  239. +};
  240. +
  241. +&pcie {
  242. + status = "okay";
  243. +};
  244. +
  245. +&pcie1 {
  246. + wifi@0,0 {
  247. + compatible = "mediatek,mt76";
  248. + reg = <0x0000 0 0 0 0>;
  249. + mediatek,mtd-eeprom = <&factory 0x0>;
  250. + };
  251. +};
  252. +
  253. +&gmac0 {
  254. + mtd-mac-address = <&factory 0x04>;
  255. +};
  256. +
  257. +&gmac1 {
  258. + mtd-mac-address = <&factory 0x0a>;
  259. + phy-mode = "rgmii";
  260. + status = "okay";
  261. +
  262. + fixed-link {
  263. + speed = <1000>;
  264. + full-duplex;
  265. + pause;
  266. + };
  267. +};
  268. +
  269. +&gsw {
  270. + mediatek,portmap = "llllw";
  271. + status = "okay";
  272. +};
  273. +
  274. +&hnat {
  275. + mtketh-wan = "eth1";
  276. + mtketh-ppd = "eth0";
  277. + mtketh-lan = "eth0";
  278. + mtketh-max-gmac = <2>;
  279. + /delete-property/ mtkdsa-wan-port;
  280. +};
  281. +
  282. +&switch0 {
  283. + status = "disabled";
  284. +};
  285. +
  286. +&state_default {
  287. + gpio {
  288. + groups = "jtag", "wdt";
  289. + function = "gpio";
  290. + };
  291. +};
  292. diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk
  293. index e2402fc9701e2..efc1d0515b45d 100644
  294. --- a/target/linux/ramips/image/mt7621.mk
  295. +++ b/target/linux/ramips/image/mt7621.mk
  296. @@ -582,6 +582,23 @@
  297. endef
  298. TARGET_DEVICES += cudy_m1800
  299. +define Device/c-life_xg1
  300. + $(Device/dsa-migration)
  301. + BLOCKSIZE := 128k
  302. + PAGESIZE := 2048
  303. + UBINIZE_OPTS := -E 5
  304. + KERNEL_SIZE := 4096k
  305. + IMAGE_SIZE := 91136k
  306. + IMAGES += factory.bin
  307. + IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
  308. + IMAGE/factory.bin := append-kernel | pad-to $$(KERNEL_SIZE) | append-ubi | \
  309. + check-size
  310. + DEVICE_VENDOR := C-Life
  311. + DEVICE_MODEL := XG1
  312. + DEVICE_PACKAGES := kmod-mt7915-firmware uboot-envtools kmod-usb3
  313. +endef
  314. +TARGET_DEVICES += c-life_xg1
  315. +
  316. define Device/cudy_wr1300-v1
  317. $(Device/dsa-migration)
  318. IMAGE_SIZE := 15872k
  319. diff --git a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network
  320. index 250210a473211..83623652e99a9 100644
  321. --- a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network
  322. +++ b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network
  323. @@ -198,6 +198,11 @@ ramips_setup_macs()
  324. lan_mac=$wan_mac
  325. label_mac=$wan_mac
  326. ;;
  327. + c-life,xg1)
  328. + base_mac=$(cat /sys/class/net/eth0/address)
  329. + lan_mac=$(macaddr_add "$base_mac" -1)
  330. + wan_mac=$(macaddr_add "$lan_mac" -1)
  331. + ;;
  332. dlink,dir-860l-b1)
  333. lan_mac=$(mtd_get_mac_ascii factory lanmac)
  334. wan_mac=$(mtd_get_mac_ascii factory wanmac)
  335. diff --git a/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac b/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac
  336. index bb66c1e6a2d80..937986230e4f1 100644
  337. --- a/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac
  338. +++ b/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac
  339. @@ -33,6 +33,12 @@
  340. [ "$PHYNBR" = "1" ] && \
  341. macaddr_setbit_la "$(macaddr_add $hw_mac_addr 0x100000)" > /sys${DEVPATH}/macaddress
  342. ;;
  343. + c-life,xg1)
  344. + if [ "$PHYNBR" = "1" ]; then
  345. + base_mac=$(macaddr_add "$(mtd_get_mac_binary factory 0x4)" 1)
  346. + macaddr_setbit_la "$base_mac" > /sys${DEVPATH}/macaddress
  347. + fi
  348. + ;;
  349. dlink,dap-1620-b1|\
  350. dlink,dir-853-a1)
  351. lan_mac_addr="$(mtd_get_mac_binary factory 0xe000)"
  352. diff --git a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh
  353. index af9dc9ca9a1eb..427c39c0675ff 100755
  354. --- a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh
  355. +++ b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh
  356. @@ -63,6 +63,7 @@
  357. beeline,smartbox-turbo|\
  358. beeline,smartbox-turbo-plus|\
  359. belkin,rt1800|\
  360. + c-life,xg1|\
  361. dlink,dap-x1860-a1|\
  362. dlink,dir-1960-a1|\
  363. dlink,dir-2640-a1|\