summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJörg Hohensohn <hohensoh@rockbox.org>2004-01-18 17:34:12 +0000
committerJörg Hohensohn <hohensoh@rockbox.org>2004-01-18 17:34:12 +0000
commite692b0e34b4d3ebe115924fc38def10e8851dc0c (patch)
tree5b2bfb83e395facf21ad6718a03753065d90d325
parenta8c9dd2e11d8f4eb3485e4b15c9518734127709b (diff)
downloadrockbox-e692b0e34b4d3ebe115924fc38def10e8851dc0c.tar.gz
rockbox-e692b0e34b4d3ebe115924fc38def10e8851dc0c.zip
prepared to flash uncompressed ucl such that suitable Rockbox builds directly execute from ROM
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4252 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/plugins/rockbox_flash.c52
1 files changed, 33 insertions, 19 deletions
diff --git a/apps/plugins/rockbox_flash.c b/apps/plugins/rockbox_flash.c
index 661203b8b8..eb04fbb566 100644
--- a/apps/plugins/rockbox_flash.c
+++ b/apps/plugins/rockbox_flash.c
@@ -243,7 +243,7 @@ tImageHeader* GetSecondImage(void)
if (pImage1->destination != ROCKBOX_DEST ||
pImage1->execute != ROCKBOX_EXEC)
- return 0; /* seems to be no Rockbox stuff in here */
+ return 0; /* seems to be no Archos/Rockbox image in here */
if (pImage1->size != 0)
{
@@ -262,7 +262,8 @@ tImageHeader* GetSecondImage(void)
/*********** Image File Functions ************/
/* so far, only compressed images in UCL NRV algorithm 2e supported */
-tCheckResult CheckImageFile(char* filename, int space, tImageHeader* pHeader)
+tCheckResult CheckImageFile(char* filename, int space, tImageHeader* pHeader,
+ UINT8* pos)
{
int i;
int fd;
@@ -311,13 +312,6 @@ tCheckResult CheckImageFile(char* filename, int space, tImageHeader* pHeader)
}
}
- /* check for supported algorithm */
- if (ucl_header[12] != 0x2E)
- {
- rb->close(fd);
- return eWrongAlgorithm;
- }
-
pHeader->size = Read32(ucl_header + 22); /* compressed size */
if (pHeader->size != filesize - sizeof(ucl_header) - 8)
{
@@ -325,15 +319,39 @@ tCheckResult CheckImageFile(char* filename, int space, tImageHeader* pHeader)
return eMultiBlocks;
}
+ /* fill in the hardcoded defaults of the header */
+ pHeader->destination = ROCKBOX_DEST;
+ pHeader->execute = ROCKBOX_EXEC;
+
if (Read32(ucl_header + 18) > pHeader->size) /* compare with uncompressed
size */
- { /* normal case */
+ { /* compressed, normal case */
pHeader->flags = 0x00000001; /* flags for UCL compressed */
+
+ /* check for supported algorithm */
+ if (ucl_header[12] != 0x2E)
+ {
+ rb->close(fd);
+ return eWrongAlgorithm;
+ }
}
else
- {
- pHeader->flags = 0x00000000; /* very unlikely, content was not
- compressible */
+ { /* uncompressed, either to be copied or run directly in flash */
+ UINT32 reset_vector; /* image has to start with reset vector */
+
+ pHeader->flags = 0x00000000; /* uncompressed */
+
+ read = rb->read(fd, &reset_vector, sizeof(reset_vector));
+ fileread += read;
+ if (read != sizeof(reset_vector))
+ {
+ rb->close(fd);
+ return eReadErr;
+ }
+ pHeader->execute = reset_vector;
+ if (reset_vector != ROCKBOX_EXEC) /* nonstandard address? */
+ /* assume in-place, executing directly in flash */
+ pHeader->destination = (UINT32)(pos + sizeof(tImageHeader));
}
/* check if we can read the whole file */
@@ -348,10 +366,6 @@ tCheckResult CheckImageFile(char* filename, int space, tImageHeader* pHeader)
if (fileread != filesize)
return eReadErr;
- /* fill in the hardcoded rest of the header */
- pHeader->destination = ROCKBOX_DEST;
- pHeader->execute = ROCKBOX_EXEC;
-
return eOK;
}
@@ -567,7 +581,7 @@ void DoUserDialog(char* filename, bool show_greet)
space = FlashInfo.size - (pos-FB + sizeof(ImageHeader));
/* size minus start */
- rc = CheckImageFile(filename, space, &ImageHeader);
+ rc = CheckImageFile(filename, space, &ImageHeader, pos);
if (rc != eOK)
{
rb->lcd_clear_display(); /* make room for error message */
@@ -743,7 +757,7 @@ void DoUserDialog(char* filename, bool show_greet)
space = FlashInfo.size - (pos-FB + sizeof(ImageHeader));
/* size minus start */
- rc = CheckImageFile(filename, space, &ImageHeader);
+ rc = CheckImageFile(filename, space, &ImageHeader, pos);
rb->lcd_puts(0, 0, "Checked:");
switch (rc) {
case eOK: