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/gigabeat-s.c | |
parent | 1dff29a9d6780c2fd10ac1ad32929cb6808c0936 (diff) | |
download | rockbox-c2ca8c710c9841892ca8123e39d2acdf0a0e5de3.tar.gz rockbox-c2ca8c710c9841892ca8123e39d2acdf0a0e5de3.zip |
* 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/gigabeat-s.c')
-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 25b9ab5f35..d692dcba09 100644 --- a/bootloader/gigabeat-s.c +++ b/bootloader/gigabeat-s.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include "kernel.h" | 28 | #include "kernel.h" |
29 | #include "thread.h" | 29 | #include "thread.h" |
30 | #include "ata.h" | 30 | #include "ata.h" |
31 | #include "dir.h" | ||
31 | #include "fat.h" | 32 | #include "fat.h" |
32 | #include "disk.h" | 33 | #include "disk.h" |
33 | #include "font.h" | 34 | #include "font.h" |
@@ -47,13 +48,18 @@ | |||
47 | #include <stdarg.h> | 48 | #include <stdarg.h> |
48 | 49 | ||
49 | char version[] = APPSVERSION; | 50 | char version[] = APPSVERSION; |
51 | char buf[MAX_PATH]; | ||
52 | char basedir[] = "/Content/0b00/00/"; /* Where files sent via MTP are stored */ | ||
53 | char model[5]; | ||
54 | int (*kernel_entry)(void); | ||
50 | 55 | ||
51 | void main(void) | 56 | void main(void) |
52 | { | 57 | { |
53 | lcd_clear_display(); | 58 | lcd_clear_display(); |
54 | printf("Hello world!"); | 59 | printf("Hello world!"); |
55 | printf("Gigabeat S Rockbox Bootloader v.00000001"); | 60 | printf("Gigabeat S Rockbox Bootloader v.00000001"); |
56 | kernel_init(); | 61 | kernel_init(); |
62 | printf("kernel init done"); | ||
57 | int rc; | 63 | int rc; |
58 | 64 | ||
59 | rc = ata_init(); | 65 | rc = ata_init(); |
@@ -62,8 +68,10 @@ void main(void) | |||
62 | reset_screen(); | 68 | reset_screen(); |
63 | error(EATA, rc); | 69 | error(EATA, rc); |
64 | } | 70 | } |
71 | printf("ata init done"); | ||
65 | 72 | ||
66 | disk_init(); | 73 | disk_init(); |
74 | printf("disk init done"); | ||
67 | 75 | ||
68 | rc = disk_mount_all(); | 76 | rc = disk_mount_all(); |
69 | if (rc<=0) | 77 | if (rc<=0) |
@@ -71,24 +79,48 @@ void main(void) | |||
71 | error(EDISK,rc); | 79 | error(EDISK,rc); |
72 | } | 80 | } |
73 | 81 | ||
74 | printf("Congratulations!"); | 82 | /* Look for the first valid firmware file */ |
75 | while(1); | 83 | struct dirent_uncached* entry; |
84 | DIR_UNCACHED* dir; | ||
85 | int fd; | ||
86 | dir = opendir_uncached(basedir); | ||
87 | while ((entry = readdir_uncached(dir))) | ||
88 | { | ||
89 | if (*entry->d_name != '.') | ||
90 | { | ||
91 | snprintf(buf, sizeof(buf), "%s%s", basedir, entry->d_name); | ||
92 | fd = open(buf, O_RDONLY); | ||
93 | if (fd >= 0) | ||
94 | { | ||
95 | lseek(fd, 4, SEEK_SET); | ||
96 | rc = read(fd, model, 4); | ||
97 | close(fd); | ||
98 | if (rc == 4) | ||
99 | { | ||
100 | model[4] = 0; | ||
101 | if (strcmp(model, "gigs") == 0) | ||
102 | break; | ||
103 | } | ||
104 | } | ||
105 | } | ||
106 | } | ||
76 | 107 | ||
77 | #if 0 | 108 | printf("Firmware file: %s", buf); |
78 | printf("Loading firmware"); | 109 | printf("Loading firmware"); |
79 | 110 | ||
80 | loadbuffer = (unsigned char*) 0x100; | 111 | unsigned char *loadbuffer = (unsigned char *)0x88000000; |
81 | buffer_size = (unsigned char*)0x400000 - loadbuffer; | 112 | int buffer_size = 1024*1024; |
82 | 113 | ||
83 | rc = load_firmware(loadbuffer, BOOTFILE, buffer_size); | 114 | rc = load_firmware(loadbuffer, buf, buffer_size); |
84 | if(rc < 0) | 115 | if(rc < 0) |
85 | error(EBOOTFILE, rc); | 116 | error(buf, rc); |
86 | 117 | ||
87 | if (rc == EOK) | 118 | if (rc == EOK) |
88 | { | 119 | { |
89 | kernel_entry = (void*) loadbuffer; | 120 | kernel_entry = (void*) loadbuffer; |
90 | rc = kernel_entry(); | 121 | rc = kernel_entry(); |
91 | } | 122 | } |
92 | #endif | 123 | |
124 | while (1); | ||
93 | } | 125 | } |
94 | 126 | ||