diff options
Diffstat (limited to 'rbutil/mkimxboot/main.c')
-rw-r--r-- | rbutil/mkimxboot/main.c | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/rbutil/mkimxboot/main.c b/rbutil/mkimxboot/main.c index 611715f7c1..90f2f20a5f 100644 --- a/rbutil/mkimxboot/main.c +++ b/rbutil/mkimxboot/main.c | |||
@@ -72,10 +72,9 @@ static void usage(void) | |||
72 | printf(" -i <file> Set input file\n"); | 72 | printf(" -i <file> Set input file\n"); |
73 | printf(" -b <file> Set boot file\n"); | 73 | printf(" -b <file> Set boot file\n"); |
74 | printf(" -d/--debug Enable debug output\n"); | 74 | printf(" -d/--debug Enable debug output\n"); |
75 | printf(" -t <type> Set type (dualboot, singleboot, recovery, charge)\n"); | 75 | printf(" -t <type> Set type (dualboot, singleboot, recovery, origfw, charge)\n"); |
76 | printf(" -v <v> Set variant\n"); | 76 | printf(" -v <v> Set variant\n"); |
77 | printf(" -x Dump device informations\n"); | 77 | printf(" -x Dump device informations\n"); |
78 | printf(" -w Extract the original firmware\n"); | ||
79 | printf(" -p <ver> Force product and component version\n"); | 78 | printf(" -p <ver> Force product and component version\n"); |
80 | printf(" -5 <type> Compute <type> MD5 sum of the input file\n"); | 79 | printf(" -5 <type> Compute <type> MD5 sum of the input file\n"); |
81 | printf(" -m <model> Specify model (useful for soft MD5 sum)\n"); | 80 | printf(" -m <model> Specify model (useful for soft MD5 sum)\n"); |
@@ -108,14 +107,14 @@ static void usage(void) | |||
108 | exit(1); | 107 | exit(1); |
109 | } | 108 | } |
110 | 109 | ||
111 | static int print_md5(const char *file, enum imx_model_t model, const char *type) | 110 | static int print_md5(const char *file, const char *type) |
112 | { | 111 | { |
113 | uint8_t md5sum[16]; | 112 | uint8_t md5sum[16]; |
114 | enum imx_error_t err; | 113 | enum imx_error_t err; |
115 | if(strcmp(type, "full") == 0) | 114 | if(strcmp(type, "full") == 0) |
116 | err = compute_md5sum(file, md5sum); | 115 | err = compute_md5sum(file, md5sum); |
117 | else if(strcmp(type, "soft") == 0) | 116 | else if(strcmp(type, "soft") == 0) |
118 | err = compute_soft_md5sum(file, model, md5sum); | 117 | err = compute_soft_md5sum(file, md5sum); |
119 | else | 118 | else |
120 | { | 119 | { |
121 | printf("Invalid md5sum type '%s'\n", type); | 120 | printf("Invalid md5sum type '%s'\n", type); |
@@ -142,7 +141,6 @@ int main(int argc, char *argv[]) | |||
142 | enum imx_output_type_t type = IMX_DUALBOOT; | 141 | enum imx_output_type_t type = IMX_DUALBOOT; |
143 | enum imx_model_t model = MODEL_UNKNOWN; | 142 | enum imx_model_t model = MODEL_UNKNOWN; |
144 | bool debug = false; | 143 | bool debug = false; |
145 | bool extract_of = false; | ||
146 | const char *md5type = NULL; | 144 | const char *md5type = NULL; |
147 | const char *force_version = NULL; | 145 | const char *force_version = NULL; |
148 | 146 | ||
@@ -153,7 +151,7 @@ int main(int argc, char *argv[]) | |||
153 | { | 151 | { |
154 | static struct option long_options[] = | 152 | static struct option long_options[] = |
155 | { | 153 | { |
156 | {"help", no_argument, 0, '?'}, | 154 | {"help", no_argument, 0, 'h'}, |
157 | {"in-file", no_argument, 0, 'i'}, | 155 | {"in-file", no_argument, 0, 'i'}, |
158 | {"out-file", required_argument, 0, 'o'}, | 156 | {"out-file", required_argument, 0, 'o'}, |
159 | {"boot-file", required_argument, 0, 'b'}, | 157 | {"boot-file", required_argument, 0, 'b'}, |
@@ -166,7 +164,7 @@ int main(int argc, char *argv[]) | |||
166 | {0, 0, 0, 0} | 164 | {0, 0, 0, 0} |
167 | }; | 165 | }; |
168 | 166 | ||
169 | int c = getopt_long(argc, argv, "?di:o:b:t:v:xwp:m:5:", long_options, NULL); | 167 | int c = getopt_long(argc, argv, "hdi:o:b:t:v:xp:m:5:", long_options, NULL); |
170 | if(c == -1) | 168 | if(c == -1) |
171 | break; | 169 | break; |
172 | switch(c) | 170 | switch(c) |
@@ -174,7 +172,7 @@ int main(int argc, char *argv[]) | |||
174 | case 'd': | 172 | case 'd': |
175 | debug = true; | 173 | debug = true; |
176 | break; | 174 | break; |
177 | case '?': | 175 | case 'h': |
178 | usage(); | 176 | usage(); |
179 | break; | 177 | break; |
180 | case 'o': | 178 | case 'o': |
@@ -195,6 +193,8 @@ int main(int argc, char *argv[]) | |||
195 | type = IMX_RECOVERY; | 193 | type = IMX_RECOVERY; |
196 | else if(strcmp(optarg, "charge") == 0) | 194 | else if(strcmp(optarg, "charge") == 0) |
197 | type = IMX_CHARGE; | 195 | type = IMX_CHARGE; |
196 | else if(strcmp(optarg, "origfw") == 0) | ||
197 | type = IMX_ORIG_FW; | ||
198 | else | 198 | else |
199 | { | 199 | { |
200 | printf("Invalid boot type '%s'\n", optarg); | 200 | printf("Invalid boot type '%s'\n", optarg); |
@@ -223,9 +223,6 @@ int main(int argc, char *argv[]) | |||
223 | for(int i = 0; i < sizeof(imx_variants) / sizeof(imx_variants[0]); i++) | 223 | for(int i = 0; i < sizeof(imx_variants) / sizeof(imx_variants[0]); i++) |
224 | printf(" %s -> variant=%d\n", imx_variants[i].name, imx_variants[i].variant); | 224 | printf(" %s -> variant=%d\n", imx_variants[i].name, imx_variants[i].variant); |
225 | break; | 225 | break; |
226 | case 'w': | ||
227 | extract_of = true; | ||
228 | break; | ||
229 | case 'p': | 226 | case 'p': |
230 | force_version = optarg; | 227 | force_version = optarg; |
231 | break; | 228 | break; |
@@ -266,24 +263,19 @@ int main(int argc, char *argv[]) | |||
266 | printf("You must specify an output file\n"); | 263 | printf("You must specify an output file\n"); |
267 | return 1; | 264 | return 1; |
268 | } | 265 | } |
269 | if(!bootfile && !extract_of) | 266 | |
267 | if(!bootfile && type != IMX_ORIG_FW) | ||
270 | { | 268 | { |
271 | printf("You must specify an boot file\n"); | 269 | printf("You must specify an boot file\n"); |
272 | return 1; | 270 | return 1; |
273 | } | 271 | } |
272 | |||
274 | if(optind != argc) | 273 | if(optind != argc) |
275 | { | 274 | { |
276 | printf("Extra arguments on command line\n"); | 275 | printf("Extra arguments on command line\n"); |
277 | return 1; | 276 | return 1; |
278 | } | 277 | } |
279 | 278 | ||
280 | if(extract_of) | ||
281 | { | ||
282 | enum imx_error_t err = extract_firmware(infile, variant, outfile); | ||
283 | printf("Result: %d\n", err); | ||
284 | return 0; | ||
285 | } | ||
286 | |||
287 | struct imx_option_t opt; | 279 | struct imx_option_t opt; |
288 | memset(&opt, 0, sizeof(opt)); | 280 | memset(&opt, 0, sizeof(opt)); |
289 | opt.debug = debug; | 281 | opt.debug = debug; |