From cf6ccef8f22dd76221606d7cdf392e8f83b4c87c Mon Sep 17 00:00:00 2001 From: Daniel Gimpelevich Date: Sun, 21 Jul 2019 13:51:04 -0700 Subject: [PATCH] test Signed-off-by: Daniel Gimpelevich --- package/boot/uboot-envtools/files/ath79 | 2 + .../ath79/base-files/etc/board.d/01_leds | 2 + .../ath79/base-files/etc/board.d/02_network | 2 + .../etc/hotplug.d/firmware/10-ath9k-eeprom | 2 + .../ath79/base-files/etc/init.d/bootcount | 4 + .../ath79/base-files/lib/upgrade/platform.sh | 16 ++++ .../ath79/dts/ar9344_adtran_bsap1920.dts | 9 ++ .../ath79/dts/ar9344_adtran_bsap1925.dts | 9 ++ .../ath79/dts/ar9344_adtran_bsap192x.dtsi | 93 +++++++++++++++++++ target/linux/ath79/image/generic.mk | 18 ++++ .../997-device_tree_cmdline.patch | 50 ++++++++++ .../drivers/mtd/mtdsplit/mtdsplit_uimage.c | 29 ++++++ 12 files changed, 236 insertions(+) create mode 100644 target/linux/ath79/dts/ar9344_adtran_bsap1920.dts create mode 100644 target/linux/ath79/dts/ar9344_adtran_bsap1925.dts create mode 100644 target/linux/ath79/dts/ar9344_adtran_bsap192x.dtsi create mode 100644 target/linux/ath79/patches-4.19/997-device_tree_cmdline.patch diff --git a/package/boot/uboot-envtools/files/ath79 b/package/boot/uboot-envtools/files/ath79 index 4e6aa5aa9882b8..c0b32cbf3f817c 100644 --- a/package/boot/uboot-envtools/files/ath79 +++ b/package/boot/uboot-envtools/files/ath79 @@ -13,6 +13,8 @@ touch /etc/config/ubootenv board=$(board_name) case "$board" in +adtran,bsap1920|\ +adtran,bsap1925|\ alfa-network,ap121f|\ buffalo,bhr-4grv2|\ engenius,ecb1750|\ diff --git a/target/linux/ath79/base-files/etc/board.d/01_leds b/target/linux/ath79/base-files/etc/board.d/01_leds index f4285c5207349f..e1b8209363a92b 100755 --- a/target/linux/ath79/base-files/etc/board.d/01_leds +++ b/target/linux/ath79/base-files/etc/board.d/01_leds @@ -108,6 +108,8 @@ on,n150r) ucidef_set_led_switch "lan1" "LAN1" "netgear:green:lan1" "switch0" "0x02" "0x0f" ucidef_set_led_switch "lan2" "LAN2" "netgear:green:lan2" "switch0" "0x04" "0x0f" ;; +adtran,bsap1920|\ +adtran,bsap1925|\ pcs,cap324) ucidef_set_led_netdev "lan" "LAN" "senao:lan:green" "eth0" ;; diff --git a/target/linux/ath79/base-files/etc/board.d/02_network b/target/linux/ath79/base-files/etc/board.d/02_network index 5b47af8ef7bcf6..deb4b920603fa1 100755 --- a/target/linux/ath79/base-files/etc/board.d/02_network +++ b/target/linux/ath79/base-files/etc/board.d/02_network @@ -11,6 +11,8 @@ ath79_setup_interfaces() case "$board" in adtran,bsap1800-v2|\ adtran,bsap1840|\ + adtran,bsap1920|\ + adtran,bsap1925|\ alfa-network,ap121f|\ aruba,ap-105|\ avm,fritz300e|\ diff --git a/target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom b/target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom index f07dbf83c485d9..af3d36fa61bb5d 100644 --- a/target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom +++ b/target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom @@ -158,6 +158,8 @@ case "$FIRMWARE" in ath9k_eeprom_extract "art" 0x5000 0x440 ath9k_patch_fw_mac_crc $(macaddr_add $(mtd_get_mac_text "mac" 0x18) 1) 0x2 ;; + adtran,bsap1920|\ + adtran,bsap1925|\ ocedo,raccoon|\ tplink,tl-wdr3500-v1|\ tplink,tl-wdr3600-v1|\ diff --git a/target/linux/ath79/base-files/etc/init.d/bootcount b/target/linux/ath79/base-files/etc/init.d/bootcount index 7807559d810333..aebdb19583939a 100755 --- a/target/linux/ath79/base-files/etc/init.d/bootcount +++ b/target/linux/ath79/base-files/etc/init.d/bootcount @@ -8,6 +8,10 @@ boot() { adtran,bsap1840) fconfig -s -w -d $(find_mtd_part "RedBoot config") -n boot_cntb -x 0 ;; + adtran,bsap1920|\ + adtran,bsap1925) + fw_setenv bootcnt 0 + ;; qihoo,c301) local n=$(fw_printenv activeregion | cut -d = -f 2) fw_setenv "image${n}trynum" 0 diff --git a/target/linux/ath79/base-files/lib/upgrade/platform.sh b/target/linux/ath79/base-files/lib/upgrade/platform.sh index f4fca06384b1f0..7c31b34489091a 100644 --- a/target/linux/ath79/base-files/lib/upgrade/platform.sh +++ b/target/linux/ath79/base-files/lib/upgrade/platform.sh @@ -2,7 +2,11 @@ # Copyright (C) 2011 OpenWrt.org # +. /lib/functions/system.sh + PART_NAME=firmware +RAMFS_COPY_DATA='/etc/fw_env.config /var/lock/fw_printenv.lock' +RAMFS_COPY_BIN='nandwrite fw_printenv fw_setenv' REQUIRE_IMAGE_METADATA=1 redboot_fis_do_upgrade() { @@ -44,6 +48,18 @@ platform_do_upgrade() { adtran,bsap1840) redboot_fis_do_upgrade "$1" vmlinux_2 ;; + adtran,bsap1920|\ + adtran,bsap1925) + if [ $(grep -ow 'root=31:0[68]' /proc/cmdline) = "root=31:08" ] + then + PART_NAME=firmware1 + fw_setenv boot_bank A + else + PART_NAME=firmware2 + fw_setenv boot_bank B + fi + default_do_upgrade "$1" + ;; jjplus,ja76pf2) redboot_fis_do_upgrade "$1" linux ;; diff --git a/target/linux/ath79/dts/ar9344_adtran_bsap1920.dts b/target/linux/ath79/dts/ar9344_adtran_bsap1920.dts new file mode 100644 index 00000000000000..40f4aca2604076 --- /dev/null +++ b/target/linux/ath79/dts/ar9344_adtran_bsap1920.dts @@ -0,0 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/dts-v1/; + +#include "ar9344_adtran_bsap192x.dtsi" + +/ { + model = "Adtran Bluesocket BSAP-1920"; + compatible = "adtran,bsap1920", "qca,ar9344"; +}; diff --git a/target/linux/ath79/dts/ar9344_adtran_bsap1925.dts b/target/linux/ath79/dts/ar9344_adtran_bsap1925.dts new file mode 100644 index 00000000000000..18623a83a1ae38 --- /dev/null +++ b/target/linux/ath79/dts/ar9344_adtran_bsap1925.dts @@ -0,0 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/dts-v1/; + +#include "ar9344_adtran_bsap192x.dtsi" + +/ { + model = "Adtran Bluesocket BSAP-1925"; + compatible = "adtran,bsap1925", "qca,ar9344"; +}; diff --git a/target/linux/ath79/dts/ar9344_adtran_bsap192x.dtsi b/target/linux/ath79/dts/ar9344_adtran_bsap192x.dtsi new file mode 100644 index 00000000000000..ff0235e2485163 --- /dev/null +++ b/target/linux/ath79/dts/ar9344_adtran_bsap192x.dtsi @@ -0,0 +1,93 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/dts-v1/; + +#include "ar9344_senao_cap4200ag.dtsi" + +/ { + chosen { + /delete-property/ bootargs; + bootargs-append = "root="; + }; +}; + +&aliases { + label-mac-device = ð0; +}; + +&partitions { + uboot: partition@0 { + label = "u-boot"; + reg = <0x0000000 0x0040000>; + read-only; + }; + + partition@40000 { + label = "u-boot-env"; + reg = <0x0040000 0x0010000>; + }; + + partition@50000 { + label = "Cert"; + reg = <0x0050000 0x0040000>; + }; + + partition@90000 { + label = "Kdump"; + reg = <0x0090000 0x0170000>; + }; + + partition@200000 { + label = "/var"; + reg = <0x0200000 0x0100000>; + }; + + partition@300000 { + compatible = "denx,uimage"; + active-if-supplied-root = "31:06"; + label = "firmware1"; + reg = <0x0300000 0x0d00000>; + }; + + partition@1000000 { + compatible = "denx,uimage"; + active-if-supplied-root = "31:08"; + label = "firmware2"; + reg = <0x1000000 0x0d00000>; + }; + + partition@1d00000 { + label = "/home"; + reg = <0x1d00000 0x0100000>; + }; + + partition@1e00000 { + label = "/log"; + reg = <0x1e00000 0x0180000>; + }; + + senao: partition@1fe0000 { + label = "SENAO"; + reg = <0x1fe0000 0x0010000>; + read-only; + }; + + art: partition@1ff0000 { + label = "art"; + reg = <0x1ff0000 0x0010000>; + read-only; + }; +}; + +&ath9k { + mtd-mac-address = <&senao 0x18>; + mtd-mac-address-increment = <1>; +}; + +&wmac { + mtd-mac-address = <&senao 0x18>; + mtd-mac-address-increment = <9>; +}; + +ð0 { + mtd-mac-address = <&senao 0x18>; +}; diff --git a/target/linux/ath79/image/generic.mk b/target/linux/ath79/image/generic.mk index dffb4bf577f6a7..95a1b801b143ee 100644 --- a/target/linux/ath79/image/generic.mk +++ b/target/linux/ath79/image/generic.mk @@ -124,6 +124,24 @@ define Device/adtran_bsap1840 endef TARGET_DEVICES += adtran_bsap1840 +define Device/adtran_bsap192x + ATH_SOC := ar9344 + DEVICE_VENDOR := Adtran + IMAGE_SIZE := 13312k +endef + +define Device/adtran_bsap1920 + $(Device/adtran_bsap192x) + DEVICE_MODEL := Bluesocket BSAP-1920 +endef +TARGET_DEVICES += adtran_bsap1920 + +define Device/adtran_bsap1925 + $(Device/adtran_bsap192x) + DEVICE_MODEL := Bluesocket BSAP-1925 +endef +TARGET_DEVICES += adtran_bsap1925 + define Device/alfa-network_ap121f ATH_SOC := ar9331 DEVICE_VENDOR := ALFA Network diff --git a/target/linux/ath79/patches-4.19/997-device_tree_cmdline.patch b/target/linux/ath79/patches-4.19/997-device_tree_cmdline.patch new file mode 100644 index 00000000000000..97f66c9d5bc89f --- /dev/null +++ b/target/linux/ath79/patches-4.19/997-device_tree_cmdline.patch @@ -0,0 +1,50 @@ +--- a/drivers/of/fdt.c ++++ b/drivers/of/fdt.c +@@ -1090,6 +1090,11 @@ int __init early_init_dt_scan_chosen(uns + p = of_get_flat_dt_prop(node, "bootargs", &l); + if (p != NULL && l > 0) + strlcpy(data, p, min((int)l, COMMAND_LINE_SIZE)); ++ p = of_get_flat_dt_prop(node, "bootargs-append", &l); ++ if (p != NULL && l > 0) { ++ strlcat(data, " ", COMMAND_LINE_SIZE); ++ strlcat(data, p, min(l + strlen(data), COMMAND_LINE_SIZE)); ++ } + + /* + * CONFIG_CMDLINE is meant to be a default in case nothing else +--- a/arch/mips/kernel/setup.c ++++ b/arch/mips/kernel/setup.c +@@ -853,7 +853,10 @@ static void __init arch_mem_init(char ** + * CONFIG_CMDLINE ourselves below & don't want to duplicate its + * content because repeating arguments can be problematic. + */ +- strlcpy(boot_command_line, " ", COMMAND_LINE_SIZE); ++ if (USE_DTB_CMDLINE) ++ strlcpy(boot_command_line, arcs_cmdline, COMMAND_LINE_SIZE); ++ else ++ strlcpy(boot_command_line, " ", COMMAND_LINE_SIZE); + + /* call board setup routine */ + plat_mem_setup(); +@@ -877,9 +880,10 @@ static void __init arch_mem_init(char ** + #if defined(CONFIG_CMDLINE_BOOL) && defined(CONFIG_CMDLINE_OVERRIDE) + strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE); + #else +- if ((USE_PROM_CMDLINE && arcs_cmdline[0]) || +- (USE_DTB_CMDLINE && !boot_command_line[0])) ++ if (USE_PROM_CMDLINE) + strlcpy(boot_command_line, arcs_cmdline, COMMAND_LINE_SIZE); ++ else if (!strcmp(boot_command_line, " ")) ++ boot_command_line[0] = '\0'; + + if (EXTEND_WITH_PROM && arcs_cmdline[0]) { + if (boot_command_line[0]) +@@ -888,7 +892,7 @@ static void __init arch_mem_init(char ** + } + + #if defined(CONFIG_CMDLINE_BOOL) +- if (builtin_cmdline[0]) { ++ if (builtin_cmdline[0] && strcmp(boot_command_line, builtin_cmdline)) { + if (boot_command_line[0]) + strlcat(boot_command_line, " ", COMMAND_LINE_SIZE); + strlcat(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE); diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c index a6e50b51130d15..951a862a24a901 100644 --- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c +++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c @@ -9,6 +9,9 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#include +#include +#include #include #include #include @@ -100,6 +103,32 @@ static int __mtdsplit_parse_uimage(struct mtd_info *master, int extralen; enum mtdsplit_part_type type; + const char *rarg = of_get_property(mtd_get_of_node(master), + "active-if-supplied-root", &ret); + if (rarg && ret > 0 && *rarg) { + const char *ind; + + for (ind = strnstr + (boot_command_line, "root=", COMMAND_LINE_SIZE); + ind && ind != boot_command_line + && !isspace(ind[-1]); ind = strnstr + (ind + 1, "root=", COMMAND_LINE_SIZE - (ind + 1 + - boot_command_line))) + ; + if (!ind) + return -ENODEV; + ind += 5; + for (offset = ind - boot_command_line; + offset < COMMAND_LINE_SIZE + && boot_command_line[offset] + && !isspace(boot_command_line[offset]); + ++offset) + ; + offset -= ind - boot_command_line; + if (offset != strnlen(rarg, ret) || memcmp(ind, rarg, offset)) + return -ENODEV; + } + nr_parts = 2; parts = kzalloc(nr_parts * sizeof(*parts), GFP_KERNEL); if (!parts)