diff options
author | Amaury Pouly <amaury.pouly@gmail.com> | 2013-10-22 00:48:33 +0200 |
---|---|---|
committer | Amaury Pouly <amaury.pouly@gmail.com> | 2013-10-22 00:48:33 +0200 |
commit | 2e0c558064ad6c92624a0a826721a83321b227af (patch) | |
tree | 6a579d0f24e3b3de023bd3241092f0c89598e1fb /rbutil/mkzenboot/main.c | |
parent | 5cfb148ae275993d6b9bc8d59355196c5f4f7dc1 (diff) | |
download | rockbox-2e0c558064ad6c92624a0a826721a83321b227af.tar.gz rockbox-2e0c558064ad6c92624a0a826721a83321b227af.zip |
Introduce rbutil/mkzenboot, a replacement for tools/mkzenboot
The old tools/mkzenboot has a number of problems: very hard to maintain,
poor integration with rbutil. Restart from scratch by recycling all the
crypto and descrambling code, rewrite the actual firmware modification part
to handle all scenarios in a much clearer way. The code is ready to be
integrated into Rockbox Utility, by using the very similar interface to
mkimxboot.
I copied all the keys from the old mkzenboot, so it can potentially support
the older Creative ports, but since this is untested, I prefer not do so
at the moment. However, I did add a "mixed" boot option to support the
dualboot style used in the older ports.
Change-Id: I80cfc48fa78187baa1b1692e8a30ec7137cea37b
Diffstat (limited to 'rbutil/mkzenboot/main.c')
-rw-r--r-- | rbutil/mkzenboot/main.c | 123 |
1 files changed, 123 insertions, 0 deletions
diff --git a/rbutil/mkzenboot/main.c b/rbutil/mkzenboot/main.c new file mode 100644 index 0000000000..7aef2b76a3 --- /dev/null +++ b/rbutil/mkzenboot/main.c | |||
@@ -0,0 +1,123 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2013 by Amaury Pouly | ||
11 | * | ||
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. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include <getopt.h> | ||
23 | #include <stdlib.h> | ||
24 | #include <stdio.h> | ||
25 | #include <string.h> | ||
26 | #include "mkzenboot.h" | ||
27 | |||
28 | static void usage(void) | ||
29 | { | ||
30 | printf("Usage: mkzenboot [options | file]...\n"); | ||
31 | printf("Options:\n"); | ||
32 | printf(" -?/--help Display this message\n"); | ||
33 | printf(" -i <file> Set input file\n"); | ||
34 | printf(" -o <file> Set output file\n"); | ||
35 | printf(" -b <file> Set boot file\n"); | ||
36 | printf(" -t <type> Set output type\n"); | ||
37 | printf(" -d/--debug Enable debug output\n"); | ||
38 | printf("Output types: dualboot, deferred_dualboot, singleboot, recovery\n"); | ||
39 | printf("By default a dualboot image is built\n"); | ||
40 | exit(1); | ||
41 | } | ||
42 | |||
43 | int main(int argc, char *argv[]) | ||
44 | { | ||
45 | char *outfile = NULL; | ||
46 | char *bootfile = NULL; | ||
47 | char *infile = NULL; | ||
48 | struct zen_option_t opt; | ||
49 | memset(&opt, 0, sizeof(opt)); | ||
50 | |||
51 | if(argc == 1) | ||
52 | usage(); | ||
53 | |||
54 | while(1) | ||
55 | { | ||
56 | static struct option long_options[] = | ||
57 | { | ||
58 | {"help", no_argument, 0, '?'}, | ||
59 | {"debug", no_argument, 0, 'd'}, | ||
60 | {0, 0, 0, 0} | ||
61 | }; | ||
62 | |||
63 | int c = getopt_long(argc, argv, "?di:o:b:t:", long_options, NULL); | ||
64 | if(c == -1) | ||
65 | break; | ||
66 | switch(c) | ||
67 | { | ||
68 | case 'd': | ||
69 | opt.debug = true; | ||
70 | break; | ||
71 | case '?': | ||
72 | usage(); | ||
73 | break; | ||
74 | case 'o': | ||
75 | outfile = optarg; | ||
76 | break; | ||
77 | case 'i': | ||
78 | infile = optarg; | ||
79 | break; | ||
80 | case 'b': | ||
81 | bootfile = optarg; | ||
82 | break; | ||
83 | case 't': | ||
84 | if(strcmp(optarg, "dualboot") == 0) opt.output = ZEN_DUALBOOT; | ||
85 | else if(strcmp(optarg, "mixedboot") == 0) opt.output = ZEN_MIXEDBOOT; | ||
86 | else if(strcmp(optarg, "singleboot") == 0) opt.output = ZEN_SINGLEBOOT; | ||
87 | else if(strcmp(optarg, "recovery") == 0) opt.output = ZEN_RECOVERY; | ||
88 | else | ||
89 | { | ||
90 | printf("Unknown output type '%s'\n", optarg); | ||
91 | return 1; | ||
92 | } | ||
93 | break; | ||
94 | default: | ||
95 | abort(); | ||
96 | } | ||
97 | } | ||
98 | |||
99 | if(!outfile) | ||
100 | { | ||
101 | printf("You must specify an output file\n"); | ||
102 | return 1; | ||
103 | } | ||
104 | if(!bootfile) | ||
105 | { | ||
106 | printf("You must specify a boot file\n"); | ||
107 | return 1; | ||
108 | } | ||
109 | if(!infile) | ||
110 | { | ||
111 | printf("You must specify an input file\n"); | ||
112 | return 1; | ||
113 | } | ||
114 | if(optind != argc) | ||
115 | { | ||
116 | printf("Extra arguments on command line\n"); | ||
117 | return 1; | ||
118 | } | ||
119 | |||
120 | enum zen_error_t err = mkzenboot(infile, bootfile, outfile, opt); | ||
121 | printf("Result: %d\n", err); | ||
122 | return 0; | ||
123 | } | ||