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"; 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; diff --git a/tools/sysupgrade.c b/tools/sysupgrade.c index d19bf3e338..eba81f1c7e 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,24 +907,8 @@ 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"))) { - 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 + 4; - } - byte = byte + 1; - } - } - } if (write(ofd, (void *)((uint8_t *)ubi_ec + data_offset), data_size) == -1) { printf("Write error\n"); close(fd); @@ -939,6 +927,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 +974,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 +982,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 +1002,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) + 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 +1029,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 +1388,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 +1752,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 +1777,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; }