diff options
Diffstat (limited to 'rbutil/mktccboot')
-rw-r--r-- | rbutil/mktccboot/mktccboot.c | 16 | ||||
-rw-r--r-- | rbutil/mktccboot/mktccboot.h | 3 |
2 files changed, 18 insertions, 1 deletions
diff --git a/rbutil/mktccboot/mktccboot.c b/rbutil/mktccboot/mktccboot.c index 432bc03213..7103f23895 100644 --- a/rbutil/mktccboot/mktccboot.c +++ b/rbutil/mktccboot/mktccboot.c | |||
@@ -175,6 +175,12 @@ error: | |||
175 | return NULL; | 175 | return NULL; |
176 | } | 176 | } |
177 | 177 | ||
178 | /* A CRC test in order to reject non OF file */ | ||
179 | int test_firmware_tcc(unsigned char* buf, int length) | ||
180 | { | ||
181 | return telechips_test_crc(buf, length); | ||
182 | } | ||
183 | |||
178 | #ifndef LIB | 184 | #ifndef LIB |
179 | int main(int argc, char *argv[]) | 185 | int main(int argc, char *argv[]) |
180 | { | 186 | { |
@@ -185,7 +191,7 @@ int main(int argc, char *argv[]) | |||
185 | unsigned char *boot_buf = NULL; | 191 | unsigned char *boot_buf = NULL; |
186 | unsigned char* image = NULL; | 192 | unsigned char* image = NULL; |
187 | int ret = 0; | 193 | int ret = 0; |
188 | 194 | ||
189 | if(argc < 3) { | 195 | if(argc < 3) { |
190 | usage(); | 196 | usage(); |
191 | } | 197 | } |
@@ -202,6 +208,14 @@ int main(int argc, char *argv[]) | |||
202 | goto error_exit; | 208 | goto error_exit; |
203 | } | 209 | } |
204 | 210 | ||
211 | /* Validate input file */ | ||
212 | if (test_firmware_tcc(of_buf, of_size)) | ||
213 | { | ||
214 | printf("[ERR] Unknown OF file used, aborting\n"); | ||
215 | ret = 2; | ||
216 | goto error_exit; | ||
217 | } | ||
218 | |||
205 | boot_buf = file_read(bootfile, &boot_size); | 219 | boot_buf = file_read(bootfile, &boot_size); |
206 | if (!boot_buf) | 220 | if (!boot_buf) |
207 | { | 221 | { |
diff --git a/rbutil/mktccboot/mktccboot.h b/rbutil/mktccboot/mktccboot.h index 6c6410c258..2df2c54506 100644 --- a/rbutil/mktccboot/mktccboot.h +++ b/rbutil/mktccboot/mktccboot.h | |||
@@ -35,6 +35,9 @@ unsigned char *patch_firmware_tcc(unsigned char *of_buf, int of_size, | |||
35 | 35 | ||
36 | unsigned char *file_read(char *filename, int *size); | 36 | unsigned char *file_read(char *filename, int *size); |
37 | 37 | ||
38 | /* Test TCC firmware file for consistency using CRC test */ | ||
39 | int test_firmware_tcc(unsigned char* buf, int length); | ||
40 | |||
38 | #ifdef __cplusplus | 41 | #ifdef __cplusplus |
39 | }; | 42 | }; |
40 | #endif | 43 | #endif |