ath79: add support for Atheros PB42 reference board
authorZoltan HERPAI <wigyori@uid0.hu>
Sun, 13 Dec 2020 00:37:56 +0000 (01:37 +0100)
committerZoltan HERPAI <wigyori@uid0.hu>
Thu, 3 Feb 2022 09:37:34 +0000 (10:37 +0100)
Specifications:

SoC: AR7130
DRAM: 32Mb DDR1
Flash: 8Mb SPI-NOR
LAN: 4x 10/100Mbps via ADM6996 switch on MII
WAN: 1x 10/100Mbps via RMII
PCI: 2x mini-PCI
UART: standard QCA UART header
JTAG: yes
Button: 1x WPS, 1x reset
LEDs: 8x LEDs

Installation instructions:

The original FIS partitioning does not provide enough
space for the kernel, so the installation must start
with re-partitioning the flash from RedBoot.

The suggested partition table is the following:

RedBoot           0xBF000000  0xBF000000  0x00040000  0x00000000
kernel            0xBF040000  0x80060000  0x001F0000  0x80060000
rootfs            0xBF230000  0x00000000  0x005B0000  0x00000000
FIS directory     0xBF7E0000  0xBF7E0000  0x0000F000  0x00000000
RedBoot config    0xBF7EF000  0xBF7EF000  0x00001000  0x00000000

Which can be created with:
fis init
fis create -r 0x80060000 -e 0x80060000 -b 0xbf040000 -l 0x220000 kernel
fis create -b 0xbf260000 -l 0x580000 rootfs

The kernel and the rootfs must then be loaded from TFTP:

load -r -v -b 0x80060000 openwrt-ath79-generic-atheros_pb42-squashfs-kernel.bin
fis create kernel
load -r -v -b 0x80100000 openwrt-ath79-generic-atheros_pb42-squashfs-rootfs.bin
fis create rootfs

Once OpenWrt is installed, the normal sysupgrade method will work for
upgrades.

The MAC address is stored in the "boardconfig" partition, which is
automatically created.

Signed-off-by: Zoltan HERPAI <wigyori@uid0.hu>
target/linux/ath79/dts/ar7130_atheros_pb42.dts [new file with mode: 0644]
target/linux/ath79/generic/base-files/etc/board.d/01_leds
target/linux/ath79/generic/base-files/etc/board.d/02_network
target/linux/ath79/generic/base-files/lib/upgrade/platform.sh
target/linux/ath79/image/generic.mk
target/linux/ath79/patches-5.10/940-redboot_boardconfig.patch [new file with mode: 0644]

