Merge Official Source

Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
This commit is contained in:
Tianling Shen 2023-12-08 03:14:32 +08:00
commit fd6c1f6026
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
13 changed files with 458 additions and 242 deletions

View File

@ -11,6 +11,36 @@ get_dt_led_path() {
echo "$ledpath"
}
get_dt_led_color_func() {
local enum
local func
local idx
local label
[ -e "$1/function" ] && func=$(cat "$1/function")
[ -e "$1/color" ] && idx=$((0x$(hexdump -n 4 -e '4/1 "%02x"' "$1/color")))
[ -e "$1/function-enumerator" ] && \
enum=$((0x$(hexdump -n 4 -e '4/1 "%02x"' "$1/function-enumerator")))
[ -z "$idx" ] && [ -z "$func" ] && return 2
if [ -n "$idx" ]; then
for color in "white" "red" "green" "blue" "amber" \
"violet" "yellow" "ir" "multicolor" "rgb" \
"purple" "orange" "pink" "cyan" "lime"
do
[ $idx -eq 0 ] && label="$color" && break
idx=$((idx-1))
done
fi
label="$label:$func"
[ -n "$enum" ] && label="$label-$enum"
echo "$label"
return 0
}
get_dt_led() {
local label
local ledpath=$(get_dt_led_path $1)
@ -18,6 +48,7 @@ get_dt_led() {
[ -n "$ledpath" ] && \
label=$(cat "$ledpath/label" 2>/dev/null) || \
label=$(cat "$ledpath/chan-name" 2>/dev/null) || \
label=$(get_dt_led_color_func "$ledpath") || \
label=$(basename "$ledpath")
echo "$label"

View File

@ -38,6 +38,7 @@ bananapi,bpi-r3-mini)
;;
esac
;;
cetron,ct3003-stock|\
cetron,ct3003-ubootmod|\
cmcc,rax3000m-nand-ubootmod|\
netgear,wax220|\

View File

@ -0,0 +1,44 @@
Revert "tools: env: use /run to store lockfile"
In OpenWRT we still use /var/lock as default location for lock files and
/run might not even exist. Revert the upstream change and restore the
previous default path.
This reverts upstream commit
https://source.denx.de/u-boot/u-boot/-/commit/aeb40f1166e072856f865d26d42a4bea1ec3a514
---
tools/env/fw_env_main.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/env/fw_env_main.c b/tools/env/fw_env_main.c
index 0b201b9e62..1d193bd437 100644
--- a/tools/env/fw_env_main.c
+++ b/tools/env/fw_env_main.c
@@ -73,7 +73,7 @@ void usage_printenv(void)
" -c, --config configuration file, default:" CONFIG_FILE "\n"
#endif
" -n, --noheader do not repeat variable name in output\n"
- " -l, --lock lock node, default:/run\n"
+ " -l, --lock lock node, default:/var/lock\n"
"\n");
}
@@ -88,7 +88,7 @@ void usage_env_set(void)
#ifdef CONFIG_FILE
" -c, --config configuration file, default:" CONFIG_FILE "\n"
#endif
- " -l, --lock lock node, default:/run\n"
+ " -l, --lock lock node, default:/var/lock\n"
" -s, --script batch mode to minimize writes\n"
"\n"
"Examples:\n"
@@ -206,7 +206,7 @@ int parse_setenv_args(int argc, char *argv[])
int main(int argc, char *argv[])
{
- char *lockname = "/run/" CMD_PRINTENV ".lock";
+ char *lockname = "/var/lock/" CMD_PRINTENV ".lock";
int lockfd = -1;
int retval = EXIT_SUCCESS;
char *_cmdname;

View File

@ -0,0 +1,26 @@
// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
/dts-v1/;
#include "mt7981b-cetron-ct3003.dtsi"
/ {
model = "CETRON CT3003 (stock layout)";
compatible = "cetron,ct3003-stock", "mediatek,mt7981";
};
&partitions {
partition@580000 {
label = "ubi";
reg = <0x0580000 0x2000000>;
};
partition@2580000 {
label = "ubi_backup";
reg = <0x2580000 0x2000000>;
};
partition@4580000 {
label = "Config_backup";
reg = <0x4580000 0x0400000>;
};
};

View File

@ -1,247 +1,17 @@
// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
/*
* Copyright (C) 2023 Tianling Shen <cnsztl@immortalwrt.org>
*/
/dts-v1/;
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>
#include "mt7981.dtsi"
#include "mt7981b-cetron-ct3003.dtsi"
/ {
model = "CETRON CT3003 (custom U-Boot layout)";
compatible = "cetron,ct3003-ubootmod", "mediatek,mt7981";
aliases {
led-boot = &status_red_led;
led-failsafe = &status_red_led;
led-running = &status_green_led;
led-upgrade = &status_green_led;
serial0 = &uart0;
};
chosen {
stdout-path = "serial0:115200n8";
};
memory {
reg = <0 0x40000000 0 0x10000000>;
};
gpio-keys {
compatible = "gpio-keys";
button-reset {
label = "reset";
linux,code = <KEY_RESTART>;
gpios = <&pio 1 GPIO_ACTIVE_LOW>;
};
button-wps {
label = "wps";
linux,code = <KEY_WPS_BUTTON>;
gpios = <&pio 0 GPIO_ACTIVE_HIGH>;
};
};
gpio-leds {
compatible = "gpio-leds";
status_red_led: led-0 {
label = "red:status";
gpios = <&pio 3 GPIO_ACTIVE_LOW>;
};
status_green_led: led-1 {
label = "green:status";
gpios = <&pio 7 GPIO_ACTIVE_LOW>;
};
};
};
&eth {
status = "okay";
gmac0: mac@0 {
compatible = "mediatek,eth-mac";
reg = <0>;
phy-mode = "2500base-x";
nvmem-cells = <&macaddr_art_7b 0>;
nvmem-cell-names = "mac-address";
fixed-link {
speed = <2500>;
full-duplex;
pause;
};
&partitions {
partition@580000 {
label = "ubi";
reg = <0x580000 0x6e80000>;
};
};
&mdio_bus {
switch: switch@1f {
compatible = "mediatek,mt7531";
reg = <31>;
reset-gpios = <&pio 39 GPIO_ACTIVE_HIGH>;
interrupt-controller;
#interrupt-cells = <1>;
interrupt-parent = <&pio>;
interrupts = <38 IRQ_TYPE_LEVEL_HIGH>;
};
};
&spi0 {
pinctrl-names = "default";
pinctrl-0 = <&spi0_flash_pins>;
status = "okay";
spi_nand: flash@0 {
#address-cells = <1>;
#size-cells = <1>;
compatible = "spi-nand";
reg = <0>;
spi-max-frequency = <52000000>;
spi-cal-enable;
spi-cal-mode = "read-data";
spi-cal-datalen = <7>;
spi-cal-data = /bits/ 8 <0x53 0x50 0x49 0x4E 0x41 0x4E 0x44>;
spi-cal-addrlen = <5>;
spi-cal-addr = /bits/ 32 <0x0 0x0 0x0 0x0 0x0>;
spi-tx-bus-width = <4>;
spi-rx-bus-width = <4>;
mediatek,nmbm;
mediatek,bmt-max-ratio = <1>;
mediatek,bmt-max-reserved-blocks = <64>;
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
partition@0 {
label = "BL2";
reg = <0x00000 0x100000>;
read-only;
};
partition@100000 {
label = "u-boot-env";
reg = <0x100000 0x80000>;
};
partition@180000 {
label = "art";
reg = <0x180000 0x100000>;
compatible = "nvmem-cells";
nvmem-layout {
compatible = "fixed-layout";
#address-cells = <1>;
#size-cells = <1>;
macaddr_art_7b: macaddr@7b {
compatible = "mac-base";
reg = <0x7b 0x11>;
#nvmem-cell-cells = <1>;
};
};
};
factory: partition@280000 {
label = "Factory";
reg = <0x280000 0x100000>;
};
partition@380000 {
label = "FIP";
reg = <0x380000 0x200000>;
};
partition@580000 {
label = "ubi";
reg = <0x580000 0x6e80000>;
};
};
};
};
&switch {
ports {
#address-cells = <1>;
#size-cells = <0>;
port@0 {
reg = <0>;
label = "lan1";
};
port@1 {
reg = <1>;
label = "lan2";
};
port@2 {
reg = <2>;
label = "lan3";
};
port@3 {
reg = <3>;
label = "wan";
nvmem-cells = <&macaddr_art_7b 3>;
nvmem-cell-names = "mac-address";
};
port@6 {
reg = <6>;
ethernet = <&gmac0>;
phy-mode = "2500base-x";
fixed-link {
speed = <2500>;
full-duplex;
pause;
};
};
};
};
&pio {
spi0_flash_pins: spi0-pins {
mux {
function = "spi";
groups = "spi0", "spi0_wp_hold";
};
conf-pu {
pins = "SPI0_CS", "SPI0_HOLD", "SPI0_WP";
drive-strength = <8>;
bias-pull-up = <103>;
};
conf-pd {
pins = "SPI0_CLK", "SPI0_MOSI", "SPI0_MISO";
drive-strength = <8>;
bias-pull-down = <103>;
};
};
};
&uart0 {
status = "okay";
};
&watchdog {
status = "okay";
};
&wifi {
status = "okay";
mediatek,mtd-eeprom = <&factory 0x0>;
};

View File

@ -0,0 +1,239 @@
// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
/*
* Copyright (C) 2023 Tianling Shen <cnsztl@immortalwrt.org>
*/
/dts-v1/;
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>
#include "mt7981.dtsi"
/ {
aliases {
led-boot = &status_red_led;
led-failsafe = &status_red_led;
led-running = &status_green_led;
led-upgrade = &status_green_led;
serial0 = &uart0;
};
chosen {
stdout-path = "serial0:115200n8";
};
memory {
reg = <0 0x40000000 0 0x10000000>;
};
gpio-keys {
compatible = "gpio-keys";
button-reset {
label = "reset";
linux,code = <KEY_RESTART>;
gpios = <&pio 1 GPIO_ACTIVE_LOW>;
};
button-wps {
label = "wps";
linux,code = <KEY_WPS_BUTTON>;
gpios = <&pio 0 GPIO_ACTIVE_HIGH>;
};
};
gpio-leds {
compatible = "gpio-leds";
status_red_led: led-0 {
label = "red:status";
gpios = <&pio 3 GPIO_ACTIVE_LOW>;
};
status_green_led: led-1 {
label = "green:status";
gpios = <&pio 7 GPIO_ACTIVE_LOW>;
};
};
};
&eth {
status = "okay";
gmac0: mac@0 {
compatible = "mediatek,eth-mac";
reg = <0>;
phy-mode = "2500base-x";
nvmem-cells = <&macaddr_art_7b 0>;
nvmem-cell-names = "mac-address";
fixed-link {
speed = <2500>;
full-duplex;
pause;
};
};
};
&mdio_bus {
switch: switch@1f {
compatible = "mediatek,mt7531";
reg = <31>;
reset-gpios = <&pio 39 GPIO_ACTIVE_HIGH>;
interrupt-controller;
#interrupt-cells = <1>;
interrupt-parent = <&pio>;
interrupts = <38 IRQ_TYPE_LEVEL_HIGH>;
};
};
&spi0 {
pinctrl-names = "default";
pinctrl-0 = <&spi0_flash_pins>;
status = "okay";
spi_nand: flash@0 {
#address-cells = <1>;
#size-cells = <1>;
compatible = "spi-nand";
reg = <0>;
spi-max-frequency = <52000000>;
spi-cal-enable;
spi-cal-mode = "read-data";
spi-cal-datalen = <7>;
spi-cal-data = /bits/ 8 <0x53 0x50 0x49 0x4E 0x41 0x4E 0x44>;
spi-cal-addrlen = <5>;
spi-cal-addr = /bits/ 32 <0x0 0x0 0x0 0x0 0x0>;
spi-tx-bus-width = <4>;
spi-rx-bus-width = <4>;
mediatek,nmbm;
mediatek,bmt-max-ratio = <1>;
mediatek,bmt-max-reserved-blocks = <64>;
partitions: partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
partition@0 {
label = "BL2";
reg = <0x00000 0x100000>;
read-only;
};
partition@100000 {
label = "u-boot-env";
reg = <0x100000 0x80000>;
};
partition@180000 {
label = "art";
reg = <0x180000 0x100000>;
read-only;
compatible = "nvmem-cells";
nvmem-layout {
compatible = "fixed-layout";
#address-cells = <1>;
#size-cells = <1>;
macaddr_art_7b: macaddr@7b {
compatible = "mac-base";
reg = <0x7b 0x11>;
#nvmem-cell-cells = <1>;
};
};
};
factory: partition@280000 {
label = "Factory";
reg = <0x280000 0x100000>;
};
partition@380000 {
label = "FIP";
reg = <0x380000 0x200000>;
};
};
};
};
&switch {
ports {
#address-cells = <1>;
#size-cells = <0>;
port@0 {
reg = <0>;
label = "lan1";
};
port@1 {
reg = <1>;
label = "lan2";
};
port@2 {
reg = <2>;
label = "lan3";
};
port@3 {
reg = <3>;
label = "wan";
nvmem-cells = <&macaddr_art_7b 3>;
nvmem-cell-names = "mac-address";
};
port@6 {
reg = <6>;
ethernet = <&gmac0>;
phy-mode = "2500base-x";
fixed-link {
speed = <2500>;
full-duplex;
pause;
};
};
};
};
&pio {
spi0_flash_pins: spi0-pins {
mux {
function = "spi";
groups = "spi0", "spi0_wp_hold";
};
conf-pu {
pins = "SPI0_CS", "SPI0_HOLD", "SPI0_WP";
drive-strength = <MTK_DRIVE_8mA>;
bias-pull-up = <MTK_PUPD_SET_R1R0_11>;
};
conf-pd {
pins = "SPI0_CLK", "SPI0_MOSI", "SPI0_MISO";
drive-strength = <MTK_DRIVE_8mA>;
bias-pull-down = <MTK_PUPD_SET_R1R0_11>;
};
};
};
&uart0 {
status = "okay";
};
&watchdog {
status = "okay";
};
&wifi {
status = "okay";
mediatek,mtd-eeprom = <&factory 0x0>;
};

View File

@ -36,6 +36,7 @@ mediatek_setup_interfaces()
bananapi,bpi-r3-mini)
ucidef_set_interfaces_lan_wan "eth0" "eth1"
;;
cetron,ct3003-stock|\
cetron,ct3003-ubootmod|\
cmcc,a10-ubootmod|\
cudy,wr3000-v1|\

