diff options
Diffstat (limited to 'rbutil/sansapatcher/sansapatcher.c')
-rw-r--r-- | rbutil/sansapatcher/sansapatcher.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/rbutil/sansapatcher/sansapatcher.c b/rbutil/sansapatcher/sansapatcher.c index 2081e396c2..310f312052 100644 --- a/rbutil/sansapatcher/sansapatcher.c +++ b/rbutil/sansapatcher/sansapatcher.c | |||
@@ -28,14 +28,16 @@ | |||
28 | 28 | ||
29 | #include "sansaio.h" | 29 | #include "sansaio.h" |
30 | #include "sansapatcher.h" | 30 | #include "sansapatcher.h" |
31 | #include "bootimg.h" | ||
32 | 31 | ||
32 | #ifndef RBUTIL | ||
33 | #include "bootimg.h" | ||
34 | #endif | ||
33 | /* The offset of the MI4 image header in the firmware partition */ | 35 | /* The offset of the MI4 image header in the firmware partition */ |
34 | #define PPMI_OFFSET 0x80000 | 36 | #define PPMI_OFFSET 0x80000 |
35 | 37 | ||
36 | extern int verbose; | 38 | extern int verbose; |
37 | 39 | ||
38 | /* Windows requires the buffer for disk I/O to be aligned in memory on a | 40 | /* Windows requires the buffer for disk I/O to be aligned in memory on a |
39 | multiple of the disk volume size - so we use a single global variable | 41 | multiple of the disk volume size - so we use a single global variable |
40 | and initialise it with sansa_alloc_buf() in main(). | 42 | and initialise it with sansa_alloc_buf() in main(). |
41 | */ | 43 | */ |
@@ -369,8 +371,8 @@ int is_e200(struct sansa_t* sansa) | |||
369 | sansa->hasoldbootloader = 0; | 371 | sansa->hasoldbootloader = 0; |
370 | if (memcmp(sectorbuf+0x1f8,"RBBL",4)==0) { | 372 | if (memcmp(sectorbuf+0x1f8,"RBBL",4)==0) { |
371 | /* Look for an original firmware after the first image */ | 373 | /* Look for an original firmware after the first image */ |
372 | if (sansa_seek_and_read(sansa, | 374 | if (sansa_seek_and_read(sansa, |
373 | sansa->start + PPMI_OFFSET + 0x200 + ppmi_length, | 375 | sansa->start + PPMI_OFFSET + 0x200 + ppmi_length, |
374 | sectorbuf, 512) < 0) { | 376 | sectorbuf, 512) < 0) { |
375 | return -7; | 377 | return -7; |
376 | } | 378 | } |
@@ -461,14 +463,14 @@ static int load_original_firmware(struct sansa_t* sansa, unsigned char* buf, str | |||
461 | 463 | ||
462 | if (get_mi4header(buf,mi4header)==0) { | 464 | if (get_mi4header(buf,mi4header)==0) { |
463 | /* We have a valid MI4 file after a bootloader, so we use this. */ | 465 | /* We have a valid MI4 file after a bootloader, so we use this. */ |
464 | if ((n = sansa_seek_and_read(sansa, | 466 | if ((n = sansa_seek_and_read(sansa, |
465 | sansa->start + PPMI_OFFSET + 0x200 + ppmi_length, | 467 | sansa->start + PPMI_OFFSET + 0x200 + ppmi_length, |
466 | buf, mi4header->mi4size)) < 0) { | 468 | buf, mi4header->mi4size)) < 0) { |
467 | return -1; | 469 | return -1; |
468 | } | 470 | } |
469 | } else { | 471 | } else { |
470 | /* No valid MI4 file, so read the first image. */ | 472 | /* No valid MI4 file, so read the first image. */ |
471 | if ((n = sansa_seek_and_read(sansa, | 473 | if ((n = sansa_seek_and_read(sansa, |
472 | sansa->start + PPMI_OFFSET + 0x200, | 474 | sansa->start + PPMI_OFFSET + 0x200, |
473 | buf, ppmi_length)) < 0) { | 475 | buf, ppmi_length)) < 0) { |
474 | return -1; | 476 | return -1; |
@@ -571,7 +573,9 @@ int sansa_add_bootloader(struct sansa_t* sansa, char* filename, int type) | |||
571 | 573 | ||
572 | bl_length = filesize(infile); | 574 | bl_length = filesize(infile); |
573 | } else { | 575 | } else { |
576 | #ifndef RBUTIL | ||
574 | bl_length = LEN_bootimg; | 577 | bl_length = LEN_bootimg; |
578 | #endif | ||
575 | } | 579 | } |
576 | 580 | ||
577 | /* Create PPMI header */ | 581 | /* Create PPMI header */ |
@@ -595,7 +599,9 @@ int sansa_add_bootloader(struct sansa_t* sansa, char* filename, int type) | |||
595 | return -1; | 599 | return -1; |
596 | } | 600 | } |
597 | } else { | 601 | } else { |
602 | #ifndef RBUTIL | ||
598 | memcpy(sectorbuf+0x200,bootimg,LEN_bootimg); | 603 | memcpy(sectorbuf+0x200,bootimg,LEN_bootimg); |
604 | #endif | ||
599 | } | 605 | } |
600 | 606 | ||
601 | /* Load original firmware from Sansa to the space after the bootloader */ | 607 | /* Load original firmware from Sansa to the space after the bootloader */ |