Message ID | 20190514223956.19663-4-lede@allycomm.com |
---|---|
State | Superseded |
Delegated to: | Petr Štetiar |
Headers | show |
Series | ath79: Extend GL.iNet AR750S support toNAND file system | expand |
Jeff Kletsky <lede@allycomm.com> [2019-05-14 15:39:56]: > diff --git a/target/linux/ath79/base-files/etc/board.d/01_leds b/target/linux/ath79/base-files/etc/board.d/01_leds > index 9c353baabe..c974c12d14 100755 > --- a/target/linux/ath79/base-files/etc/board.d/01_leds > +++ b/target/linux/ath79/base-files/etc/board.d/01_leds > @@ -78,6 +78,10 @@ glinet,gl-ar300m-nor) > glinet,gl-ar300m-lite) > ucidef_set_led_netdev "lan" "LAN" "gl-ar300m-lite:green:lan" "eth0" > ;; > +glinet,gl-ar750s-*) > + ucidef_set_led_netdev "wlan2g" "WLAN 2G" "gl-ar750s:green:wlan2g" > + ucidef_set_led_netdev "wlan5g" "WLAN 5G" "gl-ar750s:green:wlan5g" why do you need this? It's already being set in the DTS by the LED triggers, isn't it? Having it defined in DTS is preferred. > +# During image creation the "board name" is of the format mfgr_board-name > +# However, on a running device it is of the format mfgr,board-name That's already clear from the code, so drop this comment. > +comma_to_underscore() { > + echo "${1%%,*}_${1#*,}" > +} > + > platform_check_image() { > - return 0 > + local board=$(board_name) > + > + case "$board" in > + glinet,gl-ar750s-nand) > + nand_do_platform_check "$(comma_to_underscore "$board")" "$IMAGE" > + ;; > + *) > + return 0 > + ;; > + esac > } I think, that it would be better to add support for DT compatible based board_name format directly into nand_do_platform_check, so it could be reused by other platforms as well. > diff --git a/target/linux/ath79/dts/qca9563_glinet_gl-ar750s.dts b/target/linux/ath79/dts/qca9563_glinet_gl-ar750s.dtsi > similarity index 64% > rename from target/linux/ath79/dts/qca9563_glinet_gl-ar750s.dts > rename to target/linux/ath79/dts/qca9563_glinet_gl-ar750s.dtsi > index 378de5de90..e38879182e 100644 > --- a/target/linux/ath79/dts/qca9563_glinet_gl-ar750s.dts > +++ b/target/linux/ath79/dts/qca9563_glinet_gl-ar750s.dtsi > @@ -15,10 +15,10 @@ > }; > > aliases { > - led-boot = &power; > - led-failsafe = &power; > - led-running = &power; > - led-upgrade = &power; > + led-boot = &led_power; > + led-failsafe = &led_wlan2g; > + led-running = &led_power; > + led-upgrade = &led_wlan5g; > }; Please don't do this, those LEDs have defined functions and using wlan5g LED to signal an upgrade might be confusing. It has been discussed a lot of times already. > + i2c@0 { > + compatible = "i2c-gpio"; > + > + sda-gpios = <&gpio 5 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>; > + scl-gpios = <&gpio 21 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>; > + i2c-gpio,delay-us = <2>; /* ~100 kHz */ What was wrong with the default value? Have you actually checked the resulting clock frequency somehow? > + #address-cells = <1>; > + #size-cells = <0>; The #address-cells and #size-cells properties may be used in any device node that has children in the devicetree hierarchy and describes how child device nodes should be addressed. The #address-cells property defines the number of <u32> cells used to encode the address field in a child node’s reg property. The #size-cells property defines the number of <u32> cells used to encode the size field in a child node’s reg property. So you can drop this. > diff --git a/target/linux/ath79/image/nand.mk b/target/linux/ath79/image/nand.mk > index e69de29bb2..7db5f51c98 100644 > --- a/target/linux/ath79/image/nand.mk > +++ b/target/linux/ath79/image/nand.mk > @@ -0,0 +1,15 @@ > +define Device/glinet_gl-ar750s-nand > + ATH_SOC := qca9563 > + DEVICE_TITLE := GL.iNet GL-AR750S > + DEVICE_PACKAGES := kmod-usb2 kmod-ath10k-ct ath10k-firmware-qca9887-ct kmod-i2c-gpio > + KERNEL_SIZE := 2048k > + BLOCKSIZE := 128k > + PAGESIZE := 2048 > + VID_HDR_OFFSET := 2048 > + IMAGES += factory.img > + IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata > + IMAGE/factory.img := append-kernel | pad-to $$$$(KERNEL_SIZE) | append-ubi > + SUPPORTED_DEVICES += gl-ar750s I'm really not sure about this. Do we've enough checks in place, that we won't allow sysupgrade from NOR? -- ynezz
On 5/15/19 2:00 AM, Petr Štetiar wrote: > Jeff Kletsky <lede@allycomm.com> [2019-05-14 15:39:56]: [...] A question and an answer as I wrap up the punch-down list on this >> +comma_to_underscore() { >> + echo "${1%%,*}_${1#*,}" >> +} >> + >> [...] > I think, that it would be better to add support for DT compatible based > board_name format directly into nand_do_platform_check, so it could be reused > by other platforms as well. I originally had applied this in `nand_do_platform_check()`, but when I checked for potential adverse impact on other boards I found that there was an unfortunate exception with the pistachio marduck board, which passes `img,pistachio-marduk` to nand_do_platform_check(), preventing a "blind" change in that function[1]. "img" is apparently from "imgtec.com". While `target/linux/pistachio/image/Makefile` uses IMAGE/sysupgrade.tar := sysupgrade-tar it also defines a custom board name define Device/marduk BOARD_NAME := img,pistachio-marduk DEVICE_DTS := img/pistachio_marduk apparently resulting in the comma being in the tar directory sysupgrade-img,pistachio-marduk/ sysupgrade-img,pistachio-marduk/root sysupgrade-img,pistachio-marduk/CONTROL sysupgrade-img,pistachio-marduk/kernel While this likely could be fixed by unifying the board name and tar directory name with current convention, I'm hesitant to change a device build that I can't test, especially around flashing and upgrade. As a side note, the pistachio platform is a "snowflake" in other ways, including what looks like a custom SPI-NAND framework originally on Linux 4.9. `git log -1 52c17bff3c` The remainder of the boards that I found that call `nand_do_platform_check()` do so with a comma-free board_name or with an explicit, comma-free string. Surprisingly few make this check; ath79, imx6, ar71xx, layerscape For clarity, orthogonality, and maintainability, I was considering handling this with two, distinct commits: (1) Add the "automatic" first-comma-to-underscore transformation to package/base-files/files/lib/upgrade/nand.sh:nand_do_platform_check() (2) Add a specific exception to (1) for `img,pistachio-marduk` Is this a reasonable approach? [...] >> diff --git a/target/linux/ath79/image/nand.mk b/target/linux/ath79/image/nand.mk >> index e69de29bb2..7db5f51c98 100644 >> --- a/target/linux/ath79/image/nand.mk >> +++ b/target/linux/ath79/image/nand.mk >> @@ -0,0 +1,15 @@ >> +define Device/glinet_gl-ar750s-nand >> + ATH_SOC := qca9563 >> + DEVICE_TITLE := GL.iNet GL-AR750S >> + DEVICE_PACKAGES := kmod-usb2 kmod-ath10k-ct ath10k-firmware-qca9887-ct kmod-i2c-gpio >> + KERNEL_SIZE := 2048k >> + BLOCKSIZE := 128k >> + PAGESIZE := 2048 >> + VID_HDR_OFFSET := 2048 >> + IMAGES += factory.img >> + IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata >> + IMAGE/factory.img := append-kernel | pad-to $$$$(KERNEL_SIZE) | append-ubi >> + SUPPORTED_DEVICES += gl-ar750s > I'm really not sure about this. Do we've enough checks in place, that we won't > allow sysupgrade from NOR? > The ath79 builds, prior to this proposed patch set, use `glinet,gl-ar750s`, so are not impacted. After this patch set there will be a `-nor` and `-nand` suffix to clearly differentiate between the two variants. The `gl-ar750s` board name comes from ar71xx builds for this board, either from OpenWrt or GL.iNet (based on 18.06.1) source[2]. GL.iNet only provides the NAND-based variant through their download site[3], from what I can tell. GL.iNet and their U-Boot differentiate NOR-based with a .bin extension, NAND-based with a .img or .tar extension. From target/linux/ar71xx/base-files/lib/upgrade/platform.sh 331 [ "$magic" != "2705" ] && { 332 echo "Invalid image type." 333 return 1 334 } 335 336 return 0 337 ;; "2705" is keying off U-Boot's #define IH_MAGIC 0x27051956 /* Image Magic Number */ GL.iNet provides similar checks for their boards in their source including detection if `gl_board_is_nand()` [4]. I have confirmed that this works as expected on OpenWrt snapshots as well as from a NOR-based build from the GL.iNet sources. Surprisingly, there is no first-order image check for the ath79 platform. This would be a project unto itself, based on looking at the ar71xx code. Jeff --- [1] http://lists.infradead.org/pipermail/openwrt-devel/2019-May/017045.html [2] https://github.com/gl-inet/openwrt [3] https://dl.gl-inet.com/firmware/ar750s/ [4] https://github.com/gl-inet/openwrt/blob/develop/target/linux/ar71xx/base-files/lib/upgrade/platform.sh#L215
diff --git a/package/boot/uboot-envtools/files/ath79 b/package/boot/uboot-envtools/files/ath79 index 2144f61070..faa5c501f3 100644 --- a/package/boot/uboot-envtools/files/ath79 +++ b/package/boot/uboot-envtools/files/ath79 @@ -19,6 +19,7 @@ buffalo,wzr-hp-ag300h) buffalo,bhr-4grv2|\ glinet,gl-ar300m-nand|\ glinet,gl-ar300m-nor|\ +glinet,gl-ar750s-*|\ librerouter,librerouter-v1|\ netgear,ex6400|\ netgear,ex7300|\ diff --git a/target/linux/ath79/base-files/etc/board.d/01_leds b/target/linux/ath79/base-files/etc/board.d/01_leds index 9c353baabe..c974c12d14 100755 --- a/target/linux/ath79/base-files/etc/board.d/01_leds +++ b/target/linux/ath79/base-files/etc/board.d/01_leds @@ -78,6 +78,10 @@ glinet,gl-ar300m-nor) glinet,gl-ar300m-lite) ucidef_set_led_netdev "lan" "LAN" "gl-ar300m-lite:green:lan" "eth0" ;; +glinet,gl-ar750s-*) + ucidef_set_led_netdev "wlan2g" "WLAN 2G" "gl-ar750s:green:wlan2g" + ucidef_set_led_netdev "wlan5g" "WLAN 5G" "gl-ar750s:green:wlan5g" + ;; glinet,gl-x750) ucidef_set_led_netdev "wan" "WAN" "$boardname:green:wan" "eth0" ;; diff --git a/target/linux/ath79/base-files/etc/board.d/02_network b/target/linux/ath79/base-files/etc/board.d/02_network index f877669f98..f1f8a11f81 100755 --- a/target/linux/ath79/base-files/etc/board.d/02_network +++ b/target/linux/ath79/base-files/etc/board.d/02_network @@ -114,7 +114,7 @@ ath79_setup_interfaces() etactica,eg200) ucidef_set_interface_lan "eth0" "dhcp" ;; - glinet,gl-ar750s) + glinet,gl-ar750s-*) ucidef_add_switch "switch0" \ "0@eth0" "2:lan:2" "3:lan:1" "1:wan" ;; diff --git a/target/linux/ath79/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ath79/base-files/etc/hotplug.d/firmware/11-ath10k-caldata index fc3f7142bb..34248039b6 100644 --- a/target/linux/ath79/base-files/etc/hotplug.d/firmware/11-ath10k-caldata +++ b/target/linux/ath79/base-files/etc/hotplug.d/firmware/11-ath10k-caldata @@ -109,7 +109,7 @@ case "$FIRMWARE" in ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_ascii u-boot-env ethaddr) +1) ;; engenius,ews511ap|\ - glinet,gl-ar750s|\ + glinet,gl-ar750s-*|\ glinet,gl-x750|\ tplink,re450-v2) ath10kcal_extract "art" 20480 2116 diff --git a/target/linux/ath79/base-files/lib/upgrade/platform.sh b/target/linux/ath79/base-files/lib/upgrade/platform.sh index c2fe08154d..aa46a03555 100644 --- a/target/linux/ath79/base-files/lib/upgrade/platform.sh +++ b/target/linux/ath79/base-files/lib/upgrade/platform.sh @@ -1,3 +1,4 @@ +#!/bin/sh # # Copyright (C) 2011 OpenWrt.org # @@ -32,14 +33,34 @@ redboot_fis_do_upgrade() { fi } + +# During image creation the "board name" is of the format mfgr_board-name +# However, on a running device it is of the format mfgr,board-name + +comma_to_underscore() { + echo "${1%%,*}_${1#*,}" +} + platform_check_image() { - return 0 + local board=$(board_name) + + case "$board" in + glinet,gl-ar750s-nand) + nand_do_platform_check "$(comma_to_underscore "$board")" "$IMAGE" + ;; + *) + return 0 + ;; + esac } platform_do_upgrade() { local board=$(board_name) case "$board" in + glinet,gl-ar750s-nand) + nand_do_upgrade "$ARGV" + ;; jjplus,ja76pf2) redboot_fis_do_upgrade "$ARGV" linux ;; diff --git a/target/linux/ath79/dts/qca9563_glinet_gl-ar750s-nand.dts b/target/linux/ath79/dts/qca9563_glinet_gl-ar750s-nand.dts new file mode 100644 index 0000000000..3d5947d441 --- /dev/null +++ b/target/linux/ath79/dts/qca9563_glinet_gl-ar750s-nand.dts @@ -0,0 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/dts-v1/; + +#include "qca9563_glinet_gl-ar750s.dtsi" + +/ { + compatible = "glinet,gl-ar750s-nand", "qca,qca9563"; +}; + +/delete-node/ &nor_firmware; diff --git a/target/linux/ath79/dts/qca9563_glinet_gl-ar750s-nor.dts b/target/linux/ath79/dts/qca9563_glinet_gl-ar750s-nor.dts new file mode 100644 index 0000000000..37e50d71f6 --- /dev/null +++ b/target/linux/ath79/dts/qca9563_glinet_gl-ar750s-nor.dts @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/dts-v1/; + +#include "qca9563_glinet_gl-ar750s.dtsi" + +/ { + compatible = "glinet,gl-ar750s-nor", "qca,qca9563"; +}; + +/delete-node/ &nor_kernel; +/delete-node/ &nor_rootfs; + +&nand_ubi { + label = "nand_ubi"; +}; diff --git a/target/linux/ath79/dts/qca9563_glinet_gl-ar750s.dts b/target/linux/ath79/dts/qca9563_glinet_gl-ar750s.dtsi similarity index 64% rename from target/linux/ath79/dts/qca9563_glinet_gl-ar750s.dts rename to target/linux/ath79/dts/qca9563_glinet_gl-ar750s.dtsi index 378de5de90..e38879182e 100644 --- a/target/linux/ath79/dts/qca9563_glinet_gl-ar750s.dts +++ b/target/linux/ath79/dts/qca9563_glinet_gl-ar750s.dtsi @@ -15,10 +15,10 @@ }; aliases { - led-boot = &power; - led-failsafe = &power; - led-running = &power; - led-upgrade = &power; + led-boot = &led_power; + led-failsafe = &led_wlan2g; + led-running = &led_power; + led-upgrade = &led_wlan5g; }; keys { @@ -44,36 +44,48 @@ leds { compatible = "gpio-leds"; - power: power { + led_power: power { label = "gl-ar750s:green:power"; gpios = <&gpio 1 GPIO_ACTIVE_LOW>; default-state = "keep"; }; - wlan2g { + led_wlan2g: wlan2g { label = "gl-ar750s:green:wlan2g"; gpios = <&gpio 19 GPIO_ACTIVE_LOW>; linux,default-trigger = "phy1tpt"; }; - wlan5g { + led_wlan5g: wlan5g { label = "gl-ar750s:green:wlan5g"; gpios = <&gpio 20 GPIO_ACTIVE_HIGH>; linux,default-trigger = "phy0tpt"; }; }; + + i2c@0 { + compatible = "i2c-gpio"; + + sda-gpios = <&gpio 5 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>; + scl-gpios = <&gpio 21 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>; + i2c-gpio,delay-us = <2>; /* ~100 kHz */ + #address-cells = <1>; + #size-cells = <0>; + }; }; &spi { status = "okay"; - num-cs = <0>; - flash@0 { + num-cs = <2>; + cs-gpios = <0>, <0>; + + flash_nor: flash@0 { compatible = "jedec,spi-nor"; reg = <0>; spi-max-frequency = <25000000>; - partitions { + nor_partitions: partitions { compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; @@ -95,40 +107,61 @@ read-only; }; - partition@60000 { + nor_firmware: partition@60000 { compatible = "denx,uimage"; label = "firmware"; reg = <0x060000 0xfa0000>; }; + + nor_kernel: partition_alt@60000 { + label = "kernel"; + reg = <0x060000 0x200000>; + }; + + nor_rootfs: parition_alt@260000 { + label = "nor_rootfs"; + reg = <0x260000 0xda0000>; + }; }; }; -}; -&pcie { - status = "okay"; -}; + flash_nand: flash@1 { + compatible = "spi-nand"; + reg = <1>; + spi-max-frequency = <25000000>; -&uart { - status = "okay"; + nand_partitions: partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + nand_ubi: partition@0 { + label = "ubi"; + reg = <0x000000 0x8000000>; + }; + }; + }; }; -&usb0 { - #address-cells = <1>; - #size-cells = <0>; +ð0 { status = "okay"; - hub_port: port@1 { - reg = <1>; - #trigger-source-cells = <0>; - }; + phy-handle = <&phy0>; + mtd-mac-address = <&art 0x0>; }; -&usb_phy0 { - status = "okay"; +&gpio { + usb_power { + gpio-hog; + gpios = <7 GPIO_ACTIVE_HIGH>; + output-high; + line-name = "usb-power"; + }; }; &mdio0 { status = "okay"; + phy-mask = <0>; phy0: ethernet-phy@0 { @@ -141,15 +174,33 @@ }; }; -ð0 { +&pcie { status = "okay"; +}; - mtd-mac-address = <&art 0x0>; - phy-handle = <&phy0>; +&uart { + status = "okay"; +}; + +&usb0 { + status = "okay"; +}; + +&usb1 { + status = "okay"; +}; + +&usb_phy0 { + status = "okay"; +}; + +&usb_phy1 { + status = "okay"; }; &wmac { status = "okay"; + mtd-cal-data = <&art 0x1000>; mtd-mac-address = <&art 0x1002>; }; diff --git a/target/linux/ath79/image/generic.mk b/target/linux/ath79/image/generic.mk index 8e162e1d0e..0982a80460 100644 --- a/target/linux/ath79/image/generic.mk +++ b/target/linux/ath79/image/generic.mk @@ -360,14 +360,14 @@ define Device/glinet_gl-ar300m-nor endef TARGET_DEVICES += glinet_gl-ar300m-nor -define Device/glinet_gl-ar750s +define Device/glinet_gl-ar750s-nor ATH_SOC := qca9563 DEVICE_TITLE := GL.iNet GL-AR750S DEVICE_PACKAGES := kmod-usb2 kmod-ath10k-ct ath10k-firmware-qca9887-ct IMAGE_SIZE := 16000k - SUPPORTED_DEVICES += gl-ar750s + SUPPORTED_DEVICES += gl-ar750s glinet_gl-ar750s endef -TARGET_DEVICES += glinet_gl-ar750s +TARGET_DEVICES += glinet_gl-ar750s-nor define Device/glinet_gl-x750 ATH_SOC := qca9531 diff --git a/target/linux/ath79/image/nand.mk b/target/linux/ath79/image/nand.mk index e69de29bb2..7db5f51c98 100644 --- a/target/linux/ath79/image/nand.mk +++ b/target/linux/ath79/image/nand.mk @@ -0,0 +1,15 @@ +define Device/glinet_gl-ar750s-nand + ATH_SOC := qca9563 + DEVICE_TITLE := GL.iNet GL-AR750S + DEVICE_PACKAGES := kmod-usb2 kmod-ath10k-ct ath10k-firmware-qca9887-ct kmod-i2c-gpio + KERNEL_SIZE := 2048k + BLOCKSIZE := 128k + PAGESIZE := 2048 + VID_HDR_OFFSET := 2048 + IMAGES += factory.img + IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata + IMAGE/factory.img := append-kernel | pad-to $$$$(KERNEL_SIZE) | append-ubi + SUPPORTED_DEVICES += gl-ar750s +endef +TARGET_DEVICES += glinet_gl-ar750s-nand +