summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/plugins/rockbox_flash.c33
1 files changed, 31 insertions, 2 deletions
diff --git a/apps/plugins/rockbox_flash.c b/apps/plugins/rockbox_flash.c
index 9a403197dd..4c552622e5 100644
--- a/apps/plugins/rockbox_flash.c
+++ b/apps/plugins/rockbox_flash.c
@@ -82,6 +82,7 @@ typedef enum
82 eNotUCL, 82 eNotUCL,
83 eWrongAlgorithm, 83 eWrongAlgorithm,
84 eMultiBlocks, 84 eMultiBlocks,
85 eBadRomLink
85} tCheckResult; 86} tCheckResult;
86 87
87typedef struct 88typedef struct
@@ -438,10 +439,31 @@ tCheckResult CheckImageFile(char* filename, int space, tImageHeader* pHeader,
438 rb->close(fd); 439 rb->close(fd);
439 return eReadErr; 440 return eReadErr;
440 } 441 }
441 pHeader->execute = reset_vector; 442 if (reset_vector >= (UINT32)FB
442 if (reset_vector != ROCKBOX_EXEC) /* nonstandard address? */ 443 && reset_vector < (UINT32)FB+512*1024) /* ROM address? */
444 {
443 /* assume in-place, executing directly in flash */ 445 /* assume in-place, executing directly in flash */
444 pHeader->destination = (UINT32)(pos + sizeof(tImageHeader)); 446 pHeader->destination = (UINT32)(pos + sizeof(tImageHeader));
447
448 /* for new RomBox, this isn't the reset vector,
449 but the link address, for us to check the position */
450 if(pHeader->destination != reset_vector) /* compare link addr. */
451 {
452 rb->close(fd);
453 return eBadRomLink; /* not matching the start address */
454 }
455
456 /* read the now following reset vector */
457 read = rb->read(fd, &reset_vector, sizeof(reset_vector));
458 fileread += read;
459 if (read != sizeof(reset_vector))
460 {
461 rb->close(fd);
462 return eReadErr;
463 }
464 }
465
466 pHeader->execute = reset_vector;
445 } 467 }
446 468
447 /* check if we can read the whole file */ 469 /* check if we can read the whole file */
@@ -737,6 +759,10 @@ void DoUserDialog(char* filename)
737 rb->lcd_puts(0, 2, "Blocksize"); 759 rb->lcd_puts(0, 2, "Blocksize");
738 rb->lcd_puts(0, 3, " too small?"); 760 rb->lcd_puts(0, 3, " too small?");
739 break; 761 break;
762 case eBadRomLink:
763 rb->lcd_puts(0, 1, "RomBox mismatch.");
764 rb->lcd_puts(0, 2, "Wrong ROM position");
765 break;
740 default: 766 default:
741 rb->lcd_puts(0, 1, "Check failed."); 767 rb->lcd_puts(0, 1, "Check failed.");
742 break; 768 break;
@@ -906,6 +932,9 @@ void DoUserDialog(char* filename)
906 case eMultiBlocks: 932 case eMultiBlocks:
907 rb->lcd_puts_scroll(0, 1, "File invalid. Blocksize too small?"); 933 rb->lcd_puts_scroll(0, 1, "File invalid. Blocksize too small?");
908 break; 934 break;
935 case eBadRomLink:
936 rb->lcd_puts_scroll(0, 1, "BootBox mismatch");
937 break;
909 default: 938 default:
910 rb->lcd_puts_scroll(0, 1, "Check failed."); 939 rb->lcd_puts_scroll(0, 1, "Check failed.");
911 break; 940 break;