From 58bdbe73212a7f1c2755cf640e21b01e9b2d7b04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Tue, 2 Jun 2020 08:30:44 +0200 Subject: [PATCH 01/19] scripts: support Sercomm partition tags MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sercomm uses a custom layout for partition tags: char part_name[32]; char size[32]; char part_version[32]; char reserved[32]; char rootfs_version[32]; Signed-off-by: Álvaro Fernández Rojas --- scripts/sercomm-partition-tag.py | 81 ++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100755 scripts/sercomm-partition-tag.py diff --git a/scripts/sercomm-partition-tag.py b/scripts/sercomm-partition-tag.py new file mode 100755 index 0000000000..ef49af8c05 --- /dev/null +++ b/scripts/sercomm-partition-tag.py @@ -0,0 +1,81 @@ +#!/usr/bin/env python3 + +import argparse +import os +import struct + +def create_header(args, size): + header = struct.pack('32s32s32s32s32s', + args.part_name.encode('ascii'), + str(size).encode('ascii'), + args.part_version.encode('ascii'), + "".encode('ascii'), + args.rootfs_version.encode('ascii')) + + return header + +def create_output(args): + in_st = os.stat(args.input_file) + in_size = in_st.st_size + + header = create_header(args, in_size) + print(header) + + in_f = open(args.input_file, 'r+b') + in_bytes = in_f.read(in_size) + in_f.close() + + out_f = open(args.output_file, 'w+b') + out_f.write(header) + out_f.write(in_bytes) + out_f.close() + +def main(): + global args + + parser = argparse.ArgumentParser(description='') + + parser.add_argument('--input-file', + dest='input_file', + action='store', + type=str, + help='Input file') + + parser.add_argument('--output-file', + dest='output_file', + action='store', + type=str, + help='Output file') + + parser.add_argument('--part-name', + dest='part_name', + action='store', + type=str, + help='Partition Name') + + parser.add_argument('--part-version', + dest='part_version', + action='store', + type=str, + help='Partition Version') + + parser.add_argument('--rootfs-version', + dest='rootfs_version', + action='store', + type=str, + help='RootFS lib version') + + args = parser.parse_args() + + if not args.rootfs_version: + args.rootfs_version = "" + + if ((not args.input_file) or + (not args.output_file) or + (not args.part_name) or + (not args.part_version)): + parser.print_help() + + create_output(args) + +main() From 7f1250a7fea716a13c1678a14dbc417ff57e461f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Tue, 2 Jun 2020 08:37:54 +0200 Subject: [PATCH 02/19] scripts: support Sercomm crypto MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sercomm firmwares are encrypted with AES 256 CBC. The key is generated with a custom algorithm from the firmware tag: char key[32]; char version[32]; char iv[32]; char random[32]; char size[32]; Key must be generated with Sercomm's algorithm. However, the rest of the header can be empty. IV and random are set to 0 on purpose. Signed-off-by: Álvaro Fernández Rojas --- scripts/sercomm-crypto.py | 86 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100755 scripts/sercomm-crypto.py diff --git a/scripts/sercomm-crypto.py b/scripts/sercomm-crypto.py new file mode 100755 index 0000000000..bed3e494b6 --- /dev/null +++ b/scripts/sercomm-crypto.py @@ -0,0 +1,86 @@ +#!/usr/bin/env python3 + +import argparse +import binascii +import hashlib +import os +import struct + +def create_header(key, version, iv, random, size): + header = struct.pack('32s32s32s32s32s', key, version, iv, random, size) + + return header + +def create_output(args): + in_st = os.stat(args.input_file) + in_size = in_st.st_size + + key = "".encode('ascii') + version = args.version.encode('ascii') + iv = "".encode('ascii') + random = "".encode('ascii') + size = str(in_size).encode('ascii') + header = create_header(key, version, iv, random, size) + + out_f = open(args.output_file, 'w+b') + out_f.write(header) + out_f.close() + + md5 = hashlib.md5() + md5.update(header[0x60:0x80]) + md5.update(header[0x20:0x40]) + md5_1 = md5.digest() + + md5 = hashlib.md5() + md5.update(header[0x80:0xA0]) + md5.update(header[0x20:0x40]) + md5_2 = md5.digest() + + key = md5_1 + md5_2 + + key_f = open(args.key_file, 'w+b') + key_f.write(binascii.hexlify(bytearray(key))) + key_f.close() + + print("AES 256 CBC Key:", binascii.hexlify(bytearray(key))) + +def main(): + global args + + parser = argparse.ArgumentParser(description='') + + parser.add_argument('--input-file', + dest='input_file', + action='store', + type=str, + help='Input file') + + parser.add_argument('--key-file', + dest='key_file', + action='store', + type=str, + help='AES 256 CBC Key File') + + parser.add_argument('--output-file', + dest='output_file', + action='store', + type=str, + help='Output file') + + parser.add_argument('--version', + dest='version', + action='store', + type=str, + help='Version') + + args = parser.parse_args() + + if ((not args.input_file) or + (not args.key_file) or + (not args.output_file) or + (not args.version)): + parser.print_help() + + create_output(args) + +main() From cd81d105d50d29dfa253c8659509e9e0272d9b32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Tue, 2 Jun 2020 08:50:15 +0200 Subject: [PATCH 03/19] kernel: mtdsplit: bcm_wfi: code refactoring MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Rename master to mtd. - Pass mtd size as an argument. - Rename of_match_table. Signed-off-by: Álvaro Fernández Rojas --- .../drivers/mtd/mtdsplit/mtdsplit_bcm_wfi.c | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_bcm_wfi.c b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_bcm_wfi.c index 0298de7a2f..f99685c8e6 100644 --- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_bcm_wfi.c +++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_bcm_wfi.c @@ -48,21 +48,22 @@ static bool jffs2_dirent_valid(struct jffs2_raw_dirent *node) je32_to_cpu(node->node_crc) == jffs2_dirent_crc(node)); } -static int jffs2_find_file(struct mtd_info *master, uint8_t *buf, +static int jffs2_find_file(struct mtd_info *mtd, uint8_t *buf, const char *name, size_t name_len, - loff_t *offs) + loff_t *offs, loff_t size) { + const loff_t end = *offs + size; struct jffs2_raw_dirent *node; bool valid = false; size_t retlen; uint16_t magic; int rc; - for (; *offs < master->size; *offs += master->erasesize) { + for (; *offs < end; *offs += mtd->erasesize) { unsigned int block_offs = 0; /* Skip CFE erased blocks */ - rc = mtd_read(master, *offs, sizeof(magic), &retlen, + rc = mtd_read(mtd, *offs, sizeof(magic), &retlen, (void *) &magic); if (rc || retlen != sizeof(magic)) { continue; @@ -73,14 +74,14 @@ static int jffs2_find_file(struct mtd_info *master, uint8_t *buf, continue; /* Read full block */ - rc = mtd_read(master, *offs, master->erasesize, &retlen, + rc = mtd_read(mtd, *offs, mtd->erasesize, &retlen, (void *) buf); if (rc) return rc; - if (retlen != master->erasesize) + if (retlen != mtd->erasesize) return -EINVAL; - while (block_offs < master->erasesize) { + while (block_offs < mtd->erasesize) { node = (struct jffs2_raw_dirent *) &buf[block_offs]; if (!jffs2_dirent_valid(node)) { @@ -102,14 +103,15 @@ static int jffs2_find_file(struct mtd_info *master, uint8_t *buf, return -ENOENT; } -static int ubifs_find(struct mtd_info *master, loff_t *offs) +static int ubifs_find(struct mtd_info *mtd, loff_t *offs, loff_t size) { + const loff_t end = *offs + size; uint32_t magic; size_t retlen; int rc; - for (; *offs < master->size; *offs += master->erasesize) { - rc = mtd_read(master, *offs, sizeof(magic), &retlen, + for (; *offs < end; *offs += mtd->erasesize) { + rc = mtd_read(mtd, *offs, sizeof(magic), &retlen, (unsigned char *) &magic); if (rc || retlen != sizeof(magic)) continue; @@ -149,7 +151,8 @@ static int mtdsplit_parse_bcm_wfi(struct mtd_info *master, cfe_off = 0; ret = jffs2_find_file(master, buf, CFERAM_NAME, - CFERAM_NAME_LEN, &cfe_off); + CFERAM_NAME_LEN, &cfe_off, + master->size); if (ret) { kfree(buf); return ret; @@ -161,13 +164,13 @@ static int mtdsplit_parse_bcm_wfi(struct mtd_info *master, } ret = jffs2_find_file(master, buf, KERNEL_NAME, KERNEL_NAME_LEN, - &kernel_off); + &kernel_off, master->size); kfree(buf); if (ret) return ret; rootfs_off = kernel_off + master->erasesize; - ret = ubifs_find(master, &rootfs_off); + ret = ubifs_find(master, &rootfs_off, master->size); if (ret) return ret; @@ -203,7 +206,7 @@ static int mtdsplit_parse_bcm_wfi(struct mtd_info *master, return num_parts; } -static const struct of_device_id mtdsplit_fit_of_match_table[] = { +static const struct of_device_id mtdsplit_bcm_wfi_of_match[] = { { .compatible = "brcm,wfi" }, { .compatible = "brcm,wfi-sercomm" }, { }, @@ -212,7 +215,7 @@ static const struct of_device_id mtdsplit_fit_of_match_table[] = { static struct mtd_part_parser mtdsplit_bcm_wfi_parser = { .owner = THIS_MODULE, .name = "bcm-wfi-fw", - .of_match_table = mtdsplit_fit_of_match_table, + .of_match_table = mtdsplit_bcm_wfi_of_match, .parse_fn = mtdsplit_parse_bcm_wfi, .type = MTD_PARSER_TYPE_FIRMWARE, }; From fce7380e0ea89b2b78a3de65ca56d8e42c77e732 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Tue, 2 Jun 2020 08:57:38 +0200 Subject: [PATCH 04/19] kernel: mtdsplit: bcm_wfi: support Sercomm bootflags MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sercomm uses 2 bootflag partitions and boots the firmware with the highest bootflag. Support splitting the firmware partition while keeping support for unsplitted layout. Signed-off-by: Álvaro Fernández Rojas --- .../drivers/mtd/mtdsplit/mtdsplit_bcm_wfi.c | 148 ++++++++++++++++++ 1 file changed, 148 insertions(+) diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_bcm_wfi.c b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_bcm_wfi.c index f99685c8e6..7eb6526f9e 100644 --- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_bcm_wfi.c +++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_bcm_wfi.c @@ -24,6 +24,8 @@ #include "mtdsplit.h" +#define char_to_num(c) ((c >= '0' && c <= '9') ? (c - '0') : (0)) + #define BCM_WFI_PARTS 3 #define CFERAM_NAME "cferam" @@ -35,6 +37,11 @@ #define UBI_MAGIC 0x55424923 +#define SERCOMM_MAGIC_PFX "eRcOmM." +#define SERCOMM_MAGIC_PFX_LEN (sizeof(SERCOMM_MAGIC_PFX) - 1) +#define SERCOMM_MAGIC "eRcOmM.000" +#define SERCOMM_MAGIC_LEN (sizeof(SERCOMM_MAGIC) - 1) + static u32 jffs2_dirent_crc(struct jffs2_raw_dirent *node) { return crc32(0, node, sizeof(struct jffs2_raw_dirent) - 8); @@ -220,9 +227,150 @@ static struct mtd_part_parser mtdsplit_bcm_wfi_parser = { .type = MTD_PARSER_TYPE_FIRMWARE, }; +static int sercomm_bootflag_value(struct mtd_info *mtd, uint8_t *buf) +{ + size_t retlen; + loff_t offs; + int rc; + + for (offs = 0; offs < mtd->size; offs += mtd->erasesize) { + rc = mtd_read(mtd, offs, SERCOMM_MAGIC_LEN, &retlen, buf); + if (rc || retlen != SERCOMM_MAGIC_LEN) + continue; + + if (memcmp(buf, SERCOMM_MAGIC_PFX, SERCOMM_MAGIC_PFX_LEN)) + continue; + + rc = char_to_num(buf[SERCOMM_MAGIC_PFX_LEN + 0]) * 100; + rc += char_to_num(buf[SERCOMM_MAGIC_PFX_LEN + 1]) * 10; + rc += char_to_num(buf[SERCOMM_MAGIC_PFX_LEN + 2]) * 1; + + return rc; + } + + return -ENOENT; +} + +static int mtdsplit_parse_ser_wfi(struct mtd_info *master, + const struct mtd_partition **pparts, + struct mtd_part_parser_data *data) +{ + struct mtd_info *mtd_bf1, *mtd_bf2; + struct erase_info bf_erase; + struct mtd_partition *parts; + loff_t kernel_off, rootfs_off, img_size; + loff_t img2_off, img2_size = 0; + unsigned int num_parts = BCM_WFI_PARTS, cur_part = 0; + uint8_t *buf; + int bf1, bf2; + int ret; + + mtd_bf1 = get_mtd_device_nm("bootflag1"); + if (IS_ERR(mtd_bf1)) + return -ENOENT; + + mtd_bf2 = get_mtd_device_nm("bootflag2"); + if (IS_ERR(mtd_bf2)) + return -ENOENT; + + buf = kzalloc(master->erasesize, GFP_KERNEL); + if (!buf) + return -ENOMEM; + + bf1 = sercomm_bootflag_value(mtd_bf1, buf); + if (bf1 >= 0) + printk("sercomm: bootflag1=%d\n", bf1); + + bf2 = sercomm_bootflag_value(mtd_bf2, buf); + if (bf2 >= 0) + printk("sercomm: bootflag2=%d\n", bf2); + + if (bf1 == bf2 && bf2 >= 0) { + bf2 = -ENOENT; + bf_erase.addr = 0; + bf_erase.len = mtd_bf2->size; + mtd_erase(mtd_bf2, &bf_erase); + } + + if (bf1 >= bf2) { + kernel_off = 0; + if (bf2 >= 0) { + img_size = master->size / 2; + + img2_off = img_size; + img2_size = master->size - img2_off; + num_parts++; + } else { + img_size = master->size; + } + } else { + kernel_off = master->size / 2; + img_size = master->size; + + img2_off = 0; + img2_size = kernel_off; + num_parts++; + } + + ret = jffs2_find_file(master, buf, KERNEL_NAME, KERNEL_NAME_LEN, + &kernel_off, img_size); + kfree(buf); + if (ret) + return ret; + + rootfs_off = kernel_off + master->erasesize; + ret = ubifs_find(master, &rootfs_off, img_size); + if (ret) + return ret; + + parts = kzalloc(num_parts * sizeof(*parts), GFP_KERNEL); + if (!parts) + return -ENOMEM; + + parts[cur_part].name = "firmware"; + parts[cur_part].offset = kernel_off; + parts[cur_part].size = img_size - kernel_off; + cur_part++; + + parts[cur_part].name = KERNEL_PART_NAME; + parts[cur_part].offset = kernel_off; + parts[cur_part].size = rootfs_off - kernel_off; + cur_part++; + + parts[cur_part].name = UBI_PART_NAME; + parts[cur_part].offset = rootfs_off; + parts[cur_part].size = img_size - rootfs_off; + cur_part++; + + if (img2_size) { + parts[cur_part].name = "img2"; + parts[cur_part].offset = img2_off; + parts[cur_part].size = img2_size; + cur_part++; + } + + *pparts = parts; + + return num_parts; +} + +static const struct of_device_id mtdsplit_ser_wfi_of_match[] = { + { .compatible = "sercomm,wfi" }, + { }, +}; + +static struct mtd_part_parser mtdsplit_ser_wfi_parser = { + .owner = THIS_MODULE, + .name = "ser-wfi-fw", + .of_match_table = mtdsplit_ser_wfi_of_match, + .parse_fn = mtdsplit_parse_ser_wfi, + .type = MTD_PARSER_TYPE_FIRMWARE, +}; + static int __init mtdsplit_bcm_wfi_init(void) { register_mtd_parser(&mtdsplit_bcm_wfi_parser); + register_mtd_parser(&mtdsplit_ser_wfi_parser); return 0; } From 80d811480256bda63b0f0d087b55a9e35b59e91e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Tue, 2 Jun 2020 08:59:58 +0200 Subject: [PATCH 05/19] bcm63xx: ad1018: switch to Sercomm WFI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Support Sercomm firmware partition split. WFI partition must be defined after bootflag partitions in order for the parser to properly find bootflag1 and bootflag2 partitions. Signed-off-by: Álvaro Fernández Rojas --- .../bcm63xx/base-files/etc/uci-defaults/09_fix_crc | 3 --- target/linux/bcm63xx/dts/bcm6328-sercomm-ad1018.dts | 12 ++++++------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/target/linux/bcm63xx/base-files/etc/uci-defaults/09_fix_crc b/target/linux/bcm63xx/base-files/etc/uci-defaults/09_fix_crc index 3fcf40434f..fdb5ddec72 100644 --- a/target/linux/bcm63xx/base-files/etc/uci-defaults/09_fix_crc +++ b/target/linux/bcm63xx/base-files/etc/uci-defaults/09_fix_crc @@ -41,7 +41,4 @@ case "$(board_name)" in zyxel,p870hw-51a-v2) do_fixcrc ;; - sercomm,ad1018) - mtd erase bootflag2 - ;; esac diff --git a/target/linux/bcm63xx/dts/bcm6328-sercomm-ad1018.dts b/target/linux/bcm63xx/dts/bcm6328-sercomm-ad1018.dts index 440c653dca..421029054a 100644 --- a/target/linux/bcm63xx/dts/bcm6328-sercomm-ad1018.dts +++ b/target/linux/bcm63xx/dts/bcm6328-sercomm-ad1018.dts @@ -167,12 +167,6 @@ read-only; }; - partition@520000 { - compatible = "brcm,wfi-sercomm"; - label = "wfi"; - reg = <0x0520000 0x6400000>; - }; - partition@6920000 { label = "bootflag1"; reg = <0x6920000 0x0140000>; @@ -183,6 +177,12 @@ reg = <0x6a60000 0x0140000>; }; + partition@520000 { + compatible = "sercomm,wfi"; + label = "wfi"; + reg = <0x0520000 0x6400000>; + }; + partition@6ba0000 { label = "xml_cfg"; reg = <0x6ba0000 0x0280000>; From 4b2fe12953e173df90a36326ae92486331594f4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Tue, 2 Jun 2020 09:02:23 +0200 Subject: [PATCH 06/19] kernel: mtdsplit: bcm_wfi: remove brcm,wfi-sercomm compatibility MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The only Sercomm WFI user has been migrated to a dedicated firmware parser. Keep support for no cferam partition based on a boolean DT property. Signed-off-by: Álvaro Fernández Rojas --- .../generic/files/drivers/mtd/mtdsplit/mtdsplit_bcm_wfi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_bcm_wfi.c b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_bcm_wfi.c index 7eb6526f9e..4e46ded587 100644 --- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_bcm_wfi.c +++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_bcm_wfi.c @@ -150,7 +150,7 @@ static int mtdsplit_parse_bcm_wfi(struct mtd_info *master, if (!mtd_node) return -EINVAL; - if (of_device_is_compatible(mtd_node, "brcm,wfi-sercomm")) + if (of_property_read_bool(mtd_node, "brcm,no-cferam")) cfe_part = false; if (cfe_part) { @@ -215,7 +215,6 @@ static int mtdsplit_parse_bcm_wfi(struct mtd_info *master, static const struct of_device_id mtdsplit_bcm_wfi_of_match[] = { { .compatible = "brcm,wfi" }, - { .compatible = "brcm,wfi-sercomm" }, { }, }; From f263a0f9ff5c050312f676b6684396ea118a8884 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Tue, 2 Jun 2020 09:12:05 +0200 Subject: [PATCH 07/19] bcm63xx: nand: support Sercomm firmwares MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add support for Sercomm factory firmwares (AES 256 CBC encrypted). Signed-off-by: Álvaro Fernández Rojas --- target/linux/bcm63xx/image/Makefile | 58 ++++++++++++++++++++++ target/linux/bcm63xx/image/bcm63xx_nand.mk | 9 ++++ 2 files changed, 67 insertions(+) diff --git a/target/linux/bcm63xx/image/Makefile b/target/linux/bcm63xx/image/Makefile index 5fbe8ea470..fdeb100dd9 100644 --- a/target/linux/bcm63xx/image/Makefile +++ b/target/linux/bcm63xx/image/Makefile @@ -223,6 +223,64 @@ define Build/cfe-part-tag dd if=$@.part >> $@ endef +define Build/cfe-sercomm-part + $(TOPDIR)/scripts/sercomm-partition-tag.py \ + --input-file $@ \ + --output-file $@.kernel_rootfs \ + --part-name kernel_rootfs \ + --part-version OpenWrt \ + --rootfs-version $(SERCOMM_VERSION) + + rm -rf $@-rootfs_lib + mkdir -p $@-rootfs_lib + echo $(SERCOMM_VERSION) > $@-rootfs_lib/lib_ver + $(call Build/cfe-jffs2,$@-rootfs_lib) + $(call Build/pad-to,$(BLOCKSIZE)) + $(TOPDIR)/scripts/sercomm-partition-tag.py \ + --input-file $@ \ + --output-file $@.rootfs_lib \ + --part-name rootfs_lib \ + --part-version $(SERCOMM_VERSION) + + rm -rf $@-bootloader + mkdir -p $@-bootloader + cp $(KDIR)/bcm63xx-cfe/$(CFE_RAM_FILE) $@-bootloader/$(CFE_RAM_JFFS2_NAME) + $(call Build/cfe-jffs2,$@-bootloader) + $(call Build/pad-to,$(BLOCKSIZE)) + $(TOPDIR)/scripts/sercomm-partition-tag.py \ + --input-file $@ \ + --output-file $@.bootloader \ + --part-name bootloader \ + --part-version $(SERCOMM_VERSION) + + mv $@.kernel_rootfs $@ + dd if=$@.rootfs_lib >> $@ + dd if=$@.bootloader >> $@ +endef + +define Build/cfe-sercomm-load + mv $@ $@.ser + echo $(SERCOMM_PID) | xxd -p -r > $@ + sha256sum $@.ser | awk '{ print $1 }' | xxd -p -r >> $@ + dd if=$@.ser >> $@ + rm -f $@.ser +endef + +define Build/cfe-sercomm-crypto + $(TOPDIR)/scripts/sercomm-crypto.py \ + --input-file $@ \ + --key-file $@.key \ + --output-file $@.ser \ + --version OpenWrt + $(STAGING_DIR_HOST)/bin/openssl enc -md md5 -aes-256-cbc \ + -in $@ -out $@.enc \ + -K `cat $@.key` \ + -iv 00000000000000000000000000000000 + dd if=$@.enc >> $@.ser + mv $@.ser $@ + rm -f $@.enc $@.key +endef + define Build/cfe-old-bin $(TOPDIR)/scripts/brcmImage.pl -t -p \ -o $@ -b $(CFE_BOARD_ID) -c $(CHIP_ID) \ diff --git a/target/linux/bcm63xx/image/bcm63xx_nand.mk b/target/linux/bcm63xx/image/bcm63xx_nand.mk index 5483c73077..57a895f9db 100644 --- a/target/linux/bcm63xx/image/bcm63xx_nand.mk +++ b/target/linux/bcm63xx/image/bcm63xx_nand.mk @@ -7,6 +7,7 @@ DEVICE_VARS += CFE_RAM_FILE DEVICE_VARS += CFE_RAM_JFFS2_NAME CFE_RAM_JFFS2_PAD DEVICE_VARS += CFE_WFI_CHIP_ID CFE_WFI_FLASH_TYPE DEVICE_VARS += CFE_WFI_FLAGS CFE_WFI_VERSION +DEVICE_VARS += SERCOMM_PID SERCOMM_VERSION # CFE expects a single JFFS2 partition with cferam and kernel. However, # it's possible to fool CFE into properly loading both cferam and kernel @@ -36,6 +37,14 @@ define Device/bcm63xx-nand SUPPORTED_DEVICES := $(subst _,$(comma),$(1)) endef +define Device/sercomm-nand + $(Device/bcm63xx-nand) + IMAGES += factory.img + IMAGE/factory.img := append-kernel | pad-to $$$$(KERNEL_SIZE) | append-ubi | cfe-sercomm-part | gzip | cfe-sercomm-load | cfe-sercomm-crypto + SERCOM_PID := + SERCOMM_VERSION := +endef + ### Comtrend ### define Device/comtrend_vr-3032u $(Device/bcm63xx-nand) From a47acae319c9b49c2737bbcc6302678d4706df3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Tue, 2 Jun 2020 09:16:49 +0200 Subject: [PATCH 08/19] bcm63xx: ad1018: support Sercomm factory images MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This images can be flashed from the official firmware, as opposed to CFE images, which can only be flashed from CFE and require opening the case. Signed-off-by: Álvaro Fernández Rojas --- target/linux/bcm63xx/image/bcm63xx_nand.mk | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/target/linux/bcm63xx/image/bcm63xx_nand.mk b/target/linux/bcm63xx/image/bcm63xx_nand.mk index 57a895f9db..7dff893e4f 100644 --- a/target/linux/bcm63xx/image/bcm63xx_nand.mk +++ b/target/linux/bcm63xx/image/bcm63xx_nand.mk @@ -121,7 +121,7 @@ TARGET_DEVICES += netgear_dgnd3700-v2 ### Sercomm ### define Device/sercomm_ad1018 - $(Device/bcm63xx-nand) + $(Device/sercomm-nand) IMAGE/cfe.bin := append-kernel | pad-to $$$$(KERNEL_SIZE) | ad1018-jffs2-cferam | append-ubi | cfe-wfi-tag DEVICE_VENDOR := Sercomm DEVICE_MODEL := AD1018 @@ -134,5 +134,15 @@ define Device/sercomm_ad1018 VID_HDR_OFFSET := 2048 DEVICE_PACKAGES += $(B43_PACKAGES) $(USB2_PACKAGES) CFE_WFI_FLASH_TYPE := 3 + SERCOMM_PID := \ + 30 30 30 30 30 30 30 31 34 31 35 31 35 33 30 30 \ + 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 \ + 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 \ + 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 \ + 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 \ + 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 \ + 30 30 30 30 33 30 31 33 30 30 30 30 30 30 30 30 \ + 0D 0A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + SERCOMM_VERSION := 1001 endef TARGET_DEVICES += sercomm_ad1018 From 35d7f92c60efb161fec26313ea47895197da4506 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Tue, 2 Jun 2020 12:50:37 +0200 Subject: [PATCH 09/19] scripts: support Sercomm load tags MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Header consists in Sercomm PID bytes, followed by a SHA256 hash of the input binary. Signed-off-by: Álvaro Fernández Rojas --- scripts/config/mconf_check | 0 scripts/sercomm-payload.py | 56 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 scripts/config/mconf_check create mode 100755 scripts/sercomm-payload.py diff --git a/scripts/config/mconf_check b/scripts/config/mconf_check new file mode 100644 index 0000000000..e69de29bb2 diff --git a/scripts/sercomm-payload.py b/scripts/sercomm-payload.py new file mode 100755 index 0000000000..5193069b6c --- /dev/null +++ b/scripts/sercomm-payload.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python3 + +import argparse +import hashlib +import os + +def create_output(args): + in_st = os.stat(args.input_file) + in_size = in_st.st_size + + in_f = open(args.input_file, 'r+b') + in_bytes = in_f.read(in_size) + in_f.close() + + sha256 = hashlib.sha256() + sha256.update(in_bytes) + + out_f = open(args.output_file, 'w+b') + out_f.write(bytes.fromhex(args.pid)) + out_f.write(sha256.digest()) + out_f.write(in_bytes) + out_f.close() + +def main(): + global args + + parser = argparse.ArgumentParser(description='') + + parser.add_argument('--input-file', + dest='input_file', + action='store', + type=str, + help='Input file') + + parser.add_argument('--output-file', + dest='output_file', + action='store', + type=str, + help='Output file') + + parser.add_argument('--pid', + dest='pid', + action='store', + type=str, + help='Sercomm PID') + + args = parser.parse_args() + + if ((not args.input_file) or + (not args.output_file) or + (not args.pid)): + parser.print_help() + + create_output(args) + +main() From e238c85e571f5260a55a4c85fe92c68699e23521 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Tue, 2 Jun 2020 13:01:35 +0200 Subject: [PATCH 10/19] bcm63xx: nand: sercomm: switch to sercomm-load script MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit xxd is not a valid dependency and shouldn't be used. Fixes buildbot failure. Signed-off-by: Álvaro Fernández Rojas --- target/linux/bcm63xx/image/Makefile | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/target/linux/bcm63xx/image/Makefile b/target/linux/bcm63xx/image/Makefile index fdeb100dd9..eb4b78b06a 100644 --- a/target/linux/bcm63xx/image/Makefile +++ b/target/linux/bcm63xx/image/Makefile @@ -259,11 +259,12 @@ define Build/cfe-sercomm-part endef define Build/cfe-sercomm-load - mv $@ $@.ser - echo $(SERCOMM_PID) | xxd -p -r > $@ - sha256sum $@.ser | awk '{ print $1 }' | xxd -p -r >> $@ - dd if=$@.ser >> $@ - rm -f $@.ser + $(TOPDIR)/scripts/sercomm-payload.py \ + --input-file $@ \ + --output-file $@.new \ + --pid "$(SERCOMM_PID)" + + mv $@.new $@ endef define Build/cfe-sercomm-crypto From 392c64d8fdb5ae38813c009c439bad6f43e1a10b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0tetiar?= Date: Tue, 2 Jun 2020 10:51:02 +0200 Subject: [PATCH 11/19] kernel: bump 5.4 to 5.4.43 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refreshed patches, removed upstreamed patch: bcm27xx: 950-0642-component-Silence-bind-error-on-EPROBE_DEFER.patch Run tested: qemu-x86-64 Build tested: x86/64, imx6, sunxi/a53 Signed-off-by: Petr Štetiar --- include/kernel-version.mk | 4 +- .../910-unaligned_access_hacks.patch | 2 +- ...ce-quirks-for-Freeway-Airmouse-T3-an.patch | 4 +- ....dtbo-overlays-to-be-built-piecemeal.patch | 2 +- ...t-Silence-bind-error-on-EPROBE_DEFER.patch | 41 ------------------- .../203-kallsyms_uncompressed.patch | 2 +- .../205-backtrace_module_info.patch | 4 +- .../300-mvneta-tx-queue-workaround.patch | 4 +- ...-arm64-dts-add-uDPU-i2c-bus-recovery.patch | 5 --- 9 files changed, 11 insertions(+), 57 deletions(-) delete mode 100644 target/linux/bcm27xx/patches-5.4/950-0642-component-Silence-bind-error-on-EPROBE_DEFER.patch diff --git a/include/kernel-version.mk b/include/kernel-version.mk index 9394897b1f..3a446ffb18 100644 --- a/include/kernel-version.mk +++ b/include/kernel-version.mk @@ -8,11 +8,11 @@ endif LINUX_VERSION-4.14 = .180 LINUX_VERSION-4.19 = .123 -LINUX_VERSION-5.4 = .42 +LINUX_VERSION-5.4 = .43 LINUX_KERNEL_HASH-4.14.180 = 444ef973d9b6a6ea174e4a9086f0aea980d8575d13302e431ad688f22e27ed0e LINUX_KERNEL_HASH-4.19.123 = a79914d31a8d8c6b0e2bb0f2b143d615fe8a6c4dd2e0f36e97aa20efd69a993f -LINUX_KERNEL_HASH-5.4.42 = 4e431b7c0266a07b76fdb77f8917ad681f0fa34ffba0eb8a172b67f7ef57bc31 +LINUX_KERNEL_HASH-5.4.43 = 2667b90a42d42557aca9e3d37bba1b4e71809b9523958e6870ada311c4790744 remove_uri_prefix=$(subst git://,,$(subst http://,,$(subst https://,,$(1)))) sanitize_uri=$(call qstrip,$(subst @,_,$(subst :,_,$(subst .,_,$(subst -,_,$(subst /,_,$(1))))))) diff --git a/target/linux/ath79/patches-5.4/910-unaligned_access_hacks.patch b/target/linux/ath79/patches-5.4/910-unaligned_access_hacks.patch index cf943d8c44..0f41faf9df 100644 --- a/target/linux/ath79/patches-5.4/910-unaligned_access_hacks.patch +++ b/target/linux/ath79/patches-5.4/910-unaligned_access_hacks.patch @@ -464,7 +464,7 @@ #define IGMP_HOST_MEMBERSHIP_REPORT 0x12 /* Ditto */ --- a/net/core/flow_dissector.c +++ b/net/core/flow_dissector.c -@@ -196,7 +196,7 @@ __be32 __skb_flow_get_ports(const struct +@@ -212,7 +212,7 @@ __be32 __skb_flow_get_ports(const struct ports = __skb_header_pointer(skb, thoff + poff, sizeof(_ports), data, hlen, &_ports); if (ports) diff --git a/target/linux/bcm27xx/patches-5.4/950-0283-hid-usb-Add-device-quirks-for-Freeway-Airmouse-T3-an.patch b/target/linux/bcm27xx/patches-5.4/950-0283-hid-usb-Add-device-quirks-for-Freeway-Airmouse-T3-an.patch index 203e8638a2..7f2b53562e 100644 --- a/target/linux/bcm27xx/patches-5.4/950-0283-hid-usb-Add-device-quirks-for-Freeway-Airmouse-T3-an.patch +++ b/target/linux/bcm27xx/patches-5.4/950-0283-hid-usb-Add-device-quirks-for-Freeway-Airmouse-T3-an.patch @@ -33,7 +33,7 @@ Signed-off-by: Jonathan Bell #define USB_VENDOR_ID_BELKIN 0x050d #define USB_DEVICE_ID_FLIP_KVM 0x3201 -@@ -1226,6 +1229,9 @@ +@@ -1231,6 +1234,9 @@ #define USB_VENDOR_ID_XAT 0x2505 #define USB_DEVICE_ID_XAT_CSR 0x0220 @@ -53,7 +53,7 @@ Signed-off-by: Jonathan Bell { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_MULTI_TOUCH), HID_QUIRK_MULTI_INPUT }, { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_PIXART_USB_OPTICAL_MOUSE), HID_QUIRK_ALWAYS_POLL }, { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_PIXART_USB_OPTICAL_MOUSE2), HID_QUIRK_ALWAYS_POLL }, -@@ -176,6 +177,7 @@ static const struct hid_device_id hid_qu +@@ -177,6 +178,7 @@ static const struct hid_device_id hid_qu { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP_LTD2, USB_DEVICE_ID_SMARTJOY_DUAL_PLUS), HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT }, { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_QUAD_USB_JOYPAD), HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT }, { HID_USB_DEVICE(USB_VENDOR_ID_XIN_MO, USB_DEVICE_ID_XIN_MO_DUAL_ARCADE), HID_QUIRK_MULTI_INPUT }, diff --git a/target/linux/bcm27xx/patches-5.4/950-0316-kbuild-Allow-.dtbo-overlays-to-be-built-piecemeal.patch b/target/linux/bcm27xx/patches-5.4/950-0316-kbuild-Allow-.dtbo-overlays-to-be-built-piecemeal.patch index 826311e9ec..24b11387e6 100644 --- a/target/linux/bcm27xx/patches-5.4/950-0316-kbuild-Allow-.dtbo-overlays-to-be-built-piecemeal.patch +++ b/target/linux/bcm27xx/patches-5.4/950-0316-kbuild-Allow-.dtbo-overlays-to-be-built-piecemeal.patch @@ -32,5 +32,5 @@ Signed-off-by: Phil Elwell + $(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@ + PHONY += dtbs dtbs_install dtbs_check - dtbs dtbs_check: include/config/kernel.release scripts_dtc + dtbs: include/config/kernel.release scripts_dtc $(Q)$(MAKE) $(build)=$(dtstree) diff --git a/target/linux/bcm27xx/patches-5.4/950-0642-component-Silence-bind-error-on-EPROBE_DEFER.patch b/target/linux/bcm27xx/patches-5.4/950-0642-component-Silence-bind-error-on-EPROBE_DEFER.patch deleted file mode 100644 index f7b1217527..0000000000 --- a/target/linux/bcm27xx/patches-5.4/950-0642-component-Silence-bind-error-on-EPROBE_DEFER.patch +++ /dev/null @@ -1,41 +0,0 @@ -From 8695764265eb6e749c9fdc901e98c2e7b4d2adfc Mon Sep 17 00:00:00 2001 -From: James Hilliard -Date: Fri, 10 Apr 2020 20:23:13 -0600 -Subject: [PATCH] component: Silence bind error on -EPROBE_DEFER - -If a component fails to bind due to -EPROBE_DEFER we should not log an -error as this is not a real failure. - -Fixes: -vc4-drm soc:gpu: failed to bind 3f902000.hdmi (ops vc4_hdmi_ops): -517 -vc4-drm soc:gpu: master bind failed: -517 - -Signed-off-by: James Hilliard ---- - drivers/base/component.c | 8 +++++--- - 1 file changed, 5 insertions(+), 3 deletions(-) - ---- a/drivers/base/component.c -+++ b/drivers/base/component.c -@@ -257,7 +257,8 @@ static int try_to_bring_up_master(struct - ret = master->ops->bind(master->dev); - if (ret < 0) { - devres_release_group(master->dev, NULL); -- dev_info(master->dev, "master bind failed: %d\n", ret); -+ if (ret != -EPROBE_DEFER) -+ dev_info(master->dev, "master bind failed: %d\n", ret); - return ret; - } - -@@ -611,8 +612,9 @@ static int component_bind(struct compone - devres_release_group(component->dev, NULL); - devres_release_group(master->dev, NULL); - -- dev_err(master->dev, "failed to bind %s (ops %ps): %d\n", -- dev_name(component->dev), component->ops, ret); -+ if (ret != -EPROBE_DEFER) -+ dev_err(master->dev, "failed to bind %s (ops %ps): %d\n", -+ dev_name(component->dev), component->ops, ret); - } - - return ret; diff --git a/target/linux/generic/pending-5.4/203-kallsyms_uncompressed.patch b/target/linux/generic/pending-5.4/203-kallsyms_uncompressed.patch index 1a3065d89f..c977b377b7 100644 --- a/target/linux/generic/pending-5.4/203-kallsyms_uncompressed.patch +++ b/target/linux/generic/pending-5.4/203-kallsyms_uncompressed.patch @@ -106,7 +106,7 @@ Signed-off-by: Felix Fietkau } --- a/scripts/link-vmlinux.sh +++ b/scripts/link-vmlinux.sh -@@ -152,6 +152,10 @@ kallsyms() +@@ -164,6 +164,10 @@ kallsyms() kallsymopt="${kallsymopt} --base-relative" fi diff --git a/target/linux/generic/pending-5.4/205-backtrace_module_info.patch b/target/linux/generic/pending-5.4/205-backtrace_module_info.patch index 857db9a930..39a4365113 100644 --- a/target/linux/generic/pending-5.4/205-backtrace_module_info.patch +++ b/target/linux/generic/pending-5.4/205-backtrace_module_info.patch @@ -11,7 +11,7 @@ Signed-off-by: Felix Fietkau --- a/lib/vsprintf.c +++ b/lib/vsprintf.c -@@ -907,8 +907,10 @@ char *symbol_string(char *buf, char *end +@@ -914,8 +914,10 @@ char *symbol_string(char *buf, char *end struct printf_spec spec, const char *fmt) { unsigned long value; @@ -23,7 +23,7 @@ Signed-off-by: Felix Fietkau #endif if (fmt[1] == 'R') -@@ -925,8 +927,14 @@ char *symbol_string(char *buf, char *end +@@ -932,8 +934,14 @@ char *symbol_string(char *buf, char *end return string_nocheck(buf, end, sym, spec); #else diff --git a/target/linux/mvebu/patches-5.4/300-mvneta-tx-queue-workaround.patch b/target/linux/mvebu/patches-5.4/300-mvneta-tx-queue-workaround.patch index 1056d801be..ff4be6006c 100644 --- a/target/linux/mvebu/patches-5.4/300-mvneta-tx-queue-workaround.patch +++ b/target/linux/mvebu/patches-5.4/300-mvneta-tx-queue-workaround.patch @@ -9,7 +9,7 @@ Signed-off-by: Felix Fietkau --- --- a/drivers/net/ethernet/marvell/mvneta.c +++ b/drivers/net/ethernet/marvell/mvneta.c -@@ -4644,6 +4644,14 @@ static int mvneta_ethtool_set_eee(struct +@@ -4652,6 +4652,14 @@ static int mvneta_ethtool_set_eee(struct return phylink_ethtool_set_eee(pp->phylink, eee); } @@ -24,7 +24,7 @@ Signed-off-by: Felix Fietkau static const struct net_device_ops mvneta_netdev_ops = { .ndo_open = mvneta_open, .ndo_stop = mvneta_stop, -@@ -4654,6 +4662,7 @@ static const struct net_device_ops mvnet +@@ -4662,6 +4670,7 @@ static const struct net_device_ops mvnet .ndo_fix_features = mvneta_fix_features, .ndo_get_stats64 = mvneta_get_stats64, .ndo_do_ioctl = mvneta_ioctl, diff --git a/target/linux/mvebu/patches-5.4/551-v5.8-arm64-dts-add-uDPU-i2c-bus-recovery.patch b/target/linux/mvebu/patches-5.4/551-v5.8-arm64-dts-add-uDPU-i2c-bus-recovery.patch index b1c508abab..53916a59e6 100644 --- a/target/linux/mvebu/patches-5.4/551-v5.8-arm64-dts-add-uDPU-i2c-bus-recovery.patch +++ b/target/linux/mvebu/patches-5.4/551-v5.8-arm64-dts-add-uDPU-i2c-bus-recovery.patch @@ -12,8 +12,6 @@ Signed-off-by: Russell King .../boot/dts/marvell/armada-3720-uDPU.dts | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) -diff --git a/arch/arm64/boot/dts/marvell/armada-3720-uDPU.dts b/arch/arm64/boot/dts/marvell/armada-3720-uDPU.dts -index 7eb6c1796cef..95d46e8d081c 100644 --- a/arch/arm64/boot/dts/marvell/armada-3720-uDPU.dts +++ b/arch/arm64/boot/dts/marvell/armada-3720-uDPU.dts @@ -117,18 +117,36 @@ @@ -55,6 +53,3 @@ index 7eb6c1796cef..95d46e8d081c 100644 lm75@48 { status = "okay"; --- -2.20.1 - From 3f8e163e0145419e88662a02717089e9582f33f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Tue, 2 Jun 2020 18:17:31 +0200 Subject: [PATCH 12/19] scripts: config: remove accidentally added file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also ignore the file. Signed-off-by: Álvaro Fernández Rojas --- scripts/config/.gitignore | 1 + scripts/config/mconf_check | 0 2 files changed, 1 insertion(+) delete mode 100644 scripts/config/mconf_check diff --git a/scripts/config/.gitignore b/scripts/config/.gitignore index 737c5b7953..bedb9757ef 100644 --- a/scripts/config/.gitignore +++ b/scripts/config/.gitignore @@ -3,6 +3,7 @@ # *.moc *conf-cfg +mconf_check # # configuration programs diff --git a/scripts/config/mconf_check b/scripts/config/mconf_check deleted file mode 100644 index e69de29bb2..0000000000 From eed8a927eeada76626dc34dc13a834a5c533efb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Tue, 2 Jun 2020 17:37:12 +0200 Subject: [PATCH 13/19] kernel: mtdsplit: bcm_wfi: refactor code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Create new parse_bcm_wfi function with common code from current parsers. Signed-off-by: Álvaro Fernández Rojas --- .../drivers/mtd/mtdsplit/mtdsplit_bcm_wfi.c | 151 ++++++++---------- 1 file changed, 69 insertions(+), 82 deletions(-) diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_bcm_wfi.c b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_bcm_wfi.c index 4e46ded587..cf57f59a58 100644 --- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_bcm_wfi.c +++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_bcm_wfi.c @@ -130,54 +130,37 @@ static int ubifs_find(struct mtd_info *mtd, loff_t *offs, loff_t size) return -ENOENT; } -static int mtdsplit_parse_bcm_wfi(struct mtd_info *master, - const struct mtd_partition **pparts, - struct mtd_part_parser_data *data) +static int parse_bcm_wfi(struct mtd_info *master, + const struct mtd_partition **pparts, + uint8_t *buf, loff_t off, loff_t size, bool cfe_part) { struct mtd_partition *parts; - struct device_node *mtd_node; loff_t cfe_off, kernel_off, rootfs_off; - bool cfe_part = true; unsigned int num_parts = BCM_WFI_PARTS, cur_part = 0; - uint8_t *buf; int ret; - buf = kzalloc(master->erasesize, GFP_KERNEL); - if (!buf) - return -ENOMEM; - - mtd_node = mtd_get_of_node(master); - if (!mtd_node) - return -EINVAL; - - if (of_property_read_bool(mtd_node, "brcm,no-cferam")) - cfe_part = false; - if (cfe_part) { num_parts++; - cfe_off = 0; + cfe_off = off; ret = jffs2_find_file(master, buf, CFERAM_NAME, CFERAM_NAME_LEN, &cfe_off, - master->size); - if (ret) { - kfree(buf); + size - (cfe_off - off)); + if (ret) return ret; - } kernel_off = cfe_off + master->erasesize; } else { - kernel_off = 0; + kernel_off = off; } ret = jffs2_find_file(master, buf, KERNEL_NAME, KERNEL_NAME_LEN, - &kernel_off, master->size); - kfree(buf); + &kernel_off, size - (kernel_off - off)); if (ret) return ret; rootfs_off = kernel_off + master->erasesize; - ret = ubifs_find(master, &rootfs_off, master->size); + ret = ubifs_find(master, &rootfs_off, size - (rootfs_off - off)); if (ret) return ret; @@ -188,14 +171,14 @@ static int mtdsplit_parse_bcm_wfi(struct mtd_info *master, if (cfe_part) { parts[cur_part].name = "cferam"; parts[cur_part].mask_flags = MTD_WRITEABLE; - parts[cur_part].offset = 0; - parts[cur_part].size = kernel_off; + parts[cur_part].offset = cfe_off; + parts[cur_part].size = kernel_off - cfe_off; cur_part++; } parts[cur_part].name = "firmware"; parts[cur_part].offset = kernel_off; - parts[cur_part].size = master->size - kernel_off; + parts[cur_part].size = size - (kernel_off - off); cur_part++; parts[cur_part].name = KERNEL_PART_NAME; @@ -205,7 +188,7 @@ static int mtdsplit_parse_bcm_wfi(struct mtd_info *master, parts[cur_part].name = UBI_PART_NAME; parts[cur_part].offset = rootfs_off; - parts[cur_part].size = master->size - rootfs_off; + parts[cur_part].size = size - (rootfs_off - off); cur_part++; *pparts = parts; @@ -213,6 +196,33 @@ static int mtdsplit_parse_bcm_wfi(struct mtd_info *master, return num_parts; } +static int mtdsplit_parse_bcm_wfi(struct mtd_info *master, + const struct mtd_partition **pparts, + struct mtd_part_parser_data *data) +{ + struct device_node *mtd_node; + bool cfe_part = true; + uint8_t *buf; + int ret; + + mtd_node = mtd_get_of_node(master); + if (!mtd_node) + return -EINVAL; + + buf = kzalloc(master->erasesize, GFP_KERNEL); + if (!buf) + return -ENOMEM; + + if (of_property_read_bool(mtd_node, "brcm,no-cferam")) + cfe_part = false; + + ret = parse_bcm_wfi(master, pparts, buf, 0, master->size, cfe_part); + + kfree(buf); + + return ret; +} + static const struct of_device_id mtdsplit_bcm_wfi_of_match[] = { { .compatible = "brcm,wfi" }, { }, @@ -256,10 +266,12 @@ static int mtdsplit_parse_ser_wfi(struct mtd_info *master, { struct mtd_info *mtd_bf1, *mtd_bf2; struct erase_info bf_erase; - struct mtd_partition *parts; - loff_t kernel_off, rootfs_off, img_size; - loff_t img2_off, img2_size = 0; - unsigned int num_parts = BCM_WFI_PARTS, cur_part = 0; + loff_t img1_off = 0; + loff_t img2_off = master->size / 2; + loff_t img1_size = (img2_off - img1_off); + loff_t img2_size = (master->size - img2_off); + loff_t active_off, inactive_off; + loff_t active_size, inactive_size; uint8_t *buf; int bf1, bf2; int ret; @@ -292,65 +304,40 @@ static int mtdsplit_parse_ser_wfi(struct mtd_info *master, } if (bf1 >= bf2) { - kernel_off = 0; - if (bf2 >= 0) { - img_size = master->size / 2; - - img2_off = img_size; - img2_size = master->size - img2_off; - num_parts++; - } else { - img_size = master->size; - } + active_off = img1_off; + active_size = img1_size; + inactive_off = img2_off; + inactive_size = img2_size; } else { - kernel_off = master->size / 2; - img_size = master->size; - - img2_off = 0; - img2_size = kernel_off; - num_parts++; + active_off = img2_off; + active_size = img2_size; + inactive_off = img1_off; + inactive_size = img1_size; } - ret = jffs2_find_file(master, buf, KERNEL_NAME, KERNEL_NAME_LEN, - &kernel_off, img_size); + ret = parse_bcm_wfi(master, pparts, buf, active_off, active_size, false); + kfree(buf); - if (ret) - return ret; - rootfs_off = kernel_off + master->erasesize; - ret = ubifs_find(master, &rootfs_off, img_size); - if (ret) - return ret; + if (ret > 0) { + struct mtd_partition *parts; - parts = kzalloc(num_parts * sizeof(*parts), GFP_KERNEL); - if (!parts) - return -ENOMEM; + parts = kzalloc((ret + 1) * sizeof(*parts), GFP_KERNEL); + if (!parts) + return -ENOMEM; - parts[cur_part].name = "firmware"; - parts[cur_part].offset = kernel_off; - parts[cur_part].size = img_size - kernel_off; - cur_part++; + memcpy(parts, *pparts, ret * sizeof(*parts)); + kfree(*pparts); - parts[cur_part].name = KERNEL_PART_NAME; - parts[cur_part].offset = kernel_off; - parts[cur_part].size = rootfs_off - kernel_off; - cur_part++; + parts[ret].name = "img2"; + parts[ret].offset = inactive_off; + parts[ret].size = inactive_size; + ret++; - parts[cur_part].name = UBI_PART_NAME; - parts[cur_part].offset = rootfs_off; - parts[cur_part].size = img_size - rootfs_off; - cur_part++; - - if (img2_size) { - parts[cur_part].name = "img2"; - parts[cur_part].offset = img2_off; - parts[cur_part].size = img2_size; - cur_part++; + *pparts = parts; } - *pparts = parts; - - return num_parts; + return ret; } static const struct of_device_id mtdsplit_ser_wfi_of_match[] = { From 1fd3dabfaf189f4ebe23c131b260fda52cc7f002 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Tue, 2 Jun 2020 17:47:57 +0200 Subject: [PATCH 14/19] kernel: mtdsplit: improve JFFS2 scan MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Allow retrieving full file name and length by parameters. Signed-off-by: Álvaro Fernández Rojas --- .../drivers/mtd/mtdsplit/mtdsplit_bcm_wfi.c | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_bcm_wfi.c b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_bcm_wfi.c index cf57f59a58..7487567ed5 100644 --- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_bcm_wfi.c +++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_bcm_wfi.c @@ -57,7 +57,8 @@ static bool jffs2_dirent_valid(struct jffs2_raw_dirent *node) static int jffs2_find_file(struct mtd_info *mtd, uint8_t *buf, const char *name, size_t name_len, - loff_t *offs, loff_t size) + loff_t *offs, loff_t size, + char **out_name, size_t *out_name_len) { const loff_t end = *offs + size; struct jffs2_raw_dirent *node; @@ -97,10 +98,22 @@ static int jffs2_find_file(struct mtd_info *mtd, uint8_t *buf, } if (!memcmp(node->name, OPENWRT_NAME, - OPENWRT_NAME_LEN)) + OPENWRT_NAME_LEN)) { valid = true; - else if (!memcmp(node->name, name, name_len)) - return valid ? 0 : -EINVAL; + } else if (!memcmp(node->name, name, name_len)) { + if (!valid) + return -EINVAL; + + if (out_name) + *out_name = kstrndup(node->name, + node->nsize, + GFP_KERNEL); + + if (out_name_len) + *out_name_len = node->nsize; + + return 0; + } block_offs += je32_to_cpu(node->totlen); block_offs = (block_offs + 0x3) & ~0x3; @@ -145,7 +158,7 @@ static int parse_bcm_wfi(struct mtd_info *master, ret = jffs2_find_file(master, buf, CFERAM_NAME, CFERAM_NAME_LEN, &cfe_off, - size - (cfe_off - off)); + size - (cfe_off - off), NULL, NULL); if (ret) return ret; @@ -155,7 +168,8 @@ static int parse_bcm_wfi(struct mtd_info *master, } ret = jffs2_find_file(master, buf, KERNEL_NAME, KERNEL_NAME_LEN, - &kernel_off, size - (kernel_off - off)); + &kernel_off, size - (kernel_off - off), + NULL, NULL); if (ret) return ret; From 18d2eeab8e4b12fd8c1083a760cf00e519a913f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Tue, 2 Jun 2020 17:52:12 +0200 Subject: [PATCH 15/19] kernel: mtdsplit: support Broadcom WFI bootflags MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When firmware is flashed, cferam.000 extension is renamed to the next number. When booting, CFE scans the NAND and picks the partition with the highest cferam extension and ignores the other one. Signed-off-by: Álvaro Fernández Rojas --- .../drivers/mtd/mtdsplit/mtdsplit_bcm_wfi.c | 110 ++++++++++++++++++ 1 file changed, 110 insertions(+) diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_bcm_wfi.c b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_bcm_wfi.c index 7487567ed5..56bcff31c2 100644 --- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_bcm_wfi.c +++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_bcm_wfi.c @@ -37,6 +37,10 @@ #define UBI_MAGIC 0x55424923 +#define CFE_MAGIC_PFX "cferam." +#define CFE_MAGIC_PFX_LEN (sizeof(CFE_MAGIC_PFX) - 1) +#define CFE_MAGIC "cferam.000" +#define CFE_MAGIC_LEN (sizeof(CFE_MAGIC) - 1) #define SERCOMM_MAGIC_PFX "eRcOmM." #define SERCOMM_MAGIC_PFX_LEN (sizeof(SERCOMM_MAGIC_PFX) - 1) #define SERCOMM_MAGIC "eRcOmM.000" @@ -250,6 +254,111 @@ static struct mtd_part_parser mtdsplit_bcm_wfi_parser = { .type = MTD_PARSER_TYPE_FIRMWARE, }; +static int cferam_bootflag_value(const char *name, size_t name_len) +{ + int rc = -ENOENT; + + if (name && + (name_len >= CFE_MAGIC_LEN) && + !memcmp(name, CFE_MAGIC_PFX, CFE_MAGIC_PFX_LEN)) { + rc = char_to_num(name[CFE_MAGIC_PFX_LEN + 0]) * 100; + rc += char_to_num(name[CFE_MAGIC_PFX_LEN + 1]) * 10; + rc += char_to_num(name[CFE_MAGIC_PFX_LEN + 2]) * 1; + } + + return rc; +} + +static int mtdsplit_parse_bcm_wfi_split(struct mtd_info *master, + const struct mtd_partition **pparts, + struct mtd_part_parser_data *data) +{ + loff_t cfe_off; + loff_t img1_off = 0; + loff_t img2_off = master->size / 2; + loff_t img1_size = (img2_off - img1_off); + loff_t img2_size = (master->size - img2_off); + loff_t active_off, inactive_off; + loff_t active_size, inactive_size; + uint8_t *buf; + char *cfe1_name = NULL, *cfe2_name = NULL; + size_t cfe1_size = 0, cfe2_size = 0; + int ret; + int bf1, bf2; + + buf = kzalloc(master->erasesize, GFP_KERNEL); + if (!buf) + return -ENOMEM; + + cfe_off = img1_off; + ret = jffs2_find_file(master, buf, CFERAM_NAME, CFERAM_NAME_LEN, + &cfe_off, img1_size, &cfe1_name, &cfe1_size); + + cfe_off = img2_off; + ret = jffs2_find_file(master, buf, CFERAM_NAME, CFERAM_NAME_LEN, + &cfe_off, img2_size, &cfe2_name, &cfe2_size); + + bf1 = cferam_bootflag_value(cfe1_name, cfe1_size); + if (bf1 >= 0) + printk("cferam: bootflag1=%d\n", bf1); + + bf2 = cferam_bootflag_value(cfe2_name, cfe2_size); + if (bf2 >= 0) + printk("cferam: bootflag2=%d\n", bf2); + + kfree(cfe1_name); + kfree(cfe2_name); + + if (bf1 >= bf2) { + active_off = img1_off; + active_size = img1_size; + inactive_off = img2_off; + inactive_size = img2_size; + } else { + active_off = img2_off; + active_size = img2_size; + inactive_off = img1_off; + inactive_size = img1_size; + } + + ret = parse_bcm_wfi(master, pparts, buf, active_off, active_size, true); + + kfree(buf); + + if (ret > 0) { + struct mtd_partition *parts; + + parts = kzalloc((ret + 1) * sizeof(*parts), GFP_KERNEL); + if (!parts) + return -ENOMEM; + + memcpy(parts, *pparts, ret * sizeof(*parts)); + kfree(*pparts); + + parts[ret].name = "img2"; + parts[ret].offset = inactive_off; + parts[ret].size = inactive_size; + ret++; + + *pparts = parts; + } + + return ret; +} + +static const struct of_device_id mtdsplit_bcm_wfi_split_of_match[] = { + { .compatible = "brcm,wfi-split" }, + { }, +}; + +static struct mtd_part_parser mtdsplit_bcm_wfi_split_parser = { + .owner = THIS_MODULE, + .name = "bcm-wfi-split-fw", + .of_match_table = mtdsplit_bcm_wfi_split_of_match, + .parse_fn = mtdsplit_parse_bcm_wfi_split, + .type = MTD_PARSER_TYPE_FIRMWARE, +}; + static int sercomm_bootflag_value(struct mtd_info *mtd, uint8_t *buf) { size_t retlen; @@ -370,6 +479,7 @@ static struct mtd_part_parser mtdsplit_ser_wfi_parser = { static int __init mtdsplit_bcm_wfi_init(void) { register_mtd_parser(&mtdsplit_bcm_wfi_parser); + register_mtd_parser(&mtdsplit_bcm_wfi_split_parser); register_mtd_parser(&mtdsplit_ser_wfi_parser); return 0; From 824cb78cf33524b335bd51c7241231bf13b48cd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Tue, 2 Jun 2020 17:56:31 +0200 Subject: [PATCH 16/19] bcm63xx: nand: add CFE_WFI_VERSION values for each device MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CFE_WFI_VERSION should be defined per device instead of using a generic value. Signed-off-by: Álvaro Fernández Rojas --- target/linux/bcm63xx/image/bcm63xx_nand.mk | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/target/linux/bcm63xx/image/bcm63xx_nand.mk b/target/linux/bcm63xx/image/bcm63xx_nand.mk index 7dff893e4f..a42c469197 100644 --- a/target/linux/bcm63xx/image/bcm63xx_nand.mk +++ b/target/linux/bcm63xx/image/bcm63xx_nand.mk @@ -28,7 +28,7 @@ define Device/bcm63xx-nand CFE_RAM_FILE := CFE_RAM_JFFS2_NAME := CFE_RAM_JFFS2_PAD := - CFE_WFI_VERSION := 0x5731 + CFE_WFI_VERSION := CFE_WFI_CHIP_ID = 0x$$(CHIP_ID) CFE_WFI_FLASH_TYPE := CFE_WFI_FLAGS := @@ -59,6 +59,7 @@ define Device/comtrend_vr-3032u SUBPAGESIZE := 512 VID_HDR_OFFSET := 2048 DEVICE_PACKAGES += $(USB2_PACKAGES) + CFE_WFI_VERSION := 0x5731 CFE_WFI_FLASH_TYPE := 3 endef TARGET_DEVICES += comtrend_vr-3032u @@ -76,6 +77,7 @@ define Device/comtrend_vg-8050 SUBPAGESIZE := 512 VID_HDR_OFFSET := 2048 DEVICE_PACKAGES += $(USB2_PACKAGES) + CFE_WFI_VERSION := 0x5731 CFE_WFI_FLASH_TYPE := 3 endef TARGET_DEVICES += comtrend_vg-8050 @@ -115,6 +117,7 @@ define Device/netgear_dgnd3700-v2 BLOCKSIZE := 16k PAGESIZE := 512 DEVICE_PACKAGES += $(B43_PACKAGES) $(USB2_PACKAGES) + CFE_WFI_VERSION := 0x5731 CFE_WFI_FLASH_TYPE := 2 endef TARGET_DEVICES += netgear_dgnd3700-v2 @@ -134,6 +137,7 @@ define Device/sercomm_ad1018 VID_HDR_OFFSET := 2048 DEVICE_PACKAGES += $(B43_PACKAGES) $(USB2_PACKAGES) CFE_WFI_FLASH_TYPE := 3 + CFE_WFI_VERSION := 0x5731 SERCOMM_PID := \ 30 30 30 30 30 30 30 31 34 31 35 31 35 33 30 30 \ 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 \ From 82cf488819d947134ff0bb552508e87dc3cb67b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Tue, 2 Jun 2020 17:59:24 +0200 Subject: [PATCH 17/19] bcm63xx: nand: order devices alphabetically MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Álvaro Fernández Rojas --- target/linux/bcm63xx/image/bcm63xx_nand.mk | 36 +++++++++++----------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/target/linux/bcm63xx/image/bcm63xx_nand.mk b/target/linux/bcm63xx/image/bcm63xx_nand.mk index a42c469197..f0441c0f0a 100644 --- a/target/linux/bcm63xx/image/bcm63xx_nand.mk +++ b/target/linux/bcm63xx/image/bcm63xx_nand.mk @@ -46,24 +46,6 @@ define Device/sercomm-nand endef ### Comtrend ### -define Device/comtrend_vr-3032u - $(Device/bcm63xx-nand) - DEVICE_VENDOR := Comtrend - DEVICE_MODEL := VR-3032u - CHIP_ID := 63268 - SOC := bcm63168 - CFE_RAM_FILE := comtrend,vr-3032u/cferam.000 - CFE_RAM_JFFS2_NAME := cferam.000 - BLOCKSIZE := 128k - PAGESIZE := 2048 - SUBPAGESIZE := 512 - VID_HDR_OFFSET := 2048 - DEVICE_PACKAGES += $(USB2_PACKAGES) - CFE_WFI_VERSION := 0x5731 - CFE_WFI_FLASH_TYPE := 3 -endef -TARGET_DEVICES += comtrend_vr-3032u - define Device/comtrend_vg-8050 $(Device/bcm63xx-nand) DEVICE_VENDOR := Comtrend @@ -82,6 +64,24 @@ define Device/comtrend_vg-8050 endef TARGET_DEVICES += comtrend_vg-8050 +define Device/comtrend_vr-3032u + $(Device/bcm63xx-nand) + DEVICE_VENDOR := Comtrend + DEVICE_MODEL := VR-3032u + CHIP_ID := 63268 + SOC := bcm63168 + CFE_RAM_FILE := comtrend,vr-3032u/cferam.000 + CFE_RAM_JFFS2_NAME := cferam.000 + BLOCKSIZE := 128k + PAGESIZE := 2048 + SUBPAGESIZE := 512 + VID_HDR_OFFSET := 2048 + DEVICE_PACKAGES += $(USB2_PACKAGES) + CFE_WFI_VERSION := 0x5731 + CFE_WFI_FLASH_TYPE := 3 +endef +TARGET_DEVICES += comtrend_vr-3032u + ### Huawei ### define Device/huawei_hg253s-v2 $(Device/bcm63xx-nand) From b1d375b744199181e2c131b9098700e99777509d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Tue, 2 Jun 2020 18:00:10 +0200 Subject: [PATCH 18/19] bcm63xx: vr-3032u: switch to bcm-wfi-split MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Allows to keep a backup firmware in case active firmware is corrupted. Signed-off-by: Álvaro Fernández Rojas --- target/linux/bcm63xx/dts/bcm63168-comtrend-vr-3032u.dts | 4 ++-- target/linux/bcm63xx/image/bcm63xx_nand.mk | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/target/linux/bcm63xx/dts/bcm63168-comtrend-vr-3032u.dts b/target/linux/bcm63xx/dts/bcm63168-comtrend-vr-3032u.dts index cc96c403b6..af44b66756 100644 --- a/target/linux/bcm63xx/dts/bcm63168-comtrend-vr-3032u.dts +++ b/target/linux/bcm63xx/dts/bcm63168-comtrend-vr-3032u.dts @@ -172,9 +172,9 @@ }; partition@20000 { - compatible = "brcm,wfi"; + compatible = "brcm,wfi-split"; label = "wfi"; - reg = <0x0020000 0x7ee0000>; + reg = <0x0020000 0x7a80000>; }; }; }; diff --git a/target/linux/bcm63xx/image/bcm63xx_nand.mk b/target/linux/bcm63xx/image/bcm63xx_nand.mk index f0441c0f0a..e1aeed66db 100644 --- a/target/linux/bcm63xx/image/bcm63xx_nand.mk +++ b/target/linux/bcm63xx/image/bcm63xx_nand.mk @@ -77,7 +77,7 @@ define Device/comtrend_vr-3032u SUBPAGESIZE := 512 VID_HDR_OFFSET := 2048 DEVICE_PACKAGES += $(USB2_PACKAGES) - CFE_WFI_VERSION := 0x5731 + CFE_WFI_VERSION := 0x5732 CFE_WFI_FLASH_TYPE := 3 endef TARGET_DEVICES += comtrend_vr-3032u From e73c61a978c56d41a2cdae4b5a2ca660aec4931b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Tue, 2 Jun 2020 18:04:45 +0200 Subject: [PATCH 19/19] bcm63xx: vg-8050: switch to bcm-wfi-split MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Allows to keep a backup firmware in case active firmware is corrupted. Also fix hsspi address warning. Signed-off-by: Álvaro Fernández Rojas --- target/linux/bcm63xx/dts/bcm63169-comtrend-vg-8050.dts | 10 +++++----- target/linux/bcm63xx/image/bcm63xx_nand.mk | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/target/linux/bcm63xx/dts/bcm63169-comtrend-vg-8050.dts b/target/linux/bcm63xx/dts/bcm63169-comtrend-vg-8050.dts index 93a1cb8fa1..01158a3791 100644 --- a/target/linux/bcm63xx/dts/bcm63169-comtrend-vg-8050.dts +++ b/target/linux/bcm63xx/dts/bcm63169-comtrend-vg-8050.dts @@ -107,7 +107,7 @@ pinctrl-names = "default"; pinctrl-0 = <&pinctrl_hsspi_cs5>; - switch@0 { + switch@5 { compatible = "brcm,bcm53125"; reg = <5>; spi-max-frequency = <781000>; @@ -178,16 +178,16 @@ #address-cells = <1>; #size-cells = <1>; - cferom@0 { + partition@0 { label = "cferom"; reg = <0x0000000 0x0020000>; read-only; }; - wfi@20000 { - compatible = "brcm,wfi"; + partition@20000 { + compatible = "brcm,wfi-split"; label = "wfi"; - reg = <0x0020000 0x7ee0000>; + reg = <0x0020000 0x7a80000>; }; }; }; diff --git a/target/linux/bcm63xx/image/bcm63xx_nand.mk b/target/linux/bcm63xx/image/bcm63xx_nand.mk index e1aeed66db..74f23f52af 100644 --- a/target/linux/bcm63xx/image/bcm63xx_nand.mk +++ b/target/linux/bcm63xx/image/bcm63xx_nand.mk @@ -59,7 +59,7 @@ define Device/comtrend_vg-8050 SUBPAGESIZE := 512 VID_HDR_OFFSET := 2048 DEVICE_PACKAGES += $(USB2_PACKAGES) - CFE_WFI_VERSION := 0x5731 + CFE_WFI_VERSION := 0x5732 CFE_WFI_FLASH_TYPE := 3 endef TARGET_DEVICES += comtrend_vg-8050