X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=tools%2Fzynqimage.c;fp=tools%2Fzynqimage.c;h=43876e7a302499fed65ac33ef0afdbc09f2376b9;hb=3b6460809c2a28360029c1c48247648fac4455c9;hp=c43bd5d48820a1ba9337cc93b85fff08f21d461a;hpb=29e0cfb4f77f7aa369136302cee14a91e22dca71;p=people%2Fms%2Fu-boot.git diff --git a/tools/zynqimage.c b/tools/zynqimage.c index c43bd5d488..43876e7a30 100644 --- a/tools/zynqimage.c +++ b/tools/zynqimage.c @@ -222,6 +222,30 @@ static int zynqimage_check_image_types(uint8_t type) return EXIT_FAILURE; } +static void zynqimage_parse_initparams(struct zynq_header *zynqhdr, + const char *filename) +{ + /* Expect a table of register-value pairs, e.g. "0x12345678 0x4321" */ + FILE *fp = fopen(filename, "r"); + struct zynq_reginit reginit; + unsigned int reg_count = 0; + int r; + + if (!fp) { + fprintf(stderr, "Cannot open initparams file: %s\n", filename); + exit(1); + } + 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 zynqimage_set_header(void *ptr, struct stat *sbuf, int ifd, struct image_tool_params *params) { @@ -237,6 +261,10 @@ static void zynqimage_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)) + zynqimage_parse_initparams(zynqhdr, params->imagename2); + zynqhdr->checksum = zynqimage_checksum(zynqhdr); }