summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2021-08-21 22:10:51 -0400
committerSolomon Peachy <pizza@shaftnet.org>2021-08-21 22:20:20 -0400
commit2c9e2db72197d8b2d5bcbeaf02b381542e7495d7 (patch)
treed597017df701b74f59e92941397d11c380cb2208
parente07c460eef832fc4cfe22750ecf15db1ff2fc213 (diff)
downloadrockbox-2c9e2db72197d8b2d5bcbeaf02b381542e7495d7.tar.gz
rockbox-2c9e2db72197d8b2d5bcbeaf02b381542e7495d7.zip
xduoox3: More bootloader updates
* Rework the LCD initialization a bit * Power off after 5 seconds if we hit a fatal error * Turn on verbose output if PLAY is held down on powerup * Minor code style cleanups The goal is to not perform the LCD init unless it's needed; ie only if we run into an error or enter USB mode. Change-Id: I3f93e881ff55d104f453985ed452f35b433a7d99
-rw-r--r--bootloader/xduoox3.c67
1 files changed, 48 insertions, 19 deletions
diff --git a/bootloader/xduoox3.c b/bootloader/xduoox3.c
index 330431f9c9..aa27f4ea86 100644
--- a/bootloader/xduoox3.c
+++ b/bootloader/xduoox3.c
@@ -41,12 +41,33 @@
41 41
42#include "xdebug.h" 42#include "xdebug.h"
43 43
44#define SHOW_LOGO
45
44extern void show_logo(void); 46extern void show_logo(void);
45extern void power_off(void); 47extern void power_off(void);
46 48
49static int lcd_inited = 0;
50void init_lcd(void)
51{
52 if(lcd_inited)
53 return;
54
55 lcd_init();
56 font_init();
57 lcd_setfont(FONT_SYSFIXED);
58
59 lcd_clear_display();
60 lcd_update();
61
62 backlight_init();
63
64 lcd_inited = true;
65}
66
47#ifdef HAVE_BOOTLOADER_USB_MODE 67#ifdef HAVE_BOOTLOADER_USB_MODE
48static void show_splash(int timeout, const char *msg) 68static void show_splash(int timeout, const char *msg)
49{ 69{
70 init_lcd();
50 reset_screen(); 71 reset_screen();
51 lcd_putsxy( (LCD_WIDTH - (SYSFONT_WIDTH * strlen(msg))) / 2, 72 lcd_putsxy( (LCD_WIDTH - (SYSFONT_WIDTH * strlen(msg))) / 2,
52 (LCD_HEIGHT - SYSFONT_HEIGHT) / 2, msg); 73 (LCD_HEIGHT - SYSFONT_HEIGHT) / 2, msg);
@@ -68,19 +89,20 @@ static void usb_mode(void)
68 usb_inited = 1; 89 usb_inited = 1;
69 } 90 }
70 91
92 init_lcd();
93 reset_screen();
94
71 /* Wait for threads to connect */ 95 /* Wait for threads to connect */
72 show_splash(HZ/2, "Waiting for USB"); 96 show_splash(HZ/2, "Waiting for USB");
73 97
74 while (1) 98 while (1) {
75 {
76 button = button_get_w_tmo(HZ/2); 99 button = button_get_w_tmo(HZ/2);
77 100
78 if (button == SYS_USB_CONNECTED) 101 if (button == SYS_USB_CONNECTED)
79 break; /* Hit */ 102 break; /* Hit */
80 } 103 }
81 104
82 if (button == SYS_USB_CONNECTED) 105 if (button == SYS_USB_CONNECTED) {
83 {
84 /* Got the message - wait for disconnect */ 106 /* Got the message - wait for disconnect */
85 show_splash(0, "Bootloader USB mode"); 107 show_splash(0, "Bootloader USB mode");
86 108
@@ -113,8 +135,7 @@ static int boot_rockbox(void)
113 135
114 printf("Mounting disk...\n"); 136 printf("Mounting disk...\n");
115 137
116 while((rc = disk_mount_all()) <= 0) 138 while((rc = disk_mount_all()) <= 0) {
117 {
118 verbose = true; 139 verbose = true;
119#ifdef HAVE_BOOTLOADER_USB_MODE 140#ifdef HAVE_BOOTLOADER_USB_MODE
120 error(EDISK, rc, false); 141 error(EDISK, rc, false);
@@ -126,10 +147,9 @@ static int boot_rockbox(void)
126 147
127 printf("Loading firmware...\n"); 148 printf("Loading firmware...\n");
128 rc = load_firmware((unsigned char *)CONFIG_SDRAM_START, BOOTFILE, 0x400000); 149 rc = load_firmware((unsigned char *)CONFIG_SDRAM_START, BOOTFILE, 0x400000);
129 if(rc <= EFILE_EMPTY) 150 if(rc <= EFILE_EMPTY) {
130 return rc; 151 return rc;
131 else 152 } else {
132 {
133 printf("Starting Rockbox...\n"); 153 printf("Starting Rockbox...\n");
134 adc_close(); /* Disable SADC, seems to fix the re-init Rockbox does */ 154 adc_close(); /* Disable SADC, seems to fix the re-init Rockbox does */
135 disable_interrupt(); 155 disable_interrupt();
@@ -166,15 +186,19 @@ int main(void)
166 system_init(); 186 system_init();
167 kernel_init(); 187 kernel_init();
168 188
169 lcd_init(); 189 init_lcd();
170 font_init(); 190#ifdef SHOW_LOGO
171 lcd_setfont(FONT_SYSFIXED);
172 backlight_init();
173 show_logo(); 191 show_logo();
192#endif
193
194 button_init();
195 int btn = button_read_device();
196 if(btn & BUTTON_PLAY) {
197 verbose = true;
198 }
174 199
175 rc = storage_init(); 200 rc = storage_init();
176 if(rc) 201 if(rc) {
177 {
178 verbose = true; 202 verbose = true;
179 error(EATA, rc, true); 203 error(EATA, rc, true);
180 } 204 }
@@ -185,8 +209,6 @@ int main(void)
185 which are fixable in USB mode */ 209 which are fixable in USB mode */
186 210
187#ifdef HAVE_BOOTLOADER_USB_MODE 211#ifdef HAVE_BOOTLOADER_USB_MODE
188 button_init();
189 int btn = button_read_device();
190 212
191 /* Enter USB mode if USB is plugged and PLAY button is pressed */ 213 /* Enter USB mode if USB is plugged and PLAY button is pressed */
192 if(btn & BUTTON_PLAY) { 214 if(btn & BUTTON_PLAY) {
@@ -197,20 +219,27 @@ int main(void)
197 219
198 reset_screen(); 220 reset_screen();
199 221
222#ifndef SHOW_LOGO
200 printf(MODEL_NAME" Rockbox Bootloader\n"); 223 printf(MODEL_NAME" Rockbox Bootloader\n");
201 printf("Version %s\n", rbversion); 224 printf("Version %s\n", rbversion);
225#endif
202 226
203 rc = boot_rockbox(); 227 rc = boot_rockbox();
204 228
205 if(rc <= EFILE_EMPTY) 229 if(rc <= EFILE_EMPTY) {
206 {
207 verbose = true; 230 verbose = true;
208 printf("Error: %s", loader_strerror(rc)); 231 printf("Error: %s", loader_strerror(rc));
209 } 232 }
210 233
234#if 1
235 /* Power off */
236 sleep(5*HZ);
237 power_off();
238#else
211 /* Halt */ 239 /* Halt */
212 while (1) 240 while (1)
213 core_idle(); 241 core_idle();
242#endif
214 243
215 return 0; 244 return 0;
216} 245}