[OpenWrt-Devel] [PATCH v2] ar71xx: add support for RB SXTsq 2nD

Thibaut VARÈNE hacks at slashdirt.org
Sun Mar 15 06:34:51 EDT 2020


[no change, commit msg update: fixed installation instructions]

This patch adds support for the MikroTik RouterBOARD SXTsq Lite2
https://mikrotik.com/product/sxtsq_lite2

Specifications:
- SoC: Qualcomm QCA9533 (650MHz)
- RAM: 64MB
- Storage: 16MB SPI NOR flash
- Wireless: QCA9533 built-in, dual-chain 802.11b/g/n
- Ethernet: 1x100M

Note: the reset button shares its GPIO with the last RSSI LED:
this is not supported, the last LED is thus disabled (reset works).
That aside, the device is fully supported.

Installation:
(Standard Mikrotik TFTP)

1. Setup a DHCP/BOOTP Server with the following parameters:
   * DHCP-Option 66 (TFTP server name): pointing to a local TFTP
     server within the same subnet of the DHCP range
   * DHCP-Option 67 (Bootfile-Name): matching the initramfs filename
     of the to be booted image. The usable intramfs files are:
       - openwrt-ar71xx-mikrotik-vmlinux-initramfs.elf
       - openwrt-ar71xx-mikrotik-vmlinux-initramfs-lzma.elf
       - openwrt-ar71xx-mikrotik-rb-nor-flash-16M-initramfs-kernel.bin

2. Press the reset button on the board and keep that pressed.

3. Connect the board to your local network via its ethernet port.

4. Release the button after the LEDs on the board are turned off.
   Now the board should load and start the initramfs image from
   the TFTP server.

5. Upload the sysupgrade image to the board with scp:
     $ scp openwrt-ar71xx-mikrotik-rb-nor-flash-16M-squashfs-sysupgrade.bin root at 192.168.1.1:/tmp/fw.bin

6. Log in to the running system listening on 192.168.1.1 via ssh
   as root (without password):
     $ ssh root at 192.168.1.1

7. Flash the uploaded firmware file from the ssh session via the
   sysupgrade command:
     root at OpenWrt:~# sysupgrade /tmp/fw.bin

Signed-off-by: Thibaut VARÈNE <hacks at slashdirt.org>
---
 target/linux/ar71xx/base-files/etc/board.d/01_leds |  3 +-
 .../linux/ar71xx/base-files/etc/board.d/02_network |  1 +
 target/linux/ar71xx/base-files/etc/diag.sh         |  1 +
 target/linux/ar71xx/base-files/lib/ar71xx.sh       |  3 +
 .../ar71xx/base-files/lib/upgrade/platform.sh      |  2 +
 .../ar71xx/files/arch/mips/ath79/Kconfig.openwrt   |  1 +
 .../ar71xx/files/arch/mips/ath79/mach-rbspi.c      | 78 +++++++++++++++++++++-
 .../linux/ar71xx/files/arch/mips/ath79/machtypes.h |  1 +
 target/linux/ar71xx/image/mikrotik.mk              |  2 +-
 9 files changed, 89 insertions(+), 3 deletions(-)

diff --git a/target/linux/ar71xx/base-files/etc/board.d/01_leds b/target/linux/ar71xx/base-files/etc/board.d/01_leds
index 54727a6e52..4d50f489d5 100755
--- a/target/linux/ar71xx/base-files/etc/board.d/01_leds
+++ b/target/linux/ar71xx/base-files/etc/board.d/01_leds
@@ -683,7 +683,8 @@ rb-2011uias-2hnd-r2)
 	ucidef_set_led_switch "eth9" "ETH9" "rb:green:eth9" "switch1" "0x04"
 	ucidef_set_led_switch "eth10" "ETH10" "rb:green:eth10" "switch1" "0x02"
 	;;
