From 8813edd8d9695d4e3939fdaa3c530c682f91de11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Wed, 14 Jun 2023 23:21:34 +0200 Subject: [PATCH 01/12] kernel: mtd: bcm-wfi: add cferam name support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some devices rename cferam bootloader using specific patterns and don't follow broadcom standards for renaming cferam files. This requires supporting different cferam file names. Signed-off-by: Álvaro Fernández Rojas --- .../drivers/mtd/mtdsplit/mtdsplit_bcm_wfi.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_bcm_wfi.c b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_bcm_wfi.c index 1ddcf6745f..1cafc91fde 100644 --- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_bcm_wfi.c +++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_bcm_wfi.c @@ -31,6 +31,7 @@ #define CFERAM_NAME "cferam" #define CFERAM_NAME_LEN (sizeof(CFERAM_NAME) - 1) +#define CFERAM_NAME_MAX_LEN 32 #define KERNEL_NAME "vmlinux.lz" #define KERNEL_NAME_LEN (sizeof(KERNEL_NAME) - 1) #define OPENWRT_NAME "1-openwrt" @@ -157,17 +158,28 @@ static int parse_bcm_wfi(struct mtd_info *master, const struct mtd_partition **pparts, uint8_t *buf, loff_t off, loff_t size, bool cfe_part) { + struct device_node *mtd_node; struct mtd_partition *parts; loff_t cfe_off, kernel_off, rootfs_off; unsigned int num_parts = BCM_WFI_PARTS, cur_part = 0; + const char *cferam_name = CFERAM_NAME; + size_t cferam_name_len; int ret; + mtd_node = mtd_get_of_node(master); + if (mtd_node) + of_property_read_string(mtd_node, "brcm,cferam", &cferam_name); + + cferam_name_len = strnlen(cferam_name, CFERAM_NAME_MAX_LEN); + if (cferam_name_len > 0) + cferam_name_len--; + if (cfe_part) { num_parts++; cfe_off = off; - ret = jffs2_find_file(master, buf, CFERAM_NAME, - CFERAM_NAME_LEN, &cfe_off, + ret = jffs2_find_file(master, buf, cferam_name, + cferam_name_len, &cfe_off, size - (cfe_off - off), NULL, NULL); if (ret) return ret; From 915e914cfaa243ea36f8c7a4f0f045ec890304fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Wed, 14 Jun 2023 23:23:14 +0200 Subject: [PATCH 02/12] bmips: fix NETGEAR DGND3700v2 boot loop MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The DGND3700v2 renames the cferam bootloader from cferam to cfeXXX, where XXX is the number of firmware upgrades performed by the bootloader. Other bcm63xx devices rename cferam.000 to cferam.XXX, but this device is special because the cferam name isn't changed on the first firmware flashing but it's changed on the subsequent ones. Therefore, we need to look for "cfe" instead of "cferam" to properly detect the cferam partition and fix the bootlop. Signed-off-by: Álvaro Fernández Rojas --- target/linux/bmips/dts/bcm6362-netgear-dgnd3700-v2.dts | 1 + 1 file changed, 1 insertion(+) diff --git a/target/linux/bmips/dts/bcm6362-netgear-dgnd3700-v2.dts b/target/linux/bmips/dts/bcm6362-netgear-dgnd3700-v2.dts index 46bb3e8bf6..a335218be0 100644 --- a/target/linux/bmips/dts/bcm6362-netgear-dgnd3700-v2.dts +++ b/target/linux/bmips/dts/bcm6362-netgear-dgnd3700-v2.dts @@ -222,6 +222,7 @@ compatible = "brcm,wfi"; label = "wfi"; reg = <0x0004000 0x1c7c000>; + brcm,cferam = "cfe"; }; partition@1c80000 { From cdfcac6e246de9f237d1425e498db3f34ddebbaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Wed, 14 Jun 2023 23:27:29 +0200 Subject: [PATCH 03/12] bcm63xx: fix NETGEAR DGND3700v2 boot loop MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The DGND3700v2 renames the cferam bootloader from cferam to cfeXXX, where XXX is the number of firmware upgrades performed by the bootloader. Other bcm63xx devices rename cferam.000 to cferam.XXX, but this device is special because the cferam name isn't changed on the first firmware flashing but it's changed on the subsequent ones. Therefore, we need to look for "cfe" instead of "cferam" to properly detect the cferam partition and fix the bootlop. Signed-off-by: Álvaro Fernández Rojas --- target/linux/bcm63xx/dts/bcm6362-netgear-dgnd3700-v2.dts | 1 + 1 file changed, 1 insertion(+) diff --git a/target/linux/bcm63xx/dts/bcm6362-netgear-dgnd3700-v2.dts b/target/linux/bcm63xx/dts/bcm6362-netgear-dgnd3700-v2.dts index 50133265f7..4bef5908e0 100644 --- a/target/linux/bcm63xx/dts/bcm6362-netgear-dgnd3700-v2.dts +++ b/target/linux/bcm63xx/dts/bcm6362-netgear-dgnd3700-v2.dts @@ -167,6 +167,7 @@ compatible = "brcm,wfi"; label = "wfi"; reg = <0x0004000 0x1c7c000>; + brcm,cferam = "cfe"; }; partition@1c80000 { From 434df8df549a4d709be9eb19c0d2bd8abb4d4881 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Thu, 15 Jun 2023 10:46:10 +0200 Subject: [PATCH 04/12] base-files: upgrade: nand: add JFFS2 cleanmarkers support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some Broadcom MIPS devices require JFFS2 cleanmarkers to be present on the kernel partition or the bootloader will identify the partition as corrupt and won't boot the kernel. Signed-off-by: Álvaro Fernández Rojas --- package/base-files/files/lib/upgrade/nand.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/package/base-files/files/lib/upgrade/nand.sh b/package/base-files/files/lib/upgrade/nand.sh index fa29d575a8..d910bf1791 100644 --- a/package/base-files/files/lib/upgrade/nand.sh +++ b/package/base-files/files/lib/upgrade/nand.sh @@ -301,6 +301,7 @@ nand_upgrade_fit() { nand_upgrade_tar() { local tar_file="$1" local gz="$2" + local jffs2_markers="${CI_JFFS2_CLEAN_MARKERS:-0}" # WARNING: This fails if tar contains more than one 'sysupgrade-*' directory. local board_dir="$(tar t${gz}f "$tar_file" | grep -m 1 '^sysupgrade-.*/$')" @@ -329,6 +330,7 @@ nand_upgrade_tar() { ubi_kernel_length="$kernel_length" fi fi + local has_env=0 nand_upgrade_prepare_ubi "$rootfs_length" "$rootfs_type" "$ubi_kernel_length" "$has_env" || return 1 @@ -340,8 +342,14 @@ nand_upgrade_tar() { fi if [ "$kernel_length" ]; then if [ "$kernel_mtd" ]; then - tar xO${gz}f "$tar_file" "$board_dir/kernel" | \ - mtd write - "$CI_KERNPART" + if [ "$jffs2_markers" = 1 ]; then + flash_erase -j "/dev/mtd${kernel_mtd}" 0 0 + tar xO${gz}f "$tar_file" "$board_dir/kernel" | \ + nandwrite "/dev/mtd${kernel_mtd}" - + else + tar xO${gz}f "$tar_file" "$board_dir/kernel" | \ + mtd write - "$CI_KERNPART" + fi else local ubidev="$( nand_find_ubi "${CI_KERN_UBIPART:-$CI_UBIPART}" )" local kern_ubivol="$( nand_find_volume $ubidev "$CI_KERNPART" )" From 464dfac049daecad145184f8c2dd4a46a7fdd37c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Thu, 15 Jun 2023 10:48:25 +0200 Subject: [PATCH 05/12] bmips: switch to standard nand_do_upgrade MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now that JFFS2 cleanmarkers are supported on the standard nand_do_upgrade function we can start using it on bmips. Signed-off-by: Álvaro Fernández Rojas --- .../base-files/lib/upgrade/cfe-jffs2-nand.sh | 37 ------------------- .../base-files/lib/upgrade/platform.sh | 5 +-- .../base-files/lib/upgrade/platform.sh | 2 - .../base-files/lib/upgrade/platform.sh | 5 +-- 4 files changed, 4 insertions(+), 45 deletions(-) delete mode 100644 target/linux/bmips/base-files/lib/upgrade/cfe-jffs2-nand.sh diff --git a/target/linux/bmips/base-files/lib/upgrade/cfe-jffs2-nand.sh b/target/linux/bmips/base-files/lib/upgrade/cfe-jffs2-nand.sh deleted file mode 100644 index 64b8df652b..0000000000 --- a/target/linux/bmips/base-files/lib/upgrade/cfe-jffs2-nand.sh +++ /dev/null @@ -1,37 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-or-later - -cfe_jffs2_nand_upgrade() { - local tar_file="$1" - local kernel_mtd="$(find_mtd_index $CI_KERNPART)" - - if [ -z "$kernel_mtd" ]; then - echo "$CI_KERNPART partition not found" - return 1 - fi - - local board_dir=$(tar tf $tar_file | grep -m 1 '^sysupgrade-.*/$') - board_dir=${board_dir%/} - - local kernel_length=$(tar xf $tar_file ${board_dir}/kernel -O | wc -c 2> /dev/null) - local rootfs_length=$(tar xf $tar_file ${board_dir}/root -O | wc -c 2> /dev/null) - - if [ "$kernel_length" = 0 ]; then - echo "kernel cannot be empty" - return 1 - fi - - flash_erase -j /dev/mtd${kernel_mtd} 0 0 - tar xf $tar_file ${board_dir}/kernel -O | nandwrite /dev/mtd${kernel_mtd} - - - local rootfs_type="$(identify_tar "$tar_file" ${board_dir}/root)" - - nand_upgrade_prepare_ubi "$rootfs_length" "$rootfs_type" "0" "0" - - local ubidev="$( nand_find_ubi "$CI_UBIPART" )" - - local root_ubivol="$(nand_find_volume $ubidev $CI_ROOTPART)" - tar xf $tar_file ${board_dir}/root -O | \ - ubiupdatevol /dev/$root_ubivol -s $rootfs_length - - - nand_do_upgrade_success -} diff --git a/target/linux/bmips/bcm63268/base-files/lib/upgrade/platform.sh b/target/linux/bmips/bcm63268/base-files/lib/upgrade/platform.sh index 0aaf10442b..befffd346e 100644 --- a/target/linux/bmips/bcm63268/base-files/lib/upgrade/platform.sh +++ b/target/linux/bmips/bcm63268/base-files/lib/upgrade/platform.sh @@ -1,7 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-or-later -. /lib/upgrade/cfe-jffs2-nand.sh - PART_NAME=firmware REQUIRE_IMAGE_METADATA=1 @@ -12,7 +10,8 @@ platform_check_image() { platform_do_upgrade() { case "$(board_name)" in comtrend,vr-3032u) - cfe_jffs2_nand_upgrade "$1" + CI_JFFS2_CLEAN_MARKERS=1 + nand_do_upgrade "$1" ;; sercomm,h500-s-lowi |\ sercomm,h500-s-vfes |\ diff --git a/target/linux/bmips/bcm6328/base-files/lib/upgrade/platform.sh b/target/linux/bmips/bcm6328/base-files/lib/upgrade/platform.sh index eb1d7fd0e5..1cf95be26a 100644 --- a/target/linux/bmips/bcm6328/base-files/lib/upgrade/platform.sh +++ b/target/linux/bmips/bcm6328/base-files/lib/upgrade/platform.sh @@ -1,7 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-or-later -. /lib/upgrade/cfe-jffs2-nand.sh - PART_NAME=firmware REQUIRE_IMAGE_METADATA=1 diff --git a/target/linux/bmips/bcm6362/base-files/lib/upgrade/platform.sh b/target/linux/bmips/bcm6362/base-files/lib/upgrade/platform.sh index 9175cf4255..ded966e4cc 100644 --- a/target/linux/bmips/bcm6362/base-files/lib/upgrade/platform.sh +++ b/target/linux/bmips/bcm6362/base-files/lib/upgrade/platform.sh @@ -1,7 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-or-later -. /lib/upgrade/cfe-jffs2-nand.sh - PART_NAME=firmware REQUIRE_IMAGE_METADATA=1 @@ -13,7 +11,8 @@ platform_do_upgrade() { case "$(board_name)" in huawei,hg253s-v2 |\ netgear,dgnd3700-v2) - cfe_jffs2_nand_upgrade "$1" + CI_JFFS2_CLEAN_MARKERS=1 + nand_do_upgrade "$1" ;; *) default_do_upgrade "$1" From 60fc3bc9487cbda7092e1b926467b07ea041bc60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Thu, 15 Jun 2023 10:53:08 +0200 Subject: [PATCH 06/12] bcm63xx: switch to standard nand_do_upgrade MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now that JFFS2 cleanmarkers are supported on the standard nand_do_upgrade function we can start using it on bcm63xx. Signed-off-by: Álvaro Fernández Rojas --- .../base-files/lib/upgrade/platform.sh | 39 +------------------ 1 file changed, 2 insertions(+), 37 deletions(-) diff --git a/target/linux/bcm63xx/base-files/lib/upgrade/platform.sh b/target/linux/bcm63xx/base-files/lib/upgrade/platform.sh index 0d836729ee..620e0ab4f4 100644 --- a/target/linux/bcm63xx/base-files/lib/upgrade/platform.sh +++ b/target/linux/bcm63xx/base-files/lib/upgrade/platform.sh @@ -29,42 +29,6 @@ platform_check_image() { esac } -cfe_jffs2_upgrade_tar() { - local tar_file="$1" - local kernel_mtd="$(find_mtd_index $CI_KERNPART)" - - if [ -z "$kernel_mtd" ]; then - echo "$CI_KERNPART partition not found" - return 1 - fi - - local board_dir=$(tar tf $tar_file | grep -m 1 '^sysupgrade-.*/$') - board_dir=${board_dir%/} - - local kernel_length=$(tar xf $tar_file ${board_dir}/kernel -O | wc -c 2> /dev/null) - local rootfs_length=$(tar xf $tar_file ${board_dir}/root -O | wc -c 2> /dev/null) - - if [ "$kernel_length" = 0 ]; then - echo "kernel cannot be empty" - return 1 - fi - - flash_erase -j /dev/mtd${kernel_mtd} 0 0 - tar xf $tar_file ${board_dir}/kernel -O | nandwrite /dev/mtd${kernel_mtd} - - - local rootfs_type="$(identify_tar "$tar_file" ${board_dir}/root)" - - nand_upgrade_prepare_ubi "$rootfs_length" "$rootfs_type" "0" "0" - - local ubidev="$( nand_find_ubi "$CI_UBIPART" )" - - local root_ubivol="$(nand_find_volume $ubidev $CI_ROOTPART)" - tar xf $tar_file ${board_dir}/root -O | \ - ubiupdatevol /dev/$root_ubivol -s $rootfs_length - - - nand_do_upgrade_success -} - platform_do_upgrade() { case "$(board_name)" in comtrend,vg-8050|\ @@ -72,7 +36,8 @@ platform_do_upgrade() { huawei,hg253s-v2|\ netgear,dgnd3700-v2) REQUIRE_IMAGE_METADATA=1 - cfe_jffs2_upgrade_tar "$1" + CI_JFFS2_CLEAN_MARKERS=1 + nand_do_upgrade "$1" ;; sercomm,ad1018|\ sercomm,h500-s-lowi|\ From e1a55de7a7eafd40a4fab5f29153a1a3c3606818 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Gonz=C3=A1lez=20Cabanelas?= Date: Tue, 13 Jun 2023 22:45:53 +0200 Subject: [PATCH 07/12] bmips: add support for Actiontec R1000H MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Actiontec R1000H is a gigabit wifi router, 2.4 GHz single band with two external antennas. It comes with a coaxial HomePNA port. Hardware: - SoC: Broadcom BCM6368 - CPU: dual core BMIPS4350 V3.1 @400Mhz - RAM: 64 MB DDR - Flash: 32 MB parallel NOR - LAN switch: Broadcom BCM53115, 5x 1Gbit - LAN coaxial : 1x HPNA 3.1, CG3211 + CG3213 - Wifi 2.4 GHz: Broadcom BCM4322 802.11bgn - USB: 1x 2.0 - Buttons: 2x, 1 reset - LEDs: 7x - UART: yes The HPNA hardware probably needs a firmware to make the coaxial port work. In the OEM firmware, it's apparently sent with an utility (inhpna) through the ethernet port. Installation via CFE web UI: 1. Connect the UART serial port. 2. Power on the router and press enter at the console prompt to stop the bootloader. 4. Browse to http://192.168.1.1 and upload the OpenWrt CFE firmware 5. Wait a few minutes for it to finish Signed-off-by: Daniel González Cabanelas --- .../bcm6368/base-files/etc/board.d/01_leds | 4 + .../bcm6368/base-files/etc/board.d/02_network | 1 + .../base-files/etc/uci-defaults/09_fix_crc | 1 + .../bmips/dts/bcm6368-actiontec-r1000h.dts | 220 ++++++++++++++++++ target/linux/bmips/image/bcm6368.mk | 15 ++ 5 files changed, 241 insertions(+) create mode 100644 target/linux/bmips/dts/bcm6368-actiontec-r1000h.dts diff --git a/target/linux/bmips/bcm6368/base-files/etc/board.d/01_leds b/target/linux/bmips/bcm6368/base-files/etc/board.d/01_leds index c7e61fe72f..9af5257c11 100644 --- a/target/linux/bmips/bcm6368/base-files/etc/board.d/01_leds +++ b/target/linux/bmips/bcm6368/base-files/etc/board.d/01_leds @@ -6,6 +6,10 @@ board_config_update case "$(board_name)" in +actiontec,r1000h) + ucidef_set_led_usbport "usb" "USB" "green:usb" "usb1-port1" "usb2-port1" + ucidef_set_led_netdev "wan" "WAN" "green:wan" "wan" + ;; comtrend,wap-5813n) ucidef_set_led_usbport "usb" "USB" "green:usb" "usb1-port1" "usb2-port1" ;; diff --git a/target/linux/bmips/bcm6368/base-files/etc/board.d/02_network b/target/linux/bmips/bcm6368/base-files/etc/board.d/02_network index 58fba05fec..fabc4216cd 100644 --- a/target/linux/bmips/bcm6368/base-files/etc/board.d/02_network +++ b/target/linux/bmips/bcm6368/base-files/etc/board.d/02_network @@ -14,6 +14,7 @@ comtrend,vr-3025un) ucidef_set_bridge_device switch ucidef_set_interface_lan "lan1 lan2 lan3 iptv" ;; +actiontec,r1000h |\ comtrend,wap-5813n |\ netgear,dgnd3700-v1 |\ netgear,dgnd3800b |\ diff --git a/target/linux/bmips/bcm6368/base-files/etc/uci-defaults/09_fix_crc b/target/linux/bmips/bcm6368/base-files/etc/uci-defaults/09_fix_crc index 63d10c9a8e..f3b1eafdfc 100644 --- a/target/linux/bmips/bcm6368/base-files/etc/uci-defaults/09_fix_crc +++ b/target/linux/bmips/bcm6368/base-files/etc/uci-defaults/09_fix_crc @@ -3,6 +3,7 @@ . /lib/functions.sh case "$(board_name)" in +actiontec,r1000h |\ comtrend,vr-3025u |\ comtrend,vr-3025un |\ comtrend,wap-5813n |\ diff --git a/target/linux/bmips/dts/bcm6368-actiontec-r1000h.dts b/target/linux/bmips/dts/bcm6368-actiontec-r1000h.dts new file mode 100644 index 0000000000..ff115afb8f --- /dev/null +++ b/target/linux/bmips/dts/bcm6368-actiontec-r1000h.dts @@ -0,0 +1,220 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "bcm6368.dtsi" + +/ { + model = "Actiontec R1000H"; + compatible = "actiontec,r1000h", "brcm,bcm6368"; + + aliases { + led-boot = &led_power_green; + led-failsafe = &led_power_red; + led-running = &led_power_green; + led-upgrade = &led_power_green; + }; + + keys { + compatible = "gpio-keys-polled"; + poll-interval = <100>; + + reset { + label = "reset"; + gpios = <&gpio 34 GPIO_ACTIVE_LOW>; + linux,code = ; + debounce-interval = <60>; + }; + + wps { + label = "wps"; + gpios = <&gpio 35 GPIO_ACTIVE_LOW>; + linux,code = ; + debounce-interval = <60>; + }; + }; + + leds { + compatible = "gpio-leds"; + + led@5 { + label = "green:wan"; + gpios = <&gpio 5 GPIO_ACTIVE_HIGH>; + }; + + led@21 { + label = "green:usb"; + gpios = <&gpio 21 GPIO_ACTIVE_LOW>; + }; + + led_power_green: led@22 { + label = "green:power"; + gpios = <&gpio 22 GPIO_ACTIVE_HIGH>; + }; + + led@23 { + label = "green:wps"; + gpios = <&gpio 23 GPIO_ACTIVE_LOW>; + }; + + led_power_red: led@24 { + label = "red:power"; + gpios = <&gpio 24 GPIO_ACTIVE_HIGH>; + panic-indicator; + }; + + led@30 { + label = "red:wps"; + gpios = <&gpio 30 GPIO_ACTIVE_LOW>; + }; + + led@31 { + label = "red:wan"; + gpios = <&gpio 31 GPIO_ACTIVE_HIGH>; + }; + }; +}; + +&ehci { + status = "okay"; +}; + +ðernet { + status = "okay"; + + nvmem-cells = <&macaddr_cfe_6a0>; + nvmem-cell-names = "mac-address"; +}; + +&mdio_ext { + switch@1e { + compatible = "brcm,bcm53115"; + reg = <30>; + + dsa,member = <1 0>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + label = "lan1"; + }; + + port@1 { + reg = <1>; + label = "lan2"; + }; + + port@2 { + reg = <2>; + label = "lan3"; + }; + + port@3 { + reg = <3>; + label = "lan4"; + }; + + port@4 { + reg = <4>; + label = "wan"; + }; + + port@5 { + /* HPNA coaxial port */ + reg = <5>; + label = "coax"; + + phy-mode = "mii"; + + fixed-link { + speed = <100>; + full-duplex; + }; + }; + + port@8 { + reg = <8>; + + phy-mode = "rgmii"; + ethernet = <&switch0port5>; + + fixed-link { + speed = <1000>; + full-duplex; + }; + }; + }; + }; +}; + +&switch0 { + dsa,member = <0 0>; + + ports { + switch0port5: port@5 { + reg = <5>; + label = "extsw"; + + phy-mode = "rgmii"; + + fixed-link { + speed = <1000>; + full-duplex; + }; + }; + }; +}; + +&pflash { + status = "okay"; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + cfe: partition@0 { + label = "CFE"; + reg = <0x000000 0x020000>; + read-only; + }; + + partition@20000 { + label = "firmware"; + reg = <0x020000 0x1fc0000>; + compatible = "brcm,bcm963xx-imagetag"; + }; + + partition@fe0000 { + label = "nvram"; + reg = <0x1fe0000 0x020000>; + }; + }; +}; + +&ohci { + status = "okay"; +}; + +&pci { + status = "okay"; +}; + +&uart0 { + status = "okay"; +}; + +&usbh { + status = "okay"; +}; + +&cfe { + compatible = "nvmem-cells"; + #address-cells = <1>; + #size-cells = <1>; + + macaddr_cfe_6a0: macaddr@6a0 { + reg = <0x6a0 0x6>; + }; +}; diff --git a/target/linux/bmips/image/bcm6368.mk b/target/linux/bmips/image/bcm6368.mk index 83cd096959..39fcb02318 100644 --- a/target/linux/bmips/image/bcm6368.mk +++ b/target/linux/bmips/image/bcm6368.mk @@ -1,5 +1,20 @@ # SPDX-License-Identifier: GPL-2.0-or-later +define Device/actiontec_r1000h + $(Device/bcm63xx-cfe) + DEVICE_VENDOR := Actiontec + DEVICE_MODEL := R1000H + CHIP_ID := 6368 + CFE_BOARD_ID := 96368VVW + BLOCKSIZE := 0x20000 + FLASH_MB := 32 + CFE_EXTRAS += --signature "$$(DEVICE_VENDOR)" + DEVICE_PACKAGES += $(USB2_PACKAGES) \ + $(B43_PACKAGES) \ + kmod-leds-gpio +endef +TARGET_DEVICES += actiontec_r1000h + define Device/comtrend_vr-3025u $(Device/bcm63xx-cfe) DEVICE_VENDOR := Comtrend From 705ee2198ca5d46999b5853ccdde87c129af74eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Fri, 9 Jun 2023 19:53:08 +0200 Subject: [PATCH 08/12] bcm63xx: mark as source-only MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Maintaining bcm63xx is a nightmare due to the amount of devices and patches required, since every board requires an individual patch due to the lack of full device tree compatibility. Moreover, there are a lot of devices supported on this target which won't work due to not having enough resources (16M-32M of RAM and/or 4M of flash). Therefore, any development efforts should be focused on bmips and support for those devices with enough resources should be added on bmips target. Signed-off-by: Álvaro Fernández Rojas --- target/linux/bcm63xx/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/linux/bcm63xx/Makefile b/target/linux/bcm63xx/Makefile index 4bcf9613d9..f206aed3d3 100644 --- a/target/linux/bcm63xx/Makefile +++ b/target/linux/bcm63xx/Makefile @@ -9,7 +9,7 @@ ARCH:=mips BOARD:=bcm63xx BOARDNAME:=Broadcom BCM63xx SUBTARGETS:=generic smp -FEATURES:=squashfs usb atm pci pcmcia usbgadget +FEATURES:=squashfs usb atm pci pcmcia usbgadget source-only KERNEL_PATCHVER:=5.15 From 434434ca4748ba669176ce38b70a6525f90598b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Thu, 15 Jun 2023 13:21:18 +0200 Subject: [PATCH 09/12] bmips: bump LOADER_ENTRY to RAM + 16M MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is needed on devices like Sercomm AD1018 for booting recent kernels due to bigger kernels. Signed-off-by: Álvaro Fernández Rojas --- target/linux/bmips/image/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/linux/bmips/image/Makefile b/target/linux/bmips/image/Makefile index 5ce026c584..9311e2df09 100644 --- a/target/linux/bmips/image/Makefile +++ b/target/linux/bmips/image/Makefile @@ -4,7 +4,7 @@ include $(TOPDIR)/rules.mk include $(INCLUDE_DIR)/image.mk KERNEL_LOADADDR := 0x80010000 # RAM start + 64K -LOADER_ENTRY := 0x80a00000 # RAM start + 10M, for relocate +LOADER_ENTRY := 0x81000000 # RAM start + 16M, for relocate LZMA_TEXT_START := 0x82000000 # RAM start + 32M DEVICE_VARS += CFE_BOARD_ID CFE_EXTRAS From 38ebb2eafde604ff6d9b0021d1d21208070a2d09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Mon, 12 Jun 2023 19:51:22 +0200 Subject: [PATCH 10/12] bmips: add support for Sercomm AD1018 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Sercomm AD1018 is a wifi fast ethernet router, 2.4 GHz single band with two internal antennas. Hardware: - SoC: Broadcom BCM6328 - CPU: single core BMIPS4350 @ 320Mhz - RAM: 64 MB (v1) / 128 MB (v2) DDR - Flash: 128 MB NAND - Ethernet LAN: 4x 100Mbit - Wifi 2.4 GHz: miniPCI Broadcom BCM43217 802.11bgn - USB: 1x 2.0 - Buttons: 3x (reset) - LEDs: yes - UART: yes Installation via OEM web UI: 1. Use the admin credentials to login via web UI 2. Go to Managament->Update firmware and select the OpenWrt CFE firmware 3. Press "Update Firmware" button and wait some minutes until it finish Signed-off-by: Álvaro Fernández Rojas --- .../bcm6328/base-files/etc/board.d/01_leds | 16 + .../bcm6328/base-files/etc/board.d/02_network | 4 + .../base-files/lib/upgrade/platform.sh | 3 + .../bmips/dts/bcm6328-sercomm-ad1018.dts | 312 ++++++++++++++++++ target/linux/bmips/image/bcm6328.mk | 18 + 5 files changed, 353 insertions(+) create mode 100644 target/linux/bmips/bcm6328/base-files/etc/board.d/01_leds create mode 100644 target/linux/bmips/dts/bcm6328-sercomm-ad1018.dts diff --git a/target/linux/bmips/bcm6328/base-files/etc/board.d/01_leds b/target/linux/bmips/bcm6328/base-files/etc/board.d/01_leds new file mode 100644 index 0000000000..5ece1f7ba1 --- /dev/null +++ b/target/linux/bmips/bcm6328/base-files/etc/board.d/01_leds @@ -0,0 +1,16 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +. /lib/functions/leds.sh +. /lib/functions/uci-defaults.sh + +board_config_update + +case "$(board_name)" in +sercomm,ad1018) + ucidef_set_led_usbport "usb" "USB" "green:usb" "usb1-port1" "usb2-port1" + ;; +esac + +board_config_flush + +exit 0 diff --git a/target/linux/bmips/bcm6328/base-files/etc/board.d/02_network b/target/linux/bmips/bcm6328/base-files/etc/board.d/02_network index c9c704067e..66f9282e48 100644 --- a/target/linux/bmips/bcm6328/base-files/etc/board.d/02_network +++ b/target/linux/bmips/bcm6328/base-files/etc/board.d/02_network @@ -10,6 +10,10 @@ comtrend,ar-5387un) ucidef_set_bridge_device switch ucidef_set_interface_lan "lan1 lan2 lan3 lan4" ;; +sercomm,ad1018) + ucidef_set_bridge_device switch + ucidef_set_interface_lan "lan1 lan2 lan3 fibre" + ;; esac board_config_flush diff --git a/target/linux/bmips/bcm6328/base-files/lib/upgrade/platform.sh b/target/linux/bmips/bcm6328/base-files/lib/upgrade/platform.sh index 1cf95be26a..d820b20718 100644 --- a/target/linux/bmips/bcm6328/base-files/lib/upgrade/platform.sh +++ b/target/linux/bmips/bcm6328/base-files/lib/upgrade/platform.sh @@ -9,6 +9,9 @@ platform_check_image() { platform_do_upgrade() { case "$(board_name)" in + sercomm,ad1018) + nand_do_upgrade "$1" + ;; *) default_do_upgrade "$1" ;; diff --git a/target/linux/bmips/dts/bcm6328-sercomm-ad1018.dts b/target/linux/bmips/dts/bcm6328-sercomm-ad1018.dts new file mode 100644 index 0000000000..5d18266818 --- /dev/null +++ b/target/linux/bmips/dts/bcm6328-sercomm-ad1018.dts @@ -0,0 +1,312 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "bcm6328.dtsi" + +/ { + model = "Sercomm AD1018"; + compatible = "sercomm,ad1018", "brcm,bcm6328"; + + aliases { + led-boot = &led_power_green; + led-failsafe = &led_power_green; + led-running = &led_power_green; + led-upgrade = &led_power_green; + }; + + keys { + compatible = "gpio-keys-polled"; + poll-interval = <100>; + + wps { + label = "wps"; + gpios = <&gpio 24 GPIO_ACTIVE_LOW>; + linux,code = ; + debounce-interval = <60>; + }; + + wlan { + label = "wlan"; + gpios = <&gpio 25 GPIO_ACTIVE_LOW>; + linux,code = ; + debounce-interval = <60>; + }; + + reset { + label = "reset"; + gpios = <&gpio 31 GPIO_ACTIVE_LOW>; + linux,code = ; + debounce-interval = <60>; + }; + }; + + bcm432217-sprom { + compatible = "brcm,bcma-sprom"; + + pci-bus = <1>; + pci-dev = <0>; + + nvmem-cells = <&macaddr_cferom_6a0>; + nvmem-cell-names = "mac-address"; + mac-address-increment = <1>; + + brcm,sprom = "brcm/bcm43217-sprom.bin"; + brcm,sprom-fixups = <6 0x1c00>, + <65 0x1256>, + <96 0x2046>, + <97 0xfe69>, + <98 0x1726>, + <99 0xfa5c>, + <112 0x2046>, + <113 0xfea8>, + <114 0x1978>, + <115 0xfa26>, + <161 0x2222>, + <169 0x2222>, + <171 0x2222>, + <173 0x2222>, + <174 0x4444>, + <175 0x2222>, + <176 0x4444>; + }; +}; + +&ehci { + status = "okay"; +}; + +ðernet { + status = "okay"; + + nvmem-cells = <&macaddr_cferom_6a0>; + nvmem-cell-names = "mac-address"; +}; + +&leds { + status = "okay"; + + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_leds &pinctrl_serial_led + &pinctrl_ephy0_spd_led &pinctrl_ephy1_act_led + &pinctrl_ephy2_act_led &pinctrl_ephy3_act_led>; + + brcm,serial-leds; + brcm,serial-shift-inv; + brcm,serial-dat-low; + + led@0 { + reg = <0>; + active-low; + label = "red:internet"; + }; + + led@1 { + reg = <1>; + active-low; + label = "green:internet"; + }; + + led_power_green: led@8 { + reg = <8>; + active-low; + label = "green:power"; + default-state = "on"; + }; + + led@10 { + reg = <10>; + active-low; + label = "green:adsl"; + }; + + led@11 { + reg = <11>; + active-low; + label = "red:adsl"; + }; + + led@12 { + reg = <12>; + active-low; + label = "green:phone"; + }; + + led@13 { + reg = <13>; + active-low; + label = "green:wps"; + }; + + led@14 { + reg = <14>; + active-low; + label = "green:wifi"; + }; + + led@15 { + reg = <15>; + active-low; + label = "green:usb"; + }; + + led@17 { + /* EPHY0 Spd */ + reg = <17>; + brcm,hardware-controlled; + }; +}; + +&ohci { + status = "okay"; +}; + +&pcie { + status = "okay"; +}; + +&pinctrl { + pinctrl_leds: leds { + function = "led"; + pins = "gpio0", "gpio1"; + }; +}; + +&nflash { + status = "okay"; + + nandcs@0 { + compatible = "brcm,nandcs"; + reg = <0>; + nand-ecc-step-size = <512>; + nand-ecc-strength = <15>; + nand-on-flash-bbt; + + #address-cells = <1>; + #size-cells = <1>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + cferom: partition@0 { + label = "cferom"; + reg = <0x0000000 0x0020000>; + read-only; + }; + + partition@20000 { + label = "mmap"; + reg = <0x0020000 0x00a0000>; + read-only; + }; + + partition@c0000 { + label = "cferam1"; + reg = <0x00c0000 0x0140000>; + read-only; + }; + + partition@200000 { + label = "cferam2"; + reg = <0x0200000 0x0140000>; + read-only; + }; + + partition@340000 { + label = "serial"; + reg = <0x0340000 0x00a0000>; + read-only; + }; + + partition@3e0000 { + label = "protect"; + reg = <0x03e0000 0x0140000>; + read-only; + }; + + partition@6920000 { + label = "bootflag1"; + reg = <0x6920000 0x0140000>; + read-only; + }; + + partition@6a60000 { + label = "bootflag2"; + reg = <0x6a60000 0x0140000>; + read-only; + }; + + partition@520000 { + compatible = "sercomm,wfi"; + label = "wfi"; + reg = <0x0520000 0x6400000>; + }; + + partition@6ba0000 { + label = "xml_cfg"; + reg = <0x6ba0000 0x0280000>; + read-only; + }; + + partition@6e20000 { + label = "app_dat"; + reg = <0x6e20000 0x0280000>; + read-only; + }; + }; + }; +}; + +&switch0 { + ports { + port@0 { + reg = <0>; + label = "fibre"; + + phy-handle = <&phy1>; + phy-mode = "mii"; + }; + + port@1 { + reg = <1>; + label = "lan3"; + + phy-handle = <&phy2>; + phy-mode = "mii"; + }; + + port@2 { + reg = <2>; + label = "lan2"; + + phy-handle = <&phy3>; + phy-mode = "mii"; + }; + + port@3 { + reg = <3>; + label = "lan1"; + + phy-handle = <&phy4>; + phy-mode = "mii"; + }; + }; +}; + +&uart0 { + status = "okay"; +}; + +&usbh { + status = "okay"; +}; + +&cferom { + compatible = "nvmem-cells"; + #address-cells = <1>; + #size-cells = <1>; + + macaddr_cferom_6a0: macaddr@6a0 { + reg = <0x6a0 0x6>; + }; +}; diff --git a/target/linux/bmips/image/bcm6328.mk b/target/linux/bmips/image/bcm6328.mk index dfa134df94..ef74410f1e 100644 --- a/target/linux/bmips/image/bcm6328.mk +++ b/target/linux/bmips/image/bcm6328.mk @@ -25,3 +25,21 @@ define Device/comtrend_ar-5387un kmod-leds-bcm6328 endef TARGET_DEVICES += comtrend_ar-5387un + +define Device/sercomm_ad1018 + $(Device/sercomm-nand) + DEVICE_VENDOR := Sercomm + DEVICE_MODEL := AD1018 + CHIP_ID := 6328 + BLOCKSIZE := 128k + PAGESIZE := 2048 + SUBPAGESIZE := 512 + VID_HDR_OFFSET := 2048 + DEVICE_PACKAGES += $(USB2_PACKAGES) \ + $(B43_PACKAGES) broadcom-43217-sprom \ + kmod-leds-bcm6328 + SERCOMM_FSVER := 1001 + SERCOMM_HWVER := 1415153 + SERCOMM_SWVER := 3013 +endef +TARGET_DEVICES += sercomm_ad1018 From d9210c5ff797896317d1b6293a5ad768b7482cfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Thu, 15 Jun 2023 20:53:11 +0200 Subject: [PATCH 11/12] bmips: dts: dgnd3700: fix WAN port MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit All switch ports are labeled as port@address so let's follow the same pattern. Fixes: ed79519b8d89 ("bmips: add support for Netgear DGND3700 v1, DGND3800B") Signed-off-by: Álvaro Fernández Rojas --- target/linux/bmips/dts/bcm6368-netgear-dgnd3700.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/linux/bmips/dts/bcm6368-netgear-dgnd3700.dtsi b/target/linux/bmips/dts/bcm6368-netgear-dgnd3700.dtsi index 7449455631..c878dd2cff 100644 --- a/target/linux/bmips/dts/bcm6368-netgear-dgnd3700.dtsi +++ b/target/linux/bmips/dts/bcm6368-netgear-dgnd3700.dtsi @@ -123,7 +123,7 @@ #address-cells = <1>; #size-cells = <0>; - wan@0 { + port@0 { reg = <0>; label = "wan"; }; From b57703264f0eba086f22894c5c2ef996e135a993 Mon Sep 17 00:00:00 2001 From: Stijn Tintel Date: Tue, 23 May 2023 05:30:15 +0300 Subject: [PATCH 12/12] hostapd: add UCI option for Multiple BSSID Add an UCI option to enable Multiple BSSID Advertisement. Enabling this will announce all BSSIDS on a phy in a single beacon frame. The interface that is brought up first will be the transmitting profile, all others are non-transmitting profiles and will be advertised in the Multiple BSSID element in Beacon and Probe Response frames of the first interface. This depends on driver and client support. Enabling this will result in all but the first interface not being visible at all for clients that do not support it. Signed-off-by: Stijn Tintel --- package/network/services/hostapd/files/hostapd.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/package/network/services/hostapd/files/hostapd.sh b/package/network/services/hostapd/files/hostapd.sh index 28bd210623..bf3625c92d 100644 --- a/package/network/services/hostapd/files/hostapd.sh +++ b/package/network/services/hostapd/files/hostapd.sh @@ -121,6 +121,7 @@ hostapd_common_add_device_config() { config_add_array hostapd_options config_add_int airtime_mode + config_add_int mbssid hostapd_add_log_config } @@ -133,7 +134,8 @@ hostapd_prepare_device_config() { json_get_vars country country3 country_ie beacon_int:100 doth require_mode legacy_rates \ acs_chan_bias local_pwr_constraint spectrum_mgmt_required airtime_mode cell_density \ - rts_threshold beacon_rate rssi_reject_assoc_rssi rssi_ignore_probe_request maxassoc + rts_threshold beacon_rate rssi_reject_assoc_rssi rssi_ignore_probe_request maxassoc \ + mbssid:0 hostapd_set_log_options base_cfg @@ -234,6 +236,7 @@ hostapd_prepare_device_config() { [ -n "$rts_threshold" ] && append base_cfg "rts_threshold=$rts_threshold" "$N" [ "$airtime_mode" -gt 0 ] && append base_cfg "airtime_mode=$airtime_mode" "$N" [ -n "$maxassoc" ] && append base_cfg "iface_max_num_sta=$maxassoc" "$N" + [ "$mbssid" -gt 0 ] && [ "$mbssid" -le 2 ] && append base_cfg "mbssid=$mbssid" "$N" json_get_values opts hostapd_options for val in $opts; do