diff --git a/target/linux/econet/base-files/etc/board.d/02_network b/target/linux/econet/base-files/etc/board.d/02_network new file mode 100644 index 0000000000..e27926df68 --- /dev/null +++ b/target/linux/econet/base-files/etc/board.d/02_network @@ -0,0 +1,43 @@ +. /lib/functions/system.sh +. /lib/functions/uci-defaults.sh + +econet_setup_interfaces() +{ + local board="$1" + + case "$board" in + *) + # econet lacks DSA support now + ucidef_set_interface_lan "eth0" + ;; + esac +} + +econet_setup_macs() +{ + local board="$1" + local lan_mac="" + local wan_mac="" + local label_mac="" + + case "$board" in + huawei,hg2821t-u) + local conffile="/tmp/configuration_a/factory.conf" + lan_mac=$(get_mac_ascii "$conffile" brmac) + wan_mac=$(get_mac_ascii "$conffile" internetmac) + label_mac=$wan_mac + ;; + esac + + [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" "$lan_mac" + [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" "$wan_mac" + [ -n "$label_mac" ] && ucidef_set_label_macaddr "$label_mac" +} + +board_config_update +board=$(board_name) +econet_setup_interfaces $board +econet_setup_macs $board +board_config_flush + +exit 0 diff --git a/target/linux/econet/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac b/target/linux/econet/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac new file mode 100755 index 0000000000..b479abe977 --- /dev/null +++ b/target/linux/econet/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac @@ -0,0 +1,17 @@ +[ "$ACTION" = "add" ] || exit 0 + +PHYNBR=${DEVPATH##*/phy} + +[ -n "$PHYNBR" ] || exit 0 + +. /lib/functions/system.sh + +board=$(board_name) + +case "$board" in +huawei,hg2821t-u) + conffile="/tmp/configuration_a/factory.conf" + [ "$PHYNBR" -eq 0 ] && get_mac_ascii "$conffile" APMAC_5G > /sys${DEVPATH}/macaddress + [ "$PHYNBR" -eq 1 ] && get_mac_ascii "$conffile" APMAC > /sys${DEVPATH}/macaddress + ;; +esac diff --git a/target/linux/econet/base-files/lib/preinit/09_mount_factory_data b/target/linux/econet/base-files/lib/preinit/09_mount_factory_data new file mode 100644 index 0000000000..a6e553b586 --- /dev/null +++ b/target/linux/econet/base-files/lib/preinit/09_mount_factory_data @@ -0,0 +1,18 @@ +preinit_mount_factory_data() { + local mtd_path=$(find_mtd_part "$1") + + [ -n "$mtd_path" ] || return + + mkdir -p "/tmp/$1" + mount -o ro,noatime -t jffs2 "$mtd_path" "/tmp/$1" +} + +preinit_mount_factory_partitions() { + case $(board_name) in + huawei,hg2821t-u) + preinit_mount_factory_data configuration_a + ;; + esac +} + +boot_hook_add preinit_main preinit_mount_factory_partitions diff --git a/target/linux/econet/base-files/sbin/en75_chboot b/target/linux/econet/base-files/sbin/en75_chboot index a582d64a5d..57ba961ba9 100755 --- a/target/linux/econet/base-files/sbin/en75_chboot +++ b/target/linux/econet/base-files/sbin/en75_chboot @@ -111,6 +111,14 @@ main() { code_openwrt=0000000101000002 code_factory=0000000101010003 ;; + huawei,hg2821t-u) + part=$(part_named '"flag"') + offset_blocks=14 + block_size=$((1024 * 128)) + code_offset=0 + code_openwrt=30ffffff30ffffff + code_factory=31ffffff31ffffff + ;; nokia,g240g-e) part=$(part_named '"flag"') offset_blocks=0 diff --git a/target/linux/econet/dts/en751221_huawei_hg2821t-u.dts b/target/linux/econet/dts/en751221_huawei_hg2821t-u.dts new file mode 100644 index 0000000000..b60a27218c --- /dev/null +++ b/target/linux/econet/dts/en751221_huawei_hg2821t-u.dts @@ -0,0 +1,118 @@ +// SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +/dts-v1/; + +#include "en751221.dtsi" + +/ { + model = "Huawei HG2821T-U"; + compatible = "huawei,hg2821t-u", "econet,en751221"; + + memory@0 { + device_type = "memory"; + reg = <0x00000000 0x1c000000>; + }; + + chosen { + stdout-path = "/serial@1fbf0000:115200"; + bootargs = "ubi.mtd=rootfs_a"; + }; +}; + +&nand { + status = "okay"; + econet,bmt; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "bootloader"; + reg = <0x0 0x20000>; + read-only; + }; + + partition@20000 { + label = "flag"; + reg = <0x20000 0x1e0000>; + econet,enable-remap; + }; + + partition@200000 { + label = "kernel_a"; + reg = <0x200000 0x400000>; + econet,enable-remap; + }; + + partition@600000 { + label = "rootfs_a"; + reg = <0x600000 0x3800000>; + econet,boot-flag-value = <0>; + }; + + partition@3e00000 { + label = "kernel_b"; + reg = <0x3e00000 0x400000>; + econet,enable-remap; + }; + + partition@4200000 { + label = "rootfs_b"; + reg = <0x4200000 0x3800000>; + econet,boot-flag-value = <1>; + }; + + partition@7a00000 { + label = "configuration_a"; + reg = <0x7a00000 0x200000>; + read-only; + }; + + partition@7c00000 { + label = "configuration_b"; + reg = <0x7c00000 0xa00000>; + econet,enable-remap; + }; + + partition@8600000 { + label = "userlocalct"; + reg = <0x8600000 0x400000>; + econet,enable-remap; + }; + + partition@8a00000 { + label = "userdata"; + reg = <0x8a00000 0x600000>; + econet,enable-remap; + }; + + partition@9000000 { + label = "framework1"; + reg = <0x9000000 0x800000>; + econet,enable-remap; + }; + + partition@9800000 { + label = "framework2"; + reg = <0x9800000 0x800000>; + econet,enable-remap; + }; + + /* UBI */ + partition@a000000 { + label = "apps"; + reg = <0xa000000 0x4a00000>; + }; + + partition@ea00000 { + label = "reservearea"; + reg = <0xea00000 0x100000>; + econet,enable-remap; + }; + }; +}; + +&gmac0 { + status = "okay"; +}; diff --git a/target/linux/econet/en751221/config-6.12 b/target/linux/econet/en751221/config-6.12 index d68d0ca44d..fe69f10c74 100644 --- a/target/linux/econet/en751221/config-6.12 +++ b/target/linux/econet/en751221/config-6.12 @@ -91,7 +91,8 @@ CONFIG_IRQ_DOMAIN_HIERARCHY=y CONFIG_IRQ_FORCED_THREADING=y CONFIG_IRQ_MIPS_CPU=y CONFIG_IRQ_WORK=y -# CONFIG_JFFS2_FS is not set +CONFIG_JFFS2_FS=y +CONFIG_JFFS2_ZLIB=y CONFIG_LIBFDT=y CONFIG_LOCK_DEBUGGING_SUPPORT=y CONFIG_LZO_COMPRESS=y diff --git a/target/linux/econet/image/Makefile b/target/linux/econet/image/Makefile index 2d96d13747..a496a0891e 100644 --- a/target/linux/econet/image/Makefile +++ b/target/linux/econet/image/Makefile @@ -13,14 +13,35 @@ define Build/tclinux-trx mv $@.new $@ endef +# If TCSUPPORT_FREE_BOOTBASE is enabled, bootloader will decompress the kernel +# at 0x80002000 instead of 0x80020000. +# +# You can tell it by looking at the bootloader version string +# " at %s version %s free bootbase". +define Build/tclinux-free-bootbase-jump + @[ "$(KERNEL_LOADADDR)" = 0x80020000 ] || { \ + $(call ERROR_MESSAGE,WARNING: KERNEL_LOADADDR changed); \ + rm -f $@; \ + } + printf '\010\000\200\000' > $@.new + dd if=/dev/zero bs=122876 count=1 >> $@.new + cat $@ >> $@.new + mv $@.new $@ +endef + # tclinux bootloader requires LZMA, BUT only provides 7.5MB of space # to decompress into. So we use vmlinuz and decompress twice. define Device/Default DEVICE_DTS_DIR := ../dts + BLOCKSIZE := 128k + PAGESIZE := 2048 + # decompression buffer limit, the size of LZMA-compressed data is read from + # the trx header KERNEL_SIZE := 7480k KERNEL_NAME := vmlinuz.bin KERNEL_LOADADDR := 0x80020000 KERNEL := kernel-bin | append-dtb + UBINIZE_OPTS := -E 5 endef include $(SUBTARGET).mk diff --git a/target/linux/econet/image/en751221.mk b/target/linux/econet/image/en751221.mk index 89fc0bdee2..13b8de4ddc 100644 --- a/target/linux/econet/image/en751221.mk +++ b/target/linux/econet/image/en751221.mk @@ -9,6 +9,26 @@ define Device/en751221_generic endef TARGET_DEVICES += en751221_generic +define Device/huawei_hg2821t-u + DEVICE_VENDOR := Huawei + DEVICE_MODEL := HG2821T-U + DEVICE_DTS := en751221_huawei_hg2821t-u + KERNEL_DECOMPRESSED_SIZE := 7672k + KERNEL_SIZE := 4096k + IMAGE_SIZE := 57344k + FACTORY_SIZE := 40960k + NAND_SIZE := 256m + KERNEL := kernel-bin | append-dtb | tclinux-free-bootbase-jump | \ + check-size $$(KERNEL_DECOMPRESSED_SIZE) | lzma + KERNEL_INITRAMFS := kernel-bin | append-dtb + IMAGES := kernel.bin rootfs.bin sysupgrade.bin + IMAGE/kernel.bin := append-kernel + IMAGE/rootfs.bin := append-ubi | check-size $$(FACTORY_SIZE) + IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata + DEVICE_PACKAGES := kmod-usb3 +endef +TARGET_DEVICES += huawei_hg2821t-u + define Device/nokia_g240g-e DEVICE_VENDOR := Nokia DEVICE_MODEL := G-240G-E