1 This patch makes it possible to set a custom image magic.
5 @@ -26,6 +26,7 @@ static struct image_tool_params params =
7 .type = IH_TYPE_KERNEL,
10 .dtc = MKIMAGE_DEFAULT_DTC_OPTIONS,
13 @@ -89,11 +90,12 @@ static void usage(const char *msg)
17 - " %s [-x] -A arch -O os -T type -C comp -a addr -e ep -n name -d data_file[:data_file...] image\n"
18 + " %s [-x] -A arch -O os -T type -C comp -M magic -a addr -e ep -n name -d data_file[:data_file...] image\n"
19 " -A ==> set architecture to 'arch'\n"
20 " -O ==> set operating system to 'os'\n"
21 " -T ==> set image type to 'type'\n"
22 " -C ==> set compression type 'comp'\n"
23 + " -M ==> set image magic to 'magic'\n"
24 " -a ==> set load address to 'addr' (hex)\n"
25 " -e ==> set entry point to 'ep' (hex)\n"
26 " -n ==> set image name to 'name'\n"
27 @@ -159,7 +161,7 @@ static int add_content(int type, const c
30 static const char optstring[] =
31 - "a:A:b:B:c:C:d:D:e:Ef:Fg:G:i:k:K:ln:N:o:O:p:qrR:stT:vVx";
32 + "a:A:b:B:c:C:d:D:e:Ef:Fg:G:i:k:K:lM:n:N:o:O:p:qrR:stT:vVx";
34 static const struct option longopts[] = {
35 { "load-address", required_argument, NULL, 'a' },
36 @@ -302,6 +304,14 @@ static void process_args(int argc, char
41 + params.magic = strtoull(optarg, &ptr, 16);
43 + fprintf(stderr, "%s: invalid magic %s\n",
44 + params.cmdname, optarg);
49 params.imagename = optarg;
51 --- a/tools/default_image.c
52 +++ b/tools/default_image.c
53 @@ -67,7 +67,7 @@ static int image_verify_header(unsigned
55 memcpy(hdr, ptr, sizeof(struct legacy_img_hdr));
57 - if (be32_to_cpu(hdr->ih_magic) != IH_MAGIC) {
58 + if (be32_to_cpu(hdr->ih_magic) != params->magic) {
59 debug("%s: Bad Magic Number: \"%s\" is no valid image\n",
60 params->cmdname, params->imagefile);
61 return -FDT_ERR_BADMAGIC;
62 @@ -146,7 +146,7 @@ static void image_set_header(void *ptr,
65 /* Build new header */
66 - image_set_magic(hdr, IH_MAGIC);
67 + image_set_magic(hdr, params->magic);
68 image_set_time(hdr, time);
69 image_set_size(hdr, imagesize);
70 image_set_load(hdr, addr);
71 --- a/tools/imagetool.h
72 +++ b/tools/imagetool.h
73 @@ -67,6 +67,7 @@ struct image_tool_params {