diff options
| author | Nicolas Pennequin <nicolas.pennequin@free.fr> | 2007-11-27 15:40:29 +0000 |
|---|---|---|
| committer | Nicolas Pennequin <nicolas.pennequin@free.fr> | 2007-11-27 15:40:29 +0000 |
| commit | c2ca8c710c9841892ca8123e39d2acdf0a0e5de3 (patch) | |
| tree | 3559f4629701ad4ce7b0142bb3160a2a96ea92c1 /bootloader | |
| parent | 1dff29a9d6780c2fd10ac1ad32929cb6808c0936 (diff) | |
| download | rockbox-c2ca8c710c9841892ca8123e39d2acdf0a0e5de3.zip rockbox-c2ca8c710c9841892ca8123e39d2acdf0a0e5de3.tar.gz rockbox-c2ca8c710c9841892ca8123e39d2acdf0a0e5de3.tar.bz2 rockbox-c2ca8c710c9841892ca8123e39d2acdf0a0e5de3.tar.xz | |
* Make the Gigabeat S bootloader a bit more interesting: it looks for the first firmware file it finds on the second partition and attempts to load it. Loading fails to get past the splash screen though.
* Make the main binary compile.
To send a firmware file, use mtp-sendfile. To update you'll need to delete the previous firmware file, as files are named sequentially and the first one is loaded.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15836 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'bootloader')
| -rw-r--r-- | bootloader/gigabeat-s.c | 50 |
1 files changed, 41 insertions, 9 deletions
diff --git a/bootloader/gigabeat-s.c b/bootloader/gigabeat-s.c index 25b9ab5..d692dcb 100644 --- a/bootloader/gigabeat-s.c +++ b/bootloader/gigabeat-s.c @@ -28,6 +28,7 @@ #include "kernel.h" #include "thread.h" #include "ata.h" +#include "dir.h" #include "fat.h" #include "disk.h" #include "font.h" @@ -47,13 +48,18 @@ #include <stdarg.h> char version[] = APPSVERSION; +char buf[MAX_PATH]; +char basedir[] = "/Content/0b00/00/"; /* Where files sent via MTP are stored */ +char model[5]; +int (*kernel_entry)(void); void main(void) { lcd_clear_display(); printf("Hello world!"); - printf("Gigabeat S Rockbox Bootloader v.00000001"); + printf("Gigabeat S Rockbox Bootloader v.00000001"); kernel_init(); + printf("kernel init done"); int rc; rc = ata_init(); @@ -62,8 +68,10 @@ void main(void) reset_screen(); error(EATA, rc); } + printf("ata init done"); disk_init(); + printf("disk init done"); rc = disk_mount_all(); if (rc<=0) @@ -71,24 +79,48 @@ void main(void) error(EDISK,rc); } - printf("Congratulations!"); - while(1); + /* Look for the first valid firmware file */ + struct dirent_uncached* entry; + DIR_UNCACHED* dir; + int fd; + dir = opendir_uncached(basedir); + while ((entry = readdir_uncached(dir))) + { + if (*entry->d_name != '.') + { + snprintf(buf, sizeof(buf), "%s%s", basedir, entry->d_name); + fd = open(buf, O_RDONLY); + if (fd >= 0) + { + lseek(fd, 4, SEEK_SET); + rc = read(fd, model, 4); + close(fd); + if (rc == 4) + { + model[4] = 0; + if (strcmp(model, "gigs") == 0) + break; + } + } + } + } -#if 0 + printf("Firmware file: %s", buf); printf("Loading firmware"); - loadbuffer = (unsigned char*) 0x100; - buffer_size = (unsigned char*)0x400000 - loadbuffer; + unsigned char *loadbuffer = (unsigned char *)0x88000000; + int buffer_size = 1024*1024; - rc = load_firmware(loadbuffer, BOOTFILE, buffer_size); + rc = load_firmware(loadbuffer, buf, buffer_size); if(rc < 0) - error(EBOOTFILE, rc); + error(buf, rc); if (rc == EOK) { kernel_entry = (void*) loadbuffer; rc = kernel_entry(); } -#endif + + while (1); } |