-rb-lhg-5nd)
+rb-lhg-5nd|\
+rb-sxtsq-2nd)
 	ucidef_set_led_netdev "lan" "LAN" "rb:green:eth" "eth0"
 	ucidef_set_rssimon "wlan0" "200000" "1"
 	ucidef_set_led_rssi "rssilow" "RSSILOW" "rb:green:rssi0" "wlan0" "1" "100" "0" "13"
diff --git a/target/linux/ar71xx/base-files/etc/board.d/02_network b/target/linux/ar71xx/base-files/etc/board.d/02_network
index 1487ff58de..1334e48e7a 100755
--- a/target/linux/ar71xx/base-files/etc/board.d/02_network
+++ b/target/linux/ar71xx/base-files/etc/board.d/02_network
@@ -116,6 +116,7 @@ ar71xx_setup_interfaces()
 	rb-sxt2n|\
 	rb-sxt-2nd-r3|\
 	rb-sxt5n|\
+	rb-sxtsq-2nd|\
 	rb-wap-2nd|\
 	rb-wapr-2nd|\
 	rb-wapg-5hact2hnd|\
diff --git a/target/linux/ar71xx/base-files/etc/diag.sh b/target/linux/ar71xx/base-files/etc/diag.sh
index c5fe5bdcc1..b0e56fda8a 100644
--- a/target/linux/ar71xx/base-files/etc/diag.sh
+++ b/target/linux/ar71xx/base-files/etc/diag.sh
@@ -381,6 +381,7 @@ get_status_led() {
 	rb-map-2nd|\
 	rb-mapl-2nd|\
 	rb-sxt-2nd-r3|\
+	rb-sxtsq-2nd|\
 	rb-wap-2nd|\
 	rb-wapr-2nd)
 		status_led="rb:green:user"
diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh
index 044ef4eae5..cf792783c4 100755
--- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
+++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
@@ -542,6 +542,9 @@ mikrotik_board_detect() {
 	*"SXT Lite5")
 		name="rb-sxt5n"
 		;;
+	*"SXTsq 2nD")
+		name="rb-sxtsq-2nd"
+		;;
 	*"wAP 2nD r2")
 		name="rb-wap-2nd"
 		;;
diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
index a76842bdde..618fb3b8ca 100755
--- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
+++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
@@ -726,6 +726,7 @@ platform_check_image() {
 	rb-map-2nd|\
 	rb-mapl-2nd|\
 	rb-sxt-2nd-r3|\
+	rb-sxtsq-2nd|\
 	rb-wap-2nd|\
 	rb-wapg-5hact2hnd|\
 	rb-wapr-2nd)
@@ -786,6 +787,7 @@ platform_do_upgrade() {
 	rb-map-2nd|\
 	rb-mapl-2nd|\
 	rb-sxt-2nd-r3|\
+	rb-sxtsq-2nd|\
 	rb-wap-2nd|\
 	rb-wapg-5hact2hnd|\
 	rb-wapr-2nd)
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
index 6fd78c46a0..3657f9ca49 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
+++ b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
@@ -1189,6 +1189,7 @@ config ATH79_MACH_RBSPI
 	  MikroTik RouterBOARD LHG 5
 	  MikroTik RouterBOARD cAP (EXPERIMENTAL)
 	  MikroTik RouterBOARD SXT Lite 2 r3
+	  MikroTik RouterBOARD STXsq Lite2
 	  MikroTik RouterBOARD wAP
 	  MikroTik RouterBOARD wAP R-2nD
 
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-rbspi.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-rbspi.c
index 6bb42c78e3..bf4518698e 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/mach-rbspi.c
+++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-rbspi.c
@@ -14,6 +14,7 @@
  *  - MikroTik RouterBOARD 750P-PBr2
  *  - MikroTik RouterBOARD 750 r2
  *  - MikroTik RouterBOARD LHG 5nD
