summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2013-06-15 22:19:52 +0200
committerAmaury Pouly <amaury.pouly@gmail.com>2013-06-15 22:27:34 +0200
commit7c7fa369186536adaf9ff35ec356525b5c5a8379 (patch)
treebc70e26ffcc48a7d0a0a40e7c33e0cd48bd265fa
parent58e27b9fa1e9ea058eb5161f140e0909c4821c92 (diff)
downloadrockbox-7c7fa369186536adaf9ff35ec356525b5c5a8379.tar.gz
rockbox-7c7fa369186536adaf9ff35ec356525b5c5a8379.zip
sbtools,mkximboot: fix whitespace
Change-Id: I8d8adb783707172d1aaef302366c240310350ed8
-rw-r--r--rbutil/mkimxboot/main.c2
-rw-r--r--utils/imxtools/sbtools/crypto.c8
-rw-r--r--utils/imxtools/sbtools/dbparser.c2
-rw-r--r--utils/imxtools/sbtools/elf.c20
-rw-r--r--utils/imxtools/sbtools/elftosb.c14
-rw-r--r--utils/imxtools/sbtools/elftosb1.c6
-rw-r--r--utils/imxtools/sbtools/rsrc.c10
-rw-r--r--utils/imxtools/sbtools/rsrc.h2
-rw-r--r--utils/imxtools/sbtools/rsrctool.c2
-rw-r--r--utils/imxtools/sbtools/sb.c74
-rw-r--r--utils/imxtools/sbtools/sb.h4
-rw-r--r--utils/imxtools/sbtools/sb1.c6
-rw-r--r--utils/imxtools/sbtools/sb1.h2
-rw-r--r--utils/imxtools/sbtools/sbloader.c2
-rw-r--r--utils/imxtools/sbtools/sbtoelf.c10
-rw-r--r--utils/imxtools/sbtools/sha1.c4
16 files changed, 84 insertions, 84 deletions
diff --git a/rbutil/mkimxboot/main.c b/rbutil/mkimxboot/main.c
index a3e70c49fd..b77aa27ce8 100644
--- a/rbutil/mkimxboot/main.c
+++ b/rbutil/mkimxboot/main.c
@@ -145,7 +145,7 @@ int main(int argc, char *argv[])
145 } 145 }
146 printf("Invalid variant '%s'\n", optarg); 146 printf("Invalid variant '%s'\n", optarg);
147 return 1; 147 return 1;
148 148
149 Lok: 149 Lok:
150 break; 150 break;
151 } 151 }
diff --git a/utils/imxtools/sbtools/crypto.c b/utils/imxtools/sbtools/crypto.c
index d4afc6c816..4f7b799dd9 100644
--- a/utils/imxtools/sbtools/crypto.c
+++ b/utils/imxtools/sbtools/crypto.c
@@ -68,7 +68,7 @@ int crypto_apply(
68 { 68 {
69 if(out_cbc_mac && !encrypt) 69 if(out_cbc_mac && !encrypt)
70 memcpy(*out_cbc_mac, in_data + 16 * (nr_blocks - 1), 16); 70 memcpy(*out_cbc_mac, in_data + 16 * (nr_blocks - 1), 16);
71 71
72 libusb_device_handle *handle = NULL; 72 libusb_device_handle *handle = NULL;
73 libusb_context *ctx; 73 libusb_context *ctx;
74 /* init library */ 74 /* init library */
@@ -97,7 +97,7 @@ int crypto_apply(
97 printf("usbotp: configuration: %d\n", config_id); 97 printf("usbotp: configuration: %d\n", config_id);
98 printf("usbotp: interfaces: %d\n", config->bNumInterfaces); 98 printf("usbotp: interfaces: %d\n", config->bNumInterfaces);
99 } 99 }
100 100
101 const struct libusb_endpoint_descriptor *endp = NULL; 101 const struct libusb_endpoint_descriptor *endp = NULL;
102 int intf, intf_alt; 102 int intf, intf_alt;
103 for(intf = 0; intf < config->bNumInterfaces; intf++) 103 for(intf = 0; intf < config->bNumInterfaces; intf++)
@@ -147,7 +147,7 @@ int crypto_apply(
147 buffer_size, &recv_size, 1000); 147 buffer_size, &recv_size, 1000);
148 libusb_release_interface(handle, intf); 148 libusb_release_interface(handle, intf);
149 libusb_close(handle); 149 libusb_close(handle);
150 150
151 if(ret < 0) 151 if(ret < 0)
152 { 152 {
153 if(g_debug) 153 if(g_debug)
@@ -166,7 +166,7 @@ int crypto_apply(
166 memcpy(out_data, buffer + 16, 16 * nr_blocks); 166 memcpy(out_data, buffer + 16, 16 * nr_blocks);
167 if(out_cbc_mac && encrypt) 167 if(out_cbc_mac && encrypt)
168 memcpy(*out_cbc_mac, buffer + buffer_size - 16, 16); 168 memcpy(*out_cbc_mac, buffer + buffer_size - 16, 16);
169 169
170 return CRYPTO_ERROR_SUCCESS; 170 return CRYPTO_ERROR_SUCCESS;
171 } 171 }
172 #endif 172 #endif
diff --git a/utils/imxtools/sbtools/dbparser.c b/utils/imxtools/sbtools/dbparser.c
index 89a63b3767..37f812d585 100644
--- a/utils/imxtools/sbtools/dbparser.c
+++ b/utils/imxtools/sbtools/dbparser.c
@@ -733,7 +733,7 @@ struct cmd_file_t *db_parse_file(const char *file)
733 inst->type = (inst->type == CMD_CALL) ? CMD_CALL_AT : CMD_JUMP_AT; 733 inst->type = (inst->type == CMD_CALL) ? CMD_CALL_AT : CMD_JUMP_AT;
734 inst->addr = parse_intexpr(&lctx, cmd_file->constant_list); 734 inst->addr = parse_intexpr(&lctx, cmd_file->constant_list);
735 } 735 }
736 736
737 if(lexem.type == LEX_LPAREN) 737 if(lexem.type == LEX_LPAREN)
738 { 738 {
739 next(true); 739 next(true);
diff --git a/utils/imxtools/sbtools/elf.c b/utils/imxtools/sbtools/elf.c
index c41fc27fdd..5626c0f58c 100644
--- a/utils/imxtools/sbtools/elf.c
+++ b/utils/imxtools/sbtools/elf.c
@@ -208,9 +208,9 @@ void elf_add_fill_section(struct elf_params_t *params,
208 printf("oops, non-zero filling, ignore fill section\n"); 208 printf("oops, non-zero filling, ignore fill section\n");
209 return; 209 return;
210 } 210 }
211 211
212 struct elf_section_t *sec = elf_add_section(params); 212 struct elf_section_t *sec = elf_add_section(params);
213 213
214 sec->type = EST_FILL; 214 sec->type = EST_FILL;
215 sec->addr = fill_addr; 215 sec->addr = fill_addr;
216 sec->size = size; 216 sec->size = size;
@@ -239,7 +239,7 @@ void elf_simplify(struct elf_params_t *params)
239 nr_sections++; 239 nr_sections++;
240 cur_sec = cur_sec->next; 240 cur_sec = cur_sec->next;
241 } 241 }
242 242
243 /* put all sections in an array and free list */ 243 /* put all sections in an array and free list */
244 struct elf_section_t *sections = malloc(sizeof(struct elf_section_t) * nr_sections); 244 struct elf_section_t *sections = malloc(sizeof(struct elf_section_t) * nr_sections);
245 cur_sec = params->first_section; 245 cur_sec = params->first_section;
@@ -371,7 +371,7 @@ void elf_write_file(struct elf_params_t *params, elf_write_fn_t write,
371 elf_printf_fn_t printf, void *user) 371 elf_printf_fn_t printf, void *user)
372{ 372{
373 (void) printf; 373 (void) printf;
374 374
375 Elf32_Ehdr ehdr; 375 Elf32_Ehdr ehdr;
376 uint32_t phnum = 0; 376 uint32_t phnum = 0;
377 struct elf_section_t *sec = params->first_section; 377 struct elf_section_t *sec = params->first_section;
@@ -391,7 +391,7 @@ void elf_write_file(struct elf_params_t *params, elf_write_fn_t write,
391 { 391 {
392 sec->offset = 0; 392 sec->offset = 0;
393 } 393 }
394 394
395 phnum++; 395 phnum++;
396 sec = sec->next; 396 sec = sec->next;
397 } 397 }
@@ -431,7 +431,7 @@ void elf_write_file(struct elf_params_t *params, elf_write_fn_t write,
431 * - one name ".shstrtab\0" */ 431 * - one name ".shstrtab\0" */
432 char *strtbl_content = malloc(1 + strlen(".shstrtab") + 1 + 432 char *strtbl_content = malloc(1 + strlen(".shstrtab") + 1 +
433 phnum * (strlen(".textXXXX") + 1)); 433 phnum * (strlen(".textXXXX") + 1));
434 434
435 strtbl_content[0] = '\0'; 435 strtbl_content[0] = '\0';
436 strcpy(&strtbl_content[1], ".shstrtab"); 436 strcpy(&strtbl_content[1], ".shstrtab");
437 uint32_t strtbl_index = 1 + strlen(".shstrtab") + 1; 437 uint32_t strtbl_index = 1 + strlen(".shstrtab") + 1;
@@ -444,7 +444,7 @@ void elf_write_file(struct elf_params_t *params, elf_write_fn_t write,
444 while(sec) 444 while(sec)
445 { 445 {
446 sec->offset += data_offset; 446 sec->offset += data_offset;
447 447
448 phdr.p_type = PT_LOAD; 448 phdr.p_type = PT_LOAD;
449 if(sec->type == EST_LOAD) 449 if(sec->type == EST_LOAD)
450 phdr.p_offset = sec->offset; 450 phdr.p_offset = sec->offset;
@@ -549,7 +549,7 @@ bool elf_read_file(struct elf_params_t *params, elf_read_fn_t read,
549 elf_printf_fn_t printf, void *user) 549 elf_printf_fn_t printf, void *user)
550{ 550{
551 #define error_printf(...) ({printf(user, true, __VA_ARGS__); return false;}) 551 #define error_printf(...) ({printf(user, true, __VA_ARGS__); return false;})
552 552
553 /* read header */ 553 /* read header */
554 Elf32_Ehdr ehdr; 554 Elf32_Ehdr ehdr;
555 if(!read(user, 0, &ehdr, sizeof(ehdr))) 555 if(!read(user, 0, &ehdr, sizeof(ehdr)))
@@ -626,7 +626,7 @@ bool elf_read_file(struct elf_params_t *params, elf_read_fn_t read,
626 if(strtab) 626 if(strtab)
627 printf(user, false, "filter out %s\n", &strtab[shdr.sh_name], shdr.sh_type); 627 printf(user, false, "filter out %s\n", &strtab[shdr.sh_name], shdr.sh_type);
628 } 628 }
629 629
630 } 630 }
631 free(strtab); 631 free(strtab);
632 /* run through segments */ 632 /* run through segments */
@@ -647,7 +647,7 @@ bool elf_read_file(struct elf_params_t *params, elf_read_fn_t read,
647 printf(user, false, "create segment [%#x,+%#x[ -> [%#x,+%#x[\n", 647 printf(user, false, "create segment [%#x,+%#x[ -> [%#x,+%#x[\n",
648 seg->vaddr, seg->vsize, seg->paddr, seg->psize); 648 seg->vaddr, seg->vsize, seg->paddr, seg->psize);
649 } 649 }
650 650
651 return true; 651 return true;
652} 652}
653 653
diff --git a/utils/imxtools/sbtools/elftosb.c b/utils/imxtools/sbtools/elftosb.c
index 22a5b58753..fd44693a94 100644
--- a/utils/imxtools/sbtools/elftosb.c
+++ b/utils/imxtools/sbtools/elftosb.c
@@ -18,7 +18,7 @@
18 * KIND, either express or implied. 18 * KIND, either express or implied.
19 * 19 *
20 ****************************************************************************/ 20 ****************************************************************************/
21 21
22#define _ISOC99_SOURCE 22#define _ISOC99_SOURCE
23#define _POSIX_C_SOURCE 200809L /* for strdup */ 23#define _POSIX_C_SOURCE 200809L /* for strdup */
24#include <stdio.h> 24#include <stdio.h>
@@ -144,7 +144,7 @@ static struct sb_file_t *apply_cmd_file(struct cmd_file_t *cmd_file)
144 144
145 db_generate_default_sb_version(&sb->product_ver); 145 db_generate_default_sb_version(&sb->product_ver);
146 db_generate_default_sb_version(&sb->component_ver); 146 db_generate_default_sb_version(&sb->component_ver);
147 147
148 if(g_debug) 148 if(g_debug)
149 printf("Applying command file...\n"); 149 printf("Applying command file...\n");
150 /* count sections */ 150 /* count sections */
@@ -246,7 +246,7 @@ static struct sb_file_t *apply_cmd_file(struct cmd_file_t *cmd_file)
246 } 246 }
247 else 247 else
248 bug("die\n"); 248 bug("die\n");
249 249
250 cinst = cinst->next; 250 cinst = cinst->next;
251 } 251 }
252 252
@@ -308,7 +308,7 @@ static struct sb_file_t *apply_cmd_file(struct cmd_file_t *cmd_file)
308 } 308 }
309 else 309 else
310 bug("die\n"); 310 bug("die\n");
311 311
312 cinst = cinst->next; 312 cinst = cinst->next;
313 } 313 }
314 } 314 }
@@ -347,7 +347,7 @@ int main(int argc, char **argv)
347 struct crypto_key_t crypto_iv; 347 struct crypto_key_t crypto_iv;
348 real_key.method = CRYPTO_NONE; 348 real_key.method = CRYPTO_NONE;
349 crypto_iv.method = CRYPTO_NONE; 349 crypto_iv.method = CRYPTO_NONE;
350 350
351 while(1) 351 while(1)
352 { 352 {
353 static struct option long_options[] = 353 static struct option long_options[] =
@@ -452,10 +452,10 @@ int main(int argc, char **argv)
452 sb_file->first_boot_sec_id = sb_file->sections[0].identifier; 452 sb_file->first_boot_sec_id = sb_file->sections[0].identifier;
453 sb_file->flags = 0; 453 sb_file->flags = 0;
454 sb_file->minor_version = 1; 454 sb_file->minor_version = 1;
455 455
456 sb_write_file(sb_file, output_filename); 456 sb_write_file(sb_file, output_filename);
457 sb_free(sb_file); 457 sb_free(sb_file);
458 clear_keys(); 458 clear_keys();
459 459
460 return 0; 460 return 0;
461} 461}
diff --git a/utils/imxtools/sbtools/elftosb1.c b/utils/imxtools/sbtools/elftosb1.c
index 1f33058eca..be9201c396 100644
--- a/utils/imxtools/sbtools/elftosb1.c
+++ b/utils/imxtools/sbtools/elftosb1.c
@@ -265,7 +265,7 @@ static bool parse_sb_version(struct sb1_version_t *ver, char *str)
265} 265}
266 266
267/** 267/**
268 * Command line parsing 268 * Command line parsing
269 */ 269 */
270 270
271#define MAX_NR_ARGS 2 271#define MAX_NR_ARGS 2
@@ -586,7 +586,7 @@ static void usage(void)
586 printf(" -N/-nonstrict\t\t\tClear strict flag\n"); 586 printf(" -N/-nonstrict\t\t\tClear strict flag\n");
587 printf(" -call <addr>\t\t\tCall code at a specified address\n"); 587 printf(" -call <addr>\t\t\tCall code at a specified address\n");
588 printf(" -jump <addr>\t\t\tJump to code at a specified address\n"); 588 printf(" -jump <addr>\t\t\tJump to code at a specified address\n");
589 589
590 exit(1); 590 exit(1);
591} 591}
592 592
@@ -623,4 +623,4 @@ int main(int argc, char **argv)
623 623
624 return ret; 624 return ret;
625} 625}
626 626
diff --git a/utils/imxtools/sbtools/rsrc.c b/utils/imxtools/sbtools/rsrc.c
index 8967c0ed15..a3bc150fa1 100644
--- a/utils/imxtools/sbtools/rsrc.c
+++ b/utils/imxtools/sbtools/rsrc.c
@@ -161,12 +161,12 @@ static bool read_entries(struct rsrc_file_t *f, void *u,
161 printf(RED, "%c", isprint(p[i]) ? p[i] : '.'); 161 printf(RED, "%c", isprint(p[i]) ? p[i] : '.');
162 } 162 }
163 printf(OFF, "\n"); 163 printf(OFF, "\n");
164 164
165 if(RSRC_TABLE_ENTRY_TYPE(te) == RSRC_TYPE_NESTED) 165 if(RSRC_TABLE_ENTRY_TYPE(te) == RSRC_TYPE_NESTED)
166 { 166 {
167 char *p = prefix + strlen(prefix); 167 char *p = prefix + strlen(prefix);
168 sprintf(p, "%s| ", RED); 168 sprintf(p, "%s| ", RED);
169 169
170 bool ok = read_entries(f, u, cprintf, err, 170 bool ok = read_entries(f, u, cprintf, err,
171 RSRC_TABLE_ENTRY_OFFSET(te), index, 171 RSRC_TABLE_ENTRY_OFFSET(te), index,
172 level - 1, prefix); 172 level - 1, prefix);
@@ -175,7 +175,7 @@ static bool read_entries(struct rsrc_file_t *f, void *u,
175 *p = 0; 175 *p = 0;
176 } 176 }
177 } 177 }
178 178
179 return true; 179 return true;
180 #undef printf 180 #undef printf
181 #undef fatal 181 #undef fatal
@@ -220,7 +220,7 @@ struct rsrc_file_t *rsrc_read_memory(void *_buf, size_t filesize, void *u,
220 bool ok = read_entries(rsrc_file, u, cprintf, err, RSRC_SECTOR_SIZE, 0, 3, prefix); 220 bool ok = read_entries(rsrc_file, u, cprintf, err, RSRC_SECTOR_SIZE, 0, 3, prefix);
221 if(!ok) 221 if(!ok)
222 fatal(*err, "Error while parsing rsrc table\n"); 222 fatal(*err, "Error while parsing rsrc table\n");
223 223
224 return rsrc_file; 224 return rsrc_file;
225 #undef printf 225 #undef printf
226 #undef fatal 226 #undef fatal
@@ -253,4 +253,4 @@ void rsrc_dump(struct rsrc_file_t *file, void *u, rsrc_color_printf cprintf)
253 #undef printf 253 #undef printf
254 #undef print_hex 254 #undef print_hex
255} 255}
256 256
diff --git a/utils/imxtools/sbtools/rsrc.h b/utils/imxtools/sbtools/rsrc.h
index 3e03d97d73..c3e0bdfb37 100644
--- a/utils/imxtools/sbtools/rsrc.h
+++ b/utils/imxtools/sbtools/rsrc.h
@@ -92,4 +92,4 @@ void rsrc_dump(struct rsrc_file_t *file, void *u, rsrc_color_printf printf);
92void rsrc_free(struct rsrc_file_t *file); 92void rsrc_free(struct rsrc_file_t *file);
93 93
94#endif /* __RSRC_H__ */ 94#endif /* __RSRC_H__ */
95 95
diff --git a/utils/imxtools/sbtools/rsrctool.c b/utils/imxtools/sbtools/rsrctool.c
index 53235365ae..f95542fc49 100644
--- a/utils/imxtools/sbtools/rsrctool.c
+++ b/utils/imxtools/sbtools/rsrctool.c
@@ -199,4 +199,4 @@ int main(int argc, char **argv)
199 199
200 return 0; 200 return 0;
201} 201}
202 202
diff --git a/utils/imxtools/sbtools/sb.c b/utils/imxtools/sbtools/sb.c
index 2625d770c2..f64da8ff84 100644
--- a/utils/imxtools/sbtools/sb.c
+++ b/utils/imxtools/sbtools/sb.c
@@ -63,7 +63,7 @@ static void compute_sb_offsets(struct sb_file_t *sb)
63 if((i + 1) < sb->nr_sections) 63 if((i + 1) < sb->nr_sections)
64 alignment = sb->sections[i + 1].alignment; 64 alignment = sb->sections[i + 1].alignment;
65 alignment /= BLOCK_SIZE; /* alignment in block sizes */ 65 alignment /= BLOCK_SIZE; /* alignment in block sizes */
66 66
67 struct sb_section_t *sec = &sb->sections[i]; 67 struct sb_section_t *sec = &sb->sections[i];
68 sec->sec_size = 0; 68 sec->sec_size = 0;
69 69
@@ -75,7 +75,7 @@ static void compute_sb_offsets(struct sb_file_t *sb)
75 printf(" (cleartext)"); 75 printf(" (cleartext)");
76 printf("\n"); 76 printf("\n");
77 } 77 }
78 78
79 sec->file_offset = sb->image_size; 79 sec->file_offset = sb->image_size;
80 for(int j = 0; j < sec->nr_insts; j++) 80 for(int j = 0; j < sec->nr_insts; j++)
81 { 81 {
@@ -203,7 +203,7 @@ static void fix_version(struct sb_version_t *ver)
203static void produce_sb_header(struct sb_file_t *sb, struct sb_header_t *sb_hdr) 203static void produce_sb_header(struct sb_file_t *sb, struct sb_header_t *sb_hdr)
204{ 204{
205 struct sha_1_params_t sha_1_params; 205 struct sha_1_params_t sha_1_params;
206 206
207 sb_hdr->signature[0] = 'S'; 207 sb_hdr->signature[0] = 'S';
208 sb_hdr->signature[1] = 'T'; 208 sb_hdr->signature[1] = 'T';
209 sb_hdr->signature[2] = 'M'; 209 sb_hdr->signature[2] = 'M';
@@ -227,7 +227,7 @@ static void produce_sb_header(struct sb_file_t *sb, struct sb_header_t *sb_hdr)
227 * Version 1.1 requires the last 4 bytes to be 'sgtl' */ 227 * Version 1.1 requires the last 4 bytes to be 'sgtl' */
228 if(sb->minor_version >= 1) 228 if(sb->minor_version >= 1)
229 memcpy(&sb_hdr->rand_pad0[2], "sgtl", 4); 229 memcpy(&sb_hdr->rand_pad0[2], "sgtl", 4);
230 230
231 sb_hdr->timestamp = generate_timestamp(); 231 sb_hdr->timestamp = generate_timestamp();
232 sb_hdr->product_ver = sb->product_ver; 232 sb_hdr->product_ver = sb->product_ver;
233 fix_version(&sb_hdr->product_ver); 233 fix_version(&sb_hdr->product_ver);
@@ -333,17 +333,17 @@ enum sb_error_t sb_write_file(struct sb_file_t *sb, const char *filename)
333 byte *buf = xmalloc(sb_hdr.image_size * BLOCK_SIZE); 333 byte *buf = xmalloc(sb_hdr.image_size * BLOCK_SIZE);
334 byte *buf_p = buf; 334 byte *buf_p = buf;
335 #define write(p, sz) do { memcpy(buf_p, p, sz); buf_p += sz; } while(0) 335 #define write(p, sz) do { memcpy(buf_p, p, sz); buf_p += sz; } while(0)
336 336
337 sha_1_update(&file_sha1, (byte *)&sb_hdr, sizeof(sb_hdr)); 337 sha_1_update(&file_sha1, (byte *)&sb_hdr, sizeof(sb_hdr));
338 write(&sb_hdr, sizeof(sb_hdr)); 338 write(&sb_hdr, sizeof(sb_hdr));
339 339
340 memcpy(crypto_iv, &sb_hdr, 16); 340 memcpy(crypto_iv, &sb_hdr, 16);
341 341
342 /* update CBC-MACs */ 342 /* update CBC-MACs */
343 for(int i = 0; i < g_nr_keys; i++) 343 for(int i = 0; i < g_nr_keys; i++)
344 crypto_cbc((byte *)&sb_hdr, NULL, sizeof(sb_hdr) / BLOCK_SIZE, &g_key_array[i], 344 crypto_cbc((byte *)&sb_hdr, NULL, sizeof(sb_hdr) / BLOCK_SIZE, &g_key_array[i],
345 cbc_macs[i], &cbc_macs[i], 1); 345 cbc_macs[i], &cbc_macs[i], 1);
346 346
347 /* produce and write section headers */ 347 /* produce and write section headers */
348 for(int i = 0; i < sb_hdr.nr_sections; i++) 348 for(int i = 0; i < sb_hdr.nr_sections; i++)
349 { 349 {
@@ -363,7 +363,7 @@ enum sb_error_t sb_write_file(struct sb_file_t *sb, const char *filename)
363 memcpy(entry.hdr_cbc_mac, cbc_macs[i], 16); 363 memcpy(entry.hdr_cbc_mac, cbc_macs[i], 16);
364 crypto_cbc(real_key.u.key, entry.key, 1, &g_key_array[i], 364 crypto_cbc(real_key.u.key, entry.key, 1, &g_key_array[i],
365 crypto_iv, NULL, 1); 365 crypto_iv, NULL, 1);
366 366
367 write(&entry, sizeof(entry)); 367 write(&entry, sizeof(entry));
368 sha_1_update(&file_sha1, (byte *)&entry, sizeof(entry)); 368 sha_1_update(&file_sha1, (byte *)&entry, sizeof(entry));
369 } 369 }
@@ -447,7 +447,7 @@ enum sb_error_t sb_write_file(struct sb_file_t *sb, const char *filename)
447 printf("SB image buffer was not entirely filled !"); 447 printf("SB image buffer was not entirely filled !");
448 return SB_ERROR; 448 return SB_ERROR;
449 } 449 }
450 450
451 FILE *fd = fopen(filename, "wb"); 451 FILE *fd = fopen(filename, "wb");
452 if(fd == NULL) 452 if(fd == NULL)
453 return SB_OPEN_ERROR; 453 return SB_OPEN_ERROR;
@@ -472,13 +472,13 @@ static struct sb_section_t *read_section(bool data_sec, uint32_t id, byte *buf,
472 sb_free_section(*sec); \ 472 sb_free_section(*sec); \
473 free(sec); \ 473 free(sec); \
474 return NULL; } while(0) 474 return NULL; } while(0)
475 475
476 struct sb_section_t *sec = xmalloc(sizeof(struct sb_section_t)); 476 struct sb_section_t *sec = xmalloc(sizeof(struct sb_section_t));
477 memset(sec, 0, sizeof(struct sb_section_t)); 477 memset(sec, 0, sizeof(struct sb_section_t));
478 sec->identifier = id; 478 sec->identifier = id;
479 sec->is_data = data_sec; 479 sec->is_data = data_sec;
480 sec->sec_size = ROUND_UP(size, BLOCK_SIZE) / BLOCK_SIZE; 480 sec->sec_size = ROUND_UP(size, BLOCK_SIZE) / BLOCK_SIZE;
481 481
482 if(data_sec) 482 if(data_sec)
483 { 483 {
484 sec->nr_insts = 1; 484 sec->nr_insts = 1;
@@ -499,7 +499,7 @@ static struct sb_section_t *read_section(bool data_sec, uint32_t id, byte *buf,
499 499
500 struct sb_instruction_header_t *hdr = (struct sb_instruction_header_t *)&buf[pos]; 500 struct sb_instruction_header_t *hdr = (struct sb_instruction_header_t *)&buf[pos];
501 inst.inst = hdr->opcode; 501 inst.inst = hdr->opcode;
502 502
503 printf(OFF, "%s", indent); 503 printf(OFF, "%s", indent);
504 uint8_t checksum = instruction_checksum(hdr); 504 uint8_t checksum = instruction_checksum(hdr);
505 if(checksum != hdr->checksum) 505 if(checksum != hdr->checksum)
@@ -516,7 +516,7 @@ static struct sb_section_t *read_section(bool data_sec, uint32_t id, byte *buf,
516 inst.size = load->len; 516 inst.size = load->len;
517 inst.addr = load->addr; 517 inst.addr = load->addr;
518 inst.data = memdup(load + 1, load->len); 518 inst.data = memdup(load + 1, load->len);
519 519
520 printf(RED, "LOAD"); 520 printf(RED, "LOAD");
521 printf(OFF, " | "); 521 printf(OFF, " | ");
522 printf(BLUE, "addr=0x%08x", load->addr); 522 printf(BLUE, "addr=0x%08x", load->addr);
@@ -543,7 +543,7 @@ static struct sb_section_t *read_section(bool data_sec, uint32_t id, byte *buf,
543 inst.pattern = fill->pattern; 543 inst.pattern = fill->pattern;
544 inst.size = fill->len; 544 inst.size = fill->len;
545 inst.addr = fill->addr; 545 inst.addr = fill->addr;
546 546
547 printf(RED, "FILL"); 547 printf(RED, "FILL");
548 printf(OFF, " | "); 548 printf(OFF, " | ");
549 printf(BLUE, "addr=0x%08x", fill->addr); 549 printf(BLUE, "addr=0x%08x", fill->addr);
@@ -561,7 +561,7 @@ static struct sb_section_t *read_section(bool data_sec, uint32_t id, byte *buf,
561 struct sb_instruction_call_t *call = (struct sb_instruction_call_t *)&buf[pos]; 561 struct sb_instruction_call_t *call = (struct sb_instruction_call_t *)&buf[pos];
562 inst.addr = call->addr; 562 inst.addr = call->addr;
563 inst.argument = call->arg; 563 inst.argument = call->arg;
564 564
565 if(is_call) 565 if(is_call)
566 printf(RED, "CALL"); 566 printf(RED, "CALL");
567 else 567 else
@@ -577,11 +577,11 @@ static struct sb_section_t *read_section(bool data_sec, uint32_t id, byte *buf,
577 { 577 {
578 struct sb_instruction_mode_t *mode = (struct sb_instruction_mode_t *)hdr; 578 struct sb_instruction_mode_t *mode = (struct sb_instruction_mode_t *)hdr;
579 inst.argument = mode->mode; 579 inst.argument = mode->mode;
580 580
581 printf(RED, "MODE"); 581 printf(RED, "MODE");
582 printf(OFF, " | "); 582 printf(OFF, " | ");
583 printf(BLUE, "mod=0x%08x\n", mode->mode); 583 printf(BLUE, "mod=0x%08x\n", mode->mode);
584 584
585 pos += sizeof(struct sb_instruction_mode_t); 585 pos += sizeof(struct sb_instruction_mode_t);
586 } 586 }
587 else if(hdr->opcode == SB_INST_NOP) 587 else if(hdr->opcode == SB_INST_NOP)
@@ -671,7 +671,7 @@ struct sb_file_t *sb_read_memory(void *_buf, size_t filesize, bool raw_mode, voi
671{ 671{
672 struct sb_file_t *sb_file = NULL; 672 struct sb_file_t *sb_file = NULL;
673 uint8_t *buf = _buf; 673 uint8_t *buf = _buf;
674 674
675 #define printf(c, ...) cprintf(u, false, c, __VA_ARGS__) 675 #define printf(c, ...) cprintf(u, false, c, __VA_ARGS__)
676 #define fatal(e, ...) \ 676 #define fatal(e, ...) \
677 do { if(err) *err = e; \ 677 do { if(err) *err = e; \
@@ -680,7 +680,7 @@ struct sb_file_t *sb_read_memory(void *_buf, size_t filesize, bool raw_mode, voi
680 return NULL; } while(0) 680 return NULL; } while(0)
681 #define print_hex(c, p, len, nl) \ 681 #define print_hex(c, p, len, nl) \
682 do { printf(c, ""); print_hex(p, len, nl); } while(0) 682 do { printf(c, ""); print_hex(p, len, nl); } while(0)
683 683
684 struct sha_1_params_t sha_1_params; 684 struct sha_1_params_t sha_1_params;
685 sb_file = xmalloc(sizeof(struct sb_file_t)); 685 sb_file = xmalloc(sizeof(struct sb_file_t));
686 memset(sb_file, 0, sizeof(struct sb_file_t)); 686 memset(sb_file, 0, sizeof(struct sb_file_t));
@@ -730,7 +730,7 @@ struct sb_file_t *sb_read_memory(void *_buf, size_t filesize, bool raw_mode, voi
730 printf(YELLOW, "%x\n", sb_header->flags); 730 printf(YELLOW, "%x\n", sb_header->flags);
731 printf(GREEN, " Total file size : "); 731 printf(GREEN, " Total file size : ");
732 printf(YELLOW, "%ld\n", filesize); 732 printf(YELLOW, "%ld\n", filesize);
733 733
734 /* Sizes and offsets */ 734 /* Sizes and offsets */
735 printf(BLUE, "Sizes and offsets:\n"); 735 printf(BLUE, "Sizes and offsets:\n");
736 printf(GREEN, " # of encryption keys = "); 736 printf(GREEN, " # of encryption keys = ");
@@ -745,7 +745,7 @@ struct sb_file_t *sb_read_memory(void *_buf, size_t filesize, bool raw_mode, voi
745 print_hex(YELLOW, sb_header->rand_pad0, sizeof(sb_header->rand_pad0), true); 745 print_hex(YELLOW, sb_header->rand_pad0, sizeof(sb_header->rand_pad0), true);
746 printf(GREEN, " Random 2: "); 746 printf(GREEN, " Random 2: ");
747 print_hex(YELLOW, sb_header->rand_pad1, sizeof(sb_header->rand_pad1), true); 747 print_hex(YELLOW, sb_header->rand_pad1, sizeof(sb_header->rand_pad1), true);
748 748
749 uint64_t micros = sb_header->timestamp; 749 uint64_t micros = sb_header->timestamp;
750 time_t seconds = (micros / (uint64_t)1000000L); 750 time_t seconds = (micros / (uint64_t)1000000L);
751 struct tm tm_base; 751 struct tm tm_base;
@@ -770,7 +770,7 @@ struct sb_file_t *sb_read_memory(void *_buf, size_t filesize, bool raw_mode, voi
770 printf(YELLOW, "%X.%X.%X\n", product_ver.major, product_ver.minor, product_ver.revision); 770 printf(YELLOW, "%X.%X.%X\n", product_ver.major, product_ver.minor, product_ver.revision);
771 printf(GREEN, " Component version = "); 771 printf(GREEN, " Component version = ");
772 printf(YELLOW, "%X.%X.%X\n", component_ver.major, component_ver.minor, component_ver.revision); 772 printf(YELLOW, "%X.%X.%X\n", component_ver.major, component_ver.minor, component_ver.revision);
773 773
774 printf(GREEN, " Drive tag = "); 774 printf(GREEN, " Drive tag = ");
775 printf(YELLOW, "%x\n", sb_header->drive_tag); 775 printf(YELLOW, "%x\n", sb_header->drive_tag);
776 printf(GREEN, " First boot tag offset = "); 776 printf(GREEN, " First boot tag offset = ");
@@ -781,7 +781,7 @@ struct sb_file_t *sb_read_memory(void *_buf, size_t filesize, bool raw_mode, voi
781 /* encryption cbc-mac */ 781 /* encryption cbc-mac */
782 byte real_key[16]; 782 byte real_key[16];
783 bool valid_key = false; /* false until a matching key was found */ 783 bool valid_key = false; /* false until a matching key was found */
784 784
785 if(sb_header->nr_keys > 0) 785 if(sb_header->nr_keys > 0)
786 { 786 {
787 byte (*cbcmacs)[16] = xmalloc(16 * g_nr_keys); 787 byte (*cbcmacs)[16] = xmalloc(16 * g_nr_keys);
@@ -905,14 +905,14 @@ struct sb_file_t *sb_read_memory(void *_buf, size_t filesize, bool raw_mode, voi
905 { 905 {
906 uint32_t ofs = sb_header->header_size * BLOCK_SIZE + i * sizeof(struct sb_section_header_t); 906 uint32_t ofs = sb_header->header_size * BLOCK_SIZE + i * sizeof(struct sb_section_header_t);
907 struct sb_section_header_t *sec_hdr = (struct sb_section_header_t *)&buf[ofs]; 907 struct sb_section_header_t *sec_hdr = (struct sb_section_header_t *)&buf[ofs];
908 908
909 char name[5]; 909 char name[5];
910 sb_fill_section_name(name, sec_hdr->identifier); 910 sb_fill_section_name(name, sec_hdr->identifier);
911 int pos = sec_hdr->offset * BLOCK_SIZE; 911 int pos = sec_hdr->offset * BLOCK_SIZE;
912 int size = sec_hdr->size * BLOCK_SIZE; 912 int size = sec_hdr->size * BLOCK_SIZE;
913 int data_sec = !(sec_hdr->flags & SECTION_BOOTABLE); 913 int data_sec = !(sec_hdr->flags & SECTION_BOOTABLE);
914 int encrypted = !(sec_hdr->flags & SECTION_CLEARTEXT) && sb_header->nr_keys > 0; 914 int encrypted = !(sec_hdr->flags & SECTION_CLEARTEXT) && sb_header->nr_keys > 0;
915 915
916 printf(GREEN, " Section "); 916 printf(GREEN, " Section ");
917 printf(YELLOW, "'%s'\n", name); 917 printf(YELLOW, "'%s'\n", name);
918 printf(GREEN, " pos = "); 918 printf(GREEN, " pos = ");
@@ -935,7 +935,7 @@ struct sb_file_t *sb_read_memory(void *_buf, size_t filesize, bool raw_mode, voi
935 printf(GREY, " Skipping section content (no valid key)\n"); 935 printf(GREY, " Skipping section content (no valid key)\n");
936 continue; 936 continue;
937 } 937 }
938 938
939 /* save it */ 939 /* save it */
940 byte *sec = xmalloc(size); 940 byte *sec = xmalloc(size);
941 if(encrypted) 941 if(encrypted)
@@ -954,7 +954,7 @@ struct sb_file_t *sb_read_memory(void *_buf, size_t filesize, bool raw_mode, voi
954 } 954 }
955 else 955 else
956 fatal(*err, "Error reading section\n"); 956 fatal(*err, "Error reading section\n");
957 957
958 free(sec); 958 free(sec);
959 } 959 }
960 } 960 }
@@ -979,7 +979,7 @@ struct sb_file_t *sb_read_memory(void *_buf, size_t filesize, bool raw_mode, voi
979 uint8_t checksum = instruction_checksum(hdr); 979 uint8_t checksum = instruction_checksum(hdr);
980 if(checksum != hdr->checksum) 980 if(checksum != hdr->checksum)
981 printf(GREY, "[Bad checksum']"); 981 printf(GREY, "[Bad checksum']");
982 982
983 if(hdr->opcode == SB_INST_NOP) 983 if(hdr->opcode == SB_INST_NOP)
984 { 984 {
985 printf(RED, "NOOP\n"); 985 printf(RED, "NOOP\n");
@@ -1009,7 +1009,7 @@ struct sb_file_t *sb_read_memory(void *_buf, size_t filesize, bool raw_mode, voi
1009 int size = tag->len * BLOCK_SIZE; 1009 int size = tag->len * BLOCK_SIZE;
1010 int data_sec = !(tag->flags & SECTION_BOOTABLE); 1010 int data_sec = !(tag->flags & SECTION_BOOTABLE);
1011 int encrypted = !(tag->flags & SECTION_CLEARTEXT) && sb_header->nr_keys > 0; 1011 int encrypted = !(tag->flags & SECTION_CLEARTEXT) && sb_header->nr_keys > 0;
1012 1012
1013 printf(GREEN, "%sSection ", indent); 1013 printf(GREEN, "%sSection ", indent);
1014 printf(YELLOW, "'%s'\n", name); 1014 printf(YELLOW, "'%s'\n", name);
1015 printf(GREEN, "%s pos = ", indent); 1015 printf(GREEN, "%s pos = ", indent);
@@ -1032,7 +1032,7 @@ struct sb_file_t *sb_read_memory(void *_buf, size_t filesize, bool raw_mode, voi
1032 cbc_mac(buf + pos, sec, size / BLOCK_SIZE, real_key, buf, NULL, 0); 1032 cbc_mac(buf + pos, sec, size / BLOCK_SIZE, real_key, buf, NULL, 0);
1033 else 1033 else
1034 memcpy(sec, buf + pos, size); 1034 memcpy(sec, buf + pos, size);
1035 1035
1036 struct sb_section_t *s = read_section(data_sec, tag->identifier, 1036 struct sb_section_t *s = read_section(data_sec, tag->identifier,
1037 sec, size, " ", u, cprintf, err); 1037 sec, size, " ", u, cprintf, err);
1038 if(s) 1038 if(s)
@@ -1064,7 +1064,7 @@ struct sb_file_t *sb_read_memory(void *_buf, size_t filesize, bool raw_mode, voi
1064 { 1064 {
1065 printf(GREY, "Cannot read content in raw mode without a valid key\n"); 1065 printf(GREY, "Cannot read content in raw mode without a valid key\n");
1066 } 1066 }
1067 1067
1068 /* final signature */ 1068 /* final signature */
1069 printf(BLUE, "Final signature:\n"); 1069 printf(BLUE, "Final signature:\n");
1070 byte decrypted_block[32]; 1070 byte decrypted_block[32];
@@ -1095,7 +1095,7 @@ struct sb_file_t *sb_read_memory(void *_buf, size_t filesize, bool raw_mode, voi
1095 printf(RED, " Failed\n"); 1095 printf(RED, " Failed\n");
1096 fatal(SB_CHECKSUM_ERROR, "File SHA-1 error\n"); 1096 fatal(SB_CHECKSUM_ERROR, "File SHA-1 error\n");
1097 } 1097 }
1098 1098
1099 return sb_file; 1099 return sb_file;
1100 #undef printf 1100 #undef printf
1101 #undef fatal 1101 #undef fatal
@@ -1131,13 +1131,13 @@ void sb_dump(struct sb_file_t *file, void *u, sb_color_printf cprintf)
1131 #define printf(c, ...) cprintf(u, false, c, __VA_ARGS__) 1131 #define printf(c, ...) cprintf(u, false, c, __VA_ARGS__)
1132 #define print_hex(c, p, len, nl) \ 1132 #define print_hex(c, p, len, nl) \
1133 do { printf(c, ""); print_hex(p, len, nl); } while(0) 1133 do { printf(c, ""); print_hex(p, len, nl); } while(0)
1134 1134
1135 #define TREE RED 1135 #define TREE RED
1136 #define HEADER GREEN 1136 #define HEADER GREEN
1137 #define TEXT YELLOW 1137 #define TEXT YELLOW
1138 #define TEXT2 BLUE 1138 #define TEXT2 BLUE
1139 #define SEP OFF 1139 #define SEP OFF
1140 1140
1141 printf(BLUE, "SB File\n"); 1141 printf(BLUE, "SB File\n");
1142 printf(TREE, "+-"); 1142 printf(TREE, "+-");
1143 printf(HEADER, "Version: "); 1143 printf(HEADER, "Version: ");
@@ -1153,7 +1153,7 @@ void sb_dump(struct sb_file_t *file, void *u, sb_color_printf cprintf)
1153 char name[5]; 1153 char name[5];
1154 sb_fill_section_name(name, file->first_boot_sec_id); 1154 sb_fill_section_name(name, file->first_boot_sec_id);
1155 printf(TEXT, "%08x (%s)\n", file->first_boot_sec_id, name); 1155 printf(TEXT, "%08x (%s)\n", file->first_boot_sec_id, name);
1156 1156
1157 if(file->override_real_key) 1157 if(file->override_real_key)
1158 { 1158 {
1159 printf(TREE, "+-"); 1159 printf(TREE, "+-");
@@ -1174,7 +1174,7 @@ void sb_dump(struct sb_file_t *file, void *u, sb_color_printf cprintf)
1174 printf(HEADER, "Component Version: "); 1174 printf(HEADER, "Component Version: ");
1175 printf(TEXT, "%X.%X.%X\n", file->component_ver.major, file->component_ver.minor, 1175 printf(TEXT, "%X.%X.%X\n", file->component_ver.major, file->component_ver.minor,
1176 file->component_ver.revision); 1176 file->component_ver.revision);
1177 1177
1178 for(int i = 0; i < file->nr_sections; i++) 1178 for(int i = 0; i < file->nr_sections; i++)
1179 { 1179 {
1180 struct sb_section_t *sec = &file->sections[i]; 1180 struct sb_section_t *sec = &file->sections[i];
@@ -1241,7 +1241,7 @@ void sb_dump(struct sb_file_t *file, void *u, sb_color_printf cprintf)
1241 } 1241 }
1242 } 1242 }
1243 } 1243 }
1244 1244
1245 #undef printf 1245 #undef printf
1246 #undef print_hex 1246 #undef print_hex
1247} 1247}
diff --git a/utils/imxtools/sbtools/sb.h b/utils/imxtools/sbtools/sb.h
index 74d86f303a..4873195a61 100644
--- a/utils/imxtools/sbtools/sb.h
+++ b/utils/imxtools/sbtools/sb.h
@@ -180,7 +180,7 @@ struct sb_section_t
180 bool is_data; 180 bool is_data;
181 bool is_cleartext; 181 bool is_cleartext;
182 uint32_t alignment; 182 uint32_t alignment;
183 // data sections are handled as one or more SB_INST_DATA virtual instruction 183 // data sections are handled as one or more SB_INST_DATA virtual instruction
184 int nr_insts; 184 int nr_insts;
185 struct sb_inst_t *insts; 185 struct sb_inst_t *insts;
186 /* for production use */ 186 /* for production use */
@@ -196,7 +196,7 @@ struct sb_file_t
196 /* override crypto IV, use with caution ! Use NULL to generate it */ 196 /* override crypto IV, use with caution ! Use NULL to generate it */
197 bool override_crypto_iv; 197 bool override_crypto_iv;
198 uint8_t crypto_iv[16]; 198 uint8_t crypto_iv[16];
199 199
200 int nr_sections; 200 int nr_sections;
201 uint16_t drive_tag; 201 uint16_t drive_tag;
202 uint32_t first_boot_sec_id; 202 uint32_t first_boot_sec_id;
diff --git a/utils/imxtools/sbtools/sb1.c b/utils/imxtools/sbtools/sb1.c
index deb09a51e1..bb9b3d5035 100644
--- a/utils/imxtools/sbtools/sb1.c
+++ b/utils/imxtools/sbtools/sb1.c
@@ -184,7 +184,7 @@ enum sb1_error_t sb1_write_file(struct sb1_file_t *sb, const char *filename)
184 if(sb->userdata) 184 if(sb->userdata)
185 fwrite(sb->userdata, sb->userdata_size, 1, fd); 185 fwrite(sb->userdata, sb->userdata_size, 1, fd);
186 fclose(fd); 186 fclose(fd);
187 187
188 return SB1_SUCCESS; 188 return SB1_SUCCESS;
189} 189}
190 190
@@ -257,7 +257,7 @@ bool sb1_is_key_valid_fast(void *buffer, size_t size, union xorcrypt_key_t _key[
257 struct sb1_header_t *header = (struct sb1_header_t *)buffer; 257 struct sb1_header_t *header = (struct sb1_header_t *)buffer;
258 258
259 union xorcrypt_key_t key[2]; 259 union xorcrypt_key_t key[2];
260 260
261 uint8_t sector[SECTOR_SIZE]; 261 uint8_t sector[SECTOR_SIZE];
262 /* copy key and data because it's modified by the crypto code */ 262 /* copy key and data because it's modified by the crypto code */
263 memcpy(key, _key, sizeof(key)); 263 memcpy(key, _key, sizeof(key));
@@ -399,7 +399,7 @@ struct sb1_file_t *sb1_read_memory(void *_buf, size_t filesize, void *u,
399 printf(YELLOW, "%X.%X.%X\n", product_ver.major, product_ver.minor, product_ver.revision); 399 printf(YELLOW, "%X.%X.%X\n", product_ver.major, product_ver.minor, product_ver.revision);
400 printf(GREEN, " Component version: "); 400 printf(GREEN, " Component version: ");
401 printf(YELLOW, "%X.%X.%X\n", component_ver.major, component_ver.minor, component_ver.revision); 401 printf(YELLOW, "%X.%X.%X\n", component_ver.major, component_ver.minor, component_ver.revision);
402 402
403 printf(GREEN, " Drive tag: "); 403 printf(GREEN, " Drive tag: ");
404 printf(YELLOW, "%x\n", header->drive_tag); 404 printf(YELLOW, "%x\n", header->drive_tag);
405 405
diff --git a/utils/imxtools/sbtools/sb1.h b/utils/imxtools/sbtools/sb1.h
index 2adfc6a26c..83ff0e7431 100644
--- a/utils/imxtools/sbtools/sb1.h
+++ b/utils/imxtools/sbtools/sb1.h
@@ -165,4 +165,4 @@ void sb1_dump(struct sb1_file_t *file, void *u, sb1_color_printf printf);
165void sb1_free(struct sb1_file_t *file); 165void sb1_free(struct sb1_file_t *file);
166 166
167#endif /* __SB1_H__ */ 167#endif /* __SB1_H__ */
168 168
diff --git a/utils/imxtools/sbtools/sbloader.c b/utils/imxtools/sbtools/sbloader.c
index 657ef5d578..01b9fe6c01 100644
--- a/utils/imxtools/sbtools/sbloader.c
+++ b/utils/imxtools/sbtools/sbloader.c
@@ -340,7 +340,7 @@ static int probe_hid_xfer_size(libusb_device_handle *dev)
340 size -= item.total_size; 340 size -= item.total_size;
341 } 341 }
342 return xfer_size / 8; 342 return xfer_size / 8;
343 343
344 Lerr: 344 Lerr:
345 printf("Cannot probe transfer size, please specify it on command line.\n"); 345 printf("Cannot probe transfer size, please specify it on command line.\n");
346 exit(11); 346 exit(11);
diff --git a/utils/imxtools/sbtools/sbtoelf.c b/utils/imxtools/sbtools/sbtoelf.c
index e68f5e6e06..75dc58e4bd 100644
--- a/utils/imxtools/sbtools/sbtoelf.c
+++ b/utils/imxtools/sbtools/sbtoelf.c
@@ -86,10 +86,10 @@ static void extract_elf_section(struct elf_params_t *elf, int count, uint32_t id
86 sprintf(filename, "%s%s.%d.elf", g_out_prefix, name, count); 86 sprintf(filename, "%s%s.%d.elf", g_out_prefix, name, count);
87 if(g_debug) 87 if(g_debug)
88 printf("Write boot section %s to %s\n", name, filename); 88 printf("Write boot section %s to %s\n", name, filename);
89 89
90 FILE *fd = fopen(filename, "wb"); 90 FILE *fd = fopen(filename, "wb");
91 free(filename); 91 free(filename);
92 92
93 if(fd == NULL) 93 if(fd == NULL)
94 return; 94 return;
95 if(g_elf_simplify) 95 if(g_elf_simplify)
@@ -112,7 +112,7 @@ static void extract_sb_section(struct sb_section_t *sec)
112 if(g_debug) 112 if(g_debug)
113 printf("Write data section %s to %s\n", sec_name, filename); 113 printf("Write data section %s to %s\n", sec_name, filename);
114 free(filename); 114 free(filename);
115 115
116 for(int j = 0; j < sec->nr_insts; j++) 116 for(int j = 0; j < sec->nr_insts; j++)
117 { 117 {
118 assert(sec->insts[j].inst == SB_INST_DATA); 118 assert(sec->insts[j].inst == SB_INST_DATA);
@@ -494,7 +494,7 @@ int main(int argc, char **argv)
494 } 494 }
495 if(loopback) 495 if(loopback)
496 sb1_write_file(file, loopback); 496 sb1_write_file(file, loopback);
497 497
498 sb1_free(file); 498 sb1_free(file);
499 } 499 }
500 else 500 else
@@ -504,6 +504,6 @@ int main(int argc, char **argv)
504 return 1; 504 return 1;
505 } 505 }
506 clear_keys(); 506 clear_keys();
507 507
508 return 0; 508 return 0;
509} 509}
diff --git a/utils/imxtools/sbtools/sha1.c b/utils/imxtools/sbtools/sha1.c
index 0ad05bb5cd..cb34059166 100644
--- a/utils/imxtools/sbtools/sha1.c
+++ b/utils/imxtools/sbtools/sha1.c
@@ -106,7 +106,7 @@ void sha_1_block(struct sha_1_params_t *params, uint32_t cur_hash[5], byte *data
106 memmove(w, data, 64); 106 memmove(w, data, 64);
107 for(int i = 0; i < 16; i++) 107 for(int i = 0; i < 16; i++)
108 byte_swap32(&w[i]); 108 byte_swap32(&w[i]);
109 109
110 for(int i = 16; i <= 79; i++) 110 for(int i = 16; i <= 79; i++)
111 w[i] = rot_left(w[i - 3] ^ w[i - 8] ^ w[i - 14] ^ w[i - 16], 1); 111 w[i] = rot_left(w[i - 3] ^ w[i - 8] ^ w[i - 14] ^ w[i - 16], 1);
112 112
@@ -141,7 +141,7 @@ void sha_1_block(struct sha_1_params_t *params, uint32_t cur_hash[5], byte *data
141 a = temp; 141 a = temp;
142 } 142 }
143 #undef w 143 #undef w
144 144
145 cur_hash[0] += a; 145 cur_hash[0] += a;
146 cur_hash[1] += b; 146 cur_hash[1] += b;
147 cur_hash[2] += c; 147 cur_hash[2] += c;