X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=tools%2Fzynqmpimage.c;h=0c9a3daddd6a9a6e14586fe1092f1203b151072e;hb=b7b24a7a3cd74bb165d28a2959ed9143e3648fbf;hp=3f28eb401d9b439007b98083843a97cdb0a9345c;hpb=ec8fb48ce98987065493b27422200897cf0909f8;p=u-boot diff --git a/tools/zynqmpimage.c b/tools/zynqmpimage.c index 3f28eb401d..0c9a3daddd 100644 --- a/tools/zynqmpimage.c +++ b/tools/zynqmpimage.c @@ -234,6 +234,44 @@ static int zynqmpimage_check_image_types(uint8_t type) return EXIT_FAILURE; } +static void zynqmpimage_parse_initparams(struct zynqmp_header *zynqhdr, + const char *filename) +{ + FILE *fp; + struct zynqmp_reginit reginit; + unsigned int reg_count = 0; + int r, err; + struct stat path_stat; + + /* Expect a table of register-value pairs, e.g. "0x12345678 0x4321" */ + fp = fopen(filename, "r"); + if (!fp) { + fprintf(stderr, "Cannot open initparams file: %s\n", filename); + exit(1); + } + + err = fstat(fileno(fp), &path_stat); + if (err) { + fclose(fp); + return; + } + + if (!S_ISREG(path_stat.st_mode)) { + fclose(fp); + return; + } + + do { + r = fscanf(fp, "%x %x", ®init.address, ®init.data); + if (r == 2) { + zynqhdr->register_init[reg_count] = reginit; + ++reg_count; + } + r = fscanf(fp, "%*[^\n]\n"); /* Skip to next line */ + } while ((r != EOF) && (reg_count < HEADER_REGINITS)); + fclose(fp); +} + static void zynqmpimage_set_header(void *ptr, struct stat *sbuf, int ifd, struct image_tool_params *params) { @@ -250,6 +288,10 @@ static void zynqmpimage_set_header(void *ptr, struct stat *sbuf, int ifd, if (params->eflag) zynqhdr->image_load = cpu_to_le32((uint32_t)params->ep); + /* User can pass in text file with init list */ + if (strlen(params->imagename2)) + zynqmpimage_parse_initparams(zynqhdr, params->imagename2); + zynqhdr->checksum = zynqmpimage_checksum(zynqhdr); }