summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2018-12-29 10:37:47 -0500
committerSolomon Peachy <pizza@shaftnet.org>2019-01-02 05:01:50 +0100
commit7e7ca0c85847e0b7eff094710cc5167df4e852da (patch)
tree74d8535926085b87e627f48cd9bae1309abffe51
parent35930ddb8d0c704abeb7619d9b6fc59b9dd6b909 (diff)
downloadrockbox-7e7ca0c85847e0b7eff094710cc5167df4e852da.tar.gz
rockbox-7e7ca0c85847e0b7eff094710cc5167df4e852da.zip
Fix Xduoo X3 bootloader build, and silence all warnings.
Also enable USB bootloader mode Change-Id: I73224c2e694b9941993c89a114b48d2a907e0dfb
-rw-r--r--bootloader/xduoox3.c34
-rw-r--r--firmware/export/config/xduoox3.h1
-rw-r--r--firmware/target/mips/ingenic_jz47xx/debug-jz4760.c103
-rw-r--r--firmware/target/mips/ingenic_jz47xx/xduoo_x3/sadc-xduoo_x3.c4
4 files changed, 136 insertions, 6 deletions
diff --git a/bootloader/xduoox3.c b/bootloader/xduoox3.c
index 3db87a866d..d38639bfd4 100644
--- a/bootloader/xduoox3.c
+++ b/bootloader/xduoox3.c
@@ -44,6 +44,7 @@
44extern void show_logo(void); 44extern void show_logo(void);
45extern void power_off(void); 45extern void power_off(void);
46 46
47#ifdef HAVE_BOOTLOADER_USB_MODE
47static void show_splash(int timeout, const char *msg) 48static void show_splash(int timeout, const char *msg)
48{ 49{
49 reset_screen(); 50 reset_screen();
@@ -88,6 +89,7 @@ static void usb_mode(void)
88 } 89 }
89 } 90 }
90} 91}
92#endif
91 93
92static int boot_rockbox(void) 94static int boot_rockbox(void)
93{ 95{
@@ -95,11 +97,17 @@ static int boot_rockbox(void)
95 void (*kernel_entry)(void); 97 void (*kernel_entry)(void);
96 98
97 printf("Mounting disk...\n"); 99 printf("Mounting disk...\n");
98 rc = disk_mount_all(); 100
99 if (rc <= 0) 101 while((rc = disk_mount_all()) <= 0)
100 { 102 {
101 verbose = true; 103 verbose = true;
102 error(EDISK,rc, true); 104#ifdef HAVE_BOOTLOADER_USB_MODE
105 error(EDISK, rc, false);
106 usb_start_monitoring();
107 usb_mode();
108#else
109 error(EDISK, rc, true);
110#endif
103 } 111 }
104 112
105 printf("Loading firmware...\n"); 113 printf("Loading firmware...\n");
@@ -119,6 +127,7 @@ static int boot_rockbox(void)
119 } 127 }
120} 128}
121 129
130#if 0
122static void reset_configuration(void) 131static void reset_configuration(void)
123{ 132{
124 int rc; 133 int rc;
@@ -135,6 +144,7 @@ static void reset_configuration(void)
135 else 144 else
136 show_splash(HZ/2, "Couldn't reset configuration!"); 145 show_splash(HZ/2, "Couldn't reset configuration!");
137} 146}
147#endif
138 148
139int main(void) 149int main(void)
140{ 150{
@@ -151,8 +161,6 @@ int main(void)
151 161
152 show_logo(); 162 show_logo();
153 163
154 filesystem_init();
155
156 rc = storage_init(); 164 rc = storage_init();
157 if(rc) 165 if(rc)
158 { 166 {
@@ -160,6 +168,22 @@ int main(void)
160 error(EATA, rc, true); 168 error(EATA, rc, true);
161 } 169 }
162 170
171 filesystem_init();
172
173#ifdef HAVE_BOOTLOADER_USB_MODE
174 button_init_device();
175 int btn = button_read_device();
176
177 usb_init();
178
179 /* Enter USB mode if USB is plugged and PLAY button is pressed */
180 if(btn & BUTTON_PLAY) {
181 usb_start_monitoring();
182 if(usb_detect() == USB_INSERTED)
183 usb_mode();
184 }
185#endif /* HAVE_BOOTLOADER_USB_MODE */
186
163 /* Don't mount the disks yet, there could be file system/partition errors 187 /* Don't mount the disks yet, there could be file system/partition errors
164 which are fixable in USB mode */ 188 which are fixable in USB mode */
165 189
diff --git a/firmware/export/config/xduoox3.h b/firmware/export/config/xduoox3.h
index 6a7f33c842..d4d6f2ee2f 100644
--- a/firmware/export/config/xduoox3.h
+++ b/firmware/export/config/xduoox3.h
@@ -163,6 +163,7 @@
163 163
164/* enable these for the experimental usb stack */ 164/* enable these for the experimental usb stack */
165#define HAVE_USBSTACK 165#define HAVE_USBSTACK
166#define HAVE_BOOTLOADER_USB_MODE
166 167
167/* Connect by events, not by tick polling */ 168/* Connect by events, not by tick polling */
168#define USB_STATUS_BY_EVENT 169#define USB_STATUS_BY_EVENT
diff --git a/firmware/target/mips/ingenic_jz47xx/debug-jz4760.c b/firmware/target/mips/ingenic_jz47xx/debug-jz4760.c
index 848fa5343e..ffd9faaf60 100644
--- a/firmware/target/mips/ingenic_jz47xx/debug-jz4760.c
+++ b/firmware/target/mips/ingenic_jz47xx/debug-jz4760.c
@@ -169,3 +169,106 @@ bool dbg_hw_info(void)
169 } 169 }
170 return true; 170 return true;
171} 171}
172
173#define CFG_UART_BASE UART1_BASE /* Base of the UART channel */
174
175void serial_putc (const char c)
176{
177 volatile u8 *uart_lsr = (volatile u8 *)(CFG_UART_BASE + OFF_LSR);
178 volatile u8 *uart_tdr = (volatile u8 *)(CFG_UART_BASE + OFF_TDR);
179
180 if (c == '\n') serial_putc ('\r');
181
182 /* Wait for fifo to shift out some bytes */
183 while ( !((*uart_lsr & (UARTLSR_TDRQ | UARTLSR_TEMT)) == 0x60) );
184
185 *uart_tdr = (u8)c;
186}
187
188void serial_puts (const char *s)
189{
190 while (*s) {
191 serial_putc (*s++);
192 }
193}
194
195void serial_putsf(const char *format, ...)
196{
197 static char printfbuf[256];
198 int len;
199 unsigned char *ptr;
200 va_list ap;
201 va_start(ap, format);
202
203 ptr = printfbuf;
204 len = vsnprintf(ptr, sizeof(printfbuf), format, ap);
205 va_end(ap);
206 (void)len;
207
208 serial_puts(ptr);
209 serial_putc('\n');
210}
211
212void serial_put_hex(unsigned int d)
213{
214 char c[12];
215 int i;
216 for(i = 0; i < 8;i++)
217 {
218 c[i] = (d >> ((7 - i) * 4)) & 0xf;
219 if(c[i] < 10)
220 c[i] += 0x30;
221 else
222 c[i] += (0x41 - 10);
223 }
224 c[8] = '\n';
225 c[9] = 0;
226 serial_puts(c);
227
228}
229void serial_put_dec(unsigned int d)
230{
231 char c[16];
232 int i;
233 int j = 0;
234 int x = d;
235
236 while (x /= 10)
237 j++;
238
239 for (i = j; i >= 0; i--) {
240 c[i] = d % 10;
241 c[i] += 0x30;
242 d /= 10;
243 }
244 c[j + 1] = '\n';
245 c[j + 2] = 0;
246 serial_puts(c);
247}
248
249void serial_dump_data(unsigned char* data, int len)
250{
251 int i;
252 for(i=0; i<len; i++)
253 {
254 unsigned char a = ((*data)>>4) & 0xf;
255 if(a < 10)
256 a += 0x30;
257 else
258 a += (0x41 - 10);
259 serial_putc( a );
260
261 a = (*data) & 0xf;
262 if(a < 10)
263 a += 0x30;
264 else
265 a += (0x41 - 10);
266 serial_putc( a );
267
268 serial_putc( ' ' );
269
270 data++;
271 }
272
273 serial_putc( '\n' );
274}
diff --git a/firmware/target/mips/ingenic_jz47xx/xduoo_x3/sadc-xduoo_x3.c b/firmware/target/mips/ingenic_jz47xx/xduoo_x3/sadc-xduoo_x3.c
index 16d5aab782..be02167a5d 100644
--- a/firmware/target/mips/ingenic_jz47xx/xduoo_x3/sadc-xduoo_x3.c
+++ b/firmware/target/mips/ingenic_jz47xx/xduoo_x3/sadc-xduoo_x3.c
@@ -18,7 +18,7 @@
18 * KIND, either express or implied. 18 * KIND, either express or implied.
19 * 19 *
20 ****************************************************************************/ 20 ****************************************************************************/
21 21
22#include "config.h" 22#include "config.h"
23#include "system.h" 23#include "system.h"
24#include "cpu.h" 24#include "cpu.h"
@@ -86,11 +86,13 @@ bool button_hold(void)
86 86
87int button_read_device(void) 87int button_read_device(void)
88{ 88{
89#ifndef BOOTLOADER
89 static bool hold_button = false; 90 static bool hold_button = false;
90 bool hold_button_old; 91 bool hold_button_old;
91 92
92 hold_button_old = hold_button; 93 hold_button_old = hold_button;
93 hold_button = (__gpio_get_pin(PIN_BTN_HOLD) ? true : false); 94 hold_button = (__gpio_get_pin(PIN_BTN_HOLD) ? true : false);
95#endif
94 96
95 int btn = BUTTON_NONE; 97 int btn = BUTTON_NONE;
96 bool gpio_btn = (__gpio_get_pin(PIN_BTN_POWER) ? false : true); 98 bool gpio_btn = (__gpio_get_pin(PIN_BTN_POWER) ? false : true);