View File

@ -5,7 +5,7 @@ board_config_update
board=$(board_name)
case "$board" in
zbtlink,zbt-z8103ax)
zbtlink,zbt-z8102ax)
ucidef_add_gpio_switch "5g1" "Power 1st modem" "5g1" "1"
ucidef_add_gpio_switch "5g2" "Power 2nd modem" "5g2" "1"
ucidef_add_gpio_switch "pcie" "Power PCIe port" "pcie" "1"

View File

@ -42,6 +42,7 @@ case "$board" in
[ "$PHYNBR" = "1" ] && macaddr_add $addr 3 > /sys${DEVPATH}/macaddress
wifi
;;
cetron,ct3003-stock|\
cetron,ct3003-ubootmod)
addr=$(cat /sys/class/net/eth0/address)
[ "$PHYNBR" = "0" ] && macaddr_add $addr 1 > /sys${DEVPATH}/macaddress

View File

@ -0,0 +1,15 @@
set_netdev_labels() {
local dir
local label
local netdev
for dir in /sys/class/net/*; do
[ -r "$dir/of_node/label" ] || continue
label="$(cat "$dir/of_node/label")"
netdev="$(basename $dir)"
[ "$netdev" = "$label" ] && continue
ip link set "$netdev" name "$label"
done
}
boot_hook_add preinit_main set_netdev_labels

View File

@ -90,6 +90,21 @@ define Build/zyxel-nwa-fit-filogic
@mv $@.new $@
endef
define Build/cetron-header
$(eval magic=$(word 1,$(1)))
$(eval model=$(word 2,$(1)))
( \
dd if=/dev/zero bs=856 count=1 2>/dev/null; \
printf "$(model)," | dd bs=128 count=1 conv=sync 2>/dev/null; \
md5sum $@ | cut -f1 -d" " | dd bs=32 count=1 2>/dev/null; \
printf "$(magic)" | dd bs=4 count=1 conv=sync 2>/dev/null; \
cat $@; \
) > $@.tmp
fw_crc=$$(gzip -c $@.tmp | tail -c 8 | od -An -N4 -tx4 --endian little | tr -d ' \n'); \
printf "$$(echo $$fw_crc | sed 's/../\\x&/g')" | cat - $@.tmp > $@
rm $@.tmp
endef
define Device/abt_asr3000-ubootmod
DEVICE_VENDOR := ABT
DEVICE_MODEL := ASR3000 (custom U-Boot layout)
@ -244,6 +259,25 @@ define Device/bananapi_bpi-r3-mini
endef
TARGET_DEVICES += bananapi_bpi-r3-mini
define Device/cetron_ct3003-stock
DEVICE_VENDOR := Cetron
DEVICE_MODEL := CT3003
DEVICE_VARIANT := (stock layout)
DEVICE_DTS := mt7981b-cetron-ct3003-stock
DEVICE_DTS_DIR := ../dts
SUPPORTED_DEVICES += cetron,ct3003 mediatek,mt7981-spim-snand-rfb
DEVICE_PACKAGES := kmod-mt7981-firmware mt7981-wo-firmware
UBINIZE_OPTS := -E 5
BLOCKSIZE := 128k
PAGESIZE := 2048
IMAGE_SIZE := 32768k
KERNEL_IN_UBI := 1
IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
IMAGES += factory.bin
IMAGE/factory.bin := $$(IMAGE/sysupgrade.bin) | cetron-header rd30 CT3003
endef
TARGET_DEVICES += cetron_ct3003-stock
define Device/cetron_ct3003-ubootmod
DEVICE_VENDOR := Cetron
DEVICE_MODEL := CT3003
@ -398,8 +432,8 @@ define Device/glinet_gl-mt3000
DEVICE_DTS := mt7981b-glinet-gl-mt3000
DEVICE_DTS_DIR := ../dts
SUPPORTED_DEVICES += glinet,mt3000-snand
DEVICE_PACKAGES := kmod-mt7981-firmware mt7981-wo-firmware \
kmod-hwmon-pwmfan kmod-usb3 automount
DEVICE_PACKAGES := kmod-mt7981-firmware mt7981-wo-firmware kmod-hwmon-pwmfan \
kmod-usb3 automount
UBINIZE_OPTS := -E 5
BLOCKSIZE := 128k
PAGESIZE := 2048
@ -414,8 +448,8 @@ define Device/glinet_gl-mt6000
DEVICE_MODEL := GL-MT6000
DEVICE_DTS := mt7986a-glinet-gl-mt6000
DEVICE_DTS_DIR := ../dts
DEVICE_PACKAGES := kmod-mt7986-firmware mt7986-wo-firmware kmod-usb3 \
f2fsck mkf2fs automount
DEVICE_PACKAGES := kmod-usb3 kmod-mt7986-firmware mt7986-wo-firmware \
automount f2fsck mkf2fs
IMAGES += factory.bin
IMAGE/factory.bin := append-kernel | pad-to 32M | append-rootfs
IMAGE/sysupgrade.bin := sysupgrade-tar | append-gl-metadata

View File

@ -9,6 +9,9 @@
model = "Extreme Networks WS-AP3825i";
compatible = "extreme-networks,ws-ap3825i";
#address-cells = <2>;
#size-cells = <2>;
aliases {
ethernet0 = &enet0;
ethernet1 = &enet2;
@ -301,8 +304,18 @@
};
memory {
/* Reserve upper MB for second-core-bootpage */
reg = <0x0 0x0 0x0 0xff00000>;
reg = <0x0 0x0 0x0 0x10000000>;
};
reserved-memory {
#address-cells = <2>;
#size-cells = <2>;
ranges;
cpu1-bootpage@e000000 {
/* Reserve upper 1 MB for second-core-bootpage */
reg = <0x0 0xff00000 0x0 0x100000>;
};
};
soc@ffe00000 {

View File

@ -0,0 +1,41 @@
From 5f856ccc34df25060d36a5a81b7b45b574d86e35 Mon Sep 17 00:00:00 2001
From: David Bauer <mail@david-bauer.net>
Date: Sun, 3 Dec 2023 20:09:24 +0100
Subject: [PATCH] arch: powerpc: simpleboot: prevent overwrite of CPU1
spin-table
Don't overwrite the spin-table of additional CPU cores with loader-heap.
U-Boot places the spin-table for CPU1 on P1020 SoCs in the top 1MB of
system-memory. Instead of parsing reserved-memory (which would be
considerable more work), reduce the available system-memory for the
loader by 1MB.
This prevents the loader from overwriting the spin-table of
additional CPU cores on these platforms.
Linux itself needs to be made aware by this using reserved-memory
definitions.
This patch is required for using CPU1 on the Extreme Networks
WS-AP3825i.
Signed-off-by: David Bauer <mail@david-bauer.net>
---
arch/powerpc/boot/simpleboot.c | 5 +++++
1 file changed, 5 insertions(+)
--- a/arch/powerpc/boot/simpleboot.c
+++ b/arch/powerpc/boot/simpleboot.c
@@ -65,6 +65,11 @@ void platform_init(unsigned long r3, uns
if (sizeof(void *) == 4 && memsize64 >= 0x100000000ULL)
memsize64 = 0xffffffff;
+ /* Reserve upper 1 MB of memory for CPU1 spin-table */
+ if (memsize64 > 0x100000) {
+ memsize64 = memsize64 - 0x100000;
+ }
+
/* finally, setup the timebase */
node = fdt_node_offset_by_prop_value(_dtb_start, -1, "device_type",
"cpu", sizeof("cpu"));