From 2555ffb4536e2727465e9a0d426ad3c4f1ef003a Mon Sep 17 00:00:00 2001 From: Vincent Wiemann Date: Mon, 28 Dec 2020 16:00:13 +0100 Subject: [PATCH 01/23] rules_mk: use gcc versions for external toolchain When using the OpenWrt toolchain as an external toolchain the build failed due to missing LTO support. By choosing the GCC wrappers of the tools this commit makes sure that the LTO-enabled executables are being used. Signed-off-by: Vincent Wiemann [ wrap the commit description to 72 char ] Signed-off-by: Christian Marangi --- rules.mk | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/rules.mk b/rules.mk index 8a4254e638..dd375ff3d5 100644 --- a/rules.mk +++ b/rules.mk @@ -243,20 +243,13 @@ HOST_CXXFLAGS:= HOST_CFLAGS:=-O2 $(HOST_CPPFLAGS) HOST_LDFLAGS:=-L$(STAGING_DIR_HOST)/lib $(if $(IS_PACKAGE_BUILD),-L$(STAGING_DIR_HOSTPKG)/lib -L$(STAGING_DIR)/host/lib) -ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),) - TARGET_AR:=$(TARGET_CROSS)gcc-ar - TARGET_RANLIB:=$(TARGET_CROSS)gcc-ranlib - TARGET_NM:=$(TARGET_CROSS)gcc-nm -else - TARGET_AR:=$(TARGET_CROSS)ar - TARGET_RANLIB:=$(TARGET_CROSS)ranlib - TARGET_NM:=$(TARGET_CROSS)nm -endif - BUILD_KEY=$(TOPDIR)/key-build FAKEROOT:=$(STAGING_DIR_HOST)/bin/fakeroot +TARGET_AR:=$(TARGET_CROSS)gcc-ar +TARGET_RANLIB:=$(TARGET_CROSS)gcc-ranlib +TARGET_NM:=$(TARGET_CROSS)gcc-nm TARGET_CC:=$(TARGET_CROSS)gcc TARGET_CXX:=$(TARGET_CROSS)g++ KPATCH:=$(SCRIPT_DIR)/patch-kernel.sh From a90eabf60255773231ed0259e5da5eb6a36fe9ce Mon Sep 17 00:00:00 2001 From: Christian Marangi Date: Sun, 3 Jul 2022 02:06:21 +0200 Subject: [PATCH 02/23] rules_mk: don't include wrapped bin with external toolchains Don't add wrapped bin to the TARGET_PATH as it does cause compilation error. cmake.mk will use the "command -v" and will use the wrapped bin instead of the external toolchain bin as they have the same name and command will select the first result. Signed-off-by: Christian Marangi --- rules.mk | 1 - 1 file changed, 1 deletion(-) diff --git a/rules.mk b/rules.mk index dd375ff3d5..5a56fd6f4a 100644 --- a/rules.mk +++ b/rules.mk @@ -208,7 +208,6 @@ ifndef DUMP ifneq ($(TOOLCHAIN_LIB_DIRS),) TARGET_LDFLAGS+= $(patsubst %,-L%,$(TOOLCHAIN_LIB_DIRS)) endif - TARGET_PATH:=$(TOOLCHAIN_DIR)/bin:$(TARGET_PATH) endif endif endif From 53c293262fce844c8291ab82e6726a8489d3c57b Mon Sep 17 00:00:00 2001 From: Christian Marangi Date: Sun, 3 Jul 2022 02:20:11 +0200 Subject: [PATCH 03/23] scripts: ext-toolchain: fix wrong prefix in print_config generation The parsed prefix in print_config is wrong and this produce broken generated .config that won't work with any external toolchain. Currently the prefix from a CC of 'arm-openwrt-linux-muslgnueabi-gcc-12.1.0' produce a prefix 'arm-openwrt-linux-muslgnueabi-gcc-' This is wrong as the real prefix should be 'arm-openwrt-linux-muslgnueabi-' This is probably caused by a change in how the toolchain is now handled that now append also the gcc version. Probably in ancient days the version wasn't part of the name and the prefix generation stripped the '-gcc' instead of the gcc version. Fix this and correctly strip the gcc version and the gcc suffix to correctly call toolchain bins. Signed-off-by: Christian Marangi --- scripts/ext-toolchain.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/ext-toolchain.sh b/scripts/ext-toolchain.sh index 4da287591a..b52f170b32 100755 --- a/scripts/ext-toolchain.sh +++ b/scripts/ext-toolchain.sh @@ -281,8 +281,11 @@ print_config() { local mksubtarget local target="$("$CC" $CFLAGS -dumpmachine)" + local version="$("$CC" $CFLAGS -dumpversion)" local cpuarch="${target%%-*}" - local prefix="${CC##*/}"; prefix="${prefix%-*}-" + + # get CC; strip version; strip gcc and add - suffix + local prefix="${CC##*/}"; prefix="${prefix%-$version}"; prefix="${prefix%-*}-" local config="${0%/scripts/*}/.config" # if no target specified, print choice list and exit From f4dd18ca39c42a324e34633c8ee553717531bc3b Mon Sep 17 00:00:00 2001 From: Christian Marangi Date: Mon, 4 Jul 2022 18:22:18 +0200 Subject: [PATCH 04/23] scripts: ext-toolchain: add option to overwrite config It can be useful to overwrite an already generated config. Option are simply added at the end of the config and make defconfig will overwrite the relevant option with the new one. Signed-off-by: Christian Marangi --- scripts/ext-toolchain.sh | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/scripts/ext-toolchain.sh b/scripts/ext-toolchain.sh index b52f170b32..c9ceb150c1 100755 --- a/scripts/ext-toolchain.sh +++ b/scripts/ext-toolchain.sh @@ -50,6 +50,7 @@ BIN_SPECS=" gdbserver: gdbserver " +OVERWRITE_CONFIG="" test_c() { cat <<-EOT | "${CC:-false}" $CFLAGS -o /dev/null -x c - 2>/dev/null @@ -320,9 +321,13 @@ print_config() { fi # bail out if there is a .config already - if [ -f "${0%/scripts/*}/.config" ]; then - echo "There already is a .config file, refusing to overwrite!" >&2 - return 1 + if [ -f "$config" ]; then + if [ "$OVERWRITE_CONFIG" == "" ]; then + echo "There already is a .config file, refusing to overwrite!" >&2 + return 1 + else + echo "There already is a .config file, trying to overwrite!" + fi fi case "$mktarget" in */*) @@ -330,8 +335,11 @@ print_config() { mktarget="${mktarget%/*}" ;; esac + if [ ! -f "$config" ]; then + touch "$config" + fi - echo "CONFIG_TARGET_${mktarget}=y" > "$config" + echo "CONFIG_TARGET_${mktarget}=y" >> "$config" if [ -n "$mksubtarget" ]; then echo "CONFIG_TARGET_${mktarget}_${mksubtarget}=y" >> "$config" @@ -532,6 +540,10 @@ while [ -n "$1" ]; do exit $? ;; + --overwrite-config) + OVERWRITE_CONFIG=y + ;; + --config) if probe_cc; then print_config "$1" @@ -573,6 +585,8 @@ while [ -n "$1" ]; do echo -e " is used to specify C flags to be passed to the " >&2 echo -e " cross compiler when performing tests." >&2 echo -e " This parameter may be repeated multiple times." >&2 + echo -e " Use --overwrite-config before --config to overwrite" >&2 + echo -e " an already present config with the required changes.">&2 exit 1 ;; From ddeabc75ebe3151ff7da302cb1aae702b3ad7eba Mon Sep 17 00:00:00 2001 From: Christian Marangi Date: Sun, 17 Jul 2022 17:53:58 +0200 Subject: [PATCH 05/23] scripts: ext-toolchain: actually probe libc type on config generation Currently we never call probe_cc before config generation, this cause the script to never actually detect the correct libc type. Call probe_cc before config generation to correctl set the .config file. Signed-off-by: Christian Marangi --- scripts/ext-toolchain.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/ext-toolchain.sh b/scripts/ext-toolchain.sh index c9ceb150c1..1ef3f42c50 100755 --- a/scripts/ext-toolchain.sh +++ b/scripts/ext-toolchain.sh @@ -546,6 +546,7 @@ while [ -n "$1" ]; do --config) if probe_cc; then + probe_libc print_config "$1" exit $? fi From 75311977f5ff64b491cb57ac713d75e0e410d786 Mon Sep 17 00:00:00 2001 From: Christian Marangi Date: Sun, 17 Jul 2022 17:56:36 +0200 Subject: [PATCH 06/23] scripts: ext-toolchain: add support for info.mk in probe_cc Openwrt generate info.mk that contains the libc type. For probe_cc check if the file exist and parse directly it for LIBC type. Signed-off-by: Christian Marangi --- scripts/ext-toolchain.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/ext-toolchain.sh b/scripts/ext-toolchain.sh index 1ef3f42c50..1f8eca3076 100755 --- a/scripts/ext-toolchain.sh +++ b/scripts/ext-toolchain.sh @@ -463,6 +463,13 @@ probe_cpp() { } probe_libc() { + if [ -f $TOOLCHAIN/info.mk ]; then + LIBC_TYPE=$(grep LIBC_TYPE $TOOLCHAIN/info.mk | sed 's/LIBC_TYPE=//') + return 0 + fi + + echo "Warning! Can't find info.mk, trying to detect with alternative way." + if [ -z "$LIBC_TYPE" ]; then if test_uclibc; then LIBC_TYPE="uclibc" From 7be01fe13b4517e5edb8a4818f437d60144cdcb4 Mon Sep 17 00:00:00 2001 From: Christian Marangi Date: Sun, 17 Jul 2022 17:56:59 +0200 Subject: [PATCH 07/23] scripts: ext-toolchain: add support for musl Openwrt now supports only glibc and musl. Add support for musl and rework the libc check to handle the new config flags and correctly compile package basend on that. Signed-off-by: Christian Marangi --- scripts/ext-toolchain.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/scripts/ext-toolchain.sh b/scripts/ext-toolchain.sh index 1f8eca3076..fe1024c18e 100755 --- a/scripts/ext-toolchain.sh +++ b/scripts/ext-toolchain.sh @@ -369,8 +369,18 @@ print_config() { echo "CONFIG_TOOLCHAIN_PREFIX=\"$prefix\"" >> "$config" echo "CONFIG_TARGET_NAME=\"$target\"" >> "$config" - if [ "$LIBC_TYPE" != glibc ]; then - echo "CONFIG_TOOLCHAIN_LIBC=\"$LIBC_TYPE\"" >> "$config" + if [ -f "$config" ]; then + sed -i '/CONFIG_EXTERNAL_TOOLCHAIN_LIBC_USE_MUSL/d' "$config" + sed -i '/CONFIG_EXTERNAL_TOOLCHAIN_LIBC_USE_GLIBC/d' "$config" + fi + + if [ "$LIBC_TYPE" == glibc ]; then + echo "CONFIG_EXTERNAL_TOOLCHAIN_LIBC_USE_GLIBC=y" >> "$config" + elif [ "$LIBC_TYPE" == musl ]; then + echo "CONFIG_EXTERNAL_TOOLCHAIN_LIBC_USE_MUSL=y" >> "$config" + else + echo "Can't detect LIBC type. Aborting!" >&2 + return 1 fi local lib From c17c931a90e5cb9613875a42ef8eace46be539f3 Mon Sep 17 00:00:00 2001 From: Paul Spooren Date: Wed, 9 Mar 2022 18:22:22 +0100 Subject: [PATCH 08/23] CI: add Kernel compile tests Add Github Actions yaml script to build test kernel PR changes for each target. Signed-off-by: Paul Spooren [ add commit description ] Signed-off-by: Christian Marangi --- .github/workflows/kernel.yml | 143 +++++++++++++++++++++++++++++++++++ 1 file changed, 143 insertions(+) create mode 100644 .github/workflows/kernel.yml diff --git a/.github/workflows/kernel.yml b/.github/workflows/kernel.yml new file mode 100644 index 0000000000..268c703baf --- /dev/null +++ b/.github/workflows/kernel.yml @@ -0,0 +1,143 @@ +name: Build Kernel + +on: + pull_request: + paths: + - 'include/kernel-*' + - 'package/kernel/**' +jobs: + determine_targets: + name: Set targets + runs-on: ubuntu-latest + outputs: + target: ${{ steps.find_targets.outputs.target }} + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Set targets + id: find_targets + run: | + export TARGETS="$(perl ./scripts/dump-target-info.pl targets 2>/dev/null \ + | sort -u -t '/' -k1,1 \ + | awk '{ print $1 }')" + + JSON='[' + FIRST=1 + for TARGET in $TARGETS; do + [[ $FIRST -ne 1 ]] && JSON="$JSON"',' + JSON="$JSON"'"'"${TARGET}"'"' + FIRST=0 + done + JSON="$JSON"']' + + echo -e "\n---- targets ----\n" + echo "$JSON" + echo -e "\n---- targets ----\n" + + echo "::set-output name=target::$JSON" + + build: + name: Build Kernel with external toolchain + needs: determine_targets + runs-on: ubuntu-latest + strategy: + fail-fast: False + matrix: + target: ${{fromJson(needs.determine_targets.outputs.target)}} + + steps: + - name: Checkout master directory + uses: actions/checkout@v2 + with: + path: openwrt + + - name: Setup Ubuntu + env: + DEBIAN_FRONTEND: noninteractive + run: | + sudo apt-get update + sudo apt-get -y install \ + build-essential \ + ccache \ + clang-12 \ + ecj \ + fastjar \ + file \ + g++ \ + gawk \ + gettext \ + git \ + java-propose-classpath \ + libelf-dev \ + libncurses-dev \ + libssl-dev \ + mkisofs \ + python3 \ + python3-dev \ + python3-distutils \ + python3-setuptools \ + qemu-utils \ + rsync \ + subversion \ + swig \ + unzip \ + wget \ + xsltproc \ + zlib1g-dev + + - name: Initialization environment + run: | + TARGET=$(echo ${{ matrix.target }} | cut -d "/" -f 1) + SUBTARGET=$(echo ${{ matrix.target }} | cut -d "/" -f 2) + echo "TARGET=$TARGET" >> "$GITHUB_ENV" + echo "SUBTARGET=$SUBTARGET" >> "$GITHUB_ENV" + + - name: Update & Install feeds + run: | + cd openwrt + ./scripts/feeds update -a + ./scripts/feeds install -a + + - name: Setup external toolchain + run: | + cd openwrt + TOOLCHAIN_FILE=$(curl "https://downloads.openwrt.org/snapshots/targets/${{ env.TARGET }}/${{ env.SUBTARGET }}/sha256sums" \ + | sed -n -e 's/.*\(openwrt-toolchain.*\).tar.xz/\1/p') + + echo "TOOLCHAIN_FILE=$TOOLCHAIN_FILE" >> "$GITHUB_ENV" + + wget -O - https://downloads.openwrt.org/snapshots/targets/${{ env.TARGET }}/${{ env.SUBTARGET }}/${TOOLCHAIN_FILE}.tar.xz \ + | tar --xz -xf - + + - name: Configure external toolchain + run: | + cd openwrt + ./scripts/ext-toolchain.sh \ + --toolchain ${{ env.TOOLCHAIN_FILE }}/toolchain-* \ + --config ${{ env.TARGET }}/${{ env.SUBTARGET }} + + make defconfig + + - name: Build tools + run: | + cd openwrt + make tools/install -j$(nproc) BUILD_LOG=1 + + - name: Build toolchain + run: | + cd openwrt + make toolchain/install -j$(nproc) BUILD_LOG=1 + + - name: Build Kernel + run: | + cd openwrt + make target/compile -j$(nproc) BUILD_LOG=1 + + - name: Upload logs + if: failure() + uses: actions/upload-artifact@v2 + with: + name: ${{ env.TARGET }}-${{ env.SUBTARGET }}-logs + path: "openwrt/logs" From 8a77adb0485aeb40f6550eb7fcdb461b3eaffe58 Mon Sep 17 00:00:00 2001 From: Paul Spooren Date: Sun, 20 Mar 2022 15:31:24 +0000 Subject: [PATCH 09/23] CI: run inside the buildbot docker container Run github actions insider buildbot docker container. Signed-off-by: Paul Spooren [ run container under buildbot user ] Signed-off-by: Christian Marangi --- .github/workflows/kernel.yml | 70 +++++++++++++----------------------- 1 file changed, 24 insertions(+), 46 deletions(-) diff --git a/.github/workflows/kernel.yml b/.github/workflows/kernel.yml index 268c703baf..f7e5d542b4 100644 --- a/.github/workflows/kernel.yml +++ b/.github/workflows/kernel.yml @@ -47,45 +47,17 @@ jobs: matrix: target: ${{fromJson(needs.determine_targets.outputs.target)}} + container: registry.gitlab.com/openwrt/buildbot/buildworker-3.4.1 + steps: - name: Checkout master directory uses: actions/checkout@v2 with: path: openwrt - - name: Setup Ubuntu - env: - DEBIAN_FRONTEND: noninteractive + - name: Fix permission run: | - sudo apt-get update - sudo apt-get -y install \ - build-essential \ - ccache \ - clang-12 \ - ecj \ - fastjar \ - file \ - g++ \ - gawk \ - gettext \ - git \ - java-propose-classpath \ - libelf-dev \ - libncurses-dev \ - libssl-dev \ - mkisofs \ - python3 \ - python3-dev \ - python3-distutils \ - python3-setuptools \ - qemu-utils \ - rsync \ - subversion \ - swig \ - unzip \ - wget \ - xsltproc \ - zlib1g-dev + chown -R buildbot:buildbot openwrt - name: Initialization environment run: | @@ -95,25 +67,31 @@ jobs: echo "SUBTARGET=$SUBTARGET" >> "$GITHUB_ENV" - name: Update & Install feeds + shell: su buildbot -c "sh -e {0}" + working-directory: openwrt run: | - cd openwrt ./scripts/feeds update -a ./scripts/feeds install -a - - name: Setup external toolchain + - name: Parse toolchain file + working-directory: openwrt run: | - cd openwrt TOOLCHAIN_FILE=$(curl "https://downloads.openwrt.org/snapshots/targets/${{ env.TARGET }}/${{ env.SUBTARGET }}/sha256sums" \ | sed -n -e 's/.*\(openwrt-toolchain.*\).tar.xz/\1/p') echo "TOOLCHAIN_FILE=$TOOLCHAIN_FILE" >> "$GITHUB_ENV" - + + - name: Download external toolchain + shell: su buildbot -c "sh -e {0}" + working-directory: openwrt + run: | wget -O - https://downloads.openwrt.org/snapshots/targets/${{ env.TARGET }}/${{ env.SUBTARGET }}/${TOOLCHAIN_FILE}.tar.xz \ | tar --xz -xf - - name: Configure external toolchain + shell: su buildbot -c "sh -e {0}" + working-directory: openwrt run: | - cd openwrt ./scripts/ext-toolchain.sh \ --toolchain ${{ env.TOOLCHAIN_FILE }}/toolchain-* \ --config ${{ env.TARGET }}/${{ env.SUBTARGET }} @@ -121,19 +99,19 @@ jobs: make defconfig - name: Build tools - run: | - cd openwrt - make tools/install -j$(nproc) BUILD_LOG=1 + shell: su buildbot -c "sh -e {0}" + working-directory: openwrt + run: make tools/install -j$(nproc) BUILD_LOG=1 - name: Build toolchain - run: | - cd openwrt - make toolchain/install -j$(nproc) BUILD_LOG=1 + shell: su buildbot -c "sh -e {0}" + working-directory: openwrt + run: make toolchain/install -j$(nproc) BUILD_LOG=1 - name: Build Kernel - run: | - cd openwrt - make target/compile -j$(nproc) BUILD_LOG=1 + shell: su buildbot -c "sh -e {0}" + working-directory: openwrt + run: make target/compile -j$(nproc) BUILD_LOG=1 - name: Upload logs if: failure() From 6ae2f7ff4737ec8dbec026fc6c02f7d1850b521c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= Date: Wed, 20 Jul 2022 13:47:05 +0200 Subject: [PATCH 10/23] bcm4908: build bootfs image per-SoC MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In theory we could have just 1 bootfs image for all devices as each device has its own entry in the "configurations" node. It doesn't work well with default configuration though. If something goes wrong U-Boot SPL can be interrupted (by pressing A) to enter its minimalistic menu. It allows ignoring boardid. In such case bootfs default configuration is used. For above reason each SoC family (BCM4908, BCM4912) should have its own bootfs built. It allows each of them to have working default configuration. Signed-off-by: Rafał Miłecki --- target/linux/bcm4908/image/Makefile | 19 +++---- target/linux/bcm4908/image/bootfs-bcm4908.its | 48 ++++++++++++++++++ target/linux/bcm4908/image/bootfs-bcm4912.its | 34 +++++++++++++ .../image/{bootfs-generic.its => bootfs.itsi} | 50 ------------------- 4 files changed, 92 insertions(+), 59 deletions(-) create mode 100644 target/linux/bcm4908/image/bootfs-bcm4908.its create mode 100644 target/linux/bcm4908/image/bootfs-bcm4912.its rename target/linux/bcm4908/image/{bootfs-generic.its => bootfs.itsi} (52%) diff --git a/target/linux/bcm4908/image/Makefile b/target/linux/bcm4908/image/Makefile index 809ae9fad4..7116c2a9f1 100644 --- a/target/linux/bcm4908/image/Makefile +++ b/target/linux/bcm4908/image/Makefile @@ -5,19 +5,20 @@ include $(INCLUDE_DIR)/image.mk DEVICE_VARS += ASUS_PRODUCTID ASUS_BUILD_NO ASUS_FW_REV ASUS_EXT_NO DEVICE_VARS += NETGEAR_BOARD_ID NETGEAR_REGION -DEVICE_VARS += PKGTB_ITS +DEVICE_VARS += SOC define Image/Prepare - cp bootfs-generic.its $(KDIR)/ - sed -i "s=\$$$${images_dir}=$(STAGING_DIR_IMAGE)=" $(KDIR)/bootfs-generic.its - sed -i "s=\$$$${dts_dir}=$(DTS_DIR)=" $(KDIR)/bootfs-generic.its + cp bootfs*.its* $(KDIR)/ + sed -i "s=\$$$${images_dir}=$(STAGING_DIR_IMAGE)=" $(KDIR)/bootfs*.its* + sed -i "s=\$$$${dts_dir}=$(DTS_DIR)=" $(KDIR)/bootfs*.its* endef define Build/bootfs cat $@ | $(STAGING_DIR_HOST)/bin/lzma e -eos -si -so > $@.tmp mv $@.tmp $@ - sed -i "s=\$${kernel}=$@=" $(KDIR)/bootfs-generic.its - PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage -f $(KDIR)/bootfs-generic.its $(KDIR)/bootfs-generic.itb + sed -i "s=\$${kernel}=$@=" $(KDIR)/bootfs*.its* + PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage -f $(KDIR)/bootfs-bcm4908.its $(KDIR)/bootfs-bcm4908.itb + PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage -f $(KDIR)/bootfs-bcm4912.its $(KDIR)/bootfs-bcm4912.itb endef define Build/bcm4908asus @@ -54,8 +55,8 @@ endef define Build/pkgtb mv $@ $@.rootfs - cp $(PKGTB_ITS) $@.its - sed -i "s=\$${bootfs}=$(KDIR)/bootfs-generic.itb=" $@.its + cp pkgtb-$(SOC).its $@.its + sed -i "s=\$${bootfs}=$(KDIR)/bootfs-$(SOC).itb=" $@.its sed -i "s=\$${rootfs}=$@.rootfs=" $@.its PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage -f $@.its $@ endef @@ -129,7 +130,7 @@ endef define Device/netgear_raxe500 DEVICE_MODEL := RAXE500 $(Device/netgear) - PKGTB_ITS := pkgtb-bcm4908.its + SOC := bcm4908 NETGEAR_BOARD_ID := U12H449T00_NETGEAR endef # TARGET_DEVICES += netgear_raxe500 diff --git a/target/linux/bcm4908/image/bootfs-bcm4908.its b/target/linux/bcm4908/image/bootfs-bcm4908.its new file mode 100644 index 0000000000..b80cbd529e --- /dev/null +++ b/target/linux/bcm4908/image/bootfs-bcm4908.its @@ -0,0 +1,48 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +/include/ "bootfs.itsi" + +/ { + images { + uboot { + data = /incbin/("${images_dir}/u-boot/u-boot-nodtb.bin"); + }; + + fdt_uboot { + data = /incbin/("${images_dir}/u-boot/u-boot.dtb"); + }; + + fdt_uboot_RAX220 { + description = "dtb"; + data = /incbin/("${images_dir}/u-boot/RAX220.dtb"); + type = "flat_dt"; + compression = "none"; + + hash-1 { + algo = "sha256"; + }; + }; + + fdt_linux_RAX220 { + description = "dtb"; + data = /incbin/("${dts_dir}/broadcom/bcm4908/bcm4908-netgear-raxe500.dtb"); + arch = "arm64"; + type = "flat_dt"; + compression = "none"; + }; + }; + + configurations { + conf_ub_RAX220 { + description = "RAX220"; + fdt = "fdt_uboot_RAX220"; + loadables = "atf", "uboot"; + }; + + conf_lx_RAX220 { + description = "BRCM 63xxx linux"; + kernel = "kernel"; + fdt = "fdt_linux_RAX220"; + }; + }; +}; diff --git a/target/linux/bcm4908/image/bootfs-bcm4912.its b/target/linux/bcm4908/image/bootfs-bcm4912.its new file mode 100644 index 0000000000..7c91144a18 --- /dev/null +++ b/target/linux/bcm4908/image/bootfs-bcm4912.its @@ -0,0 +1,34 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +/include/ "bootfs.itsi" + +/ { + images { + uboot { + data = /incbin/("${images_dir}/u-boot/u-boot-nodtb.bin"); + }; + + fdt_uboot { + data = /incbin/("${images_dir}/u-boot/u-boot.dtb"); + }; + + fdt_GTAX6000 { + description = "dtb"; + data = /incbin/("${images_dir}/u-boot/GTAX6000.dtb"); + type = "flat_dt"; + compression = "none"; + + hash-1 { + algo = "sha256"; + }; + }; + }; + + configurations { + conf_ub_GTAX6000 { + description = "GTAX6000"; + fdt = "fdt_GTAX6000"; + loadables = "atf", "uboot"; + }; + }; +}; diff --git a/target/linux/bcm4908/image/bootfs-generic.its b/target/linux/bcm4908/image/bootfs.itsi similarity index 52% rename from target/linux/bcm4908/image/bootfs-generic.its rename to target/linux/bcm4908/image/bootfs.itsi index d32e094eb5..ceaaf10b2b 100644 --- a/target/linux/bcm4908/image/bootfs-generic.its +++ b/target/linux/bcm4908/image/bootfs.itsi @@ -24,7 +24,6 @@ uboot { description = "U-Boot"; - data = /incbin/("${images_dir}/u-boot/u-boot-nodtb.bin"); os = "U-Boot"; arch = "arm64"; compression = "none"; @@ -53,7 +52,6 @@ fdt_uboot { description = "dtb"; - data = /incbin/("${images_dir}/u-boot/u-boot.dtb"); type = "flat_dt"; compression = "none"; @@ -61,36 +59,6 @@ algo = "sha256"; }; }; - - fdt_GTAX6000 { - description = "dtb"; - data = /incbin/("${images_dir}/u-boot/GTAX6000.dtb"); - type = "flat_dt"; - compression = "none"; - - hash-1 { - algo = "sha256"; - }; - }; - - fdt_uboot_RAX220 { - description = "dtb"; - data = /incbin/("${images_dir}/u-boot/RAX220.dtb"); - type = "flat_dt"; - compression = "none"; - - hash-1 { - algo = "sha256"; - }; - }; - - fdt_linux_RAX220 { - description = "dtb"; - data = /incbin/("${dts_dir}/broadcom/bcm4908/bcm4908-netgear-raxe500.dtb"); - arch = "arm64"; - type = "flat_dt"; - compression = "none"; - }; }; configurations { @@ -101,23 +69,5 @@ fdt = "fdt_uboot"; loadables = "atf", "uboot"; }; - - conf_ub_GTAX6000 { - description = "GTAX6000"; - fdt = "fdt_GTAX6000"; - loadables = "atf", "uboot"; - }; - - conf_ub_RAX220 { - description = "RAX220"; - fdt = "fdt_uboot_RAX220"; - loadables = "atf", "uboot"; - }; - - conf_lx_RAX220 { - description = "BRCM 63xxx linux"; - kernel = "kernel"; - fdt = "fdt_linux_RAX220"; - }; }; }; From a8e1e30543239e85ff5dc220368164b66cf73fba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= Date: Wed, 20 Jul 2022 13:47:06 +0200 Subject: [PATCH 11/23] uboot-bcm4908: include SoC in output files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes problem of overwriting BCM4908 U-Boot and DTB files by BCM4912 ones. That bug didn't allow booting BCM4908 devices. Fixes: f4c2dab544ec2 ("uboot-bcm4908: add BCM4912 build") Signed-off-by: Rafał Miłecki --- package/boot/uboot-bcm4908/Makefile | 6 ++++-- target/linux/bcm4908/image/bootfs-bcm4908.its | 4 ++-- target/linux/bcm4908/image/bootfs-bcm4912.its | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/package/boot/uboot-bcm4908/Makefile b/package/boot/uboot-bcm4908/Makefile index d6b689c9ce..7eacd23a02 100644 --- a/package/boot/uboot-bcm4908/Makefile +++ b/package/boot/uboot-bcm4908/Makefile @@ -23,11 +23,13 @@ endef define U-Boot/bcm4908 NAME:=Broadcom's BCM4908 UBOOT_CONFIG:=bcm94908 + SOC:=bcm4908 endef define U-Boot/bcm4912 NAME:=Broadcom's BCM4912 UBOOT_CONFIG:=bcm94912 + SOC:=bcm4912 endef UBOOT_TARGETS := \ @@ -46,8 +48,8 @@ endef define Build/InstallDev $(INSTALL_DIR) $(STAGING_DIR_IMAGE)/u-boot - $(INSTALL_BIN) $(PKG_BUILD_DIR)/$(UBOOT_IMAGE) $(STAGING_DIR_IMAGE)/u-boot/ - $(INSTALL_BIN) $(PKG_BUILD_DIR)/u-boot.dtb $(STAGING_DIR_IMAGE)/u-boot/ + $(INSTALL_BIN) $(PKG_BUILD_DIR)/$(UBOOT_IMAGE) $(STAGING_DIR_IMAGE)/u-boot/u-boot-$(SOC).bin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/u-boot.dtb $(STAGING_DIR_IMAGE)/u-boot/u-boot-$(SOC).dtb $(INSTALL_BIN) $(PKG_BUILD_DIR)/arch/arm/dts/*.dtb $(STAGING_DIR_IMAGE)/u-boot/ endef diff --git a/target/linux/bcm4908/image/bootfs-bcm4908.its b/target/linux/bcm4908/image/bootfs-bcm4908.its index b80cbd529e..d5ac21fd6a 100644 --- a/target/linux/bcm4908/image/bootfs-bcm4908.its +++ b/target/linux/bcm4908/image/bootfs-bcm4908.its @@ -5,11 +5,11 @@ / { images { uboot { - data = /incbin/("${images_dir}/u-boot/u-boot-nodtb.bin"); + data = /incbin/("${images_dir}/u-boot/u-boot-bcm4908.bin"); }; fdt_uboot { - data = /incbin/("${images_dir}/u-boot/u-boot.dtb"); + data = /incbin/("${images_dir}/u-boot/u-boot-bcm4908.dtb"); }; fdt_uboot_RAX220 { diff --git a/target/linux/bcm4908/image/bootfs-bcm4912.its b/target/linux/bcm4908/image/bootfs-bcm4912.its index 7c91144a18..6f4548956c 100644 --- a/target/linux/bcm4908/image/bootfs-bcm4912.its +++ b/target/linux/bcm4908/image/bootfs-bcm4912.its @@ -5,11 +5,11 @@ / { images { uboot { - data = /incbin/("${images_dir}/u-boot/u-boot-nodtb.bin"); + data = /incbin/("${images_dir}/u-boot/u-boot-bcm4912.bin"); }; fdt_uboot { - data = /incbin/("${images_dir}/u-boot/u-boot.dtb"); + data = /incbin/("${images_dir}/u-boot/u-boot-bcm4912.dtb"); }; fdt_GTAX6000 { From b2681e584c0674788fc1f11dd9950cb769d961e9 Mon Sep 17 00:00:00 2001 From: Markus Stockhausen Date: Fri, 8 Jul 2022 17:27:22 +0200 Subject: [PATCH 12/23] realtek: make DGS-1210 u-boot-env partition writeable We are close to provide enduser friendly OpenWrt images for DGS-1210 switches that do not need serial console. Nevertheless a small bit is missing. We cannot switch back to the vendor partition or initiate a download of a vendor firmware image. To issue this from inside OpenWrt we need write access to U-Boot environment. Case 1: Switch back to secondary (vendor) image > fw_setenv bootcmd run addargs\; bootm 0xb4e80000 > fw_setenv image /dev/mtdblock7 > reboot Case 2: Issue D-Link Network Assistant based download on next reboot. This is a combination of some vendor specific protocol (DDP) and a TFTP download afterwards. > fw_setenv bootstop on > reboot Allow these commands by opening up u-boot-env for write access. Tested on DGS-1210-20. Signed-off-by: Markus Stockhausen --- target/linux/realtek/dts-5.10/rtl8382_d-link_dgs-1210.dtsi | 1 - 1 file changed, 1 deletion(-) diff --git a/target/linux/realtek/dts-5.10/rtl8382_d-link_dgs-1210.dtsi b/target/linux/realtek/dts-5.10/rtl8382_d-link_dgs-1210.dtsi index 09f5555307..565ba45de6 100644 --- a/target/linux/realtek/dts-5.10/rtl8382_d-link_dgs-1210.dtsi +++ b/target/linux/realtek/dts-5.10/rtl8382_d-link_dgs-1210.dtsi @@ -55,7 +55,6 @@ partition@80000 { label = "u-boot-env"; reg = <0x00080000 0x40000>; - read-only; }; partition@c0000 { label = "board-name"; From bac50e39a7b4f109bb5efed0738c9a896a1c140e Mon Sep 17 00:00:00 2001 From: Jan Hoffmann Date: Sat, 23 Jul 2022 22:53:13 +0200 Subject: [PATCH 13/23] realtek: rtl83xx-phy: fix RTL8214FC media change Toggle power on the individual PHY instead of the package. Otherwise a media change always toggles power on the first port, and not the one that is being configured. Signed-off-by: Jan Hoffmann --- .../files-5.10/drivers/net/phy/rtl83xx-phy.c | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/target/linux/realtek/files-5.10/drivers/net/phy/rtl83xx-phy.c b/target/linux/realtek/files-5.10/drivers/net/phy/rtl83xx-phy.c index f0c30b3655..2523894891 100644 --- a/target/linux/realtek/files-5.10/drivers/net/phy/rtl83xx-phy.c +++ b/target/linux/realtek/files-5.10/drivers/net/phy/rtl83xx-phy.c @@ -949,19 +949,20 @@ static void rtl8380_rtl8214fc_media_set(struct phy_device *phydev, bool set_fibr pr_info("Current media %x\n", media); if (media & 0x2) { pr_info("Powering off COPPER\n"); - phy_package_write_paged(phydev, RTL83XX_PAGE_RAW, RTL821XINT_MEDIA_PAGE_SELECT, RTL821X_MEDIA_PAGE_COPPER); + phy_write_paged(phydev, RTL83XX_PAGE_RAW, RTL821XINT_MEDIA_PAGE_SELECT, RTL821X_MEDIA_PAGE_COPPER); /* Ensure power is off */ - power = phy_package_read_paged(phydev, RTL821X_PAGE_POWER, 0x10); + power = phy_read_paged(phydev, RTL821X_PAGE_POWER, 0x10); if (!(power & (1 << 11))) - phy_package_write_paged(phydev, RTL821X_PAGE_POWER, 0x10, power | (1 << 11)); + phy_write_paged(phydev, RTL821X_PAGE_POWER, 0x10, power | (1 << 11)); } else { - pr_info("Powering off FIBRE"); - phy_package_write_paged(phydev, RTL83XX_PAGE_RAW, RTL821XINT_MEDIA_PAGE_SELECT, RTL821X_MEDIA_PAGE_FIBRE); + pr_info("Powering off FIBRE\n"); + phy_write_paged(phydev, RTL83XX_PAGE_RAW, RTL821XINT_MEDIA_PAGE_SELECT, RTL821X_MEDIA_PAGE_FIBRE); /* Ensure power is off */ - power = phy_package_read_paged(phydev, RTL821X_PAGE_POWER, 0x10); + power = phy_read_paged(phydev, RTL821X_PAGE_POWER, 0x10); if (!(power & (1 << 11))) - phy_package_write_paged(phydev, RTL821X_PAGE_POWER, 0x10, power | (1 << 11)); + phy_write_paged(phydev, RTL821X_PAGE_POWER, 0x10, power | (1 << 11)); } + phy_write_paged(phydev, RTL83XX_PAGE_RAW, RTL821XINT_MEDIA_PAGE_SELECT, RTL821X_MEDIA_PAGE_AUTO); if (set_fibre) { val |= 1 << 10; @@ -975,22 +976,21 @@ static void rtl8380_rtl8214fc_media_set(struct phy_device *phydev, bool set_fibr phy_package_write_paged(phydev, RTL83XX_PAGE_RAW, RTL821XINT_MEDIA_PAGE_SELECT, RTL821X_MEDIA_PAGE_AUTO); if (set_fibre) { - pr_info("Powering on FIBRE"); - phy_package_write_paged(phydev, RTL83XX_PAGE_RAW, RTL821XINT_MEDIA_PAGE_SELECT, RTL821X_MEDIA_PAGE_FIBRE); + pr_info("Powering on FIBRE\n"); + phy_write_paged(phydev, RTL83XX_PAGE_RAW, RTL821XINT_MEDIA_PAGE_SELECT, RTL821X_MEDIA_PAGE_FIBRE); /* Ensure power is off */ - power = phy_package_read_paged(phydev, RTL821X_PAGE_POWER, 0x10); + power = phy_read_paged(phydev, RTL821X_PAGE_POWER, 0x10); if (power & (1 << 11)) - phy_package_write_paged(phydev, RTL821X_PAGE_POWER, 0x10, power & ~(1 << 11)); + phy_write_paged(phydev, RTL821X_PAGE_POWER, 0x10, power & ~(1 << 11)); } else { pr_info("Powering on COPPER\n"); - phy_package_write_paged(phydev, RTL83XX_PAGE_RAW, RTL821XINT_MEDIA_PAGE_SELECT, RTL821X_MEDIA_PAGE_COPPER); + phy_write_paged(phydev, RTL83XX_PAGE_RAW, RTL821XINT_MEDIA_PAGE_SELECT, RTL821X_MEDIA_PAGE_COPPER); /* Ensure power is off */ - power = phy_package_read_paged(phydev, RTL821X_PAGE_POWER, 0x10); + power = phy_read_paged(phydev, RTL821X_PAGE_POWER, 0x10); if (power & (1 << 11)) - phy_package_write_paged(phydev, RTL821X_PAGE_POWER, 0x10, power & ~(1 << 11)); + phy_write_paged(phydev, RTL821X_PAGE_POWER, 0x10, power & ~(1 << 11)); } - - phy_package_write_paged(phydev, RTL83XX_PAGE_RAW, RTL821XINT_MEDIA_PAGE_SELECT, RTL821X_MEDIA_PAGE_AUTO); + phy_write_paged(phydev, RTL83XX_PAGE_RAW, RTL821XINT_MEDIA_PAGE_SELECT, RTL821X_MEDIA_PAGE_AUTO); } static bool rtl8380_rtl8214fc_media_is_fibre(struct phy_device *phydev) From c6a7ea9f7f49fb805af54e586941f066e0a8786d Mon Sep 17 00:00:00 2001 From: Jan Hoffmann Date: Sat, 23 Jul 2022 22:53:14 +0200 Subject: [PATCH 14/23] realtek: rtl83xx-phy: decouple RTL8214FC media change and power config Move RTL8214FC power configuration to newly created suspend and resume methods. A media change now only results in power configuration if the PHY is not suspended, to avoid powering up a port when the interface is currently not up. While at it, remove the rtl8380 prefix from function names, as this is actually not SoC-specific. Tested-by: Birger Koblitz Signed-off-by: Jan Hoffmann --- .../files-5.10/drivers/net/phy/rtl83xx-phy.c | 152 ++++++++++-------- 1 file changed, 85 insertions(+), 67 deletions(-) diff --git a/target/linux/realtek/files-5.10/drivers/net/phy/rtl83xx-phy.c b/target/linux/realtek/files-5.10/drivers/net/phy/rtl83xx-phy.c index 2523894891..70b57924b9 100644 --- a/target/linux/realtek/files-5.10/drivers/net/phy/rtl83xx-phy.c +++ b/target/linux/realtek/files-5.10/drivers/net/phy/rtl83xx-phy.c @@ -934,66 +934,7 @@ static int rtl8218b_ext_match_phy_device(struct phy_device *phydev) return phydev->phy_id == PHY_ID_RTL8218B_E; } -static void rtl8380_rtl8214fc_media_set(struct phy_device *phydev, bool set_fibre) -{ - int mac = phydev->mdio.addr; - - static int reg[] = {16, 19, 20, 21}; - int val, media, power; - - pr_info("%s: port %d, set_fibre: %d\n", __func__, mac, set_fibre); - phy_package_write_paged(phydev, RTL83XX_PAGE_RAW, RTL821XINT_MEDIA_PAGE_SELECT, RTL821X_MEDIA_PAGE_INTERNAL); - val = phy_package_read_paged(phydev, RTL821X_PAGE_PORT, reg[mac % 4]); - - media = (val >> 10) & 0x3; - pr_info("Current media %x\n", media); - if (media & 0x2) { - pr_info("Powering off COPPER\n"); - phy_write_paged(phydev, RTL83XX_PAGE_RAW, RTL821XINT_MEDIA_PAGE_SELECT, RTL821X_MEDIA_PAGE_COPPER); - /* Ensure power is off */ - power = phy_read_paged(phydev, RTL821X_PAGE_POWER, 0x10); - if (!(power & (1 << 11))) - phy_write_paged(phydev, RTL821X_PAGE_POWER, 0x10, power | (1 << 11)); - } else { - pr_info("Powering off FIBRE\n"); - phy_write_paged(phydev, RTL83XX_PAGE_RAW, RTL821XINT_MEDIA_PAGE_SELECT, RTL821X_MEDIA_PAGE_FIBRE); - /* Ensure power is off */ - power = phy_read_paged(phydev, RTL821X_PAGE_POWER, 0x10); - if (!(power & (1 << 11))) - phy_write_paged(phydev, RTL821X_PAGE_POWER, 0x10, power | (1 << 11)); - } - phy_write_paged(phydev, RTL83XX_PAGE_RAW, RTL821XINT_MEDIA_PAGE_SELECT, RTL821X_MEDIA_PAGE_AUTO); - - if (set_fibre) { - val |= 1 << 10; - val &= ~(1 << 11); - } else { - val |= 1 << 10; - val |= 1 << 11; - } - phy_package_write_paged(phydev, RTL83XX_PAGE_RAW, RTL821XINT_MEDIA_PAGE_SELECT, RTL821X_MEDIA_PAGE_INTERNAL); - phy_package_write_paged(phydev, RTL821X_PAGE_PORT, reg[mac % 4], val); - phy_package_write_paged(phydev, RTL83XX_PAGE_RAW, RTL821XINT_MEDIA_PAGE_SELECT, RTL821X_MEDIA_PAGE_AUTO); - - if (set_fibre) { - pr_info("Powering on FIBRE\n"); - phy_write_paged(phydev, RTL83XX_PAGE_RAW, RTL821XINT_MEDIA_PAGE_SELECT, RTL821X_MEDIA_PAGE_FIBRE); - /* Ensure power is off */ - power = phy_read_paged(phydev, RTL821X_PAGE_POWER, 0x10); - if (power & (1 << 11)) - phy_write_paged(phydev, RTL821X_PAGE_POWER, 0x10, power & ~(1 << 11)); - } else { - pr_info("Powering on COPPER\n"); - phy_write_paged(phydev, RTL83XX_PAGE_RAW, RTL821XINT_MEDIA_PAGE_SELECT, RTL821X_MEDIA_PAGE_COPPER); - /* Ensure power is off */ - power = phy_read_paged(phydev, RTL821X_PAGE_POWER, 0x10); - if (power & (1 << 11)) - phy_write_paged(phydev, RTL821X_PAGE_POWER, 0x10, power & ~(1 << 11)); - } - phy_write_paged(phydev, RTL83XX_PAGE_RAW, RTL821XINT_MEDIA_PAGE_SELECT, RTL821X_MEDIA_PAGE_AUTO); -} - -static bool rtl8380_rtl8214fc_media_is_fibre(struct phy_device *phydev) +static bool rtl8214fc_media_is_fibre(struct phy_device *phydev) { int mac = phydev->mdio.addr; @@ -1003,11 +944,88 @@ static bool rtl8380_rtl8214fc_media_is_fibre(struct phy_device *phydev) phy_package_write_paged(phydev, RTL83XX_PAGE_RAW, RTL821XINT_MEDIA_PAGE_SELECT, RTL821X_MEDIA_PAGE_INTERNAL); val = phy_package_read_paged(phydev, RTL821X_PAGE_PORT, reg[mac % 4]); phy_package_write_paged(phydev, RTL83XX_PAGE_RAW, RTL821XINT_MEDIA_PAGE_SELECT, RTL821X_MEDIA_PAGE_AUTO); - if (val & (1 << 11)) + + if (val & BIT(11)) return false; + return true; } +static void rtl8214fc_power_set(struct phy_device *phydev, int port, bool on) +{ + char *state = on ? "on" : "off"; + + if (port == PORT_FIBRE) { + pr_info("%s: Powering %s FIBRE (port %d)\n", __func__, state, phydev->mdio.addr); + phy_write_paged(phydev, RTL83XX_PAGE_RAW, RTL821XINT_MEDIA_PAGE_SELECT, RTL821X_MEDIA_PAGE_FIBRE); + } else { + pr_info("%s: Powering %s COPPER (port %d)\n", __func__, state, phydev->mdio.addr); + phy_write_paged(phydev, RTL83XX_PAGE_RAW, RTL821XINT_MEDIA_PAGE_SELECT, RTL821X_MEDIA_PAGE_COPPER); + } + + if (on) { + phy_modify_paged(phydev, RTL821X_PAGE_POWER, 0x10, BIT(11), 0); + } else { + phy_modify_paged(phydev, RTL821X_PAGE_POWER, 0x10, 0, BIT(11)); + } + + phy_write_paged(phydev, RTL83XX_PAGE_RAW, RTL821XINT_MEDIA_PAGE_SELECT, RTL821X_MEDIA_PAGE_AUTO); +} + +static int rtl8214fc_suspend(struct phy_device *phydev) +{ + rtl8214fc_power_set(phydev, PORT_MII, false); + rtl8214fc_power_set(phydev, PORT_FIBRE, false); + + return 0; +} + +static int rtl8214fc_resume(struct phy_device *phydev) +{ + if (rtl8214fc_media_is_fibre(phydev)) { + rtl8214fc_power_set(phydev, PORT_MII, false); + rtl8214fc_power_set(phydev, PORT_FIBRE, true); + } else { + rtl8214fc_power_set(phydev, PORT_FIBRE, false); + rtl8214fc_power_set(phydev, PORT_MII, true); + } + + return 0; +} + +static void rtl8214fc_media_set(struct phy_device *phydev, bool set_fibre) +{ + int mac = phydev->mdio.addr; + + static int reg[] = {16, 19, 20, 21}; + int val; + + pr_info("%s: port %d, set_fibre: %d\n", __func__, mac, set_fibre); + phy_package_write_paged(phydev, RTL83XX_PAGE_RAW, RTL821XINT_MEDIA_PAGE_SELECT, RTL821X_MEDIA_PAGE_INTERNAL); + val = phy_package_read_paged(phydev, RTL821X_PAGE_PORT, reg[mac % 4]); + + val |= BIT(10); + if (set_fibre) { + val &= ~BIT(11); + } else { + val |= BIT(11); + } + + phy_package_write_paged(phydev, RTL83XX_PAGE_RAW, RTL821XINT_MEDIA_PAGE_SELECT, RTL821X_MEDIA_PAGE_INTERNAL); + phy_package_write_paged(phydev, RTL821X_PAGE_PORT, reg[mac % 4], val); + phy_package_write_paged(phydev, RTL83XX_PAGE_RAW, RTL821XINT_MEDIA_PAGE_SELECT, RTL821X_MEDIA_PAGE_AUTO); + + if (!phydev->suspended) { + if (set_fibre) { + rtl8214fc_power_set(phydev, PORT_MII, false); + rtl8214fc_power_set(phydev, PORT_FIBRE, true); + } else { + rtl8214fc_power_set(phydev, PORT_FIBRE, false); + rtl8214fc_power_set(phydev, PORT_MII, true); + } + } +} + static int rtl8214fc_set_port(struct phy_device *phydev, int port) { bool is_fibre = (port == PORT_FIBRE ? true : false); @@ -1015,7 +1033,7 @@ static int rtl8214fc_set_port(struct phy_device *phydev, int port) pr_debug("%s port %d to %d\n", __func__, addr, port); - rtl8380_rtl8214fc_media_set(phydev, is_fibre); + rtl8214fc_media_set(phydev, is_fibre); return 0; } @@ -1024,7 +1042,7 @@ static int rtl8214fc_get_port(struct phy_device *phydev) int addr = phydev->mdio.addr; pr_debug("%s: port %d\n", __func__, addr); - if (rtl8380_rtl8214fc_media_is_fibre(phydev)) + if (rtl8214fc_media_is_fibre(phydev)) return PORT_FIBRE; return PORT_MII; } @@ -1131,7 +1149,7 @@ static int rtl8214fc_set_eee(struct phy_device *phydev, pr_debug("In %s port %d, enabled %d\n", __func__, port, e->eee_enabled); - if (rtl8380_rtl8214fc_media_is_fibre(phydev)) { + if (rtl8214fc_media_is_fibre(phydev)) { netdev_err(phydev->attached_dev, "Port %d configured for FIBRE", port); return -ENOTSUPP; } @@ -1184,7 +1202,7 @@ static int rtl8214fc_get_eee(struct phy_device *phydev, int addr = phydev->mdio.addr; pr_debug("In %s port %d, enabled %d\n", __func__, addr, e->eee_enabled); - if (rtl8380_rtl8214fc_media_is_fibre(phydev)) { + if (rtl8214fc_media_is_fibre(phydev)) { netdev_err(phydev->attached_dev, "Port %d configured for FIBRE", addr); return -ENOTSUPP; } @@ -3842,8 +3860,8 @@ static struct phy_driver rtl83xx_phy_driver[] = { .flags = PHY_HAS_REALTEK_PAGES, .match_phy_device = rtl8214fc_match_phy_device, .probe = rtl8214fc_phy_probe, - .suspend = genphy_suspend, - .resume = genphy_resume, + .suspend = rtl8214fc_suspend, + .resume = rtl8214fc_resume, .set_loopback = genphy_loopback, .set_port = rtl8214fc_set_port, .get_port = rtl8214fc_get_port, From b6a0d50b7fd1ed8d62cc017d9fc5b83f436d3156 Mon Sep 17 00:00:00 2001 From: Jan Hoffmann Date: Sat, 23 Jul 2022 22:53:15 +0200 Subject: [PATCH 15/23] realtek: add SFP support for RTL8214FC PHY Probe the SFP module during PHY initialization and implement insertion/removal handlers to automatically configure the media type of the respective port. Suggested-by: Birger Koblitz Tested-by: Birger Koblitz Signed-off-by: Jan Hoffmann --- .../files-5.10/drivers/net/phy/rtl83xx-phy.c | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/target/linux/realtek/files-5.10/drivers/net/phy/rtl83xx-phy.c b/target/linux/realtek/files-5.10/drivers/net/phy/rtl83xx-phy.c index 70b57924b9..4175b95043 100644 --- a/target/linux/realtek/files-5.10/drivers/net/phy/rtl83xx-phy.c +++ b/target/linux/realtek/files-5.10/drivers/net/phy/rtl83xx-phy.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include "rtl83xx-phy.h" @@ -3676,6 +3677,29 @@ int rtl931x_link_sts_get(u32 sds) return sts1; } +static int rtl8214fc_sfp_insert(void *upstream, const struct sfp_eeprom_id *id) +{ + struct phy_device *phydev = upstream; + + rtl8214fc_media_set(phydev, true); + + return 0; +} + +static void rtl8214fc_sfp_remove(void *upstream) +{ + struct phy_device *phydev = upstream; + + rtl8214fc_media_set(phydev, false); +} + +static const struct sfp_upstream_ops rtl8214fc_sfp_ops = { + .attach = phy_sfp_attach, + .detach = phy_sfp_detach, + .module_insert = rtl8214fc_sfp_insert, + .module_remove = rtl8214fc_sfp_remove, +}; + static int rtl8214fc_phy_probe(struct phy_device *phydev) { struct device *dev = &phydev->mdio.dev; @@ -3699,7 +3723,7 @@ static int rtl8214fc_phy_probe(struct phy_device *phydev) return ret; } - return 0; + return phy_sfp_probe(phydev, &rtl8214fc_sfp_ops); } static int rtl8214c_phy_probe(struct phy_device *phydev) From 81e3017609be0ffa85c7ba430734e47519186481 Mon Sep 17 00:00:00 2001 From: Jan Hoffmann Date: Sat, 23 Jul 2022 22:53:16 +0200 Subject: [PATCH 16/23] realtek: clean up rtl838x MDIO busy wait loop Don't use udelay to allow other kernel tasks to execute if the kernel has been built without preemption. Also determine the timeout based on jiffies instead of loop iterations. This is especially important on devices containing a watchdog with a short timeout. Without this change, the watchdog is not serviced during PHY patching which can take multiple seconds. Tested-by: Birger Koblitz Signed-off-by: Jan Hoffmann --- .../drivers/net/dsa/rtl83xx/rtl838x.c | 37 +++++++++++-------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/rtl838x.c b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/rtl838x.c index cdf1766778..524594d725 100644 --- a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/rtl838x.c +++ b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/rtl838x.c @@ -1805,13 +1805,20 @@ irqreturn_t rtl838x_switch_irq(int irq, void *dev_id) int rtl838x_smi_wait_op(int timeout) { - do { - timeout--; - udelay(10); - } while ((sw_r32(RTL838X_SMI_ACCESS_PHY_CTRL_1) & 0x1) && (timeout >= 0)); - if (timeout <= 0) - return -1; - return 0; + unsigned long end = jiffies + usecs_to_jiffies(timeout); + + while (1) { + if (!(sw_r32(RTL838X_SMI_ACCESS_PHY_CTRL_1) & 0x1)) + return 0; + + if (time_after(jiffies, end)) + break; + + usleep_range(10, 20); + } + + pr_err("rtl838x_smi_wait_op: timeout\n"); + return -1; } /* @@ -1832,7 +1839,7 @@ int rtl838x_read_phy(u32 port, u32 page, u32 reg, u32 *val) mutex_lock(&smi_lock); - if (rtl838x_smi_wait_op(10000)) + if (rtl838x_smi_wait_op(100000)) goto timeout; sw_w32_mask(0xffff0000, port << 16, RTL838X_SMI_ACCESS_PHY_CTRL_2); @@ -1842,7 +1849,7 @@ int rtl838x_read_phy(u32 port, u32 page, u32 reg, u32 *val) sw_w32(v | park_page, RTL838X_SMI_ACCESS_PHY_CTRL_1); sw_w32_mask(0, 1, RTL838X_SMI_ACCESS_PHY_CTRL_1); - if (rtl838x_smi_wait_op(10000)) + if (rtl838x_smi_wait_op(100000)) goto timeout; *val = sw_r32(RTL838X_SMI_ACCESS_PHY_CTRL_2) & 0xffff; @@ -1868,7 +1875,7 @@ int rtl838x_write_phy(u32 port, u32 page, u32 reg, u32 val) return -ENOTSUPP; mutex_lock(&smi_lock); - if (rtl838x_smi_wait_op(10000)) + if (rtl838x_smi_wait_op(100000)) goto timeout; sw_w32(BIT(port), RTL838X_SMI_ACCESS_PHY_CTRL_0); @@ -1881,7 +1888,7 @@ int rtl838x_write_phy(u32 port, u32 page, u32 reg, u32 val) sw_w32(v | park_page, RTL838X_SMI_ACCESS_PHY_CTRL_1); sw_w32_mask(0, 1, RTL838X_SMI_ACCESS_PHY_CTRL_1); - if (rtl838x_smi_wait_op(10000)) + if (rtl838x_smi_wait_op(100000)) goto timeout; mutex_unlock(&smi_lock); @@ -1901,7 +1908,7 @@ int rtl838x_read_mmd_phy(u32 port, u32 addr, u32 reg, u32 *val) mutex_lock(&smi_lock); - if (rtl838x_smi_wait_op(10000)) + if (rtl838x_smi_wait_op(100000)) goto timeout; sw_w32(1 << port, RTL838X_SMI_ACCESS_PHY_CTRL_0); @@ -1916,7 +1923,7 @@ int rtl838x_read_mmd_phy(u32 port, u32 addr, u32 reg, u32 *val) v = 1 << 1 | 0 << 2 | 1; sw_w32(v, RTL838X_SMI_ACCESS_PHY_CTRL_1); - if (rtl838x_smi_wait_op(10000)) + if (rtl838x_smi_wait_op(100000)) goto timeout; *val = sw_r32(RTL838X_SMI_ACCESS_PHY_CTRL_2) & 0xffff; @@ -1940,7 +1947,7 @@ int rtl838x_write_mmd_phy(u32 port, u32 addr, u32 reg, u32 val) val &= 0xffff; mutex_lock(&smi_lock); - if (rtl838x_smi_wait_op(10000)) + if (rtl838x_smi_wait_op(100000)) goto timeout; sw_w32(1 << port, RTL838X_SMI_ACCESS_PHY_CTRL_0); @@ -1954,7 +1961,7 @@ int rtl838x_write_mmd_phy(u32 port, u32 addr, u32 reg, u32 val) v = 1 << 1 | 1 << 2 | 1; sw_w32(v, RTL838X_SMI_ACCESS_PHY_CTRL_1); - if (rtl838x_smi_wait_op(10000)) + if (rtl838x_smi_wait_op(100000)) goto timeout; mutex_unlock(&smi_lock); From 3b1261224aa0313ab8c155d3a4679e598a04d9a6 Mon Sep 17 00:00:00 2001 From: Jan Hoffmann Date: Sat, 23 Jul 2022 22:53:17 +0200 Subject: [PATCH 17/23] kernel: mtdsplit: add support for H3C VFS filesystem The bootloader on some H3C devices (for example HPE 1920 switches) only supports booting from flash by reading an image from an "VFS" filesystem which spans most of the available flash. The filesystem size is hard- coded in the bootloader. However, as long as no write operations are performed in the bootloader menu, it is sufficient if the start of the partition contains a valid filesystem with the kernel image. This mtdsplit parser reads the size and location of the kernel image and finds the location of the rootfs stored after it. It assumes that the filesystem image matches the layout of one generated by mkh3cvfs, with a filename of "openwrt-kernel.bin" for the kernel image. Signed-off-by: Jan Hoffmann --- target/linux/generic/config-5.10 | 1 + target/linux/generic/config-5.15 | 1 + .../files/drivers/mtd/mtdsplit/Kconfig | 5 + .../files/drivers/mtd/mtdsplit/Makefile | 1 + .../drivers/mtd/mtdsplit/mtdsplit_h3c_vfs.c | 170 ++++++++++++++++++ 5 files changed, 178 insertions(+) create mode 100644 target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_h3c_vfs.c diff --git a/target/linux/generic/config-5.10 b/target/linux/generic/config-5.10 index c14851dbdb..2223456fe0 100644 --- a/target/linux/generic/config-5.10 +++ b/target/linux/generic/config-5.10 @@ -3683,6 +3683,7 @@ CONFIG_MTD_SPLIT=y # CONFIG_MTD_SPLIT_FIRMWARE is not set CONFIG_MTD_SPLIT_FIRMWARE_NAME="firmware" # CONFIG_MTD_SPLIT_FIT_FW is not set +# CONFIG_MTD_SPLIT_H3C_VFS is not set # CONFIG_MTD_SPLIT_JIMAGE_FW is not set # CONFIG_MTD_SPLIT_LZMA_FW is not set # CONFIG_MTD_SPLIT_MINOR_FW is not set diff --git a/target/linux/generic/config-5.15 b/target/linux/generic/config-5.15 index 72a6ee2fbe..c21f7631ec 100644 --- a/target/linux/generic/config-5.15 +++ b/target/linux/generic/config-5.15 @@ -3827,6 +3827,7 @@ CONFIG_MTD_SPLIT=y # CONFIG_MTD_SPLIT_FIRMWARE is not set CONFIG_MTD_SPLIT_FIRMWARE_NAME="firmware" # CONFIG_MTD_SPLIT_FIT_FW is not set +# CONFIG_MTD_SPLIT_H3C_VFS is not set # CONFIG_MTD_SPLIT_JIMAGE_FW is not set # CONFIG_MTD_SPLIT_LZMA_FW is not set # CONFIG_MTD_SPLIT_MINOR_FW is not set diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/Kconfig b/target/linux/generic/files/drivers/mtd/mtdsplit/Kconfig index 794a39f2c3..f929c6153e 100644 --- a/target/linux/generic/files/drivers/mtd/mtdsplit/Kconfig +++ b/target/linux/generic/files/drivers/mtd/mtdsplit/Kconfig @@ -101,3 +101,8 @@ config MTD_SPLIT_ELF_FW bool "ELF loader firmware partition parser" depends on MTD_SPLIT_SUPPORT select MTD_SPLIT + +config MTD_SPLIT_H3C_VFS + bool "Parser finding rootfs appended to H3C VFS" + depends on MTD_SPLIT_SUPPORT + select MTD_SPLIT diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/Makefile b/target/linux/generic/files/drivers/mtd/mtdsplit/Makefile index 1461099b7c..a969c336aa 100644 --- a/target/linux/generic/files/drivers/mtd/mtdsplit/Makefile +++ b/target/linux/generic/files/drivers/mtd/mtdsplit/Makefile @@ -15,3 +15,4 @@ obj-$(CONFIG_MTD_SPLIT_WRGG_FW) += mtdsplit_wrgg.o obj-$(CONFIG_MTD_SPLIT_MINOR_FW) += mtdsplit_minor.o obj-$(CONFIG_MTD_SPLIT_JIMAGE_FW) += mtdsplit_jimage.o obj-$(CONFIG_MTD_SPLIT_ELF_FW) += mtdsplit_elf.o +obj-$(CONFIG_MTD_SPLIT_H3C_VFS) += mtdsplit_h3c_vfs.o diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_h3c_vfs.c b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_h3c_vfs.c new file mode 100644 index 0000000000..f264233dbd --- /dev/null +++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_h3c_vfs.c @@ -0,0 +1,170 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Some devices made by H3C use a "VFS" filesystem to store firmware images. + * This parses the start of the filesystem to read the length of the first + * file (the kernel image). It then searches for the rootfs after the end of + * the file data. This driver assumes that the filesystem was generated by + * mkh3cvfs, and only works if the filesystem matches the expected layout, + * which includes the file name of the kernel image. + */ + +#include +#include +#include +#include +#include +#include +#include + +#include "mtdsplit.h" + +#define VFS_ERASEBLOCK_SIZE 0x10000 +#define VFS_BLOCK_SIZE 0x400 +#define VFS_BLOCKS_PER_ERASEBLOCK (VFS_ERASEBLOCK_SIZE / VFS_BLOCK_SIZE) + +#define FORMAT_FLAG_OFFSET 0x0 + +#define FORMAT_FLAG (VFS_ERASEBLOCK_SIZE << 12 | VFS_BLOCK_SIZE) + +#define FILE_ENTRY_OFFSET 0x800 + +#define FILE_ENTRY_FLAGS 0x3f +#define FILE_ENTRY_PARENT_BLOCK 0 +#define FILE_ENTRY_PARENT_INDEX 0 +#define FILE_ENTRY_DATA_BLOCK 2 +#define FILE_ENTRY_NAME "openwrt-kernel.bin" + +#define NR_PARTS 2 + +struct file_entry { + uint8_t flags; + + uint8_t res0[5]; + + uint16_t year; + uint8_t month; + uint8_t day; + uint8_t hour; + uint8_t minute; + uint8_t second; + + uint8_t res1[3]; + + uint32_t length; + + uint32_t parent_block; + uint16_t parent_index; + + uint8_t res2[2]; + + uint32_t data_block; + + char name[96]; +} __attribute__ ((packed)); + +static inline size_t block_offset(int block) +{ + return VFS_ERASEBLOCK_SIZE * (block / (VFS_BLOCKS_PER_ERASEBLOCK-1)) + + VFS_BLOCK_SIZE * (1 + (block % (VFS_BLOCKS_PER_ERASEBLOCK-1))); +} + +static inline int block_count(size_t size) +{ + return (size + VFS_BLOCK_SIZE - 1) / VFS_BLOCK_SIZE; +} + +static int mtdsplit_h3c_vfs_parse(struct mtd_info *mtd, + const struct mtd_partition **pparts, + struct mtd_part_parser_data *data) +{ + struct mtd_partition *parts; + uint32_t format_flag; + struct file_entry file_entry; + size_t retlen; + int err; + size_t kernel_size; + size_t expected_offset; + size_t rootfs_offset; + + if (mtd->erasesize != VFS_ERASEBLOCK_SIZE) + return -EINVAL; + + /* Check format flag */ + err = mtd_read(mtd, FORMAT_FLAG_OFFSET, sizeof(format_flag), &retlen, + (void *) &format_flag); + if (err) + return err; + + if (retlen != sizeof(format_flag)) + return -EIO; + + if (format_flag != FORMAT_FLAG) + return -EINVAL; + + /* Check file entry */ + err = mtd_read(mtd, FILE_ENTRY_OFFSET, sizeof(file_entry), &retlen, + (void *) &file_entry); + if (err) + return err; + + if (retlen != sizeof(file_entry)) + return -EIO; + + if (file_entry.flags != FILE_ENTRY_FLAGS) + return -EINVAL; + + if (file_entry.parent_block != FILE_ENTRY_PARENT_BLOCK) + return -EINVAL; + + if (file_entry.parent_index != FILE_ENTRY_PARENT_INDEX) + return -EINVAL; + + if (file_entry.data_block != FILE_ENTRY_DATA_BLOCK) + return -EINVAL; + + if (strncmp(file_entry.name, FILE_ENTRY_NAME, sizeof(file_entry.name)) != 0) + return -EINVAL; + + /* Find rootfs offset */ + kernel_size = block_offset(file_entry.data_block + + block_count(file_entry.length) - 1) + + VFS_BLOCK_SIZE; + + expected_offset = mtd_roundup_to_eb(kernel_size, mtd); + + err = mtd_find_rootfs_from(mtd, expected_offset, mtd->size, + &rootfs_offset, NULL); + if (err) + return err; + + parts = kzalloc(NR_PARTS * sizeof(*parts), GFP_KERNEL); + if (!parts) + return -ENOMEM; + + parts[0].name = KERNEL_PART_NAME; + parts[0].offset = 0; + parts[0].size = rootfs_offset; + + parts[1].name = ROOTFS_PART_NAME; + parts[1].offset = rootfs_offset; + parts[1].size = mtd->size - rootfs_offset; + + *pparts = parts; + return NR_PARTS; +} + +static const struct of_device_id mtdsplit_h3c_vfs_of_match_table[] = { + { .compatible = "h3c,vfs-firmware" }, + {}, +}; +MODULE_DEVICE_TABLE(of, mtdsplit_h3c_vfs_of_match_table); + +static struct mtd_part_parser mtdsplit_h3c_vfs_parser = { + .owner = THIS_MODULE, + .name = "h3c-vfs", + .of_match_table = mtdsplit_h3c_vfs_of_match_table, + .parse_fn = mtdsplit_h3c_vfs_parse, + .type = MTD_PARSER_TYPE_FIRMWARE, +}; + +module_mtd_part_parser(mtdsplit_h3c_vfs_parser); From 5fcc6f0f19422c952db8bc4d72f324ead21232c6 Mon Sep 17 00:00:00 2001 From: Jan Hoffmann Date: Sat, 23 Jul 2022 22:53:18 +0200 Subject: [PATCH 18/23] tools: add 7z host package Add the 7zr command line tool, which is a version of the 7z application that only supports 7z archives. 7z is one of the two compression formats supported in H3C firmware images (the alternative would be ARJ). (Alternatively, the 7zr command line tool could also be built from a current version of the public-domain LZMA SDK. That would require repackaging the source package, as it is only provided in 7z format.) Signed-off-by: Jan Hoffmann --- tools/7z/Makefile | 36 ++++++++++++++++++++++++++++++++++++ tools/Makefile | 1 + 2 files changed, 37 insertions(+) create mode 100644 tools/7z/Makefile diff --git a/tools/7z/Makefile b/tools/7z/Makefile new file mode 100644 index 0000000000..c94d746c64 --- /dev/null +++ b/tools/7z/Makefile @@ -0,0 +1,36 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=7z +PKG_VERSION:=22.00 +PKG_SOURCE_VERSION:=2200 + +PKG_SOURCE:=$(PKG_NAME)$(PKG_SOURCE_VERSION)-src.tar.xz +PKG_SOURCE_URL:=https://7-zip.org/a/ +PKG_HASH:=40969f601e86aff49aaa0ba0df5ce6fd397cf7e2683a84b591b0081e461ef675 + +# This builds the 7zr variant which supports only 7z, so no non-LGPL code should be included +PKG_LICENSE:=LGPL-2.1-or-later +PKG_LICENSE_FILES:=DOC/License.txt DOC/copying.txt + +HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/$(PKG_NAME)-$(PKG_VERSION) + +include $(INCLUDE_DIR)/host-build.mk + +TAR_CMD=$(HOST_TAR) -C $(1) $(TAR_OPTIONS) + +ALONE_DIR=$(HOST_BUILD_DIR)/CPP/7zip/Bundles/Alone7z + +define Host/Compile + $(MAKE) -C $(ALONE_DIR) -f makefile.gcc +endef + +define Host/Install + $(INSTALL_DIR) $(STAGING_DIR_HOST)/bin + $(INSTALL_BIN) $(ALONE_DIR)/_o/7zr $(STAGING_DIR_HOST)/bin/7zr +endef + +define Host/Clean + rm -f $(STAGING_DIR_HOST)/bin/7zr +endef + +$(eval $(call HostBuild)) diff --git a/tools/Makefile b/tools/Makefile index be1a23ed51..0d6e675d4c 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -32,6 +32,7 @@ tools-$(BUILD_TOOLCHAIN) += expat gmp mpc mpfr tools-$(CONFIG_TARGET_apm821xx)$(CONFIG_TARGET_gemini) += genext2fs tools-$(CONFIG_TARGET_ath79) += lzma-old squashfs tools-$(CONFIG_TARGET_mxs) += elftosb sdimage +tools-$(CONFIG_TARGET_realtek) += 7z tools-$(CONFIG_TARGET_tegra) += cbootimage cbootimage-configs tools-$(CONFIG_USES_MINOR) += kernel2minor tools-$(CONFIG_USE_SPARSE) += sparse From f2f09bc00280f5bd60b36d525a5e229550958b6d Mon Sep 17 00:00:00 2001 From: Jan Hoffmann Date: Sat, 23 Jul 2022 22:53:19 +0200 Subject: [PATCH 19/23] realtek: add support for HPE 1920 series Hardware information: --------------------- - HPE 1920-8G: - RTL8380 SoC - 8 Gigabit RJ45 ports (built-in RTL8218B) - 2 SFP ports (built-in SerDes) - HPE 1920-16G / HPE 1920-24G (same board): - RTL8382 SoC - 16/24 Gigabit RJ45 ports (built-in RTL8218B, 1/2 external RTL8218D) - 4 SFP ports (external RTL8214FC) - Common: - RJ45 RS232 port on front panel - 32 MiB NOR Flash - 128 MiB DDR3 DRAM - PT7A7514 watchdog Booting initramfs image: ------------------------ - Prepare a FTP or TFTP server serving the OpenWrt initramfs image and connect the server to a switch port. - Connect to the console port of the device and enter the extended boot menu by typing Ctrl+B when prompted. - Choose the menu option "<3> Enter Ethernet SubMenu". - Set network parameters via the option "<5> Modify Ethernet Parameter". Enter the FTP/TFTP filename as "Load File Name" ("Target File Name" can be left blank, it is not required for booting from RAM). Note that the configuration is saved on flash, so it only needs to be done once. - Select "<1> Download Application Program To SDRAM And Run". Initial installation: --------------------- - Boot an initramfs image as described above, then use sysupgrade to install OpenWrt permanently. After initial installation, the bootloader needs to be configured to load the correct image file - Enter the extended boot menu again and choose "<4> File Control", then select "<2> Set Application File type". - Enter the number of the file "openwrt-kernel.bin" (should be 1), and use the option "<1> +Main" to select it as boot image. - Choose "<0> Exit To Main Menu" and then "<1> Boot System". NOTE: The bootloader on these devices can only boot from the VFS filesystem which normally spans most of the flash. With OpenWrt, only the first part of the firmware partition contains a valid filesystem, the rest is used for rootfs. As the bootloader does not know about this, you must not do any file operations in the bootloader, as this may corrupt the OpenWrt installation (selecting the boot image is an exception, as it only stores a flag in the bootloader data, but doesn't write to the filesystem). Signed-off-by: Jan Hoffmann --- .../realtek/base-files/etc/board.d/02_network | 18 ++- .../realtek/dts-5.10/rtl8380_hpe_1920-8g.dts | 113 +++++++++++++++++ .../realtek/dts-5.10/rtl8382_hpe_1920-16g.dts | 48 +++++++ .../realtek/dts-5.10/rtl8382_hpe_1920-24g.dts | 68 ++++++++++ .../realtek/dts-5.10/rtl8382_hpe_1920.dtsi | 117 ++++++++++++++++++ target/linux/realtek/dts-5.10/rtl838x.dtsi | 7 ++ .../realtek/dts-5.10/rtl838x_hpe_1920.dtsi | 96 ++++++++++++++ target/linux/realtek/image/Makefile | 49 ++++++++ target/linux/realtek/image/rtl838x.mk | 24 ++++ target/linux/realtek/rtl838x/config-5.10 | 3 + 10 files changed, 540 insertions(+), 3 deletions(-) create mode 100644 target/linux/realtek/dts-5.10/rtl8380_hpe_1920-8g.dts create mode 100644 target/linux/realtek/dts-5.10/rtl8382_hpe_1920-16g.dts create mode 100644 target/linux/realtek/dts-5.10/rtl8382_hpe_1920-24g.dts create mode 100644 target/linux/realtek/dts-5.10/rtl8382_hpe_1920.dtsi create mode 100644 target/linux/realtek/dts-5.10/rtl838x_hpe_1920.dtsi diff --git a/target/linux/realtek/base-files/etc/board.d/02_network b/target/linux/realtek/base-files/etc/board.d/02_network index af9db848dd..5356bcac65 100644 --- a/target/linux/realtek/base-files/etc/board.d/02_network +++ b/target/linux/realtek/base-files/etc/board.d/02_network @@ -22,9 +22,20 @@ ucidef_set_bridge_device switch ucidef_set_interface_lan "$lan_list" lan_mac="" +lan_mac_start="" lan_mac_end="" label_mac="" case $board in +hpe,1920-8g|\ +hpe,1920-16g|\ +hpe,1920-24g) + label_mac=$(mtd_get_mac_binary factory 0x68) + lan_mac=$label_mac + mac_count1=$(hexdump -v -n 4 -s 0x110 -e '4 "%d"' $(find_mtd_part factory) 2>/dev/null) + mac_count2=$(hexdump -v -n 4 -s 0x114 -e '4 "%d"' $(find_mtd_part factory) 2>/dev/null) + lan_mac_start=$(macaddr_add $lan_mac 2) + lan_mac_end=$(macaddr_add $lan_mac $((mac_count2-mac_count1))) + ;; *) lan_mac=$(mtd_get_mac_ascii u-boot-env2 mac_start) lan_mac_end=$(mtd_get_mac_ascii u-boot-env2 mac_end) @@ -36,10 +47,11 @@ esac ucidef_set_interface_macaddr "lan" $lan_mac ucidef_set_bridge_mac "$lan_mac" ucidef_set_network_device_mac eth0 $lan_mac +[ -z "$lan_mac_start" ] && lan_mac_start=$lan_mac for lan in $lan_list; do - ucidef_set_network_device_mac $lan $lan_mac - [ -z "$lan_mac_end" ] || [ "$lan_mac" == "$lan_mac_end" ] && lan_mac=$(macaddr_setbit_la $lan_mac) - lan_mac=$(macaddr_add $lan_mac 1) + ucidef_set_network_device_mac $lan $lan_mac_start + [ -z "$lan_mac_end" ] || [ "$lan_mac_start" == "$lan_mac_end" ] && lan_mac_start=$(macaddr_setbit_la $lan_mac_start) + lan_mac_start=$(macaddr_add $lan_mac_start 1) done [ -n "$label_mac" ] && ucidef_set_label_macaddr $label_mac diff --git a/target/linux/realtek/dts-5.10/rtl8380_hpe_1920-8g.dts b/target/linux/realtek/dts-5.10/rtl8380_hpe_1920-8g.dts new file mode 100644 index 0000000000..b51c75f355 --- /dev/null +++ b/target/linux/realtek/dts-5.10/rtl8380_hpe_1920-8g.dts @@ -0,0 +1,113 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "rtl838x.dtsi" +#include "rtl838x_hpe_1920.dtsi" + +/ { + compatible = "hpe,1920-8g", "realtek,rtl838x-soc"; + model = "HPE 1920-8G (JG920A)"; + + gpio1: rtl8231-gpio { + compatible = "realtek,rtl8231-gpio"; + #gpio-cells = <2>; + gpio-controller; + indirect-access-bus-id = <0>; + }; + + i2c0: i2c-gpio-0 { + compatible = "i2c-gpio"; + sda-gpios = <&gpio1 23 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; + scl-gpios = <&gpio1 24 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; + i2c-gpio,delay-us = <2>; + #address-cells = <1>; + #size-cells = <0>; + }; + + sfp0: sfp-0 { + compatible = "sff,sfp"; + i2c-bus = <&i2c0>; + los-gpio = <&gpio1 26 GPIO_ACTIVE_HIGH>; + mod-def0-gpio = <&gpio1 25 GPIO_ACTIVE_LOW>; + // tx-fault and tx-disable unconnected + }; + + i2c1: i2c-gpio-1 { + compatible = "i2c-gpio"; + sda-gpios = <&gpio1 13 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; + scl-gpios = <&gpio1 14 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; + i2c-gpio,delay-us = <2>; + #address-cells = <1>; + #size-cells = <0>; + }; + + sfp1: sfp-1 { + compatible = "sff,sfp"; + i2c-bus = <&i2c1>; + los-gpio = <&gpio1 22 GPIO_ACTIVE_HIGH>; + mod-def0-gpio = <&gpio1 21 GPIO_ACTIVE_LOW>; + // tx-fault and tx-disable unconnected + }; +}; + +ðernet0 { + mdio: mdio-bus { + compatible = "realtek,rtl838x-mdio"; + regmap = <ðernet0>; + #address-cells = <1>; + #size-cells = <0>; + + INTERNAL_PHY(8) + INTERNAL_PHY(9) + INTERNAL_PHY(10) + INTERNAL_PHY(11) + INTERNAL_PHY(12) + INTERNAL_PHY(13) + INTERNAL_PHY(14) + INTERNAL_PHY(15) + + INTERNAL_PHY(24) + INTERNAL_PHY(26) + }; +}; + +&switch0 { + ports { + #address-cells = <1>; + #size-cells = <0>; + + SWITCH_PORT(8, 1, internal) + SWITCH_PORT(9, 2, internal) + SWITCH_PORT(10, 3, internal) + SWITCH_PORT(11, 4, internal) + SWITCH_PORT(12, 5, internal) + SWITCH_PORT(13, 6, internal) + SWITCH_PORT(14, 7, internal) + SWITCH_PORT(15, 8, internal) + + port@24 { + reg = <24>; + label = "lan9"; + phy-mode = "1000base-x"; + managed = "in-band-status"; + sfp = <&sfp0>; + }; + + port@26 { + reg = <26>; + label = "lan10"; + phy-mode = "1000base-x"; + managed = "in-band-status"; + sfp = <&sfp1>; + }; + + port@28 { + ethernet = <ðernet0>; + reg = <28>; + phy-mode = "internal"; + fixed-link { + speed = <1000>; + full-duplex; + }; + }; + }; +}; diff --git a/target/linux/realtek/dts-5.10/rtl8382_hpe_1920-16g.dts b/target/linux/realtek/dts-5.10/rtl8382_hpe_1920-16g.dts new file mode 100644 index 0000000000..59043b2f6f --- /dev/null +++ b/target/linux/realtek/dts-5.10/rtl8382_hpe_1920-16g.dts @@ -0,0 +1,48 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "rtl8382_hpe_1920.dtsi" + +/ { + compatible = "hpe,1920-16g", "realtek,rtl838x-soc"; + model = "HPE 1920-16G (JG923A)"; +}; + +&switch0 { + ports { + #address-cells = <1>; + #size-cells = <0>; + + SWITCH_PORT(8, 1, internal) + SWITCH_PORT(9, 2, internal) + SWITCH_PORT(10, 3, internal) + SWITCH_PORT(11, 4, internal) + SWITCH_PORT(12, 5, internal) + SWITCH_PORT(13, 6, internal) + SWITCH_PORT(14, 7, internal) + SWITCH_PORT(15, 8, internal) + + SWITCH_PORT(16, 9, qsgmii) + SWITCH_PORT(17, 10, qsgmii) + SWITCH_PORT(18, 11, qsgmii) + SWITCH_PORT(19, 12, qsgmii) + SWITCH_PORT(20, 13, qsgmii) + SWITCH_PORT(21, 14, qsgmii) + SWITCH_PORT(22, 15, qsgmii) + SWITCH_PORT(23, 16, qsgmii) + + SWITCH_PORT(24, 17, qsgmii) + SWITCH_PORT(25, 18, qsgmii) + SWITCH_PORT(26, 19, qsgmii) + SWITCH_PORT(27, 20, qsgmii) + + port@28 { + ethernet = <ðernet0>; + reg = <28>; + phy-mode = "internal"; + fixed-link { + speed = <1000>; + full-duplex; + }; + }; + }; +}; diff --git a/target/linux/realtek/dts-5.10/rtl8382_hpe_1920-24g.dts b/target/linux/realtek/dts-5.10/rtl8382_hpe_1920-24g.dts new file mode 100644 index 0000000000..61781c708e --- /dev/null +++ b/target/linux/realtek/dts-5.10/rtl8382_hpe_1920-24g.dts @@ -0,0 +1,68 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "rtl8382_hpe_1920.dtsi" + +/ { + compatible = "hpe,1920-24g", "realtek,rtl838x-soc"; + model = "HPE 1920-24G (JG924A)"; +}; + +&mdio { + EXTERNAL_PHY(0) + EXTERNAL_PHY(1) + EXTERNAL_PHY(2) + EXTERNAL_PHY(3) + EXTERNAL_PHY(4) + EXTERNAL_PHY(5) + EXTERNAL_PHY(6) + EXTERNAL_PHY(7) +}; + +&switch0 { + ports { + #address-cells = <1>; + #size-cells = <0>; + + SWITCH_PORT(0, 1, qsgmii) + SWITCH_PORT(1, 2, qsgmii) + SWITCH_PORT(2, 3, qsgmii) + SWITCH_PORT(3, 4, qsgmii) + SWITCH_PORT(4, 5, qsgmii) + SWITCH_PORT(5, 6, qsgmii) + SWITCH_PORT(6, 7, qsgmii) + SWITCH_PORT(7, 8, qsgmii) + + SWITCH_PORT(8, 9, internal) + SWITCH_PORT(9, 10, internal) + SWITCH_PORT(10, 11, internal) + SWITCH_PORT(11, 12, internal) + SWITCH_PORT(12, 13, internal) + SWITCH_PORT(13, 14, internal) + SWITCH_PORT(14, 15, internal) + SWITCH_PORT(15, 16, internal) + + SWITCH_PORT(16, 17, qsgmii) + SWITCH_PORT(17, 18, qsgmii) + SWITCH_PORT(18, 19, qsgmii) + SWITCH_PORT(19, 20, qsgmii) + SWITCH_PORT(20, 21, qsgmii) + SWITCH_PORT(21, 22, qsgmii) + SWITCH_PORT(22, 23, qsgmii) + SWITCH_PORT(23, 24, qsgmii) + + SWITCH_PORT(24, 25, qsgmii) + SWITCH_PORT(25, 26, qsgmii) + SWITCH_PORT(26, 27, qsgmii) + SWITCH_PORT(27, 28, qsgmii) + + port@28 { + ethernet = <ðernet0>; + reg = <28>; + phy-mode = "internal"; + fixed-link { + speed = <1000>; + full-duplex; + }; + }; + }; +}; diff --git a/target/linux/realtek/dts-5.10/rtl8382_hpe_1920.dtsi b/target/linux/realtek/dts-5.10/rtl8382_hpe_1920.dtsi new file mode 100644 index 0000000000..5368b41c27 --- /dev/null +++ b/target/linux/realtek/dts-5.10/rtl8382_hpe_1920.dtsi @@ -0,0 +1,117 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "rtl838x.dtsi" +#include "rtl838x_hpe_1920.dtsi" + +/ { + gpio1: rtl8231-gpio { + compatible = "realtek,rtl8231-gpio"; + #gpio-cells = <2>; + gpio-controller; + indirect-access-bus-id = <0>; + }; + + i2c0: i2c-gpio-0 { + compatible = "i2c-gpio"; + sda-gpios = <&gpio1 13 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; + scl-gpios = <&gpio1 14 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; + i2c-gpio,delay-us = <2>; + #address-cells = <1>; + #size-cells = <0>; + }; + + sfp0: sfp-0 { + compatible = "sff,sfp"; + i2c-bus = <&i2c0>; + los-gpio = <&gpio1 22 GPIO_ACTIVE_HIGH>; + mod-def0-gpio = <&gpio1 21 GPIO_ACTIVE_LOW>; + // tx-fault unconnected + // tx-disable connected to RTL8214FC + }; + + i2c1: i2c-gpio-1 { + compatible = "i2c-gpio"; + sda-gpios = <&gpio1 23 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; + scl-gpios = <&gpio1 24 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; + i2c-gpio,delay-us = <2>; + #address-cells = <1>; + #size-cells = <0>; + }; + + sfp1: sfp-1 { + compatible = "sff,sfp"; + i2c-bus = <&i2c1>; + los-gpio = <&gpio1 26 GPIO_ACTIVE_HIGH>; + mod-def0-gpio = <&gpio1 25 GPIO_ACTIVE_LOW>; + // tx-fault unconnected + // tx-disable connected to RTL8214FC + }; + + i2c2: i2c-gpio-2 { + compatible = "i2c-gpio"; + sda-gpios = <&gpio1 27 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; + scl-gpios = <&gpio1 28 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; + i2c-gpio,delay-us = <2>; + #address-cells = <1>; + #size-cells = <0>; + }; + + sfp2: sfp-2 { + compatible = "sff,sfp"; + i2c-bus = <&i2c2>; + los-gpio = <&gpio1 30 GPIO_ACTIVE_HIGH>; + mod-def0-gpio = <&gpio1 29 GPIO_ACTIVE_LOW>; + // tx-fault unconnected + // tx-disable connected to RTL8214FC + }; + + i2c3: i2c-gpio-3 { + compatible = "i2c-gpio"; + sda-gpios = <&gpio1 31 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; + scl-gpios = <&gpio1 32 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; + i2c-gpio,delay-us = <2>; + #address-cells = <1>; + #size-cells = <0>; + }; + + sfp3: sfp-3 { + compatible = "sff,sfp"; + i2c-bus = <&i2c3>; + los-gpio = <&gpio1 34 GPIO_ACTIVE_HIGH>; + mod-def0-gpio = <&gpio1 33 GPIO_ACTIVE_LOW>; + // tx-fault unconnected + // tx-disable connected to RTL8214FC + }; +}; + +ðernet0 { + mdio: mdio-bus { + compatible = "realtek,rtl838x-mdio"; + regmap = <ðernet0>; + #address-cells = <1>; + #size-cells = <0>; + + INTERNAL_PHY(8) + INTERNAL_PHY(9) + INTERNAL_PHY(10) + INTERNAL_PHY(11) + INTERNAL_PHY(12) + INTERNAL_PHY(13) + INTERNAL_PHY(14) + INTERNAL_PHY(15) + + EXTERNAL_PHY(16) + EXTERNAL_PHY(17) + EXTERNAL_PHY(18) + EXTERNAL_PHY(19) + EXTERNAL_PHY(20) + EXTERNAL_PHY(21) + EXTERNAL_PHY(22) + EXTERNAL_PHY(23) + + EXTERNAL_SFP_PHY_FULL(24, 0) + EXTERNAL_SFP_PHY_FULL(25, 1) + EXTERNAL_SFP_PHY_FULL(26, 2) + EXTERNAL_SFP_PHY_FULL(27, 3) + }; +}; diff --git a/target/linux/realtek/dts-5.10/rtl838x.dtsi b/target/linux/realtek/dts-5.10/rtl838x.dtsi index 11cabc3f63..41fdbdae20 100644 --- a/target/linux/realtek/dts-5.10/rtl838x.dtsi +++ b/target/linux/realtek/dts-5.10/rtl838x.dtsi @@ -27,6 +27,13 @@ reg = <##n>; \ }; +#define EXTERNAL_SFP_PHY_FULL(n, s) \ + phy##n: ethernet-phy@##n { \ + compatible = "ethernet-phy-ieee802.3-c22"; \ + sfp = <&sfp##s>; \ + reg = <##n>; \ + }; + #define SWITCH_PORT(n, s, m) \ port@##n { \ reg = <##n>; \ diff --git a/target/linux/realtek/dts-5.10/rtl838x_hpe_1920.dtsi b/target/linux/realtek/dts-5.10/rtl838x_hpe_1920.dtsi new file mode 100644 index 0000000000..8e29af62bb --- /dev/null +++ b/target/linux/realtek/dts-5.10/rtl838x_hpe_1920.dtsi @@ -0,0 +1,96 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include +#include + +/ { + chosen { + bootargs = "console=ttyS0,38400"; + }; + + memory@0 { + device_type = "memory"; + reg = <0x0 0x8000000>; + }; + + watchdog1: watchdog { + // PT7A7514 + compatible = "linux,wdt-gpio"; + gpios = <&gpio0 0 GPIO_ACTIVE_HIGH>; + hw_algo = "toggle"; + hw_margin_ms = <1000>; + always-running; + + pinctrl-names = "default"; + pinctrl-0 = <&pinmux_disable_sys_led>; + }; +}; + +&watchdog0 { + status = "disabled"; +}; + +&spi0 { + status = "okay"; + + flash@0 { + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <50000000>; + m25p,fast-read; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "bootware_basic"; + reg = <0x0 0x50000>; + read-only; + }; + + partition@0x60000 { + label = "bootware_data"; + reg = <0x60000 0x30000>; + read-only; + }; + + partition@0x90000 { + label = "bootware_extend"; + reg = <0x90000 0x40000>; + read-only; + }; + + partition@0x100000 { + label = "bootware_basic_backup"; + reg = <0x100000 0x50000>; + read-only; + }; + + partition@0x160000 { + label = "bootware_data_backup"; + reg = <0x160000 0x30000>; + read-only; + }; + + partition@0x190000 { + label = "bootware_extend_backup"; + reg = <0x190000 0x40000>; + read-only; + }; + + partition@0x300000 { + label = "firmware"; + compatible = "h3c,vfs-firmware"; + reg = <0x300000 0x1cf0000>; + }; + + partition@0x1ff0000 { + label = "factory"; + reg = <0x1ff0000 0x10000>; + read-only; + }; + }; + }; +}; diff --git a/target/linux/realtek/image/Makefile b/target/linux/realtek/image/Makefile index cf779002e8..6165d99bfc 100644 --- a/target/linux/realtek/image/Makefile +++ b/target/linux/realtek/image/Makefile @@ -8,6 +8,7 @@ KERNEL_ENTRY = 0x80000400 DEVICE_VARS += ZYXEL_VERS DLINK_KERNEL_PART_SIZE DEVICE_VARS += CAMEO_KERNEL_PART CAMEO_ROOTFS_PART CAMEO_CUSTOMER_SIGNATURE CAMEO_BOARD_VERSION +DEVICE_VARS += H3C_PRODUCT_ID H3C_DEVICE_ID define Build/zyxel-vers ( echo VERS;\ @@ -41,6 +42,43 @@ define Build/dlink-headers cat $@.kernel_part.hex $@.rootfs_part.hex > $@ endef +define Build/7z + $(STAGING_DIR_HOST)/bin/7zr a $(@).new -t7z -m0=lzma $(@) + mv $@.new $@ +endef + +define Build/h3c-image + $(STAGING_DIR_HOST)/bin/mkh3cimg \ + -i $(@) \ + -o $(@).new \ + -c 7z \ + -p $(H3C_PRODUCT_ID) \ + -d $(H3C_DEVICE_ID) + mv $@.new $@ +endef + +define Build/h3c-vfs + $(STAGING_DIR_HOST)/bin/mkh3cvfs \ + -i $(@) \ + -o $(@).new \ + -f openwrt-kernel.bin + mv $@.new $@ +endef + +define Build/relocate-kernel + rm -rf $@.relocate + $(CP) ../../generic/image/relocate $@.relocate + $(MAKE) -j1 -C $@.relocate KERNEL_ADDR=$(KERNEL_LOADADDR) LZMA_TEXT_START=0x82000000 \ + CROSS_COMPILE=$(TARGET_CROSS) + ( \ + dd if=$@.relocate/loader.bin bs=32 conv=sync && \ + perl -e '@s = stat("$@"); print pack("N", @s[7])' && \ + cat "$@" \ + ) > "$@.new" + mv "$@.new" "$@" + rm -rf $@.relocate +endef + define Device/Default PROFILES = Default KERNEL := kernel-bin | append-dtb | gzip | uImage gzip @@ -52,6 +90,17 @@ define Device/Default check-size | append-metadata endef +define Device/hpe_1920 + DEVICE_VENDOR := HPE + IMAGE_SIZE := 29632k + BLOCKSIZE := 64k + H3C_PRODUCT_ID := 0x3c010501 + KERNEL := kernel-bin | append-dtb | relocate-kernel | 7z | h3c-image | h3c-vfs + KERNEL_INITRAMFS := kernel-bin | append-dtb | relocate-kernel | 7z | h3c-image + IMAGE/sysupgrade.bin := append-kernel | pad-to $$$$(BLOCKSIZE) | append-rootfs | \ + pad-rootfs | check-size | append-metadata +endef + # "NGE" refers to the uImage magic define Device/netgear_nge KERNEL := kernel-bin | append-dtb | lzma | uImage lzma diff --git a/target/linux/realtek/image/rtl838x.mk b/target/linux/realtek/image/rtl838x.mk index 887f82e385..60eda5359d 100644 --- a/target/linux/realtek/image/rtl838x.mk +++ b/target/linux/realtek/image/rtl838x.mk @@ -65,6 +65,30 @@ define Device/engenius_ews2910p endef TARGET_DEVICES += engenius_ews2910p +define Device/hpe_1920-8g + $(Device/hpe_1920) + SOC := rtl8380 + DEVICE_MODEL := 1920-8G (JG920A) + H3C_DEVICE_ID := 0x00010023 +endef +TARGET_DEVICES += hpe_1920-8g + +define Device/hpe_1920-16g + $(Device/hpe_1920) + SOC := rtl8382 + DEVICE_MODEL := 1920-16G (JG923A) + H3C_DEVICE_ID := 0x00010026 +endef +TARGET_DEVICES += hpe_1920-16g + +define Device/hpe_1920-24g + $(Device/hpe_1920) + SOC := rtl8382 + DEVICE_MODEL := 1920-24G (JG924A) + H3C_DEVICE_ID := 0x00010027 +endef +TARGET_DEVICES += hpe_1920-24g + define Device/inaba_aml2-17gp SOC := rtl8382 IMAGE_SIZE := 13504k diff --git a/target/linux/realtek/rtl838x/config-5.10 b/target/linux/realtek/rtl838x/config-5.10 index c117fc489a..9075aa6d3c 100644 --- a/target/linux/realtek/rtl838x/config-5.10 +++ b/target/linux/realtek/rtl838x/config-5.10 @@ -74,6 +74,8 @@ CONFIG_GPIO_PCA953X=y CONFIG_GPIO_PCA953X_IRQ=y CONFIG_GPIO_REALTEK_OTTO=y CONFIG_GPIO_RTL8231=y +CONFIG_GPIO_WATCHDOG=y +# CONFIG_GPIO_WATCHDOG_ARCH_INITCALL is not set CONFIG_GRO_CELLS=y CONFIG_HANDLE_DOMAIN_IRQ=y CONFIG_HARDWARE_WATCHPOINTS=y @@ -134,6 +136,7 @@ CONFIG_MTD_SPI_NOR=y CONFIG_MTD_SPLIT_BRNIMAGE_FW=y CONFIG_MTD_SPLIT_EVA_FW=y CONFIG_MTD_SPLIT_FIRMWARE=y +CONFIG_MTD_SPLIT_H3C_VFS=y CONFIG_MTD_SPLIT_TPLINK_FW=y CONFIG_MTD_SPLIT_UIMAGE_FW=y CONFIG_NEED_DMA_MAP_STATE=y From a63aeaecf1f3387df020854c9b22a365207399ce Mon Sep 17 00:00:00 2001 From: Sander Vanheule Date: Thu, 28 Jul 2022 15:13:52 +0200 Subject: [PATCH 20/23] realtek: remove support for HPE 1920 series Support for HPE 1920 images depends on two non-existent tools (mkh3cimg and mkh3cvfs) from the in the firmware-utils package. Revert commit f2f09bc00280 ("realtek: add support for HPE 1920 series") until support for these tools is merged and made available in OpenWrt. Signed-off-by: Sander Vanheule --- .../realtek/base-files/etc/board.d/02_network | 18 +-- .../realtek/dts-5.10/rtl8380_hpe_1920-8g.dts | 113 ----------------- .../realtek/dts-5.10/rtl8382_hpe_1920-16g.dts | 48 ------- .../realtek/dts-5.10/rtl8382_hpe_1920-24g.dts | 68 ---------- .../realtek/dts-5.10/rtl8382_hpe_1920.dtsi | 117 ------------------ target/linux/realtek/dts-5.10/rtl838x.dtsi | 7 -- .../realtek/dts-5.10/rtl838x_hpe_1920.dtsi | 96 -------------- target/linux/realtek/image/Makefile | 49 -------- target/linux/realtek/image/rtl838x.mk | 24 ---- target/linux/realtek/rtl838x/config-5.10 | 3 - 10 files changed, 3 insertions(+), 540 deletions(-) delete mode 100644 target/linux/realtek/dts-5.10/rtl8380_hpe_1920-8g.dts delete mode 100644 target/linux/realtek/dts-5.10/rtl8382_hpe_1920-16g.dts delete mode 100644 target/linux/realtek/dts-5.10/rtl8382_hpe_1920-24g.dts delete mode 100644 target/linux/realtek/dts-5.10/rtl8382_hpe_1920.dtsi delete mode 100644 target/linux/realtek/dts-5.10/rtl838x_hpe_1920.dtsi diff --git a/target/linux/realtek/base-files/etc/board.d/02_network b/target/linux/realtek/base-files/etc/board.d/02_network index 5356bcac65..af9db848dd 100644 --- a/target/linux/realtek/base-files/etc/board.d/02_network +++ b/target/linux/realtek/base-files/etc/board.d/02_network @@ -22,20 +22,9 @@ ucidef_set_bridge_device switch ucidef_set_interface_lan "$lan_list" lan_mac="" -lan_mac_start="" lan_mac_end="" label_mac="" case $board in -hpe,1920-8g|\ -hpe,1920-16g|\ -hpe,1920-24g) - label_mac=$(mtd_get_mac_binary factory 0x68) - lan_mac=$label_mac - mac_count1=$(hexdump -v -n 4 -s 0x110 -e '4 "%d"' $(find_mtd_part factory) 2>/dev/null) - mac_count2=$(hexdump -v -n 4 -s 0x114 -e '4 "%d"' $(find_mtd_part factory) 2>/dev/null) - lan_mac_start=$(macaddr_add $lan_mac 2) - lan_mac_end=$(macaddr_add $lan_mac $((mac_count2-mac_count1))) - ;; *) lan_mac=$(mtd_get_mac_ascii u-boot-env2 mac_start) lan_mac_end=$(mtd_get_mac_ascii u-boot-env2 mac_end) @@ -47,11 +36,10 @@ esac ucidef_set_interface_macaddr "lan" $lan_mac ucidef_set_bridge_mac "$lan_mac" ucidef_set_network_device_mac eth0 $lan_mac -[ -z "$lan_mac_start" ] && lan_mac_start=$lan_mac for lan in $lan_list; do - ucidef_set_network_device_mac $lan $lan_mac_start - [ -z "$lan_mac_end" ] || [ "$lan_mac_start" == "$lan_mac_end" ] && lan_mac_start=$(macaddr_setbit_la $lan_mac_start) - lan_mac_start=$(macaddr_add $lan_mac_start 1) + ucidef_set_network_device_mac $lan $lan_mac + [ -z "$lan_mac_end" ] || [ "$lan_mac" == "$lan_mac_end" ] && lan_mac=$(macaddr_setbit_la $lan_mac) + lan_mac=$(macaddr_add $lan_mac 1) done [ -n "$label_mac" ] && ucidef_set_label_macaddr $label_mac diff --git a/target/linux/realtek/dts-5.10/rtl8380_hpe_1920-8g.dts b/target/linux/realtek/dts-5.10/rtl8380_hpe_1920-8g.dts deleted file mode 100644 index b51c75f355..0000000000 --- a/target/linux/realtek/dts-5.10/rtl8380_hpe_1920-8g.dts +++ /dev/null @@ -1,113 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later OR MIT - -#include "rtl838x.dtsi" -#include "rtl838x_hpe_1920.dtsi" - -/ { - compatible = "hpe,1920-8g", "realtek,rtl838x-soc"; - model = "HPE 1920-8G (JG920A)"; - - gpio1: rtl8231-gpio { - compatible = "realtek,rtl8231-gpio"; - #gpio-cells = <2>; - gpio-controller; - indirect-access-bus-id = <0>; - }; - - i2c0: i2c-gpio-0 { - compatible = "i2c-gpio"; - sda-gpios = <&gpio1 23 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; - scl-gpios = <&gpio1 24 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; - i2c-gpio,delay-us = <2>; - #address-cells = <1>; - #size-cells = <0>; - }; - - sfp0: sfp-0 { - compatible = "sff,sfp"; - i2c-bus = <&i2c0>; - los-gpio = <&gpio1 26 GPIO_ACTIVE_HIGH>; - mod-def0-gpio = <&gpio1 25 GPIO_ACTIVE_LOW>; - // tx-fault and tx-disable unconnected - }; - - i2c1: i2c-gpio-1 { - compatible = "i2c-gpio"; - sda-gpios = <&gpio1 13 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; - scl-gpios = <&gpio1 14 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; - i2c-gpio,delay-us = <2>; - #address-cells = <1>; - #size-cells = <0>; - }; - - sfp1: sfp-1 { - compatible = "sff,sfp"; - i2c-bus = <&i2c1>; - los-gpio = <&gpio1 22 GPIO_ACTIVE_HIGH>; - mod-def0-gpio = <&gpio1 21 GPIO_ACTIVE_LOW>; - // tx-fault and tx-disable unconnected - }; -}; - -ðernet0 { - mdio: mdio-bus { - compatible = "realtek,rtl838x-mdio"; - regmap = <ðernet0>; - #address-cells = <1>; - #size-cells = <0>; - - INTERNAL_PHY(8) - INTERNAL_PHY(9) - INTERNAL_PHY(10) - INTERNAL_PHY(11) - INTERNAL_PHY(12) - INTERNAL_PHY(13) - INTERNAL_PHY(14) - INTERNAL_PHY(15) - - INTERNAL_PHY(24) - INTERNAL_PHY(26) - }; -}; - -&switch0 { - ports { - #address-cells = <1>; - #size-cells = <0>; - - SWITCH_PORT(8, 1, internal) - SWITCH_PORT(9, 2, internal) - SWITCH_PORT(10, 3, internal) - SWITCH_PORT(11, 4, internal) - SWITCH_PORT(12, 5, internal) - SWITCH_PORT(13, 6, internal) - SWITCH_PORT(14, 7, internal) - SWITCH_PORT(15, 8, internal) - - port@24 { - reg = <24>; - label = "lan9"; - phy-mode = "1000base-x"; - managed = "in-band-status"; - sfp = <&sfp0>; - }; - - port@26 { - reg = <26>; - label = "lan10"; - phy-mode = "1000base-x"; - managed = "in-band-status"; - sfp = <&sfp1>; - }; - - port@28 { - ethernet = <ðernet0>; - reg = <28>; - phy-mode = "internal"; - fixed-link { - speed = <1000>; - full-duplex; - }; - }; - }; -}; diff --git a/target/linux/realtek/dts-5.10/rtl8382_hpe_1920-16g.dts b/target/linux/realtek/dts-5.10/rtl8382_hpe_1920-16g.dts deleted file mode 100644 index 59043b2f6f..0000000000 --- a/target/linux/realtek/dts-5.10/rtl8382_hpe_1920-16g.dts +++ /dev/null @@ -1,48 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later OR MIT - -#include "rtl8382_hpe_1920.dtsi" - -/ { - compatible = "hpe,1920-16g", "realtek,rtl838x-soc"; - model = "HPE 1920-16G (JG923A)"; -}; - -&switch0 { - ports { - #address-cells = <1>; - #size-cells = <0>; - - SWITCH_PORT(8, 1, internal) - SWITCH_PORT(9, 2, internal) - SWITCH_PORT(10, 3, internal) - SWITCH_PORT(11, 4, internal) - SWITCH_PORT(12, 5, internal) - SWITCH_PORT(13, 6, internal) - SWITCH_PORT(14, 7, internal) - SWITCH_PORT(15, 8, internal) - - SWITCH_PORT(16, 9, qsgmii) - SWITCH_PORT(17, 10, qsgmii) - SWITCH_PORT(18, 11, qsgmii) - SWITCH_PORT(19, 12, qsgmii) - SWITCH_PORT(20, 13, qsgmii) - SWITCH_PORT(21, 14, qsgmii) - SWITCH_PORT(22, 15, qsgmii) - SWITCH_PORT(23, 16, qsgmii) - - SWITCH_PORT(24, 17, qsgmii) - SWITCH_PORT(25, 18, qsgmii) - SWITCH_PORT(26, 19, qsgmii) - SWITCH_PORT(27, 20, qsgmii) - - port@28 { - ethernet = <ðernet0>; - reg = <28>; - phy-mode = "internal"; - fixed-link { - speed = <1000>; - full-duplex; - }; - }; - }; -}; diff --git a/target/linux/realtek/dts-5.10/rtl8382_hpe_1920-24g.dts b/target/linux/realtek/dts-5.10/rtl8382_hpe_1920-24g.dts deleted file mode 100644 index 61781c708e..0000000000 --- a/target/linux/realtek/dts-5.10/rtl8382_hpe_1920-24g.dts +++ /dev/null @@ -1,68 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later OR MIT - -#include "rtl8382_hpe_1920.dtsi" - -/ { - compatible = "hpe,1920-24g", "realtek,rtl838x-soc"; - model = "HPE 1920-24G (JG924A)"; -}; - -&mdio { - EXTERNAL_PHY(0) - EXTERNAL_PHY(1) - EXTERNAL_PHY(2) - EXTERNAL_PHY(3) - EXTERNAL_PHY(4) - EXTERNAL_PHY(5) - EXTERNAL_PHY(6) - EXTERNAL_PHY(7) -}; - -&switch0 { - ports { - #address-cells = <1>; - #size-cells = <0>; - - SWITCH_PORT(0, 1, qsgmii) - SWITCH_PORT(1, 2, qsgmii) - SWITCH_PORT(2, 3, qsgmii) - SWITCH_PORT(3, 4, qsgmii) - SWITCH_PORT(4, 5, qsgmii) - SWITCH_PORT(5, 6, qsgmii) - SWITCH_PORT(6, 7, qsgmii) - SWITCH_PORT(7, 8, qsgmii) - - SWITCH_PORT(8, 9, internal) - SWITCH_PORT(9, 10, internal) - SWITCH_PORT(10, 11, internal) - SWITCH_PORT(11, 12, internal) - SWITCH_PORT(12, 13, internal) - SWITCH_PORT(13, 14, internal) - SWITCH_PORT(14, 15, internal) - SWITCH_PORT(15, 16, internal) - - SWITCH_PORT(16, 17, qsgmii) - SWITCH_PORT(17, 18, qsgmii) - SWITCH_PORT(18, 19, qsgmii) - SWITCH_PORT(19, 20, qsgmii) - SWITCH_PORT(20, 21, qsgmii) - SWITCH_PORT(21, 22, qsgmii) - SWITCH_PORT(22, 23, qsgmii) - SWITCH_PORT(23, 24, qsgmii) - - SWITCH_PORT(24, 25, qsgmii) - SWITCH_PORT(25, 26, qsgmii) - SWITCH_PORT(26, 27, qsgmii) - SWITCH_PORT(27, 28, qsgmii) - - port@28 { - ethernet = <ðernet0>; - reg = <28>; - phy-mode = "internal"; - fixed-link { - speed = <1000>; - full-duplex; - }; - }; - }; -}; diff --git a/target/linux/realtek/dts-5.10/rtl8382_hpe_1920.dtsi b/target/linux/realtek/dts-5.10/rtl8382_hpe_1920.dtsi deleted file mode 100644 index 5368b41c27..0000000000 --- a/target/linux/realtek/dts-5.10/rtl8382_hpe_1920.dtsi +++ /dev/null @@ -1,117 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later OR MIT - -#include "rtl838x.dtsi" -#include "rtl838x_hpe_1920.dtsi" - -/ { - gpio1: rtl8231-gpio { - compatible = "realtek,rtl8231-gpio"; - #gpio-cells = <2>; - gpio-controller; - indirect-access-bus-id = <0>; - }; - - i2c0: i2c-gpio-0 { - compatible = "i2c-gpio"; - sda-gpios = <&gpio1 13 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; - scl-gpios = <&gpio1 14 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; - i2c-gpio,delay-us = <2>; - #address-cells = <1>; - #size-cells = <0>; - }; - - sfp0: sfp-0 { - compatible = "sff,sfp"; - i2c-bus = <&i2c0>; - los-gpio = <&gpio1 22 GPIO_ACTIVE_HIGH>; - mod-def0-gpio = <&gpio1 21 GPIO_ACTIVE_LOW>; - // tx-fault unconnected - // tx-disable connected to RTL8214FC - }; - - i2c1: i2c-gpio-1 { - compatible = "i2c-gpio"; - sda-gpios = <&gpio1 23 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; - scl-gpios = <&gpio1 24 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; - i2c-gpio,delay-us = <2>; - #address-cells = <1>; - #size-cells = <0>; - }; - - sfp1: sfp-1 { - compatible = "sff,sfp"; - i2c-bus = <&i2c1>; - los-gpio = <&gpio1 26 GPIO_ACTIVE_HIGH>; - mod-def0-gpio = <&gpio1 25 GPIO_ACTIVE_LOW>; - // tx-fault unconnected - // tx-disable connected to RTL8214FC - }; - - i2c2: i2c-gpio-2 { - compatible = "i2c-gpio"; - sda-gpios = <&gpio1 27 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; - scl-gpios = <&gpio1 28 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; - i2c-gpio,delay-us = <2>; - #address-cells = <1>; - #size-cells = <0>; - }; - - sfp2: sfp-2 { - compatible = "sff,sfp"; - i2c-bus = <&i2c2>; - los-gpio = <&gpio1 30 GPIO_ACTIVE_HIGH>; - mod-def0-gpio = <&gpio1 29 GPIO_ACTIVE_LOW>; - // tx-fault unconnected - // tx-disable connected to RTL8214FC - }; - - i2c3: i2c-gpio-3 { - compatible = "i2c-gpio"; - sda-gpios = <&gpio1 31 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; - scl-gpios = <&gpio1 32 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; - i2c-gpio,delay-us = <2>; - #address-cells = <1>; - #size-cells = <0>; - }; - - sfp3: sfp-3 { - compatible = "sff,sfp"; - i2c-bus = <&i2c3>; - los-gpio = <&gpio1 34 GPIO_ACTIVE_HIGH>; - mod-def0-gpio = <&gpio1 33 GPIO_ACTIVE_LOW>; - // tx-fault unconnected - // tx-disable connected to RTL8214FC - }; -}; - -ðernet0 { - mdio: mdio-bus { - compatible = "realtek,rtl838x-mdio"; - regmap = <ðernet0>; - #address-cells = <1>; - #size-cells = <0>; - - INTERNAL_PHY(8) - INTERNAL_PHY(9) - INTERNAL_PHY(10) - INTERNAL_PHY(11) - INTERNAL_PHY(12) - INTERNAL_PHY(13) - INTERNAL_PHY(14) - INTERNAL_PHY(15) - - EXTERNAL_PHY(16) - EXTERNAL_PHY(17) - EXTERNAL_PHY(18) - EXTERNAL_PHY(19) - EXTERNAL_PHY(20) - EXTERNAL_PHY(21) - EXTERNAL_PHY(22) - EXTERNAL_PHY(23) - - EXTERNAL_SFP_PHY_FULL(24, 0) - EXTERNAL_SFP_PHY_FULL(25, 1) - EXTERNAL_SFP_PHY_FULL(26, 2) - EXTERNAL_SFP_PHY_FULL(27, 3) - }; -}; diff --git a/target/linux/realtek/dts-5.10/rtl838x.dtsi b/target/linux/realtek/dts-5.10/rtl838x.dtsi index 41fdbdae20..11cabc3f63 100644 --- a/target/linux/realtek/dts-5.10/rtl838x.dtsi +++ b/target/linux/realtek/dts-5.10/rtl838x.dtsi @@ -27,13 +27,6 @@ reg = <##n>; \ }; -#define EXTERNAL_SFP_PHY_FULL(n, s) \ - phy##n: ethernet-phy@##n { \ - compatible = "ethernet-phy-ieee802.3-c22"; \ - sfp = <&sfp##s>; \ - reg = <##n>; \ - }; - #define SWITCH_PORT(n, s, m) \ port@##n { \ reg = <##n>; \ diff --git a/target/linux/realtek/dts-5.10/rtl838x_hpe_1920.dtsi b/target/linux/realtek/dts-5.10/rtl838x_hpe_1920.dtsi deleted file mode 100644 index 8e29af62bb..0000000000 --- a/target/linux/realtek/dts-5.10/rtl838x_hpe_1920.dtsi +++ /dev/null @@ -1,96 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later OR MIT - -#include -#include - -/ { - chosen { - bootargs = "console=ttyS0,38400"; - }; - - memory@0 { - device_type = "memory"; - reg = <0x0 0x8000000>; - }; - - watchdog1: watchdog { - // PT7A7514 - compatible = "linux,wdt-gpio"; - gpios = <&gpio0 0 GPIO_ACTIVE_HIGH>; - hw_algo = "toggle"; - hw_margin_ms = <1000>; - always-running; - - pinctrl-names = "default"; - pinctrl-0 = <&pinmux_disable_sys_led>; - }; -}; - -&watchdog0 { - status = "disabled"; -}; - -&spi0 { - status = "okay"; - - flash@0 { - compatible = "jedec,spi-nor"; - reg = <0>; - spi-max-frequency = <50000000>; - m25p,fast-read; - - partitions { - compatible = "fixed-partitions"; - #address-cells = <1>; - #size-cells = <1>; - - partition@0 { - label = "bootware_basic"; - reg = <0x0 0x50000>; - read-only; - }; - - partition@0x60000 { - label = "bootware_data"; - reg = <0x60000 0x30000>; - read-only; - }; - - partition@0x90000 { - label = "bootware_extend"; - reg = <0x90000 0x40000>; - read-only; - }; - - partition@0x100000 { - label = "bootware_basic_backup"; - reg = <0x100000 0x50000>; - read-only; - }; - - partition@0x160000 { - label = "bootware_data_backup"; - reg = <0x160000 0x30000>; - read-only; - }; - - partition@0x190000 { - label = "bootware_extend_backup"; - reg = <0x190000 0x40000>; - read-only; - }; - - partition@0x300000 { - label = "firmware"; - compatible = "h3c,vfs-firmware"; - reg = <0x300000 0x1cf0000>; - }; - - partition@0x1ff0000 { - label = "factory"; - reg = <0x1ff0000 0x10000>; - read-only; - }; - }; - }; -}; diff --git a/target/linux/realtek/image/Makefile b/target/linux/realtek/image/Makefile index 6165d99bfc..cf779002e8 100644 --- a/target/linux/realtek/image/Makefile +++ b/target/linux/realtek/image/Makefile @@ -8,7 +8,6 @@ KERNEL_ENTRY = 0x80000400 DEVICE_VARS += ZYXEL_VERS DLINK_KERNEL_PART_SIZE DEVICE_VARS += CAMEO_KERNEL_PART CAMEO_ROOTFS_PART CAMEO_CUSTOMER_SIGNATURE CAMEO_BOARD_VERSION -DEVICE_VARS += H3C_PRODUCT_ID H3C_DEVICE_ID define Build/zyxel-vers ( echo VERS;\ @@ -42,43 +41,6 @@ define Build/dlink-headers cat $@.kernel_part.hex $@.rootfs_part.hex > $@ endef -define Build/7z - $(STAGING_DIR_HOST)/bin/7zr a $(@).new -t7z -m0=lzma $(@) - mv $@.new $@ -endef - -define Build/h3c-image - $(STAGING_DIR_HOST)/bin/mkh3cimg \ - -i $(@) \ - -o $(@).new \ - -c 7z \ - -p $(H3C_PRODUCT_ID) \ - -d $(H3C_DEVICE_ID) - mv $@.new $@ -endef - -define Build/h3c-vfs - $(STAGING_DIR_HOST)/bin/mkh3cvfs \ - -i $(@) \ - -o $(@).new \ - -f openwrt-kernel.bin - mv $@.new $@ -endef - -define Build/relocate-kernel - rm -rf $@.relocate - $(CP) ../../generic/image/relocate $@.relocate - $(MAKE) -j1 -C $@.relocate KERNEL_ADDR=$(KERNEL_LOADADDR) LZMA_TEXT_START=0x82000000 \ - CROSS_COMPILE=$(TARGET_CROSS) - ( \ - dd if=$@.relocate/loader.bin bs=32 conv=sync && \ - perl -e '@s = stat("$@"); print pack("N", @s[7])' && \ - cat "$@" \ - ) > "$@.new" - mv "$@.new" "$@" - rm -rf $@.relocate -endef - define Device/Default PROFILES = Default KERNEL := kernel-bin | append-dtb | gzip | uImage gzip @@ -90,17 +52,6 @@ define Device/Default check-size | append-metadata endef -define Device/hpe_1920 - DEVICE_VENDOR := HPE - IMAGE_SIZE := 29632k - BLOCKSIZE := 64k - H3C_PRODUCT_ID := 0x3c010501 - KERNEL := kernel-bin | append-dtb | relocate-kernel | 7z | h3c-image | h3c-vfs - KERNEL_INITRAMFS := kernel-bin | append-dtb | relocate-kernel | 7z | h3c-image - IMAGE/sysupgrade.bin := append-kernel | pad-to $$$$(BLOCKSIZE) | append-rootfs | \ - pad-rootfs | check-size | append-metadata -endef - # "NGE" refers to the uImage magic define Device/netgear_nge KERNEL := kernel-bin | append-dtb | lzma | uImage lzma diff --git a/target/linux/realtek/image/rtl838x.mk b/target/linux/realtek/image/rtl838x.mk index 60eda5359d..887f82e385 100644 --- a/target/linux/realtek/image/rtl838x.mk +++ b/target/linux/realtek/image/rtl838x.mk @@ -65,30 +65,6 @@ define Device/engenius_ews2910p endef TARGET_DEVICES += engenius_ews2910p -define Device/hpe_1920-8g - $(Device/hpe_1920) - SOC := rtl8380 - DEVICE_MODEL := 1920-8G (JG920A) - H3C_DEVICE_ID := 0x00010023 -endef -TARGET_DEVICES += hpe_1920-8g - -define Device/hpe_1920-16g - $(Device/hpe_1920) - SOC := rtl8382 - DEVICE_MODEL := 1920-16G (JG923A) - H3C_DEVICE_ID := 0x00010026 -endef -TARGET_DEVICES += hpe_1920-16g - -define Device/hpe_1920-24g - $(Device/hpe_1920) - SOC := rtl8382 - DEVICE_MODEL := 1920-24G (JG924A) - H3C_DEVICE_ID := 0x00010027 -endef -TARGET_DEVICES += hpe_1920-24g - define Device/inaba_aml2-17gp SOC := rtl8382 IMAGE_SIZE := 13504k diff --git a/target/linux/realtek/rtl838x/config-5.10 b/target/linux/realtek/rtl838x/config-5.10 index 9075aa6d3c..c117fc489a 100644 --- a/target/linux/realtek/rtl838x/config-5.10 +++ b/target/linux/realtek/rtl838x/config-5.10 @@ -74,8 +74,6 @@ CONFIG_GPIO_PCA953X=y CONFIG_GPIO_PCA953X_IRQ=y CONFIG_GPIO_REALTEK_OTTO=y CONFIG_GPIO_RTL8231=y -CONFIG_GPIO_WATCHDOG=y -# CONFIG_GPIO_WATCHDOG_ARCH_INITCALL is not set CONFIG_GRO_CELLS=y CONFIG_HANDLE_DOMAIN_IRQ=y CONFIG_HARDWARE_WATCHPOINTS=y @@ -136,7 +134,6 @@ CONFIG_MTD_SPI_NOR=y CONFIG_MTD_SPLIT_BRNIMAGE_FW=y CONFIG_MTD_SPLIT_EVA_FW=y CONFIG_MTD_SPLIT_FIRMWARE=y -CONFIG_MTD_SPLIT_H3C_VFS=y CONFIG_MTD_SPLIT_TPLINK_FW=y CONFIG_MTD_SPLIT_UIMAGE_FW=y CONFIG_NEED_DMA_MAP_STATE=y From aeaa02afac6b7d55dd2b8175858b9799a24fb494 Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Thu, 28 Jul 2022 16:43:17 +0200 Subject: [PATCH 21/23] firmware-utils: update to git HEAD 4f8d03d mkh3cimg: add image tool for H3C devices 2483fe7 mkh3cvfs: add filesystem tool for H3C devices Signed-off-by: Daniel Golle --- tools/firmware-utils/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/firmware-utils/Makefile b/tools/firmware-utils/Makefile index 7dc406e755..ffb3c09780 100644 --- a/tools/firmware-utils/Makefile +++ b/tools/firmware-utils/Makefile @@ -11,9 +11,9 @@ PKG_RELEASE:=1 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL=$(PROJECT_GIT)/project/firmware-utils.git -PKG_SOURCE_DATE:=2022-04-25 -PKG_SOURCE_VERSION:=e609c5d751868ae823c236332c76ce3c50acdd2e -PKG_MIRROR_HASH:=f1a5af565bff50ccc99471a2be71636ed685dd15bfb9b162be9acf8ee28033a6 +PKG_SOURCE_DATE:=2022-07-28 +PKG_SOURCE_VERSION:=2483fe782e0d406b65eaa73b39fc27afabd8a9ea +PKG_MIRROR_HASH:=140b84b33cdae1520304cd6798604a51d2f4281b828808a5913d0b2d4b1f551f include $(INCLUDE_DIR)/host-build.mk include $(INCLUDE_DIR)/cmake.mk From a49212d762fb2635564cd3365651da51d0c535d9 Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Thu, 28 Jul 2022 16:45:03 +0200 Subject: [PATCH 22/23] Revert "realtek: remove support for HPE 1920 series" This reverts commit a63aeaecf1f3387df020854c9b22a365207399ce. Signed-off-by: Daniel Golle --- .../realtek/base-files/etc/board.d/02_network | 18 ++- .../realtek/dts-5.10/rtl8380_hpe_1920-8g.dts | 113 +++++++++++++++++ .../realtek/dts-5.10/rtl8382_hpe_1920-16g.dts | 48 +++++++ .../realtek/dts-5.10/rtl8382_hpe_1920-24g.dts | 68 ++++++++++ .../realtek/dts-5.10/rtl8382_hpe_1920.dtsi | 117 ++++++++++++++++++ target/linux/realtek/dts-5.10/rtl838x.dtsi | 7 ++ .../realtek/dts-5.10/rtl838x_hpe_1920.dtsi | 96 ++++++++++++++ target/linux/realtek/image/Makefile | 49 ++++++++ target/linux/realtek/image/rtl838x.mk | 24 ++++ target/linux/realtek/rtl838x/config-5.10 | 3 + 10 files changed, 540 insertions(+), 3 deletions(-) create mode 100644 target/linux/realtek/dts-5.10/rtl8380_hpe_1920-8g.dts create mode 100644 target/linux/realtek/dts-5.10/rtl8382_hpe_1920-16g.dts create mode 100644 target/linux/realtek/dts-5.10/rtl8382_hpe_1920-24g.dts create mode 100644 target/linux/realtek/dts-5.10/rtl8382_hpe_1920.dtsi create mode 100644 target/linux/realtek/dts-5.10/rtl838x_hpe_1920.dtsi diff --git a/target/linux/realtek/base-files/etc/board.d/02_network b/target/linux/realtek/base-files/etc/board.d/02_network index af9db848dd..5356bcac65 100644 --- a/target/linux/realtek/base-files/etc/board.d/02_network +++ b/target/linux/realtek/base-files/etc/board.d/02_network @@ -22,9 +22,20 @@ ucidef_set_bridge_device switch ucidef_set_interface_lan "$lan_list" lan_mac="" +lan_mac_start="" lan_mac_end="" label_mac="" case $board in +hpe,1920-8g|\ +hpe,1920-16g|\ +hpe,1920-24g) + label_mac=$(mtd_get_mac_binary factory 0x68) + lan_mac=$label_mac + mac_count1=$(hexdump -v -n 4 -s 0x110 -e '4 "%d"' $(find_mtd_part factory) 2>/dev/null) + mac_count2=$(hexdump -v -n 4 -s 0x114 -e '4 "%d"' $(find_mtd_part factory) 2>/dev/null) + lan_mac_start=$(macaddr_add $lan_mac 2) + lan_mac_end=$(macaddr_add $lan_mac $((mac_count2-mac_count1))) + ;; *) lan_mac=$(mtd_get_mac_ascii u-boot-env2 mac_start) lan_mac_end=$(mtd_get_mac_ascii u-boot-env2 mac_end) @@ -36,10 +47,11 @@ esac ucidef_set_interface_macaddr "lan" $lan_mac ucidef_set_bridge_mac "$lan_mac" ucidef_set_network_device_mac eth0 $lan_mac +[ -z "$lan_mac_start" ] && lan_mac_start=$lan_mac for lan in $lan_list; do - ucidef_set_network_device_mac $lan $lan_mac - [ -z "$lan_mac_end" ] || [ "$lan_mac" == "$lan_mac_end" ] && lan_mac=$(macaddr_setbit_la $lan_mac) - lan_mac=$(macaddr_add $lan_mac 1) + ucidef_set_network_device_mac $lan $lan_mac_start + [ -z "$lan_mac_end" ] || [ "$lan_mac_start" == "$lan_mac_end" ] && lan_mac_start=$(macaddr_setbit_la $lan_mac_start) + lan_mac_start=$(macaddr_add $lan_mac_start 1) done [ -n "$label_mac" ] && ucidef_set_label_macaddr $label_mac diff --git a/target/linux/realtek/dts-5.10/rtl8380_hpe_1920-8g.dts b/target/linux/realtek/dts-5.10/rtl8380_hpe_1920-8g.dts new file mode 100644 index 0000000000..b51c75f355 --- /dev/null +++ b/target/linux/realtek/dts-5.10/rtl8380_hpe_1920-8g.dts @@ -0,0 +1,113 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "rtl838x.dtsi" +#include "rtl838x_hpe_1920.dtsi" + +/ { + compatible = "hpe,1920-8g", "realtek,rtl838x-soc"; + model = "HPE 1920-8G (JG920A)"; + + gpio1: rtl8231-gpio { + compatible = "realtek,rtl8231-gpio"; + #gpio-cells = <2>; + gpio-controller; + indirect-access-bus-id = <0>; + }; + + i2c0: i2c-gpio-0 { + compatible = "i2c-gpio"; + sda-gpios = <&gpio1 23 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; + scl-gpios = <&gpio1 24 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; + i2c-gpio,delay-us = <2>; + #address-cells = <1>; + #size-cells = <0>; + }; + + sfp0: sfp-0 { + compatible = "sff,sfp"; + i2c-bus = <&i2c0>; + los-gpio = <&gpio1 26 GPIO_ACTIVE_HIGH>; + mod-def0-gpio = <&gpio1 25 GPIO_ACTIVE_LOW>; + // tx-fault and tx-disable unconnected + }; + + i2c1: i2c-gpio-1 { + compatible = "i2c-gpio"; + sda-gpios = <&gpio1 13 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; + scl-gpios = <&gpio1 14 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; + i2c-gpio,delay-us = <2>; + #address-cells = <1>; + #size-cells = <0>; + }; + + sfp1: sfp-1 { + compatible = "sff,sfp"; + i2c-bus = <&i2c1>; + los-gpio = <&gpio1 22 GPIO_ACTIVE_HIGH>; + mod-def0-gpio = <&gpio1 21 GPIO_ACTIVE_LOW>; + // tx-fault and tx-disable unconnected + }; +}; + +ðernet0 { + mdio: mdio-bus { + compatible = "realtek,rtl838x-mdio"; + regmap = <ðernet0>; + #address-cells = <1>; + #size-cells = <0>; + + INTERNAL_PHY(8) + INTERNAL_PHY(9) + INTERNAL_PHY(10) + INTERNAL_PHY(11) + INTERNAL_PHY(12) + INTERNAL_PHY(13) + INTERNAL_PHY(14) + INTERNAL_PHY(15) + + INTERNAL_PHY(24) + INTERNAL_PHY(26) + }; +}; + +&switch0 { + ports { + #address-cells = <1>; + #size-cells = <0>; + + SWITCH_PORT(8, 1, internal) + SWITCH_PORT(9, 2, internal) + SWITCH_PORT(10, 3, internal) + SWITCH_PORT(11, 4, internal) + SWITCH_PORT(12, 5, internal) + SWITCH_PORT(13, 6, internal) + SWITCH_PORT(14, 7, internal) + SWITCH_PORT(15, 8, internal) + + port@24 { + reg = <24>; + label = "lan9"; + phy-mode = "1000base-x"; + managed = "in-band-status"; + sfp = <&sfp0>; + }; + + port@26 { + reg = <26>; + label = "lan10"; + phy-mode = "1000base-x"; + managed = "in-band-status"; + sfp = <&sfp1>; + }; + + port@28 { + ethernet = <ðernet0>; + reg = <28>; + phy-mode = "internal"; + fixed-link { + speed = <1000>; + full-duplex; + }; + }; + }; +}; diff --git a/target/linux/realtek/dts-5.10/rtl8382_hpe_1920-16g.dts b/target/linux/realtek/dts-5.10/rtl8382_hpe_1920-16g.dts new file mode 100644 index 0000000000..59043b2f6f --- /dev/null +++ b/target/linux/realtek/dts-5.10/rtl8382_hpe_1920-16g.dts @@ -0,0 +1,48 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "rtl8382_hpe_1920.dtsi" + +/ { + compatible = "hpe,1920-16g", "realtek,rtl838x-soc"; + model = "HPE 1920-16G (JG923A)"; +}; + +&switch0 { + ports { + #address-cells = <1>; + #size-cells = <0>; + + SWITCH_PORT(8, 1, internal) + SWITCH_PORT(9, 2, internal) + SWITCH_PORT(10, 3, internal) + SWITCH_PORT(11, 4, internal) + SWITCH_PORT(12, 5, internal) + SWITCH_PORT(13, 6, internal) + SWITCH_PORT(14, 7, internal) + SWITCH_PORT(15, 8, internal) + + SWITCH_PORT(16, 9, qsgmii) + SWITCH_PORT(17, 10, qsgmii) + SWITCH_PORT(18, 11, qsgmii) + SWITCH_PORT(19, 12, qsgmii) + SWITCH_PORT(20, 13, qsgmii) + SWITCH_PORT(21, 14, qsgmii) + SWITCH_PORT(22, 15, qsgmii) + SWITCH_PORT(23, 16, qsgmii) + + SWITCH_PORT(24, 17, qsgmii) + SWITCH_PORT(25, 18, qsgmii) + SWITCH_PORT(26, 19, qsgmii) + SWITCH_PORT(27, 20, qsgmii) + + port@28 { + ethernet = <ðernet0>; + reg = <28>; + phy-mode = "internal"; + fixed-link { + speed = <1000>; + full-duplex; + }; + }; + }; +}; diff --git a/target/linux/realtek/dts-5.10/rtl8382_hpe_1920-24g.dts b/target/linux/realtek/dts-5.10/rtl8382_hpe_1920-24g.dts new file mode 100644 index 0000000000..61781c708e --- /dev/null +++ b/target/linux/realtek/dts-5.10/rtl8382_hpe_1920-24g.dts @@ -0,0 +1,68 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "rtl8382_hpe_1920.dtsi" + +/ { + compatible = "hpe,1920-24g", "realtek,rtl838x-soc"; + model = "HPE 1920-24G (JG924A)"; +}; + +&mdio { + EXTERNAL_PHY(0) + EXTERNAL_PHY(1) + EXTERNAL_PHY(2) + EXTERNAL_PHY(3) + EXTERNAL_PHY(4) + EXTERNAL_PHY(5) + EXTERNAL_PHY(6) + EXTERNAL_PHY(7) +}; + +&switch0 { + ports { + #address-cells = <1>; + #size-cells = <0>; + + SWITCH_PORT(0, 1, qsgmii) + SWITCH_PORT(1, 2, qsgmii) + SWITCH_PORT(2, 3, qsgmii) + SWITCH_PORT(3, 4, qsgmii) + SWITCH_PORT(4, 5, qsgmii) + SWITCH_PORT(5, 6, qsgmii) + SWITCH_PORT(6, 7, qsgmii) + SWITCH_PORT(7, 8, qsgmii) + + SWITCH_PORT(8, 9, internal) + SWITCH_PORT(9, 10, internal) + SWITCH_PORT(10, 11, internal) + SWITCH_PORT(11, 12, internal) + SWITCH_PORT(12, 13, internal) + SWITCH_PORT(13, 14, internal) + SWITCH_PORT(14, 15, internal) + SWITCH_PORT(15, 16, internal) + + SWITCH_PORT(16, 17, qsgmii) + SWITCH_PORT(17, 18, qsgmii) + SWITCH_PORT(18, 19, qsgmii) + SWITCH_PORT(19, 20, qsgmii) + SWITCH_PORT(20, 21, qsgmii) + SWITCH_PORT(21, 22, qsgmii) + SWITCH_PORT(22, 23, qsgmii) + SWITCH_PORT(23, 24, qsgmii) + + SWITCH_PORT(24, 25, qsgmii) + SWITCH_PORT(25, 26, qsgmii) + SWITCH_PORT(26, 27, qsgmii) + SWITCH_PORT(27, 28, qsgmii) + + port@28 { + ethernet = <ðernet0>; + reg = <28>; + phy-mode = "internal"; + fixed-link { + speed = <1000>; + full-duplex; + }; + }; + }; +}; diff --git a/target/linux/realtek/dts-5.10/rtl8382_hpe_1920.dtsi b/target/linux/realtek/dts-5.10/rtl8382_hpe_1920.dtsi new file mode 100644 index 0000000000..5368b41c27 --- /dev/null +++ b/target/linux/realtek/dts-5.10/rtl8382_hpe_1920.dtsi @@ -0,0 +1,117 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "rtl838x.dtsi" +#include "rtl838x_hpe_1920.dtsi" + +/ { + gpio1: rtl8231-gpio { + compatible = "realtek,rtl8231-gpio"; + #gpio-cells = <2>; + gpio-controller; + indirect-access-bus-id = <0>; + }; + + i2c0: i2c-gpio-0 { + compatible = "i2c-gpio"; + sda-gpios = <&gpio1 13 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; + scl-gpios = <&gpio1 14 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; + i2c-gpio,delay-us = <2>; + #address-cells = <1>; + #size-cells = <0>; + }; + + sfp0: sfp-0 { + compatible = "sff,sfp"; + i2c-bus = <&i2c0>; + los-gpio = <&gpio1 22 GPIO_ACTIVE_HIGH>; + mod-def0-gpio = <&gpio1 21 GPIO_ACTIVE_LOW>; + // tx-fault unconnected + // tx-disable connected to RTL8214FC + }; + + i2c1: i2c-gpio-1 { + compatible = "i2c-gpio"; + sda-gpios = <&gpio1 23 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; + scl-gpios = <&gpio1 24 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; + i2c-gpio,delay-us = <2>; + #address-cells = <1>; + #size-cells = <0>; + }; + + sfp1: sfp-1 { + compatible = "sff,sfp"; + i2c-bus = <&i2c1>; + los-gpio = <&gpio1 26 GPIO_ACTIVE_HIGH>; + mod-def0-gpio = <&gpio1 25 GPIO_ACTIVE_LOW>; + // tx-fault unconnected + // tx-disable connected to RTL8214FC + }; + + i2c2: i2c-gpio-2 { + compatible = "i2c-gpio"; + sda-gpios = <&gpio1 27 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; + scl-gpios = <&gpio1 28 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; + i2c-gpio,delay-us = <2>; + #address-cells = <1>; + #size-cells = <0>; + }; + + sfp2: sfp-2 { + compatible = "sff,sfp"; + i2c-bus = <&i2c2>; + los-gpio = <&gpio1 30 GPIO_ACTIVE_HIGH>; + mod-def0-gpio = <&gpio1 29 GPIO_ACTIVE_LOW>; + // tx-fault unconnected + // tx-disable connected to RTL8214FC + }; + + i2c3: i2c-gpio-3 { + compatible = "i2c-gpio"; + sda-gpios = <&gpio1 31 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; + scl-gpios = <&gpio1 32 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; + i2c-gpio,delay-us = <2>; + #address-cells = <1>; + #size-cells = <0>; + }; + + sfp3: sfp-3 { + compatible = "sff,sfp"; + i2c-bus = <&i2c3>; + los-gpio = <&gpio1 34 GPIO_ACTIVE_HIGH>; + mod-def0-gpio = <&gpio1 33 GPIO_ACTIVE_LOW>; + // tx-fault unconnected + // tx-disable connected to RTL8214FC + }; +}; + +ðernet0 { + mdio: mdio-bus { + compatible = "realtek,rtl838x-mdio"; + regmap = <ðernet0>; + #address-cells = <1>; + #size-cells = <0>; + + INTERNAL_PHY(8) + INTERNAL_PHY(9) + INTERNAL_PHY(10) + INTERNAL_PHY(11) + INTERNAL_PHY(12) + INTERNAL_PHY(13) + INTERNAL_PHY(14) + INTERNAL_PHY(15) + + EXTERNAL_PHY(16) + EXTERNAL_PHY(17) + EXTERNAL_PHY(18) + EXTERNAL_PHY(19) + EXTERNAL_PHY(20) + EXTERNAL_PHY(21) + EXTERNAL_PHY(22) + EXTERNAL_PHY(23) + + EXTERNAL_SFP_PHY_FULL(24, 0) + EXTERNAL_SFP_PHY_FULL(25, 1) + EXTERNAL_SFP_PHY_FULL(26, 2) + EXTERNAL_SFP_PHY_FULL(27, 3) + }; +}; diff --git a/target/linux/realtek/dts-5.10/rtl838x.dtsi b/target/linux/realtek/dts-5.10/rtl838x.dtsi index 11cabc3f63..41fdbdae20 100644 --- a/target/linux/realtek/dts-5.10/rtl838x.dtsi +++ b/target/linux/realtek/dts-5.10/rtl838x.dtsi @@ -27,6 +27,13 @@ reg = <##n>; \ }; +#define EXTERNAL_SFP_PHY_FULL(n, s) \ + phy##n: ethernet-phy@##n { \ + compatible = "ethernet-phy-ieee802.3-c22"; \ + sfp = <&sfp##s>; \ + reg = <##n>; \ + }; + #define SWITCH_PORT(n, s, m) \ port@##n { \ reg = <##n>; \ diff --git a/target/linux/realtek/dts-5.10/rtl838x_hpe_1920.dtsi b/target/linux/realtek/dts-5.10/rtl838x_hpe_1920.dtsi new file mode 100644 index 0000000000..8e29af62bb --- /dev/null +++ b/target/linux/realtek/dts-5.10/rtl838x_hpe_1920.dtsi @@ -0,0 +1,96 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include +#include + +/ { + chosen { + bootargs = "console=ttyS0,38400"; + }; + + memory@0 { + device_type = "memory"; + reg = <0x0 0x8000000>; + }; + + watchdog1: watchdog { + // PT7A7514 + compatible = "linux,wdt-gpio"; + gpios = <&gpio0 0 GPIO_ACTIVE_HIGH>; + hw_algo = "toggle"; + hw_margin_ms = <1000>; + always-running; + + pinctrl-names = "default"; + pinctrl-0 = <&pinmux_disable_sys_led>; + }; +}; + +&watchdog0 { + status = "disabled"; +}; + +&spi0 { + status = "okay"; + + flash@0 { + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <50000000>; + m25p,fast-read; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "bootware_basic"; + reg = <0x0 0x50000>; + read-only; + }; + + partition@0x60000 { + label = "bootware_data"; + reg = <0x60000 0x30000>; + read-only; + }; + + partition@0x90000 { + label = "bootware_extend"; + reg = <0x90000 0x40000>; + read-only; + }; + + partition@0x100000 { + label = "bootware_basic_backup"; + reg = <0x100000 0x50000>; + read-only; + }; + + partition@0x160000 { + label = "bootware_data_backup"; + reg = <0x160000 0x30000>; + read-only; + }; + + partition@0x190000 { + label = "bootware_extend_backup"; + reg = <0x190000 0x40000>; + read-only; + }; + + partition@0x300000 { + label = "firmware"; + compatible = "h3c,vfs-firmware"; + reg = <0x300000 0x1cf0000>; + }; + + partition@0x1ff0000 { + label = "factory"; + reg = <0x1ff0000 0x10000>; + read-only; + }; + }; + }; +}; diff --git a/target/linux/realtek/image/Makefile b/target/linux/realtek/image/Makefile index cf779002e8..6165d99bfc 100644 --- a/target/linux/realtek/image/Makefile +++ b/target/linux/realtek/image/Makefile @@ -8,6 +8,7 @@ KERNEL_ENTRY = 0x80000400 DEVICE_VARS += ZYXEL_VERS DLINK_KERNEL_PART_SIZE DEVICE_VARS += CAMEO_KERNEL_PART CAMEO_ROOTFS_PART CAMEO_CUSTOMER_SIGNATURE CAMEO_BOARD_VERSION +DEVICE_VARS += H3C_PRODUCT_ID H3C_DEVICE_ID define Build/zyxel-vers ( echo VERS;\ @@ -41,6 +42,43 @@ define Build/dlink-headers cat $@.kernel_part.hex $@.rootfs_part.hex > $@ endef +define Build/7z + $(STAGING_DIR_HOST)/bin/7zr a $(@).new -t7z -m0=lzma $(@) + mv $@.new $@ +endef + +define Build/h3c-image + $(STAGING_DIR_HOST)/bin/mkh3cimg \ + -i $(@) \ + -o $(@).new \ + -c 7z \ + -p $(H3C_PRODUCT_ID) \ + -d $(H3C_DEVICE_ID) + mv $@.new $@ +endef + +define Build/h3c-vfs + $(STAGING_DIR_HOST)/bin/mkh3cvfs \ + -i $(@) \ + -o $(@).new \ + -f openwrt-kernel.bin + mv $@.new $@ +endef + +define Build/relocate-kernel + rm -rf $@.relocate + $(CP) ../../generic/image/relocate $@.relocate + $(MAKE) -j1 -C $@.relocate KERNEL_ADDR=$(KERNEL_LOADADDR) LZMA_TEXT_START=0x82000000 \ + CROSS_COMPILE=$(TARGET_CROSS) + ( \ + dd if=$@.relocate/loader.bin bs=32 conv=sync && \ + perl -e '@s = stat("$@"); print pack("N", @s[7])' && \ + cat "$@" \ + ) > "$@.new" + mv "$@.new" "$@" + rm -rf $@.relocate +endef + define Device/Default PROFILES = Default KERNEL := kernel-bin | append-dtb | gzip | uImage gzip @@ -52,6 +90,17 @@ define Device/Default check-size | append-metadata endef +define Device/hpe_1920 + DEVICE_VENDOR := HPE + IMAGE_SIZE := 29632k + BLOCKSIZE := 64k + H3C_PRODUCT_ID := 0x3c010501 + KERNEL := kernel-bin | append-dtb | relocate-kernel | 7z | h3c-image | h3c-vfs + KERNEL_INITRAMFS := kernel-bin | append-dtb | relocate-kernel | 7z | h3c-image + IMAGE/sysupgrade.bin := append-kernel | pad-to $$$$(BLOCKSIZE) | append-rootfs | \ + pad-rootfs | check-size | append-metadata +endef + # "NGE" refers to the uImage magic define Device/netgear_nge KERNEL := kernel-bin | append-dtb | lzma | uImage lzma diff --git a/target/linux/realtek/image/rtl838x.mk b/target/linux/realtek/image/rtl838x.mk index 887f82e385..60eda5359d 100644 --- a/target/linux/realtek/image/rtl838x.mk +++ b/target/linux/realtek/image/rtl838x.mk @@ -65,6 +65,30 @@ define Device/engenius_ews2910p endef TARGET_DEVICES += engenius_ews2910p +define Device/hpe_1920-8g + $(Device/hpe_1920) + SOC := rtl8380 + DEVICE_MODEL := 1920-8G (JG920A) + H3C_DEVICE_ID := 0x00010023 +endef +TARGET_DEVICES += hpe_1920-8g + +define Device/hpe_1920-16g + $(Device/hpe_1920) + SOC := rtl8382 + DEVICE_MODEL := 1920-16G (JG923A) + H3C_DEVICE_ID := 0x00010026 +endef +TARGET_DEVICES += hpe_1920-16g + +define Device/hpe_1920-24g + $(Device/hpe_1920) + SOC := rtl8382 + DEVICE_MODEL := 1920-24G (JG924A) + H3C_DEVICE_ID := 0x00010027 +endef +TARGET_DEVICES += hpe_1920-24g + define Device/inaba_aml2-17gp SOC := rtl8382 IMAGE_SIZE := 13504k diff --git a/target/linux/realtek/rtl838x/config-5.10 b/target/linux/realtek/rtl838x/config-5.10 index c117fc489a..9075aa6d3c 100644 --- a/target/linux/realtek/rtl838x/config-5.10 +++ b/target/linux/realtek/rtl838x/config-5.10 @@ -74,6 +74,8 @@ CONFIG_GPIO_PCA953X=y CONFIG_GPIO_PCA953X_IRQ=y CONFIG_GPIO_REALTEK_OTTO=y CONFIG_GPIO_RTL8231=y +CONFIG_GPIO_WATCHDOG=y +# CONFIG_GPIO_WATCHDOG_ARCH_INITCALL is not set CONFIG_GRO_CELLS=y CONFIG_HANDLE_DOMAIN_IRQ=y CONFIG_HARDWARE_WATCHPOINTS=y @@ -134,6 +136,7 @@ CONFIG_MTD_SPI_NOR=y CONFIG_MTD_SPLIT_BRNIMAGE_FW=y CONFIG_MTD_SPLIT_EVA_FW=y CONFIG_MTD_SPLIT_FIRMWARE=y +CONFIG_MTD_SPLIT_H3C_VFS=y CONFIG_MTD_SPLIT_TPLINK_FW=y CONFIG_MTD_SPLIT_UIMAGE_FW=y CONFIG_NEED_DMA_MAP_STATE=y From 57cad53f4e52be987cdd61308ff7d2704baca539 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= Date: Thu, 28 Jul 2022 17:46:33 +0200 Subject: [PATCH 23/23] bcm4908: enable & setup packet steering MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Without packet steering NAT masquarade speed on BCM4908 /jumps/ between two speeds: 1. 826 Mb/s (±3 Mb/s) 2. 909 Mb/s (±8 Mb/s) and it never reaches ~940 Mb/s. Proper packet steering can improve it. Below are testing results for running iperf TCP traffic from LAN to WAN. They were used to pick up golden values. ┌──────────┬──────────┬───────────┐ │ eth0 │ br-lan │ speed │ │ rps_cpus │ rps_cpus │ [Mbps] │ ├──────────┼──────────┼───────────┤ │ 0 │ 0 │ 743 / 804 │ │ 0 │ 1 │ 738 / 821 │ │ 0 │ 2 │ ✓ 940 │ │ 0 │ 4 │ ✓ 938 │ │ 0 │ 8 │ ✓ 941 │ ├──────────┼──────────┼───────────┤ │ 1 │ 0 │ 829 │ │ 1 │ 1 │ 829 │ │ 1 │ 2 │ ✓ 942 │ │ 1 │ 4 │ ✓ 941 │ │ 1 │ 8 │ ✓ 941 │ ├──────────┼──────────┼───────────┤ │ 2 │ 0 │ ✓ 942 │ │ 2 │ 1 │ 926 │ │ 2 │ 2 │ ✓ 942 │ │ 2 │ 4 │ ✓ 942 │ │ 2 │ 8 │ ✓ 941 │ ├──────────┼──────────┼───────────┤ │ 4 │ 0 │ ✓ 941 │ │ 4 │ 1 │ 925 │ │ 4 │ 2 │ ✓ 941 │ │ 4 │ 4 │ ✓ 941 │ │ 4 │ 8 │ ✓ 941 │ ├──────────┼──────────┼───────────┤ │ 8 │ 0 │ ✓ 942 │ │ 8 │ 1 │ 925 │ │ 8 │ 2 │ ✓ 941 │ │ 8 │ 4 │ ✓ 942 │ │ 8 │ 8 │ ✓ 942 │ └──────────┴──────────┴───────────┘ Ref: fcbd39689ebfe ("bcm53xx: enable & setup packet steering") Signed-off-by: Rafał Miłecki --- .../bcm4908/base-files/etc/init.d/fastnetwork | 46 +++++++++++++++++++ .../etc/uci-defaults/05_packet_steering | 3 ++ 2 files changed, 49 insertions(+) create mode 100755 target/linux/bcm4908/base-files/etc/init.d/fastnetwork create mode 100644 target/linux/bcm4908/base-files/etc/uci-defaults/05_packet_steering diff --git a/target/linux/bcm4908/base-files/etc/init.d/fastnetwork b/target/linux/bcm4908/base-files/etc/init.d/fastnetwork new file mode 100755 index 0000000000..88f6075990 --- /dev/null +++ b/target/linux/bcm4908/base-files/etc/init.d/fastnetwork @@ -0,0 +1,46 @@ +#!/bin/sh /etc/rc.common + +START=25 +USE_PROCD=1 + +start_service() { + reload_service +} + +service_triggers() { + procd_add_reload_trigger "network" + procd_add_reload_trigger "firewall" + procd_add_reload_interface_trigger "lan" +} + +reload_service() { + local packet_steering="$(uci -q get network.@globals[0].packet_steering)" + local num_cpus="$(grep -c "^processor.*:" /proc/cpuinfo)" + local flow_offloading="$(uci -q get firewall.@defaults[0].flow_offloading)" + local flow_offloading_hw="$(uci -q get firewall.@defaults[0].flow_offloading_hw)" + local rps_eth0=0 + local rps_br_lan=0 + + [ "$num_cpus" -le 1 ] && return + + [ "$packet_steering" = 1 ] && { + if [ ${flow_offloading_hw:-0} -gt 0 ]; then + # HW offloading + # Not implemented + : + elif [ ${flow_offloading:-0} -gt 0 ]; then + # SW offloading + # BCM4908 always reaches ~940 Mb/s + : + else + # Default + case "$num_cpus" in + 2) rps_eth0=2; rps_br_lan=2;; + 4) rps_eth0=e; rps_br_lan=e;; + esac + fi + } + + echo $rps_eth0 > /sys/class/net/eth0/queues/rx-0/rps_cpus + echo $rps_br_lan > /sys/class/net/br-lan/queues/rx-0/rps_cpus +} diff --git a/target/linux/bcm4908/base-files/etc/uci-defaults/05_packet_steering b/target/linux/bcm4908/base-files/etc/uci-defaults/05_packet_steering new file mode 100644 index 0000000000..98c9497815 --- /dev/null +++ b/target/linux/bcm4908/base-files/etc/uci-defaults/05_packet_steering @@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0-only + +uci set network.@globals[0].packet_steering="1"