From e9d2ff8045f803ec5c90b965946fa1162d5a5699 Mon Sep 17 00:00:00 2001 From: Jitao Lu Date: Wed, 14 Jun 2023 17:25:03 +0800 Subject: [PATCH 1/6] openssl: passing cflags to configure openssl sets additional cflags in its configuration script. We need to make it aware of our custom cflags to avoid adding conflicting cflags. Fixes: #12866 Signed-off-by: Jitao Lu (cherry picked from commit 51f57e7c2dd2799e34036ec74b3436bf490fade0) --- package/libs/openssl/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package/libs/openssl/Makefile b/package/libs/openssl/Makefile index a34a784973..0d09114f06 100644 --- a/package/libs/openssl/Makefile +++ b/package/libs/openssl/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=openssl PKG_VERSION:=3.0.9 -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_BUILD_FLAGS:=no-mips16 gc-sections PKG_BUILD_PARALLEL:=1 @@ -366,6 +366,7 @@ define Build/Configure --libdir=lib \ --openssldir=/etc/ssl \ --cross-compile-prefix="$(TARGET_CROSS)" \ + $(TARGET_CFLAGS) \ $(TARGET_CPPFLAGS) \ $(TARGET_LDFLAGS) \ $(OPENSSL_OPTIONS) && \ From 63942b569e08a6190ec9096a03d184127b8f3f71 Mon Sep 17 00:00:00 2001 From: Mikhail Zhilkin Date: Fri, 2 Dec 2022 15:26:17 +0000 Subject: [PATCH 2/6] scripts: sercomm-kernel-header.py: improve compatibility This improves compatibility with the elder stock firmwares of the following devices, which have not yet been merged into OpenWrt: - Beeline SmartBox Pro - Beeline SmartBox Turbo+ - WiFire S1500.NBN Without this, OpenWrt factory image installation may fail. Signed-off-by: Mikhail Zhilkin Signed-off-by: Maximilian Weinmann (cherry picked from commit 35a4418d3966ccf6229916b0021bd18871ef22dd) --- scripts/sercomm-kernel-header.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/sercomm-kernel-header.py b/scripts/sercomm-kernel-header.py index bfb29c6fe0..40bcbb1385 100755 --- a/scripts/sercomm-kernel-header.py +++ b/scripts/sercomm-kernel-header.py @@ -48,12 +48,12 @@ def get_kernel_header(args): struct.pack_into(' Date: Wed, 7 Dec 2022 23:44:09 +0700 Subject: [PATCH 3/6] ramips: Add support for Beeline SmartBox TURBO+ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This adds support for Beeline Smart Box TURBO+ (Serсomm S3 CQR) router. Device specification -------------------- SoC Type: MediaTek MT7621AT (880 MHz, 2 cores) RAM (Nanya NT5CC64M16GP): 128 MiB Flash (Macronix MX30LF1G18AC): 128 MiB Wireless 2.4 GHz (MT7603EN): b/g/n, 2x2 Wireless 5 GHz (MT7615N): a/n/ac, 4x4 Ethernet: 5 ports - 5×GbE (WAN, LAN1-4) USB ports: 1xUSB3.0 Buttons: 2 button (reset, wps) LEDs: Red, Green, Blue Zigbee (EFR32MG1B232GG): 3.0 Stock bootloader: U-Boot 1.1.3 Power: 12 VDC, 1.5 A Installation (fw 2.0.9) ----------------------- 1. Login to the web interface under SuperUser (root) credentials. Password: SDXXXXXXXXXX, where SDXXXXXXXXXX is serial number of the device written on the backplate stick. 2. Navigate to Setting -> WAN. Add: Name - WAN1 Connection Type - Static IP Address - 172.16.0.1 Netmask - 255.255.255.0 Save -> Apply. Set default: WAN1 3. Enable SSH and HTTP on WAN. Setting -> Remote control. Add: Protocol - SSH Port - 22 IP Address - 172.16.0.1 Netmask - 255.255.255.0 WAN Interface - WAN1 Save ->Apply Add: Protocol - HTTP Port - 80 IP Address - 172.16.0.1 Netmask - 255.255.255.0 WAN interface - WAN1 Save -> Apply 4. Set up your PC ethernet: Connection Type - Static IP Address - 172.16.0.2 Netmask - 255.255.255.0 Gateway - 172.16.0.1 5. Connect PC using ethernet cable to the WAN port of the router 6. Connect to the router using SSH shell under SuperUser account 7. Make a mtd backup (optional, see related section) 8. Change bootflag to Sercomm1 and reboot: printf 1 | dd bs=1 seek=7 count=1 of=/dev/mtdblock3 reboot 9. Login to the router web interface under admin account 10. Remove dots from the OpenWrt factory image filename 11. Update firmware via web using OpenWrt factory image Revert to stock --------------- Change bootflag to Sercomm1 in OpenWrt CLI and then reboot: printf 1 | dd bs=1 seek=7 count=1 of=/dev/mtdblock3 mtd backup ---------- 1. Set up a tftp server (e.g. tftpd64 for windows) 2. Connect to a router using SSH shell and run the following commands: cd /tmp for i in 0 1 2 3 4 5 6 7 8 9 10; do nanddump -f mtd$i /dev/mtd$i; \ tftp -l mtd$i -p 172.16.0.2; md5sum mtd$i >> mtd.md5; rm mtd$i; done tftp -l mtd.md5 -p 171.16.0.2 Recovery -------- Use sercomm-recovery tool. Link: https://github.com/danitool/sercomm-recovery MAC Addresses (fw 2.0.9) ------------------------ +-----+------------+---------+ | use | address | example | +-----+------------+---------+ | LAN | label | *:e8 | | WAN | label + 1 | *:e9 | | 2g | label + 4 | *:ec | | 5g | label + 5 | *:ed | +-----+------------+---------+ The label MAC address was found in Factory 0x21000 Factory image format -------------------- +---+-------------------+-------------+--------------------+ | # | Offset | Size | Description | +---+-------------------+-------------+--------------------+ | 1 | 0x0 | 0x200 | Tag Header Factory | | 2 | 0x200 | 0x100 | Tag Header Kernel1 | | 3 | 0x300 | 0x100 | Tag Header Kernel2 | | 4 | 0x400 | SIZE_KERNEL | Kernel | | 5 | 0x400+SIZE_KERNEL | SIZE_ROOTFS | RootFS(UBI) | +---+-------------------+-------------+--------------------+ Co-authored-by: Mikhail Zhilkin Signed-off-by: Maximilian Weinmann (cherry picked from commit 8fcfb21b16e7537b9a871a1f67cb218c6be93149) --- package/boot/uboot-envtools/files/ramips | 1 + .../mt7621_beeline_smartbox-turbo-plus.dts | 248 ++++++++++++++++++ target/linux/ramips/image/common-sercomm.mk | 65 ++++- target/linux/ramips/image/mt7621.mk | 12 + .../mt7621/base-files/etc/board.d/01_leds | 1 + .../mt7621/base-files/etc/init.d/bootcount | 1 + .../mt7621/base-files/lib/upgrade/platform.sh | 1 + 7 files changed, 320 insertions(+), 9 deletions(-) create mode 100644 target/linux/ramips/dts/mt7621_beeline_smartbox-turbo-plus.dts diff --git a/package/boot/uboot-envtools/files/ramips b/package/boot/uboot-envtools/files/ramips index 6f351af212..b3f37c7c3e 100644 --- a/package/boot/uboot-envtools/files/ramips +++ b/package/boot/uboot-envtools/files/ramips @@ -39,6 +39,7 @@ ampedwireless,ally-r1900k) ;; beeline,smartbox-giga|\ beeline,smartbox-turbo|\ +beeline,smartbox-turbo-plus|\ etisalat,s3|\ rostelecom,rt-sf-1) ubootenv_add_uci_config "/dev/mtd0" "0x80000" "0x1000" "0x20000" diff --git a/target/linux/ramips/dts/mt7621_beeline_smartbox-turbo-plus.dts b/target/linux/ramips/dts/mt7621_beeline_smartbox-turbo-plus.dts new file mode 100644 index 0000000000..507920bac2 --- /dev/null +++ b/target/linux/ramips/dts/mt7621_beeline_smartbox-turbo-plus.dts @@ -0,0 +1,248 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "mt7621.dtsi" + +#include +#include +#include + +/ { + compatible = "beeline,smartbox-turbo-plus", "mediatek,mt7621-soc"; + model = "Beeline SmartBox TURBO+"; + + aliases { + label-mac-device = &gmac0; + + led-boot = &led_status_green; + led-failsafe = &led_status_red; + led-running = &led_status_green; + led-upgrade = &led_status_red; + }; + + leds { + compatible = "gpio-leds"; + + led-0 { + label = "blue:wan"; + color = ; + function = LED_FUNCTION_WAN; + gpios = <&gpio 13 GPIO_ACTIVE_HIGH>; + }; + + led_status_green: led-1 { + label = "green:status"; + color = ; + function = LED_FUNCTION_STATUS; + gpios = <&gpio 15 GPIO_ACTIVE_HIGH>; + }; + + led_status_red: led-2 { + label = "red:status"; + color = ; + function = LED_FUNCTION_STATUS; + gpios = <&gpio 16 GPIO_ACTIVE_HIGH>; + }; + }; + + keys { + compatible = "gpio-keys"; + + wps { + label = "wps"; + gpios = <&gpio 11 GPIO_ACTIVE_HIGH>; + linux,code = ; + }; + + reset { + label = "reset"; + gpios = <&gpio 14 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + ubi-concat { + compatible = "mtd-concat"; + devices = <&ubiconcat0 &ubiconcat1 &ubiconcat2>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "ubi"; + reg = <0x0 0x4f80000>; + }; + }; + }; +}; + +&nand { + status = "okay"; + + partitions { + compatible = "sercomm,sc-partitions", "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "u-boot"; + reg = <0x0 0x100000>; + sercomm,scpart-id = <0>; + read-only; + }; + + partition@100000 { + label = "dynamic partition map"; + reg = <0x100000 0x100000>; + sercomm,scpart-id = <1>; + read-only; + }; + + factory: partition@200000 { + label = "Factory"; + reg = <0x200000 0x100000>; + sercomm,scpart-id = <2>; + read-only; + + compatible = "nvmem-cells"; + #address-cells = <1>; + #size-cells = <1>; + + macaddr_factory_21000: macaddr@21000 { + reg = <0x21000 0x6>; + }; + }; + + partition@300000 { + label = "Boot Flag"; + reg = <0x300000 0x100000>; + sercomm,scpart-id = <3>; + }; + + partition@400000 { + label = "kernel"; + reg = <0x400000 0x600000>; + sercomm,scpart-id = <4>; + }; + + partition@a00000 { + label = "Kernel 2"; + reg = <0xa00000 0x600000>; + sercomm,scpart-id = <5>; + read-only; + }; + + ubiconcat0: partition@1000000 { + label = "File System 1"; + reg = <0x1000000 0x2000000>; + sercomm,scpart-id = <6>; + }; + + partition@3000000 { + label = "File System 2"; + reg = <0x3000000 0x2000000>; + sercomm,scpart-id = <7>; + read-only; + }; + + ubiconcat1: partition@5000000 { + label = "Configuration/log"; + reg = <0x5000000 0x1400000>; + sercomm,scpart-id = <8>; + }; + + ubiconcat2: partition@6400000 { + label = "application tmp buffer (Ftool)"; + reg = <0x6400000 0x1b80000>; + sercomm,scpart-id = <9>; + }; + }; +}; + +&pcie { + status = "okay"; +}; + +&pcie0 { + wifi@0,0 { + compatible = "mediatek,mt76"; + reg = <0x0000 0 0 0 0>; + mediatek,mtd-eeprom = <&factory 0x8000>; + ieee80211-freq-limit = <5000000 6000000>; + + nvmem-cells = <&macaddr_factory_21000>; + nvmem-cell-names = "mac-address"; + mac-address-increment = <(5)>; + }; +}; + +&pcie1 { + wifi@0,0 { + compatible = "mediatek,mt76"; + reg = <0x0000 0 0 0 0>; + mediatek,mtd-eeprom = <&factory 0x0>; + ieee80211-freq-limit = <2400000 2500000>; + + nvmem-cells = <&macaddr_factory_21000>; + nvmem-cell-names = "mac-address"; + mac-address-increment = <(4)>; + }; +}; + +&gmac0 { + nvmem-cells = <&macaddr_factory_21000>; + nvmem-cell-names = "mac-address"; +}; + +&gmac1 { + status = "okay"; + label = "wan"; + phy-handle = <ðphy0>; + + nvmem-cells = <&macaddr_factory_21000>; + nvmem-cell-names = "mac-address"; + mac-address-increment = <(1)>; +}; + +&mdio { + ethphy0: ethernet-phy@0 { + reg = <0>; + }; +}; + +&switch0 { + ports { + port@1 { + status = "okay"; + label = "lan1"; + }; + + port@2 { + status = "okay"; + label = "lan2"; + }; + + port@3 { + status = "okay"; + label = "lan3"; + }; + + port@4 { + status = "okay"; + label = "lan4"; + }; + }; +}; + +&uartlite3 { + status = "okay"; + current-speed = <57600>; +}; + +&state_default { + gpio { + groups = "i2c", "jtag"; + function = "gpio"; + }; +}; diff --git a/target/linux/ramips/image/common-sercomm.mk b/target/linux/ramips/image/common-sercomm.mk index 83bb2a742c..fbe29d7017 100644 --- a/target/linux/ramips/image/common-sercomm.mk +++ b/target/linux/ramips/image/common-sercomm.mk @@ -1,4 +1,5 @@ DEVICE_VARS += SERCOMM_KERNEL_OFFSET SERCOMM_ROOTFS_OFFSET +DEVICE_VARS += SERCOMM_KERNEL2_OFFSET SERCOMM_ROOTFS2_OFFSET define Build/sercomm-crypto $(TOPDIR)/scripts/sercomm-crypto.py \ @@ -16,6 +17,23 @@ define Build/sercomm-crypto rm -f $@.enc $@.key endef +define Build/sercomm-factory-cqr + $(TOPDIR)/scripts/sercomm-pid.py \ + --hw-version $(SERCOMM_HWVER) \ + --hw-id $(SERCOMM_HWID) \ + --sw-version $(SERCOMM_SWVER) \ + --pid-file $@.fhdr + printf $$(stat -c%s $(IMAGE_KERNEL)) | \ + dd seek=$$((0x70)) of=$@.fhdr bs=1 conv=notrunc 2>/dev/null + printf $$(($$(stat -c%s $@)-$$(stat -c%s $(IMAGE_KERNEL))-$$((0x200)))) | \ + dd seek=$$((0x80)) of=$@.fhdr bs=1 conv=notrunc 2>/dev/null + dd bs=$$((0x200)) skip=1 if=$@ conv=notrunc 2>/dev/null | \ + $(MKHASH) md5 | awk '{print $$1}' | tr -d '\n' | \ + dd seek=$$((0x1e0)) of=$@.fhdr bs=1 conv=notrunc 2>/dev/null + dd if=$@ >> $@.fhdr 2>/dev/null + mv $@.fhdr $@ +endef + define Build/sercomm-kernel $(TOPDIR)/scripts/sercomm-kernel-header.py \ --kernel-image $@ \ @@ -26,6 +44,22 @@ define Build/sercomm-kernel mv $@.hdr $@ endef +define Build/sercomm-kernel-factory + $(TOPDIR)/scripts/sercomm-kernel-header.py \ + --kernel-image $@ \ + --kernel-offset $(SERCOMM_KERNEL_OFFSET) \ + --rootfs-offset $(SERCOMM_ROOTFS_OFFSET) \ + --output-header $@.khdr1 + $(TOPDIR)/scripts/sercomm-kernel-header.py \ + --kernel-image $@ \ + --kernel-offset $(SERCOMM_KERNEL2_OFFSET) \ + --rootfs-offset $(SERCOMM_ROOTFS2_OFFSET) \ + --output-header $@.khdr2 + cat $@.khdr1 $@.khdr2 > $@.khdr + dd if=$@ >> $@.khdr 2>/dev/null + mv $@.khdr $@ +endef + define Build/sercomm-part-tag $(call Build/sercomm-part-tag-common,$(word 1,$(1)) $@) endef @@ -64,24 +98,37 @@ define Build/sercomm-prepend-tagged-kernel mv $(IMAGE_KERNEL).tagged $@ endef -define Device/sercomm_dxx - $(Device/dsa-migration) - BLOCKSIZE := 128k - PAGESIZE := 2048 - KERNEL_SIZE := 6144k - UBINIZE_OPTS := -E 5 +define Device/sercomm + $(Device/nand) LOADER_TYPE := bin + KERNEL_SIZE := 6144k KERNEL_LOADADDR := 0x81001000 LZMA_TEXT_START := 0x82800000 + SERCOMM_KERNEL_OFFSET := 0x400100 + SERCOMM_ROOTFS_OFFSET := 0x1000000 + IMAGES += factory.img +endef + +define Device/sercomm_cxx + $(Device/sercomm) + SERCOMM_KERNEL2_OFFSET := 0xa00100 + SERCOMM_ROOTFS2_OFFSET := 0x3000000 + KERNEL := kernel-bin | append-dtb | lzma | loader-kernel | lzma -a0 | \ + uImage lzma + IMAGE/sysupgrade.bin := append-kernel | sercomm-kernel | \ + sysupgrade-tar kernel=$$$$@ | append-metadata + IMAGE/factory.img := append-kernel | sercomm-kernel-factory | \ + append-ubi | sercomm-factory-cqr +endef + +define Device/sercomm_dxx + $(Device/sercomm) KERNEL := kernel-bin | append-dtb | lzma | loader-kernel | lzma -a0 | \ uImage lzma | sercomm-kernel KERNEL_INITRAMFS := kernel-bin | append-dtb | lzma | loader-kernel | \ lzma -a0 | uImage lzma - IMAGES += factory.img IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata IMAGE/factory.img := append-ubi | check-size | \ sercomm-part-tag rootfs | sercomm-prepend-tagged-kernel kernel | \ gzip | sercomm-payload | sercomm-crypto - SERCOMM_KERNEL_OFFSET := 0x400100 - SERCOMM_ROOTFS_OFFSET := 0x1000000 endef diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk index 340d4ba4a1..b8fa0cefdb 100644 --- a/target/linux/ramips/image/mt7621.mk +++ b/target/linux/ramips/image/mt7621.mk @@ -410,6 +410,18 @@ define Device/beeline_smartbox-turbo endef TARGET_DEVICES += beeline_smartbox-turbo +define Device/beeline_smartbox-turbo-plus + $(Device/sercomm_cxx) + IMAGE_SIZE := 32768k + SERCOMM_HWID := CQR + SERCOMM_HWVER := 10000 + SERCOMM_SWVER := 2010 + DEVICE_VENDOR := Beeline + DEVICE_MODEL := SmartBox TURBO+ + DEVICE_PACKAGES := kmod-mt7603 kmod-mt7615-firmware kmod-usb3 +endef +TARGET_DEVICES += beeline_smartbox-turbo-plus + define Device/belkin_rt1800 $(Device/nand) IMAGE_SIZE := 49152k diff --git a/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds b/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds index b243acbbbf..9b15da0d22 100644 --- a/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds +++ b/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds @@ -35,6 +35,7 @@ asus,rt-n56u-b1) beeline,smartbox-flash|\ beeline,smartbox-giga|\ beeline,smartbox-turbo|\ +beeline,smartbox-turbo-plus|\ etisalat,s3|\ rostelecom,rt-sf-1) ucidef_set_led_netdev "wan" "wan" "blue:wan" "wan" diff --git a/target/linux/ramips/mt7621/base-files/etc/init.d/bootcount b/target/linux/ramips/mt7621/base-files/etc/init.d/bootcount index 597c2da60f..9db700bff5 100755 --- a/target/linux/ramips/mt7621/base-files/etc/init.d/bootcount +++ b/target/linux/ramips/mt7621/base-files/etc/init.d/bootcount @@ -9,6 +9,7 @@ boot() { echo -e "bootcount\nbootchanged\n" | /usr/sbin/fw_setenv -s - ;; beeline,smartbox-turbo|\ + beeline,smartbox-turbo-plus|\ rostelecom,rt-sf-1) [[ $(hexdump -n 1 -e '/1 "%1d"' -s $((0x20001)) /dev/mtd3) == \ $((0xff)) ]] || printf '\xff' | dd of=/dev/mtdblock3 \ diff --git a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh index ce5fdd61ed..cef58ec3ba 100755 --- a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh +++ b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh @@ -60,6 +60,7 @@ platform_do_upgrade() { beeline,smartbox-flash|\ beeline,smartbox-giga|\ beeline,smartbox-turbo|\ + beeline,smartbox-turbo-plus|\ belkin,rt1800|\ dlink,dap-x1860-a1|\ dlink,dir-1960-a1|\ From 6d3770501d883c3adbfa29b5b4e9451ae84d3ae4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Sat, 10 Jun 2023 17:17:11 +0200 Subject: [PATCH 4/6] bmips: fix DMA RAC flush MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BMIPS_GET_CBR() returns an invalid address on some SoCs. Signed-off-by: Álvaro Fernández Rojas (cherry picked from commit 62cdca25edc7e02249a7dd01c2218ee83e6ed145) --- .../203-mips-bmips-dma-fix-CBR-address.patch | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 target/linux/bmips/patches-5.15/203-mips-bmips-dma-fix-CBR-address.patch diff --git a/target/linux/bmips/patches-5.15/203-mips-bmips-dma-fix-CBR-address.patch b/target/linux/bmips/patches-5.15/203-mips-bmips-dma-fix-CBR-address.patch new file mode 100644 index 0000000000..57bf395e2e --- /dev/null +++ b/target/linux/bmips/patches-5.15/203-mips-bmips-dma-fix-CBR-address.patch @@ -0,0 +1,84 @@ +From 3e4c3863e0cfb8c2abdff6bb494ca69d3d2aed9c Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= +Date: Sat, 10 Jun 2023 17:01:40 +0200 +Subject: [PATCH] mips: bmips: dma: fix CBR address +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Some BCM63xx SoCs may return CBR address as 0. + +Signed-off-by: Álvaro Fernández Rojas +--- + arch/mips/bmips/dma.c | 12 ++++-------- + arch/mips/bmips/setup.c | 11 ++++------- + 2 files changed, 8 insertions(+), 15 deletions(-) + +--- a/arch/mips/bmips/dma.c ++++ b/arch/mips/bmips/dma.c +@@ -64,11 +64,10 @@ phys_addr_t dma_to_phys(struct device *d + return dma_addr; + } + +-bool bmips_rac_flush_disable; ++void __iomem *bmips_cbr_addr; + + void arch_sync_dma_for_cpu_all(void) + { +- void __iomem *cbr = BMIPS_GET_CBR(); + u32 cfg; + + if (boot_cpu_type() != CPU_BMIPS3300 && +@@ -76,13 +75,10 @@ void arch_sync_dma_for_cpu_all(void) + boot_cpu_type() != CPU_BMIPS4380) + return; + +- if (unlikely(bmips_rac_flush_disable)) +- return; +- + /* Flush stale data out of the readahead cache */ +- cfg = __raw_readl(cbr + BMIPS_RAC_CONFIG); +- __raw_writel(cfg | 0x100, cbr + BMIPS_RAC_CONFIG); +- __raw_readl(cbr + BMIPS_RAC_CONFIG); ++ cfg = __raw_readl(bmips_cbr_addr + BMIPS_RAC_CONFIG); ++ __raw_writel(cfg | 0x100, bmips_cbr_addr + BMIPS_RAC_CONFIG); ++ __raw_readl(bmips_cbr_addr + BMIPS_RAC_CONFIG); + } + + static int __init bmips_init_dma_ranges(void) +--- a/arch/mips/bmips/setup.c ++++ b/arch/mips/bmips/setup.c +@@ -89,7 +89,7 @@ + + #define DDR_CSEND_REG 0x8 + +-extern bool bmips_rac_flush_disable; ++extern void __iomem *bmips_cbr_addr; + + static const unsigned long kbase = VMLINUX_LOAD_ADDRESS & 0xfff00000; + +@@ -170,12 +170,6 @@ static void bcm6358_quirks(void) + * disable SMP for now + */ + bmips_smp_enabled = 0; +- +- /* +- * RAC flush causes kernel panics on BCM6358 when booting from TP1 +- * because the bootloader is not initializing it properly. +- */ +- bmips_rac_flush_disable = !!(read_c0_brcm_cmt_local() & (1 << 31)); + } + + static void bcm6368_quirks(void) +@@ -198,6 +192,11 @@ static const struct bmips_quirk bmips_qu + + void __init prom_init(void) + { ++ if (!(read_c0_brcm_cbr() >> 18)) ++ bmips_cbr_addr = (void __iomem *)0xff400000; ++ else ++ bmips_cbr_addr = BMIPS_GET_CBR(); ++ + bmips_cpu_setup(); + register_bmips_smp_ops(); + } From 43746c4c5a85e1762edf383909f1734ad0543825 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Gonz=C3=A1lez=20Cabanelas?= Date: Sat, 17 Jun 2023 19:34:05 +0200 Subject: [PATCH 5/6] bmips: enable the data Read Ahead Cache for BMIPS4350 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The data RAC is left disabled by the bootloader in some SoCs, at least in the core it boots from. Enabling this feature increases the performance up to +30% depending on the task. The kernel enables the whole RAC unconditionally on BMIPS3300 CPUs. Enable the data RAC in a similar way also for BMIPS4350. Tested on DGND3700 v1 (BCM6368) and HG556a (BCM6358). Signed-off-by: Daniel González Cabanelas (cherry picked from commit 6d1265b14850abaf8980e5cebef3e559b1fdcfb9) --- ...4-mips-bmips-enable-RAC-on-BMIPS4350.patch | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 target/linux/bmips/patches-5.15/204-mips-bmips-enable-RAC-on-BMIPS4350.patch diff --git a/target/linux/bmips/patches-5.15/204-mips-bmips-enable-RAC-on-BMIPS4350.patch b/target/linux/bmips/patches-5.15/204-mips-bmips-enable-RAC-on-BMIPS4350.patch new file mode 100644 index 0000000000..26bd03e329 --- /dev/null +++ b/target/linux/bmips/patches-5.15/204-mips-bmips-enable-RAC-on-BMIPS4350.patch @@ -0,0 +1,42 @@ +From 7f862eaedac56b67972393f0a9affcd2fe53479b Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Daniel=20Gonz=C3=A1lez=20Cabanelas?= +Date: Sun, 18 Jun 2023 19:59:25 +0200 +Subject: [PATCH] mips: bmips: enable RAC on BMIPS4350 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The data RAC is left disabled by the bootloader in some SoCs, at least in +the core it boots from. +Enabling this feature increases the performance up to +30% depending on the +task. + +Signed-off-by: Daniel González Cabanelas +Signed-off-by: Álvaro Fernández Rojas +--- + arch/mips/kernel/smp-bmips.c | 14 ++++++++++++++ + 1 file changed, 14 insertions(+) + +--- a/arch/mips/kernel/smp-bmips.c ++++ b/arch/mips/kernel/smp-bmips.c +@@ -614,6 +614,20 @@ void bmips_cpu_setup(void) + __raw_readl(cbr + BMIPS_RAC_ADDRESS_RANGE); + break; + ++ case CPU_BMIPS4350: ++ /* Enable data RAC */ ++ if (!(read_c0_brcm_cmt_local() & (1 << 31))) { ++ cfg = __raw_readl(cbr + BMIPS_RAC_CONFIG); ++ __raw_writel(cfg | 0xa, cbr + BMIPS_RAC_CONFIG); ++ __raw_readl(cbr + BMIPS_RAC_CONFIG); ++ } else { ++ cbr = (void __iomem *)0xff400000; ++ cfg = __raw_readl(cbr + BMIPS_RAC_CONFIG_1); ++ __raw_writel(cfg | 0xa, cbr + BMIPS_RAC_CONFIG_1); ++ __raw_readl(cbr + BMIPS_RAC_CONFIG_1); ++ } ++ break; ++ + case CPU_BMIPS4380: + /* CBG workaround for early BMIPS4380 CPUs */ + switch (read_c0_prid()) { From ac6832110ac4a6c6f2c4a789d2ab6fa4075a6bfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Gonz=C3=A1lez=20Cabanelas?= Date: Sun, 18 Jun 2023 21:34:59 +0200 Subject: [PATCH 6/6] bmips: add support for NuCom R5010UNv2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The NuCom R5010UNv2 is a wifi fast ethernet router, 2.4 GHz single band with two external antennas. Hardware: - SoC: Broadcom BCM6328 - CPU: single core BMIPS4350 V7.5 @ 320Mhz - RAM: 64 MB DDR2 - Flash: 16 MB SPI NOR - Ethernet LAN: 4x 100Mbit - Wifi 2.4 GHz: Broadcom BCM43217 802.11bgn (onboard) - USB: 1x 2.0 - Buttons: 2x - ADSL: yes, unsupported - LEDs: 7x - UART: yes Installation via CFE web UI: 1. Power off the router and press the RESET button 2. Power on the router and wait 12 or more seconds 3. Release the RESET button 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 (cherry picked from commit 6cb3328b4fd4939f3800d4be9d52744b753de1b6) --- .../bcm6328/base-files/etc/board.d/01_leds | 1 + .../bcm6328/base-files/etc/board.d/02_network | 3 +- .../base-files/etc/uci-defaults/09_fix_crc | 3 +- .../bmips/dts/bcm6328-nucom-r5010unv2.dts | 216 ++++++++++++++++++ target/linux/bmips/image/bcm6328.mk | 13 ++ 5 files changed, 234 insertions(+), 2 deletions(-) create mode 100644 target/linux/bmips/dts/bcm6328-nucom-r5010unv2.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 index 5ece1f7ba1..5e80eb34e7 100644 --- a/target/linux/bmips/bcm6328/base-files/etc/board.d/01_leds +++ b/target/linux/bmips/bcm6328/base-files/etc/board.d/01_leds @@ -6,6 +6,7 @@ board_config_update case "$(board_name)" in +nucom,r5010unv2 |\ sercomm,ad1018) ucidef_set_led_usbport "usb" "USB" "green:usb" "usb1-port1" "usb2-port1" ;; 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 66f9282e48..bfedad9e45 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 @@ -6,7 +6,8 @@ board_config_update case "$(board_name)" in comtrend,ar-5381u |\ -comtrend,ar-5387un) +comtrend,ar-5387un |\ +nucom,r5010unv2) ucidef_set_bridge_device switch ucidef_set_interface_lan "lan1 lan2 lan3 lan4" ;; diff --git a/target/linux/bmips/bcm6328/base-files/etc/uci-defaults/09_fix_crc b/target/linux/bmips/bcm6328/base-files/etc/uci-defaults/09_fix_crc index 21f18b4b81..2056ea017f 100644 --- a/target/linux/bmips/bcm6328/base-files/etc/uci-defaults/09_fix_crc +++ b/target/linux/bmips/bcm6328/base-files/etc/uci-defaults/09_fix_crc @@ -4,7 +4,8 @@ case "$(board_name)" in comtrend,ar-5381u |\ -comtrend,ar-5387un) +comtrend,ar-5387un |\ +nucom,r5010unv2) mtd fixtrx firmware ;; esac diff --git a/target/linux/bmips/dts/bcm6328-nucom-r5010unv2.dts b/target/linux/bmips/dts/bcm6328-nucom-r5010unv2.dts new file mode 100644 index 0000000000..826b2a61e2 --- /dev/null +++ b/target/linux/bmips/dts/bcm6328-nucom-r5010unv2.dts @@ -0,0 +1,216 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "bcm6328.dtsi" + +/ { + model = "NuCom R5010UNv2"; + compatible = "nucom,r5010unv2", "brcm,bcm6328"; + + 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 23 GPIO_ACTIVE_LOW>; + linux,code = ; + debounce-interval = <60>; + }; + + wps { + label = "wps"; + gpios = <&gpio 24 GPIO_ACTIVE_LOW>; + linux,code = ; + debounce-interval = <60>; + }; + }; + + bcm43217-sprom { + compatible = "brcm,bcma-sprom"; + + pci-bus = <1>; + pci-dev = <0>; + + nvmem-cells = <&macaddr_cfe_6a0>; + nvmem-cell-names = "mac-address"; + mac-address-increment = <1>; + + brcm,sprom = "brcm/bcm43217-sprom.bin"; + }; +}; + +&ehci { + status = "okay"; +}; + +ðernet { + status = "okay"; + + nvmem-cells = <&macaddr_cfe_6a0>; + nvmem-cell-names = "mac-address"; +}; + +&hsspi { + status = "okay"; + + flash@0 { + compatible = "jedec,spi-nor"; + spi-max-frequency = <16666667>; + spi-tx-bus-width = <2>; + spi-rx-bus-width = <2>; + reg = <0>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + cfe: partition@0 { + label = "cfe"; + reg = <0x000000 0x010000>; + read-only; + }; + + partition@10000 { + compatible = "brcm,bcm963xx-imagetag"; + label = "firmware"; + reg = <0x010000 0xfe0000>; + }; + + partition@ff0000 { + label = "nvram"; + reg = <0xff0000 0x010000>; + }; + }; + }; +}; + +&leds { + status = "okay"; + + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_ephy0_act_led &pinctrl_ephy1_act_led + &pinctrl_ephy2_act_led &pinctrl_ephy3_act_led + &pinctrl_leds>; + + led@1 { + reg = <1>; + active-low; + label = "green:internet"; + }; + + led@2 { + reg = <2>; + active-low; + label = "red:internet"; + }; + + led@3 { + reg = <3>; + active-low; + label = "green:dsl"; + }; + + led_power_green: led@4 { + reg = <4>; + active-low; + label = "green:power"; + }; + + led_power_red: led@5 { + reg = <5>; + active-low; + label = "red:power"; + panic-indicator; + }; + + led@10 { + reg = <10>; + active-low; + label = "green:wps"; + }; + + led@11 { + reg = <11>; + active-low; + label = "green:usb"; + }; +}; + +&ohci { + status = "okay"; +}; + +&pcie { + status = "okay"; +}; + +&pinctrl { + pinctrl_leds: leds { + function = "led"; + pins = "gpio1", "gpio2", "gpio3", + "gpio4", "gpio5", "gpio10", + "gpio11"; + }; +}; + +&switch0 { + ports { + port@0 { + reg = <0>; + label = "lan1"; + + phy-handle = <&phy1>; + phy-mode = "mii"; + }; + + port@1 { + reg = <1>; + label = "lan2"; + + phy-handle = <&phy2>; + phy-mode = "mii"; + }; + + port@2 { + reg = <2>; + label = "lan3"; + + phy-handle = <&phy3>; + phy-mode = "mii"; + }; + + port@3 { + reg = <3>; + label = "lan4"; + + phy-handle = <&phy4>; + phy-mode = "mii"; + }; + }; +}; + +&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/bcm6328.mk b/target/linux/bmips/image/bcm6328.mk index ef74410f1e..8023ef8fa1 100644 --- a/target/linux/bmips/image/bcm6328.mk +++ b/target/linux/bmips/image/bcm6328.mk @@ -26,6 +26,19 @@ define Device/comtrend_ar-5387un endef TARGET_DEVICES += comtrend_ar-5387un +define Device/nucom_r5010unv2 + $(Device/bcm63xx-cfe) + DEVICE_VENDOR := NuCom + DEVICE_MODEL := R5010UNv2 + CHIP_ID := 6328 + CFE_BOARD_ID := 96328ang + FLASH_MB := 16 + DEVICE_PACKAGES += $(USB2_PACKAGES) \ + $(B43_PACKAGES) broadcom-43217-sprom \ + kmod-leds-bcm6328 +endef +TARGET_DEVICES += nucom_r5010unv2 + define Device/sercomm_ad1018 $(Device/sercomm-nand) DEVICE_VENDOR := Sercomm