summaryrefslogtreecommitdiff
path: root/utils/AMS/hacking/amsinfo.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 /utils/AMS/hacking/amsinfo.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 'utils/AMS/hacking/amsinfo.c')
-rw-r--r--utils/AMS/hacking/amsinfo.c37
1 files changed, 2 insertions, 35 deletions
diff --git a/utils/AMS/hacking/amsinfo.c b/utils/AMS/hacking/amsinfo.c
index ff92175e64..433333ecca 100644
--- a/utils/AMS/hacking/amsinfo.c
+++ b/utils/AMS/hacking/amsinfo.c
@@ -66,7 +66,7 @@ uint8_t *buf; /* file content */
66 66
67/* 1st block description */ 67/* 1st block description */
68uint32_t idx,checksum,bs_multiplier,firmware_sz; 68uint32_t idx,checksum,bs_multiplier,firmware_sz;
69uint32_t unknown_4_1; uint8_t unknown_1,id; uint16_t unknown_2; 69uint32_t unknown_4_1; uint16_t unknown_1, unknown_2;
70uint32_t unknown_4_2,unknown_4_3; 70uint32_t unknown_4_2,unknown_4_3;
71 71
72static void *xmalloc(size_t s) /* malloc helper */ 72static void *xmalloc(size_t s) /* malloc helper */
@@ -76,28 +76,6 @@ static void *xmalloc(size_t s) /* malloc helper */
76 return r; 76 return r;
77} 77}
78 78
79/* known models */
80static const char * model(uint8_t id)
81{
82 switch(id)
83 {
84 case 0x1E: return "FUZE"; break;
85 case 0x22: return "CLIP"; break;
86 case 0x23: return "C200"; break;
87 case 0x24: return "E200"; break;
88 case 0x25: return "M200"; break;
89 case 0x27: return "CLV2"; break;
90 case 0x28: return "CLI+"; break;
91 case 0x70:
92 case 0x6d: return "FUZ2"; break;
93 default:
94 printf("Unknown ID 0x%x\n", id);
95
96 assert(id == 0x1E || (id >= 0x22 && id <= 0x28));
97 return "UNKNOWN!";
98 }
99}
100
101/* checksums the firmware (the firmware header contains the verification) */ 79/* checksums the firmware (the firmware header contains the verification) */
102static uint32_t do_checksum(void) 80static uint32_t do_checksum(void)
103{ 81{
@@ -142,8 +120,7 @@ static void check(void)
142 assert(bs_multiplier << 9 == PAD_TO_BOUNDARY(firmware_sz)); /* 0x200 * bs_multiplier */ 120 assert(bs_multiplier << 9 == PAD_TO_BOUNDARY(firmware_sz)); /* 0x200 * bs_multiplier */
143 121
144 unknown_4_1 = get32le(0x10 + shift); 122 unknown_4_1 = get32le(0x10 + shift);
145 unknown_1 = buf[0x14 + shift]; 123 unknown_1 = get16le(0x14 + shift);
146 id = buf[0x15 + shift];
147 unknown_2 = get16le(0x16 + shift); 124 unknown_2 = get16le(0x16 + shift);
148 unknown_4_2 = get32le(0x18 + shift); 125 unknown_4_2 = get32le(0x18 + shift);
149 unknown_4_3 = get32le(0x1c + shift); 126 unknown_4_3 = get32le(0x1c + shift);
@@ -171,9 +148,6 @@ static void check(void)
171 printf("1 Unknown %x\n",unknown_1); 148 printf("1 Unknown %x\n",unknown_1);
172 149
173 color(GREEN); 150 color(GREEN);
174 printf("1 Model ID %x (%s)\n",id,model(id));
175
176 color(GREEN);
177 printf("2 Unknown (should be 0) %x\n",unknown_2); 151 printf("2 Unknown (should be 0) %x\n",unknown_2);
178 assert(unknown_2 == 0); 152 assert(unknown_2 == 0);
179 153
@@ -185,13 +159,6 @@ static void check(void)
185 printf("4 Unknown (should be 1) %x\n",unknown_4_3); 159 printf("4 Unknown (should be 1) %x\n",unknown_4_3);
186 assert(unknown_4_3 == 1); 160 assert(unknown_4_3 == 1);
187 161
188 /* rest of the block is padded with 0xff */
189 for(i=0x20 + shift;i<0x200 - shift;i++)
190 assert(buf[i]==0xff /* normal case */ ||
191 ((id==0x1e||id==0x24) && ( /* Fuze or E200 */
192 (i>=0x3c && i<=0x3f && get32le(0x3c)==0x00005000)
193 )));
194
195 /* the 2nd block is identical, except that the 1st byte has been incremented */ 162 /* the 2nd block is identical, except that the 1st byte has been incremented */
196 assert(buf[0x0]==0&&buf[0x200]==1); 163 assert(buf[0x0]==0&&buf[0x200]==1);
197 assert(!memcmp(&buf[1],&buf[0x201],0x1FF - shift)); 164 assert(!memcmp(&buf[1],&buf[0x201],0x1FF - shift));