1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2011 by Amaury Pouly
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
26 #include "mkimxboot.h"
31 enum imx_firmware_variant_t variant
;
34 struct imx_variant_t imx_variants
[] =
36 { "default", VARIANT_DEFAULT
},
37 { "zenxfi2-recovery", VARIANT_ZENXFI2_RECOVERY
},
38 { "zenxfi2-nand", VARIANT_ZENXFI2_NAND
},
39 { "zenxfi2-sd", VARIANT_ZENXFI2_SD
},
42 #define NR_VARIANTS sizeof(imx_variants) / sizeof(imx_variants[0])
44 static void usage(void)
46 printf("Usage: elftosb [options | file]...\n");
48 printf(" -?/--help\tDisplay this message\n");
49 printf(" -o <file>\tSet output file\n");
50 printf(" -i <file>\tSet input file\n");
51 printf(" -b <file>\tSet boot file\n");
52 printf(" -d/--debug\tEnable debug output\n");
53 printf(" -t <type>\tSet type (dualboot, singleboot, recovery)\n");
54 printf(" -v <v>\tSet variant\n");
55 printf(" -x\t\tDump device informations\n");
56 printf("Supported variants: (default is standard)\n");
58 for(size_t i
= 0; i
< NR_VARIANTS
; i
++)
62 printf("%s", imx_variants
[i
].name
);
65 printf("By default a dualboot image is built\n");
69 int main(int argc
, char *argv
[])
73 char *bootfile
= NULL
;
74 enum imx_firmware_variant_t variant
= VARIANT_DEFAULT
;
75 enum imx_output_type_t type
= IMX_DUALBOOT
;
83 static struct option long_options
[] =
85 {"help", no_argument
, 0, '?'},
86 {"in-file", no_argument
, 0, 'i'},
87 {"out-file", required_argument
, 0, 'o'},
88 {"boot-file", required_argument
, 0, 'b'},
89 {"debug", no_argument
, 0, 'd'},
90 {"type", required_argument
, 0, 't'},
91 {"variant", required_argument
, 0, 'v'},
92 {"dev-info", no_argument
, 0, 'x'},
96 int c
= getopt_long(argc
, argv
, "?di:o:b:t:v:x", long_options
, NULL
);
119 if(strcmp(optarg
, "dualboot") == 0)
121 else if(strcmp(optarg
, "singleboot") == 0)
122 type
= IMX_SINGLEBOOT
;
123 else if(strcmp(optarg
, "recovery") == 0)
127 printf("Invalid boot type '%s'\n", optarg
);
133 for(size_t i
= 0; i
< NR_VARIANTS
; i
++)
135 if(strcmp(optarg
, imx_variants
[i
].name
) == 0)
137 variant
= imx_variants
[i
].variant
;
141 printf("Invalid variant '%s'\n", optarg
);
148 dump_imx_dev_info("");
149 printf("variant mapping:\n");
150 for(int i
= 0; i
< sizeof(imx_variants
) / sizeof(imx_variants
[0]); i
++)
151 printf(" %s -> variant=%d\n", imx_variants
[i
].name
, imx_variants
[i
].variant
);
160 printf("You must specify an input file\n");
165 printf("You must specify an output file\n");
170 printf("You must specify an boot file\n");
175 printf("Extra arguments on command line\n");
179 struct imx_option_t opt
;
180 memset(&opt
, 0, sizeof(opt
));
183 opt
.fw_variant
= variant
;
184 enum imx_error_t err
= mkimxboot(infile
, bootfile
, outfile
, opt
);
185 printf("Result: %d\n", err
);