Commit 7a439cadcf3192eb012a2432ca34670b676c74d2
mkimage: fix argument parsing on BSD systems
The getopt(3) optstring '-' is a GNU extension which is not available on BSD systems like OS X. Remove this dependency by implementing argument parsing in another way. This will also change the lately introduced '-b' switch behaviour. Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
Showing 3 changed files with 16 additions and 25 deletions Side-by-side Diff
... | ... | @@ -898,7 +898,7 @@ |
898 | 898 | MKIMAGEFLAGS_u-boot.img = -f auto -A $(ARCH) -T firmware -C none -O u-boot \ |
899 | 899 | -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_UBOOT_START) \ |
900 | 900 | -n "U-Boot $(UBOOTRELEASE) for $(BOARD) board" -E \ |
901 | - -b $(patsubst %,arch/$(ARCH)/dts/%.dtb,$(subst ",,$(CONFIG_OF_LIST))) | |
901 | + $(patsubst %,-b arch/$(ARCH)/dts/%.dtb,$(subst ",,$(CONFIG_OF_LIST))) | |
902 | 902 | else |
903 | 903 | MKIMAGEFLAGS_u-boot.img = -A $(ARCH) -T firmware -C none -O u-boot \ |
904 | 904 | -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_UBOOT_START) \ |
... | ... | @@ -97,8 +97,8 @@ |
97 | 97 | .B Create FIT image: |
98 | 98 | |
99 | 99 | .TP |
100 | -.BI "\-b | |
101 | -Specifies that the following arguments are device tree binary files (.dtb). | |
100 | +.BI "\-b [" "device tree file" "] | |
101 | +Appends the device tree binary file (.dtb) to the FIT. | |
102 | 102 | |
103 | 103 | .TP |
104 | 104 | .BI "\-c [" "comment" "]" |
... | ... | @@ -211,7 +211,7 @@ |
211 | 211 | .B mkimage -f auto -A arm -O linux -T kernel -C none -a 43e00000 -e 0 \\\\ |
212 | 212 | .br |
213 | 213 | .B -c """Kernel 4.4 image for production devices""" -d vmlinuz \\\\ |
214 | -.B -b /path/to/rk3288-firefly.dtb /path/to/rk3288-jerry.dtb kernel.itb | |
214 | +.B -b /path/to/rk3288-firefly.dtb -b /path/to/rk3288-jerry.dtb kernel.itb | |
215 | 215 | .fi |
216 | 216 | |
217 | 217 | .SH HOMEPAGE |
... | ... | @@ -85,8 +85,8 @@ |
85 | 85 | " -x ==> set XIP (execute in place)\n", |
86 | 86 | params.cmdname); |
87 | 87 | fprintf(stderr, |
88 | - " %s [-D dtc_options] [-f fit-image.its|-f auto|-F] [-b <dtb_list>] fit-image\n" | |
89 | - " <dtb_list> is used with -f auto, and is a space-separated list of .dtb files\n", | |
88 | + " %s [-D dtc_options] [-f fit-image.its|-f auto|-F] [-b <dtb> [-b <dtb>]] fit-image\n" | |
89 | + " <dtb> file is used with -f auto, it may occour multiple times.\n", | |
90 | 90 | params.cmdname); |
91 | 91 | fprintf(stderr, |
92 | 92 | " -D => set all options for device tree compiler\n" |
... | ... | @@ -138,7 +138,7 @@ |
138 | 138 | |
139 | 139 | expecting = IH_TYPE_COUNT; /* Unknown */ |
140 | 140 | while ((opt = getopt(argc, argv, |
141 | - "-a:A:bcC:d:D:e:Ef:Fk:K:ln:O:rR:sT:vVx")) != -1) { | |
141 | + "a:A:b:cC:d:D:e:Ef:Fk:K:ln:O:rR:sT:vVx")) != -1) { | |
142 | 142 | switch (opt) { |
143 | 143 | case 'a': |
144 | 144 | params.addr = strtoull(optarg, &ptr, 16); |
... | ... | @@ -155,6 +155,12 @@ |
155 | 155 | break; |
156 | 156 | case 'b': |
157 | 157 | expecting = IH_TYPE_FLATDT; |
158 | + if (add_content(expecting, optarg)) { | |
159 | + fprintf(stderr, | |
160 | + "%s: Out of memory adding content '%s'", | |
161 | + params.cmdname, optarg); | |
162 | + exit(EXIT_FAILURE); | |
163 | + } | |
158 | 164 | break; |
159 | 165 | case 'c': |
160 | 166 | params.comment = optarg; |
161 | 167 | |
... | ... | @@ -243,28 +249,13 @@ |
243 | 249 | case 'x': |
244 | 250 | params.xflag++; |
245 | 251 | break; |
246 | - case 1: | |
247 | - if (expecting == type || optind == argc) { | |
248 | - params.imagefile = optarg; | |
249 | - expecting = IH_TYPE_INVALID; | |
250 | - } else if (expecting == IH_TYPE_INVALID) { | |
251 | - fprintf(stderr, | |
252 | - "%s: Unknown content type: use -b before device tree files", | |
253 | - params.cmdname); | |
254 | - exit(EXIT_FAILURE); | |
255 | - } else { | |
256 | - if (add_content(expecting, optarg)) { | |
257 | - fprintf(stderr, | |
258 | - "%s: Out of memory adding content '%s'", | |
259 | - params.cmdname, optarg); | |
260 | - exit(EXIT_FAILURE); | |
261 | - } | |
262 | - } | |
263 | - break; | |
264 | 252 | default: |
265 | 253 | usage("Invalid option"); |
266 | 254 | } |
267 | 255 | } |
256 | + | |
257 | + if (optind < argc && expecting == type) | |
258 | + params.imagefile = argv[optind]; | |
268 | 259 | |
269 | 260 | /* |
270 | 261 | * For auto-generated FIT images we need to know the image type to put |
-
mentioned in commit 8edeac
-
mentioned in commit 8edeac
-
mentioned in commit 8edeac
-
mentioned in commit 8edeac
-
mentioned in commit 8edeac
-
mentioned in commit 8edeac
-
mentioned in commit 8edeac
-
mentioned in commit 8edeac
-
mentioned in commit 8edeac
-
mentioned in commit 8edeac
-
mentioned in commit 8edeac
-
mentioned in commit 8edeac
-
mentioned in commit 8edeac
-
mentioned in commit 8edeac
-
mentioned in commit 8edeac
-
mentioned in commit 8edeac
-
mentioned in commit 8edeac
-
mentioned in commit 8edeac
-
mentioned in commit 8edeac
-
mentioned in commit 8edeac
-
mentioned in commit 8edeac
-
mentioned in commit 8edeac
-
mentioned in commit 8edeac
-
mentioned in commit 8edeac
-
mentioned in commit 8edeac
-
mentioned in commit 8edeac
-
mentioned in commit 8edeac
-
mentioned in commit 8edeac
-
mentioned in commit 8edeac
-
mentioned in commit 8edeac
-
mentioned in commit 8edeac
-
mentioned in commit 8edeac
-
mentioned in commit 8edeac