From 93f6d0d8fc4689106963dc429dc676d1cd659aad Mon Sep 17 00:00:00 2001 From: Ram Kumar D Date: Thu, 13 Jul 2023 17:00:32 +0530 Subject: [PATCH 1/4] arch: arm: dts: add support boot linux 6.1 images This patch add supports to boot linux 6.1 images on IPQ5332 & IPQ9574 DB boards. Change-Id: Ifd9fb1b74c248ffc625c7c49fc96dd7d16a8670f Signed-off-by: Ram Kumar D --- arch/arm/dts/ipq5332-db-mi01.1.dts | 2 +- arch/arm/dts/ipq5332-db-mi02.1.dts | 2 +- arch/arm/dts/ipq5332-db-mi03.1.dts | 2 +- arch/arm/dts/ipq9574-db-al01-c1.dts | 2 +- arch/arm/dts/ipq9574-db-al01-c2.dts | 2 +- arch/arm/dts/ipq9574-db-al01-c3.dts | 2 +- arch/arm/dts/ipq9574-db-al02-c1.dts | 2 +- arch/arm/dts/ipq9574-db-al02-c2.dts | 2 +- arch/arm/dts/ipq9574-db-al02-c3.dts | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/arch/arm/dts/ipq5332-db-mi01.1.dts b/arch/arm/dts/ipq5332-db-mi01.1.dts index 06320e7c45..90309066ca 100644 --- a/arch/arm/dts/ipq5332-db-mi01.1.dts +++ b/arch/arm/dts/ipq5332-db-mi01.1.dts @@ -17,7 +17,7 @@ #include "ipq5332-soc.dtsi" / { machid = <0x1060001>; - config_name = "config@db-mi01.1"; + config_name = "config@db-mi01.1", "config-db-mi01.1"; aliases { console = "/serial@78AF000"; diff --git a/arch/arm/dts/ipq5332-db-mi02.1.dts b/arch/arm/dts/ipq5332-db-mi02.1.dts index 77d7ad8867..515f68e6b8 100644 --- a/arch/arm/dts/ipq5332-db-mi02.1.dts +++ b/arch/arm/dts/ipq5332-db-mi02.1.dts @@ -17,7 +17,7 @@ #include "ipq5332-soc.dtsi" / { machid = <0x1060003>; - config_name = "config@db-mi02.1"; + config_name = "config@db-mi02.1", "config-db-mi02.1"; aliases { console = "/serial@78AF000"; diff --git a/arch/arm/dts/ipq5332-db-mi03.1.dts b/arch/arm/dts/ipq5332-db-mi03.1.dts index edf788ea4e..0e5fe1b47d 100644 --- a/arch/arm/dts/ipq5332-db-mi03.1.dts +++ b/arch/arm/dts/ipq5332-db-mi03.1.dts @@ -17,7 +17,7 @@ #include "ipq5332-soc.dtsi" / { machid = <0x1060002>; - config_name = "config@db-mi03.1"; + config_name = "config@db-mi03.1", "config-db-mi03.1"; aliases { console = "/serial@78AF000"; diff --git a/arch/arm/dts/ipq9574-db-al01-c1.dts b/arch/arm/dts/ipq9574-db-al01-c1.dts index 56d08ee391..d528a0bd07 100644 --- a/arch/arm/dts/ipq9574-db-al01-c1.dts +++ b/arch/arm/dts/ipq9574-db-al01-c1.dts @@ -15,7 +15,7 @@ #include "ipq9574-soc.dtsi" / { machid = <0x1050000>; - config_name = "config@db-al01-c1"; + config_name = "config@db-al01-c1", "config-db-al01-c1"; aliases { console = "/serial@78B1000"; diff --git a/arch/arm/dts/ipq9574-db-al01-c2.dts b/arch/arm/dts/ipq9574-db-al01-c2.dts index a5d54ea7b2..a6e3bfe9c9 100644 --- a/arch/arm/dts/ipq9574-db-al01-c2.dts +++ b/arch/arm/dts/ipq9574-db-al01-c2.dts @@ -15,7 +15,7 @@ #include "ipq9574-db-al01-c1.dts" / { machid = <0x1050100>; - config_name = "config@db-al01-c2"; + config_name = "config@db-al01-c2", "config-db-al01-c2"; aliases { mmc = "/sdhci@7804000"; diff --git a/arch/arm/dts/ipq9574-db-al01-c3.dts b/arch/arm/dts/ipq9574-db-al01-c3.dts index 224ffd5694..57a0935663 100644 --- a/arch/arm/dts/ipq9574-db-al01-c3.dts +++ b/arch/arm/dts/ipq9574-db-al01-c3.dts @@ -15,7 +15,7 @@ #include "ipq9574-db-al01-c1.dts" / { machid = <0x1050200>; - config_name = "config@db-al01-c3"; + config_name = "config@db-al01-c3", "config-db-al01-c3"; ess-switch { /* Overriding port6 configuration to support AQ instead diff --git a/arch/arm/dts/ipq9574-db-al02-c1.dts b/arch/arm/dts/ipq9574-db-al02-c1.dts index af3724f049..83a1d2c9eb 100644 --- a/arch/arm/dts/ipq9574-db-al02-c1.dts +++ b/arch/arm/dts/ipq9574-db-al02-c1.dts @@ -15,7 +15,7 @@ #include "ipq9574-soc.dtsi" / { machid = <0x1050001>; - config_name = "config@db-al02-c1"; + config_name = "config@db-al02-c1", "config-db-al02-c1"; aliases { console = "/serial@78B1000"; diff --git a/arch/arm/dts/ipq9574-db-al02-c2.dts b/arch/arm/dts/ipq9574-db-al02-c2.dts index 724783cb2d..41b1d689a2 100644 --- a/arch/arm/dts/ipq9574-db-al02-c2.dts +++ b/arch/arm/dts/ipq9574-db-al02-c2.dts @@ -15,7 +15,7 @@ #include "ipq9574-db-al02-c1.dts" / { machid = <0x1050101>; - config_name = "config@db-al02-c2"; + config_name = "config@db-al02-c2", "config-db-al02-c2"; aliases { mmc = "/sdhci@7804000"; diff --git a/arch/arm/dts/ipq9574-db-al02-c3.dts b/arch/arm/dts/ipq9574-db-al02-c3.dts index 823833e1e6..bbe8f505f5 100644 --- a/arch/arm/dts/ipq9574-db-al02-c3.dts +++ b/arch/arm/dts/ipq9574-db-al02-c3.dts @@ -15,7 +15,7 @@ #include "ipq9574-db-al02-c1.dts" / { machid = <0x1050201>; - config_name = "config@db-al02-c3"; + config_name = "config@db-al02-c3", "config-db-al02-c3"; aliases { i2c0 = "/i2c@78B9000"; From 6814dfbb98adf285d41feeed248b76e9c3c863e5 Mon Sep 17 00:00:00 2001 From: Vijay Balaji Date: Mon, 17 Jul 2023 16:21:05 +0530 Subject: [PATCH 2/4] sysupgrade : add support to extract rootfs binary This change adds support to extract rootfs binary till correct data-block offset and replaces the binary for image authentication in both EMMC and Nand flashtypes. Change-Id: Ib56228a620ffc5bcfae8b51682377b68e273484f Signed-off-by: Vijay Balaji --- tools/sysupgrade.c | 52 ++++++++++++++++++---------------------------- 1 file changed, 20 insertions(+), 32 deletions(-) diff --git a/tools/sysupgrade.c b/tools/sysupgrade.c index d19bf3e338..d522bd7c59 100644 --- a/tools/sysupgrade.c +++ b/tools/sysupgrade.c @@ -24,7 +24,10 @@ #define AUTHENTICATE_FILE "/sys/devices/system/qfprom/qfprom0/authenticate" #define SEC_AUTHENTICATE_FILE "/sys/sec_upgrade/sec_auth" #define TEMP_KERNEL_PATH "/tmp/tmp_kernel.bin" -#define TEMP_ROOTFS_PATH "/tmp/rootfs.bin" +#define TEMP_ROOTFS_PATH "/tmp/rootfs_tmp.bin" +#define TEMP_METADATA_PATH "/tmp/metadata.bin" +#define TEMP_SHA_KEY_PATH "/tmp/sha_keyXXXXXX" +#define ROOTFS_OFFSET 65536 #define MAX_SBL_VERSION 11 #define MAX_HLOS_VERSION 32 #define MAX_TZ_VERSION 14 @@ -818,6 +821,7 @@ int extract_kernel_binary(struct image_section *section, char *volname) { char *ifname, *ofname; + strlcpy(section->file, TEMP_KERNEL_PATH, sizeof(TEMP_KERNEL_PATH)); ifname = section->tmp_file; ofname = section->file; @@ -903,7 +907,6 @@ int extract_ubi_volume(char *vol_name, char *if_name, char *of_name) close(fd); return 0; } - curr_vol_id = be32_to_cpu(ubi_vol->vol_id); if (curr_vol_id == ret_vol_id) { if (!strncmp(vol_name, "ubi_rootfs", strlen("ubi_rootfs"))) { @@ -915,7 +918,7 @@ int extract_ubi_volume(char *vol_name, char *if_name, char *of_name) int byte = 0; while (byte < max_limit) { if ((*(tmp+byte) == 0xde) && (*(tmp+byte+1) == 0xad) && (*(tmp+byte+2) == 0xc0) && (*(tmp+byte+3) == 0xde)) { - data_size = byte + 4; + data_size = byte; } byte = byte + 1; } @@ -939,6 +942,9 @@ int extract_ubi_volume(char *vol_name, char *if_name, char *of_name) } close(ofd); close(fd); + if (!strncmp(vol_name, "ubi_rootfs", strlen("ubi_rootfs"))) { + extract_rootfs_binary(of_name); + } printf("%s extracted from ubi image\n", vol_name); return 1; } @@ -983,7 +989,7 @@ char * check_image_exist(char *imgname) { int extract_rootfs_binary(char *filename) { - int ifd, ofd; + int ifd; uint8_t *fp; struct stat sb; @@ -991,7 +997,7 @@ int extract_rootfs_binary(char *filename) return 0; } - ifd = open(filename, O_RDONLY); + ifd = open(filename, O_RDWR); if (ifd < 0) { perror(filename); return 0; @@ -1011,42 +1017,24 @@ int extract_rootfs_binary(char *filename) return 0; } - ofd = open(TEMP_ROOTFS_PATH, O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR); - if (ofd < 0) { - perror("fopen"); - close(ifd); - return 0; - } - int offset = 0,dead_off; while ( offset < sb.st_size) { if ((fp[offset] == 0xde) && (fp[offset+1] == 0xad) && (fp[offset+2] == 0xc0) && (fp[offset+3] == 0xde)) { dead_off=offset; + break; } - offset = offset + 4096; - } - - if((write(ofd, fp, dead_off+4)) == -1) { - printf("Write error\n"); - close(ifd); - close(ofd); - return 0; + offset += ROOTFS_OFFSET; } if (munmap(fp, sb.st_size) == -1) { perror("munmap"); close(ifd); - close(ofd); return 0; } close(ifd); - close(ofd); - - if (rename(TEMP_ROOTFS_PATH, filename) != 0) { - printf("Error renaming file\n"); - } + truncate(filename, dead_off); return 1; } @@ -1056,7 +1044,7 @@ int extract_rootfs_binary(char *filename) */ int compute_sha_hash(struct image_section *section) { - char sha_hash[] = "/tmp/sha_keyXXXXXX"; + char sha_hash[] = TEMP_SHA_KEY_PATH; char command[300]; int retval; @@ -1415,8 +1403,8 @@ int parse_elf_image_phdr(struct image_section *section) printf("rootfs metada is not available\n"); return 1; } - create_file("/tmp/metadata.bin", (char *)(fp + phdr->p_offset + phdr->p_filesz), size); - printf("rootfs meta data file: %s created with size:%x\n","/tmp/metadata.bin", size); + create_file(TEMP_METADATA_PATH, (char *)(fp + phdr->p_offset + phdr->p_filesz), size); + printf("rootfs meta data file: %s created with size:%x\n",TEMP_METADATA_PATH, size); close(fd); return 1; @@ -1779,14 +1767,13 @@ int sec_image_auth(void) } len = snprintf(buf, SIG_SIZE, "%s %s", sections[i].img_code, sections[i].file); - if (!strncmp(sections[i].type, "rootfs", strlen("rootfs"))) { struct stat sb; - if (stat("/tmp/metadata.bin", &sb) == -1) + if (stat(TEMP_METADATA_PATH, &sb) == -1) continue; len = snprintf(buf, SIG_SIZE, "%s %s %s", sections[i].img_code, - "/tmp/metadata.bin", "/tmp/sha_keyXXXXXX"); + TEMP_METADATA_PATH, TEMP_SHA_KEY_PATH); } if (len < 0 || len > SIG_SIZE) { @@ -1805,6 +1792,7 @@ int sec_image_auth(void) } close(fd); free(buf); + remove_file(TEMP_KERNEL_PATH,TEMP_ROOTFS_PATH, TEMP_METADATA_PATH, TEMP_SHA_KEY_PATH); return 0; } From ad1d2f114401937ce1d006c383d28c791ef254c8 Mon Sep 17 00:00:00 2001 From: Karthick Shanmugham Date: Fri, 14 Jul 2023 11:29:29 +0530 Subject: [PATCH 3/4] board: qca: ipq9574: Add atf crypto fixup support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This changes fixup "qcom,controlled-remotely" property and "qti,config-pipe-trust-reg" property in the crypto bam node in ATF boot. This will enable the kernel to do complete bam pipe initialization. Change-Id: I454c4e4e68354506dc16b1e72b514264778314e0 Signed-off-by: Karthick Shanmugham --- board/qca/arm/ipq9574/ipq9574.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/board/qca/arm/ipq9574/ipq9574.c b/board/qca/arm/ipq9574/ipq9574.c index 84e566c170..2f26d6f805 100644 --- a/board/qca/arm/ipq9574/ipq9574.c +++ b/board/qca/arm/ipq9574/ipq9574.c @@ -1477,6 +1477,16 @@ void ipq_uboot_fdt_fixup(void) return; } +void fdt_fixup_for_atf(void *blob) +{ + if (fdt_path_offset(blob, "/soc/dma@704000") >= 0) { + parse_fdt_fixup("/soc/dma@704000%qcom,controlled-remotely%0", + blob); + parse_fdt_fixup("/soc/dma@704000%qti,config-pipe-trust-reg%2", + blob); + } +} + int do_dpr(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) { int ret; From 91b45367198811ed1a4864f63ee3a1fe300709d7 Mon Sep 17 00:00:00 2001 From: Vijay Balaji Date: Fri, 21 Jul 2023 18:28:18 +0530 Subject: [PATCH 4/4] sysupgrade : removed unused code We want to extract rootfs image from ubi without any changes, as we are traversing through the rootfs image for 0xdeadc0de in extract_rootfs_binary() to extract the image till 0xdeadc0de offset. Change-Id: Iefeec6db72b65310310d74835b68ec3d22144608 Signed-off-by: Vijay Balaji --- tools/sysupgrade.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/tools/sysupgrade.c b/tools/sysupgrade.c index d522bd7c59..eba81f1c7e 100644 --- a/tools/sysupgrade.c +++ b/tools/sysupgrade.c @@ -909,21 +909,6 @@ int extract_ubi_volume(char *vol_name, char *if_name, char *of_name) } curr_vol_id = be32_to_cpu(ubi_vol->vol_id); if (curr_vol_id == ret_vol_id) { - if (!strncmp(vol_name, "ubi_rootfs", strlen("ubi_rootfs"))) { - struct ubi_ec_hdr *ubi_ec_next = (struct ubi_ec_hdr *)((uint8_t *)ubi_ec + data_offset + data_size); - int magic = be32_to_cpu(ubi_ec_next->magic); - if(magic != UBI_EC_HDR_MAGIC) { - uint8_t *tmp = (uint8_t *)ubi_ec + data_offset; - int max_limit = data_size; - int byte = 0; - while (byte < max_limit) { - if ((*(tmp+byte) == 0xde) && (*(tmp+byte+1) == 0xad) && (*(tmp+byte+2) == 0xc0) && (*(tmp+byte+3) == 0xde)) { - data_size = byte; - } - byte = byte + 1; - } - } - } if (write(ofd, (void *)((uint8_t *)ubi_ec + data_offset), data_size) == -1) { printf("Write error\n"); close(fd); @@ -1018,7 +1003,7 @@ int extract_rootfs_binary(char *filename) } int offset = 0,dead_off; - while ( offset < sb.st_size) + while ( offset <= sb.st_size) { if ((fp[offset] == 0xde) && (fp[offset+1] == 0xad) && (fp[offset+2] == 0xc0) && (fp[offset+3] == 0xde)) { dead_off=offset;