+ *  - MikroTik RouterBOARD SXTsq 2nD
  *  - MikroTik RouterBOARD wAP2nD
  *  - MikroTik RouterBOARD wAP G-5HacT2HnDwAP (wAP AC)
  *  - MikroTik RouterBOARD wAP R-2nD
@@ -24,7 +25,7 @@
  *  hardware as the mAP L-2nD. It is unknown if they share the same board
  *  identifier.
  *
- *  Copyright (C) 2017-2018 Thibaut VARENE <varenet at parisc-linux.org>
+ *  Copyright (C) 2017-2020 Thibaut VARENE <varenet at parisc-linux.org>
  *  Copyright (C) 2016 David Hutchison <dhutchison at bluemesh.net>
  *  Copyright (C) 2017 Ryan Mounce <ryan at mounce.com.au>
  *
@@ -479,6 +480,55 @@ static struct gpio_led rblhg_leds[] __initdata = {
 	},
 };
 
+/* RB SXTsq 2nD gpios */
+#define RBSXTSQ_GPIO_LED_0	11
+#define RBSXTSQ_GPIO_LED_1	9
+#define RBSXTSQ_GPIO_LED_2	12
+#define RBSXTSQ_GPIO_LED_3	13
+#define RBSXTSQ_GPIO_LED_4	16	// shared with reset button
+#define RBSXTSQ_GPIO_LED_ETH	4
+#define RBSXTSQ_GPIO_LED_POWER	17
+#define RBSXTSQ_GPIO_LED_USER	14
+#define RBSXTSQ_GPIO_BTN_RESET	16
+
+static struct gpio_led rbsxtsq_leds[] __initdata = {
+	{
+		.name = "rb:green:rssi0",
+		.gpio = RBSXTSQ_GPIO_LED_0,
+		.active_low = 1,
+	}, {
+		.name = "rb:green:rssi1",
+		.gpio = RBSXTSQ_GPIO_LED_1,
+		.active_low = 1,
+	}, {
+		.name = "rb:green:rssi2",
+		.gpio = RBSXTSQ_GPIO_LED_2,
+		.active_low = 1,
+	}, {
+		.name = "rb:green:rssi3",
+		.gpio = RBSXTSQ_GPIO_LED_3,
+		.active_low = 1,
+/*	}, {
+		// LED_4 GPIO is shared with reset button => Do not register this LED
+		.name = "rb:green:rssi4",
+		.gpio = RBSXTSQ_GPIO_LED_4,
+		.active_low = 1,
+*/	}, {
+		.name = "rb:green:eth",
+		.gpio = RBSXTSQ_GPIO_LED_ETH,
+		.active_low = 1,
+	}, {
+		.name = "rb:green:user",
+		.gpio = RBSXTSQ_GPIO_LED_USER,
+		.active_low = 1,
+	}, {
+		.name = "rb:green:power",
+		.gpio = RBSXTSQ_GPIO_LED_POWER,
+		.active_low = 0,
+		.default_state = LEDS_GPIO_DEFSTATE_ON,
+	},
+};
+
 /* RB w APG-5HacT2HnD (wAP AC) gpios*/
 #define RBWAPGSC_WIFI_LED_1		1
 #define RBWAPGSC_WIFI_LED_2		8
@@ -1021,6 +1071,31 @@ static void __init rblhg_setup(void)
 }
 
 /*
+ * Init the SXTsq Lite2 (QCA9533).
+ * This device has a single ethernet port connected to PHY0.
+ * Wireless is provided via 2.4GHz WLAN1.
+ */
+static void __init rbsxtsq_setup(void)
+{
+	u32 flags = RBSPI_HAS_WLAN1;
+
+	if (!rbspi_platform_setup())
+		return;
+
+	rbspi_peripherals_setup(flags);
+
+	/* GMAC1 is HW MAC, WLAN1 MAC is HW MAC + 1 */
+	rbspi_network_setup(flags, 0, 0, 1);
+
+	ath79_register_leds_gpio(-1, ARRAY_SIZE(rbsxtsq_leds), rbsxtsq_leds);
+
+	/* Make the eth LED controllable by software. */
+	ath79_gpio_output_select(RBSXTSQ_GPIO_LED_ETH, AR934X_GPIO_OUT_GPIO);
+
+	rbspi_register_reset_button(RBSXTSQ_GPIO_BTN_RESET);
+}
+
+/*
  * Init the wAP hardware.
  * The wAP 2nD has a single ethernet port.
  */
@@ -1260,3 +1335,4 @@ MIPS_MACHINE_NONAME(ATH79_MACH_RB_CAP, "cap-hb", rbcap_setup);
 MIPS_MACHINE_NONAME(ATH79_MACH_RB_MAP, "map2-hb", rbmap_setup);
 MIPS_MACHINE_NONAME(ATH79_MACH_RB_WAPAC, "wapg-sc", rbwapgsc_setup);
 MIPS_MACHINE_NONAME(ATH79_MACH_RB_931, "931", rb931_setup);
+MIPS_MACHINE_NONAME(ATH79_MACH_RB_SXTSQL2, "lhg-hb", rbsxtsq_setup);
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
index 900b4ec87b..7954a62835 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
+++ b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
@@ -233,6 +233,7 @@ enum ath79_mach_type {
 	ATH79_MACH_RB_WAPAC,			/* Mikrotik RouterBOARD wAPG-5HacT2HnD */
 	ATH79_MACH_RB_SXTLITE2ND,		/* Mikrotik RouterBOARD SXT Lite 2nD */
 	ATH79_MACH_RB_SXTLITE5ND,		/* Mikrotik RouterBOARD SXT Lite 5nD */
+	ATH79_MACH_RB_SXTSQL2,			/* Mikrotik RouterBOARD SXTsq 2nD */
 	ATH79_MACH_RE355,			/* TP-LINK RE355 */
 	ATH79_MACH_RE450,			/* TP-LINK RE450 */
 	ATH79_MACH_RME_EG200,			/* eTactica EG200 */
diff --git a/target/linux/ar71xx/image/mikrotik.mk b/target/linux/ar71xx/image/mikrotik.mk
index dbbccb1c3f..d23e26c069 100644
--- a/target/linux/ar71xx/image/mikrotik.mk
+++ b/target/linux/ar71xx/image/mikrotik.mk
@@ -46,7 +46,7 @@ define Device/rb-nor-flash-16M
   DEVICE_PACKAGES := rbcfg rssileds -nand-utils kmod-ledtrig-gpio
   IMAGE_SIZE := 16000k
   KERNEL_INSTALL := 1
-  SUPPORTED_DEVICES := rb-750-r2 rb-750up-r2 rb-750p-pbr2 rb-911-2hn rb-911-5hn rb-931-2nd rb-941-2nd rb-951ui-2nd rb-952ui-5ac2nd rb-962uigs-5hact2hnt rb-lhg-5nd rb-map-2nd rb-mapl-2nd rb-wap-2nd rb-wapr-2nd rb-sxt-2nd-r3
+  SUPPORTED_DEVICES := rb-750-r2 rb-750up-r2 rb-750p-pbr2 rb-911-2hn rb-911-5hn rb-931-2nd rb-941-2nd rb-951ui-2nd rb-952ui-5ac2nd rb-962uigs-5hact2hnt rb-lhg-5nd rb-map-2nd rb-mapl-2nd rb-wap-2nd rb-wapr-2nd rb-sxt-2nd-r3 rb-sxtsq-2nd
   IMAGE/sysupgrade.bin := append-kernel | kernel2minor -s 1024 -e | pad-to $$$$(BLOCKSIZE) | \
 	append-rootfs | pad-rootfs | append-metadata | check-size $$$$(IMAGE_SIZE)
 endef
-- 
2.11.0


_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list