summaryrefslogtreecommitdiff
path: root/bootloader
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2021-08-21 21:25:01 -0400
committerSolomon Peachy <pizza@shaftnet.org>2021-08-21 21:53:03 -0400
commite07c460eef832fc4cfe22750ecf15db1ff2fc213 (patch)
treee133b39bb36ac11f2c9a5b11c27ae2bff9ac33d1 /bootloader
parent247258b9d2421046d0ed5977f8edec9f172f4038 (diff)
downloadrockbox-e07c460eef832fc4cfe22750ecf15db1ff2fc213.tar.gz
rockbox-e07c460eef832fc4cfe22750ecf15db1ff2fc213.zip
xduoox3: Bootloader improvements:
* Explicitly clear the caches prior to launching the binary * Ensure the function that launches the binary is in iram * Re-sequenced some of the subsystem initializations * Fixes for USB mode Change-Id: Ie020b18586b2599edeb88529dd3d7337e33a5a6f
Diffstat (limited to 'bootloader')
-rw-r--r--bootloader/xduoox3.c44
1 files changed, 26 insertions, 18 deletions
diff --git a/bootloader/xduoox3.c b/bootloader/xduoox3.c
index d38639bfd4..330431f9c9 100644
--- a/bootloader/xduoox3.c
+++ b/bootloader/xduoox3.c
@@ -55,13 +55,18 @@ static void show_splash(int timeout, const char *msg)
55 sleep(timeout); 55 sleep(timeout);
56} 56}
57 57
58static int usb_inited = 0;
59
58static void usb_mode(void) 60static void usb_mode(void)
59{ 61{
60 int button; 62 int button;
61 63
62 /* Init USB */ 64 /* Init USB, but only once */
63 usb_init(); 65 if (!usb_inited) {
64 usb_start_monitoring(); 66 usb_init();
67 usb_start_monitoring();
68 usb_inited = 1;
69 }
65 70
66 /* Wait for threads to connect */ 71 /* Wait for threads to connect */
67 show_splash(HZ/2, "Waiting for USB"); 72 show_splash(HZ/2, "Waiting for USB");
@@ -91,10 +96,20 @@ static void usb_mode(void)
91} 96}
92#endif 97#endif
93 98
99/* Jump to loaded binary */
100void exec(void* addr) __attribute__((noinline, noreturn, section(".icode")));
101
102void exec(void* addr)
103{
104 commit_discard_idcache();
105 typedef void(*entry_fn)(void) __attribute__((noreturn));
106 entry_fn fn = (entry_fn)addr;
107 fn();
108}
109
94static int boot_rockbox(void) 110static int boot_rockbox(void)
95{ 111{
96 int rc; 112 int rc;
97 void (*kernel_entry)(void);
98 113
99 printf("Mounting disk...\n"); 114 printf("Mounting disk...\n");
100 115
@@ -103,7 +118,6 @@ static int boot_rockbox(void)
103 verbose = true; 118 verbose = true;
104#ifdef HAVE_BOOTLOADER_USB_MODE 119#ifdef HAVE_BOOTLOADER_USB_MODE
105 error(EDISK, rc, false); 120 error(EDISK, rc, false);
106 usb_start_monitoring();
107 usb_mode(); 121 usb_mode();
108#else 122#else
109 error(EDISK, rc, true); 123 error(EDISK, rc, true);
@@ -118,11 +132,8 @@ static int boot_rockbox(void)
118 { 132 {
119 printf("Starting Rockbox...\n"); 133 printf("Starting Rockbox...\n");
120 adc_close(); /* Disable SADC, seems to fix the re-init Rockbox does */ 134 adc_close(); /* Disable SADC, seems to fix the re-init Rockbox does */
121
122 disable_interrupt(); 135 disable_interrupt();
123 kernel_entry = (void*) CONFIG_SDRAM_START; 136 exec((void*) CONFIG_SDRAM_START);
124 kernel_entry();
125
126 return 0; /* Shouldn't happen */ 137 return 0; /* Shouldn't happen */
127 } 138 }
128} 139}
@@ -152,13 +163,13 @@ int main(void)
152 163
153 serial_puts("\n\nSPL Stage 2\n\n"); 164 serial_puts("\n\nSPL Stage 2\n\n");
154 165
166 system_init();
155 kernel_init(); 167 kernel_init();
168
156 lcd_init(); 169 lcd_init();
157 font_init(); 170 font_init();
158 lcd_setfont(FONT_SYSFIXED); 171 lcd_setfont(FONT_SYSFIXED);
159 button_init();
160 backlight_init(); 172 backlight_init();
161
162 show_logo(); 173 show_logo();
163 174
164 rc = storage_init(); 175 rc = storage_init();
@@ -170,23 +181,20 @@ int main(void)
170 181
171 filesystem_init(); 182 filesystem_init();
172 183
184 /* Don't mount the disks yet, there could be file system/partition errors
185 which are fixable in USB mode */
186
173#ifdef HAVE_BOOTLOADER_USB_MODE 187#ifdef HAVE_BOOTLOADER_USB_MODE
174 button_init_device(); 188 button_init();
175 int btn = button_read_device(); 189 int btn = button_read_device();
176 190
177 usb_init();
178
179 /* Enter USB mode if USB is plugged and PLAY button is pressed */ 191 /* Enter USB mode if USB is plugged and PLAY button is pressed */
180 if(btn & BUTTON_PLAY) { 192 if(btn & BUTTON_PLAY) {
181 usb_start_monitoring();
182 if(usb_detect() == USB_INSERTED) 193 if(usb_detect() == USB_INSERTED)
183 usb_mode(); 194 usb_mode();
184 } 195 }
185#endif /* HAVE_BOOTLOADER_USB_MODE */ 196#endif /* HAVE_BOOTLOADER_USB_MODE */
186 197
187 /* Don't mount the disks yet, there could be file system/partition errors
188 which are fixable in USB mode */
189
190 reset_screen(); 198 reset_screen();
191 199
192 printf(MODEL_NAME" Rockbox Bootloader\n"); 200 printf(MODEL_NAME" Rockbox Bootloader\n");