diff --git a/target/linux/ath79/dts/ar7130_atheros_pb42.dts b/target/linux/ath79/dts/ar7130_atheros_pb42.dts
new file mode 100644 (file)
index 0000000..8f01fcf
--- /dev/null
@@ -0,0 +1,106 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+
+#include "ar7100.dtsi"
+
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+
+/ {
+       compatible = "atheros,pb42", "qca,ar7130";
+       model = "Atheros PB42 reference board";
+
+       aliases {
+               led-boot = &led_system;
+               led-failsafe = &led_system;
+               led-running = &led_system;
+               led-upgrade = &led_system;
+       };
+
+       extosc: ref {
+               compatible = "fixed-clock";
+               #clock-cells = <0>;
+               clock-output-names = "ref";
+               clock-frequency = <40000000>;
+       };
+
+       leds {
+               compatible = "gpio-leds";
+
+               led_system: system {
+                       label = "green:system";
+                       gpios = <&gpio 2 GPIO_ACTIVE_HIGH>;
+               };
+
+               led_ds1a: ds1a {
+                       label = "green:ds1a";
+                       gpios = <&gpio 5 GPIO_ACTIVE_HIGH>;
+               };
+
+               led_ds1b: ds1b {
+                       label = "green:ds1b";
+                       gpios = <&gpio 4 GPIO_ACTIVE_HIGH>;
+               };
+       };
+
+       keys {
+               compatible = "gpio-keys";
+
+               wps {
+                       label = "sw4";
+                       linux,code = <KEY_WPS_BUTTON>;
+                       gpios = <&gpio 8 GPIO_ACTIVE_LOW>;
+                       debounce-interval = <60>;
+               };
+
+               reset {
+                       label = "reset";
+                       gpios = <&gpio 3 GPIO_ACTIVE_LOW>;
+                       linux,code = <KEY_RESTART>;
+                       debounce-interval = <60>;
+               };
+       };
+};
+
+&pcie0 {
+       status = "okay";
+};
+
+&spi {
+       status = "okay";
+
+       flash@0 {
+               compatible = "jedec,spi-nor";
+               reg = <0>;
+               spi-max-frequency = <25000000>;
+
+               partitions {
+                       compatible = "ecoscentric,redboot-fis-partitions";
+               };
+       };
+};
+
+&uart {
+       status = "okay";
+};
+
+&eth0 {
+       status = "okay";
+
+       phy-mode = "mii";
+
+       fixed-link {
+               speed = <100>;
+               full-duplex;
+       };
+};
+
+&eth1 {
+       status = "okay";
+
+       phy-mode = "rmii";
+
+       fixed-link {
+               speed = <100>;
+               full-duplex;
+       };
+};
index faf8aebe7481ce5cbd0e78f64b25cbbf1ae5cc26..87ddf78a2978f9e188eb49070c31f583d88e3018 100644 (file)
@@ -58,6 +58,10 @@ asus,rp-ac66)
        ucidef_set_led_rssi "rssimedium-wlan1" "RSSIMEDIUM" "red:rssimedium-wlan1" "wlan1" "1" "79"
        ucidef_set_led_rssi "rssihigh-wlan1" "RSSIHIGH" "green:rssihigh-wlan1" "wlan1" "70" "100"
        ;;
+atheros,pb42)
+       ucidef_set_led_wlan "ds1a" "DS1A" "green:ds1a" "phy0tpt"
+       ucidef_set_led_wlan "ds1a" "DS1B" "green:ds1b" "phy1tpt"
+       ;;
 avm,fritz1750e)
        ucidef_set_led_netdev "lan" "LAN" "green:lan" "eth0"
        ucidef_set_rssimon "wlan1" "200000" "1"
index 341764d20505e23e01d4d51a14528684ff35f1e8..a9d18c986bda6d95d09acabe47539af3cb9aa357 100644 (file)
@@ -126,6 +126,8 @@ ath79_setup_interfaces()
                        "0@eth0" "2:lan" "3:lan" "4:lan" "5:lan" "1:wan"
                ucidef_add_switch "switch1" \
                        "0@eth1" "1:lan" "2:lan" "3:lan" "4:lan" "5:lan"
+       atheros,pb42)
+               ucidef_set_interfaces_lan_wan "eth1" "eth0"
                ;;
        avm,fritz4020|\
        pcs,cr3000|\
@@ -540,6 +542,10 @@ ath79_setup_macs()
                lan_mac=$(macaddr_setbit $base_mac 29)
                [ $lan_mac = $base_mac ] && lan_mac=$(macaddr_unsetbit $base_mac 29)
                ;;
+       atheros,pb42)
+               lan_mac=$(mtd_get_mac_binary "boardconfig" 0x1000)
+               wan_mac=$(mtd_get_mac_binary "boardconfig" 0x1006)
+               ;;
        avm,fritz1750e|\
        avm,fritz450e|\
        avm,fritzdvbc)
index 67e53c5fdebf29e71b920753be829fa4e41ca207..7c7302023f446041caed7969d89ad4587ac1f763 100644 (file)
@@ -62,6 +62,11 @@ platform_do_upgrade() {
                ROOTFS_FILE="root.squashfs"
                platform_do_upgrade_failsafe_datachk "$1"
                ;;
+       atheros,pb42|\
+       ubnt,routerstation|\
+       ubnt,routerstation-pro)
+               redboot_fis_do_upgrade "$1" kernel
+               ;;
        jjplus,ja76pf2)
                redboot_fis_do_upgrade "$1" linux
                ;;
