summaryrefslogtreecommitdiffstats
path: root/rbutil/mkamsboot/main.c
diff options
context:
space:
mode:
authorRafaël Carré <rafael.carre@gmail.com>2010-05-24 10:06:52 +0000
committerRafaël Carré <rafael.carre@gmail.com>2010-05-24 10:06:52 +0000
commitff6b0425e438add8d12393f90fdbfe93e1fb4746 (patch)
treeb8ac1a3254a8e01051a5d7f2c5c94e61bacd5c02 /rbutil/mkamsboot/main.c
parenteae2464e9a93dc3a8918abcc62348af6c8d9bc9b (diff)
downloadrockbox-ff6b0425e438add8d12393f90fdbfe93e1fb4746.tar.gz
rockbox-ff6b0425e438add8d12393f90fdbfe93e1fb4746.zip
mkamsboot/rbutil/amsinfo : do not try to detect the model of a given Sansa AMS OF
The field we thought was representative of the model is not, it has changed in the past for fuzev1 and fuzev2. For example the value 0x23 is found in 2 old fuzev1 OF versions, and in the c200v2 OF The only reliable way to detect the model of a given OF is by using the built-in list of md5sums. Modify mkamsboot and rbutilqt to load the rockbox bootloader first, and then check if the model in the bootloader corresponds to the model of the known md5sum of the given OF. That way we can continue to present the user with a list of known OF versions in case the OF is unknown to mkamsboot Also explicit the dependency of main.c on mkamsboot.h in case the prototypes change Correct the header's description not updated in r21648 git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26248 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'rbutil/mkamsboot/main.c')
-rw-r--r--rbutil/mkamsboot/main.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/rbutil/mkamsboot/main.c b/rbutil/mkamsboot/main.c
index 1132334261..a864c2a5c1 100644
--- a/rbutil/mkamsboot/main.c
+++ b/rbutil/mkamsboot/main.c
@@ -59,6 +59,7 @@ int main(int argc, char* argv[])
int rb_packedsize;
int patchable;
int totalsize;
+ int model;
char errstr[200];
struct md5sums sum;
char md5sum[33]; /* 32 digits + \0 */
@@ -81,11 +82,21 @@ int main(int argc, char* argv[])
bootfile = argv[2];
outfile = argv[3];
+ /* Load bootloader file */
+ rb_packed = load_rockbox_file(bootfile, &model, &bootloader_size,
+ &rb_packedsize, errstr, sizeof(errstr));
+ if (rb_packed == NULL) {
+ fprintf(stderr, "%s", errstr);
+ fprintf(stderr, "[ERR] Could not load %s\n", bootfile);
+ return 1;
+ }
+
/* Load original firmware file */
- buf = load_of_file(infile, &len, &sum,
+ buf = load_of_file(infile, model, &len, &sum,
&firmware_size, &of_packed, &of_packedsize, errstr, sizeof(errstr));
if (buf == NULL) {
+ free(rb_packed);
fprintf(stderr, "%s", errstr);
fprintf(stderr, "[ERR] Could not load %s\n", infile);
return 1;
@@ -96,17 +107,6 @@ int main(int argc, char* argv[])
model_names[sum.model], hw_revisions[sum.model], sum.version);
- /* Load bootloader file */
- rb_packed = load_rockbox_file(bootfile, sum.model, &bootloader_size,
- &rb_packedsize, errstr, sizeof(errstr));
- if (rb_packed == NULL) {
- fprintf(stderr, "%s", errstr);
- fprintf(stderr, "[ERR] Could not load %s\n", bootfile);
- free(buf);
- free(of_packed);
- return 1;
- }
-
printf("[INFO] Firmware patching has begun !\n\n");
fprintf(stderr, "[INFO] Original firmware size: %d bytes\n",