@@ -93,10 +98,6 @@ platform_do_upgrade() {
                PART_NAME="inactive"
                platform_do_upgrade_dualboot_datachk "$1"
                ;;
-       ubnt,routerstation|\
-       ubnt,routerstation-pro)
-               redboot_fis_do_upgrade "$1" kernel
-               ;;
        *)
                default_do_upgrade "$1"
                ;;
index b3598a2000c9bf1adc8dc1f96f4ca5d3485f45a7..5d3830e52054933333f0fac08cd53c7600f272d1 100644 (file)
@@ -360,6 +360,21 @@ define Device/atheros_db120
 endef
 TARGET_DEVICES += atheros_db120
 
+define Device/atheros_pb42
+  SOC := ar7130
+  DEVICE_VENDOR := Atheros
+  DEVICE_MODEL := PB42
+  IMAGE_SIZE := 7808k
+  IMAGES += kernel.bin rootfs.bin
+  IMAGE/kernel.bin := append-kernel
+  IMAGE/rootfs.bin := append-rootfs | pad-rootfs
+  IMAGE/sysupgrade.bin := append-rootfs | pad-rootfs | combined-image | \
+       append-metadata | check-size
+  KERNEL := kernel-bin | append-dtb | lzma | pad-to $$(BLOCKSIZE)
+  SUPPORTED_DEVICES += pb42
+endef
+TARGET_DEVICES += atheros_pb42
+
 define Device/avm
   DEVICE_VENDOR := AVM
   KERNEL := kernel-bin | append-dtb | lzma | eva-image
diff --git a/target/linux/ath79/patches-5.10/940-redboot_boardconfig.patch b/target/linux/ath79/patches-5.10/940-redboot_boardconfig.patch
new file mode 100644 (file)
index 0000000..4dd740d
--- /dev/null
@@ -0,0 +1,60 @@
+--- a/drivers/mtd/parsers/redboot.c
++++ b/drivers/mtd/parsers/redboot.c
+@@ -30,6 +30,8 @@
+ #include <linux/mtd/partitions.h>
+ #include <linux/module.h>
++#define BOARD_CONFIG_PART             "boardconfig"
++
+ struct fis_image_desc {
+     unsigned char name[16];      // Null terminated name
+     uint32_t    flash_base;    // Address within FLASH of image
+@@ -60,6 +62,7 @@ static int parse_redboot_partitions(stru
+                                   const struct mtd_partition **pparts,
+                                   struct mtd_part_parser_data *data)
+ {
++      unsigned long max_offset = 0;
+       int nrparts = 0;
+       struct fis_image_desc *buf;
+       struct mtd_partition *parts;
+@@ -225,14 +228,15 @@ static int parse_redboot_partitions(stru
+               }
+       }
+ #endif
+-      parts = kzalloc(sizeof(*parts)*nrparts + nulllen + namelen, GFP_KERNEL);
++      parts = kzalloc(sizeof(*parts) * (nrparts + 1) + nulllen + namelen +
++                      sizeof(BOARD_CONFIG_PART), GFP_KERNEL);
+       if (!parts) {
+               ret = -ENOMEM;
+               goto out;
+       }
+-      nullname = (char *)&parts[nrparts];
++      nullname = (char *)&parts[nrparts + 1];
+ #ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED
+       if (nulllen > 0) {
+               strcpy(nullname, nullstring);
+@@ -251,6 +255,8 @@ static int parse_redboot_partitions(stru
+       }
+ #endif
+       for ( ; i<nrparts; i++) {
++              if (max_offset < buf[i].flash_base + buf[i].size)
++                      max_offset = buf[i].flash_base + buf[i].size;
+               parts[i].size = fl->img->size;
+               parts[i].offset = fl->img->flash_base;
+               parts[i].name = names;
+@@ -284,6 +290,13 @@ static int parse_redboot_partitions(stru
+               fl = fl->next;
+               kfree(tmp_fl);
+       }
++      if (master->size - max_offset >= master->erasesize) {
++              parts[nrparts].size = master->size - max_offset;
++              parts[nrparts].offset = max_offset;
++              parts[nrparts].name = names;
++              strcpy(names, BOARD_CONFIG_PART);
++              nrparts++;
++      }
+       ret = nrparts;
+       *pparts = parts;
+  out: