summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafaël Carré <rafael.carre@gmail.com>2010-05-17 21:57:46 +0000
committerRafaël Carré <rafael.carre@gmail.com>2010-05-17 21:57:46 +0000
commit66f183077d835b7d3bc2041fad89a65f04faacb9 (patch)
treeffec90e078b3710d23d5612d24c2839d7ec7b270
parent60741f2b0deaabb12da74323e2fb7b6383f36bbb (diff)
downloadrockbox-66f183077d835b7d3bc2041fad89a65f04faacb9.tar.gz
rockbox-66f183077d835b7d3bc2041fad89a65f04faacb9.zip
Clip+: boot to OF if USB is connected
To be sure that there is no mistake in this code, it is run *after* the known to work HOME & LEFT buttons checks, unlike other Sansas git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26122 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/export/config/sansaclipplus.h2
-rw-r--r--rbutil/mkamsboot/README3
-rw-r--r--rbutil/mkamsboot/dualboot.c30
-rw-r--r--rbutil/mkamsboot/dualboot.h2
-rw-r--r--rbutil/mkamsboot/dualboot/dualboot.S63
5 files changed, 86 insertions, 14 deletions
diff --git a/firmware/export/config/sansaclipplus.h b/firmware/export/config/sansaclipplus.h
index 574c3ecc80..29694d87c2 100644
--- a/firmware/export/config/sansaclipplus.h
+++ b/firmware/export/config/sansaclipplus.h
@@ -177,7 +177,7 @@
177#define CONFIG_USBOTG USBOTG_AS3525 177#define CONFIG_USBOTG USBOTG_AS3525
178 178
179/* enable these for the experimental usb stack */ 179/* enable these for the experimental usb stack */
180//#define HAVE_USBSTACK 180#define HAVE_USBSTACK
181#define USB_VENDOR_ID 0x0781 181#define USB_VENDOR_ID 0x0781
182#define USB_PRODUCT_ID 0x74d1 182#define USB_PRODUCT_ID 0x74d1
183#endif /* BOOTLOADER */ 183#endif /* BOOTLOADER */
diff --git a/rbutil/mkamsboot/README b/rbutil/mkamsboot/README
index fd81297e06..0504c64383 100644
--- a/rbutil/mkamsboot/README
+++ b/rbutil/mkamsboot/README
@@ -61,8 +61,7 @@ firmware and the new (rockbox) firmware.
61 61
62 The player will boot into the Original Firmware as well if it is powered up by 62 The player will boot into the Original Firmware as well if it is powered up by
63inserting an usb cable. 63inserting an usb cable.
64 ***Note : on the m200v4 and Clip+, powering up by usb will cause booting into 64 ***Note : on the m200v4 powering up by usb will cause booting into the new firmware.
65the new firmware.
66 65
67Hacking 66Hacking
68------- 67-------
diff --git a/rbutil/mkamsboot/dualboot.c b/rbutil/mkamsboot/dualboot.c
index aab9a18c36..8f87ea8cb5 100644
--- a/rbutil/mkamsboot/dualboot.c
+++ b/rbutil/mkamsboot/dualboot.c
@@ -126,21 +126,31 @@ unsigned char dualboot_clipv2[280] = {
126 0x00, 0x20, 0xa0, 0xe3, 0x15, 0xff, 0x2f, 0xe1, 0x3c, 0x00, 0x00, 0x00, 0x14, 0x00, 0x0f, 0xc8, 126 0x00, 0x20, 0xa0, 0xe3, 0x15, 0xff, 0x2f, 0xe1, 0x3c, 0x00, 0x00, 0x00, 0x14, 0x00, 0x0f, 0xc8,
127 0x00, 0x00, 0x0b, 0xc8, 0x00, 0x00, 0x0e, 0xc8 127 0x00, 0x00, 0x0b, 0xc8, 0x00, 0x00, 0x0e, 0xc8
128}; 128};
129unsigned char dualboot_clipplus[216] = { 129unsigned char dualboot_clipplus[372] = {
130 0xc0, 0xf0, 0x9f, 0xe5, 0xfe, 0xff, 0xff, 0xea, 0xfe, 0xff, 0xff, 0xea, 0xfe, 0xff, 0xff, 0xea, 130 0x54, 0xf1, 0x9f, 0xe5, 0xfe, 0xff, 0xff, 0xea, 0xfe, 0xff, 0xff, 0xea, 0xfe, 0xff, 0xff, 0xea,
131 0xfe, 0xff, 0xff, 0xea, 0xfe, 0xff, 0xff, 0xea, 0xfe, 0xff, 0xff, 0xea, 0xfe, 0xff, 0xff, 0xea, 131 0xfe, 0xff, 0xff, 0xea, 0xfe, 0xff, 0xff, 0xea, 0xfe, 0xff, 0xff, 0xea, 0xfe, 0xff, 0xff, 0xea,
132 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 132 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
133 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x00, 0x1f, 0xe5, 133 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x00, 0x1f, 0xe5,
134 0x24, 0x10, 0x1f, 0xe5, 0x01, 0x20, 0x40, 0xe0, 0x18, 0x30, 0x1f, 0xe5, 0x01, 0x40, 0x50, 0xe4, 134 0x24, 0x10, 0x1f, 0xe5, 0x01, 0x20, 0x40, 0xe0, 0x18, 0x30, 0x1f, 0xe5, 0x01, 0x40, 0x50, 0xe4,
135 0x01, 0x40, 0x43, 0xe4, 0x00, 0x00, 0x52, 0xe1, 0xfb, 0xff, 0xff, 0x1a, 0x2c, 0x30, 0x0f, 0xe5, 135 0x01, 0x40, 0x43, 0xe4, 0x00, 0x00, 0x52, 0xe1, 0xfb, 0xff, 0xff, 0x1a, 0x2c, 0x30, 0x0f, 0xe5,
136 0x64, 0x00, 0x9f, 0xe5, 0x00, 0x10, 0x90, 0xe5, 0x01, 0x18, 0x81, 0xe3, 0x00, 0x10, 0x80, 0xe5, 136 0xf8, 0x00, 0x9f, 0xe5, 0x00, 0x10, 0x90, 0xe5, 0x01, 0x18, 0x81, 0xe3, 0x00, 0x10, 0x80, 0xe5,
137 0x58, 0x00, 0x9f, 0xe5, 0x20, 0x10, 0x90, 0xe5, 0x54, 0x00, 0x9f, 0xe5, 0x08, 0x20, 0x90, 0xe5, 137 0xec, 0x00, 0x9f, 0xe5, 0x20, 0x10, 0x90, 0xe5, 0xe8, 0x00, 0x9f, 0xe5, 0x08, 0x20, 0x90, 0xe5,
138 0x01, 0x20, 0x82, 0xe1, 0x00, 0x00, 0x52, 0xe3, 0x02, 0x00, 0x00, 0x1a, 0x64, 0x00, 0x1f, 0xe5, 138 0x01, 0x20, 0x82, 0xe1, 0x00, 0x00, 0x52, 0xe3, 0x27, 0x00, 0x00, 0x1a, 0xd8, 0x00, 0x9f, 0xe5,
139 0x64, 0x10, 0x1f, 0xe5, 0x01, 0x00, 0x00, 0xea, 0x78, 0x00, 0x1f, 0xe5, 0x78, 0x10, 0x1f, 0xe5, 139 0x00, 0x10, 0xa0, 0xe3, 0x00, 0x10, 0x80, 0xe5, 0xc0, 0x00, 0x9f, 0xe5, 0x00, 0x10, 0x90, 0xe5,
140 0x70, 0x30, 0x1f, 0xe5, 0x02, 0x50, 0x83, 0xe2, 0x01, 0x40, 0x43, 0xe0, 0x01, 0x20, 0x50, 0xe4, 140 0x02, 0x18, 0x81, 0xe3, 0x7f, 0x10, 0xc1, 0xe3, 0x00, 0x10, 0x80, 0xe5, 0xbc, 0x00, 0x9f, 0xe5,
141 0x01, 0x20, 0x43, 0xe4, 0x04, 0x00, 0x53, 0xe1, 0xfb, 0xff, 0xff, 0x1a, 0x01, 0x00, 0x83, 0xe2, 141 0x00, 0x10, 0xa0, 0xe3, 0x24, 0x10, 0x80, 0xe5, 0x3c, 0x10, 0xa0, 0xe3, 0x1c, 0x10, 0x80, 0xe5,
142 0x00, 0x20, 0xa0, 0xe3, 0x15, 0xff, 0x2f, 0xe1, 0x3c, 0x00, 0x00, 0x00, 0x14, 0x00, 0x0f, 0xc8, 142 0x00, 0x10, 0xa0, 0xe3, 0x20, 0x10, 0x80, 0xe5, 0x8c, 0x10, 0xa0, 0xe3, 0x04, 0x10, 0x80, 0xe5,
143 0x00, 0x00, 0x0d, 0xc8, 0x00, 0x00, 0x0b, 0xc8 143 0x51, 0x20, 0xa0, 0xe3, 0x0c, 0x20, 0x80, 0xe5, 0x30, 0x10, 0x90, 0xe5, 0x01, 0x00, 0x11, 0xe3,
144 0xfc, 0xff, 0xff, 0x1a, 0x02, 0x17, 0xa0, 0xe3, 0x01, 0x10, 0x51, 0xe2, 0xfd, 0xff, 0xff, 0x1a,
145 0x25, 0x10, 0xa0, 0xe3, 0x44, 0x10, 0x80, 0xe5, 0x02, 0x20, 0x82, 0xe3, 0x0c, 0x20, 0x80, 0xe5,
146 0x01, 0x10, 0xa0, 0xe3, 0x10, 0x10, 0x80, 0xe5, 0x10, 0x10, 0x90, 0xe5, 0x00, 0x00, 0x51, 0xe3,
147 0xfc, 0xff, 0xff, 0x1a, 0x00, 0x10, 0x90, 0xe5, 0x08, 0x00, 0x11, 0xe3, 0x02, 0x00, 0x00, 0x1a,
148 0xf8, 0x00, 0x1f, 0xe5, 0xf8, 0x10, 0x1f, 0xe5, 0x01, 0x00, 0x00, 0xea, 0x0c, 0x01, 0x1f, 0xe5,
149 0x0c, 0x11, 0x1f, 0xe5, 0x04, 0x31, 0x1f, 0xe5, 0x02, 0x50, 0x83, 0xe2, 0x01, 0x40, 0x43, 0xe0,
150 0x01, 0x20, 0x50, 0xe4, 0x01, 0x20, 0x43, 0xe4, 0x04, 0x00, 0x53, 0xe1, 0xfb, 0xff, 0xff, 0x1a,
151 0x01, 0x00, 0x83, 0xe2, 0x00, 0x20, 0xa0, 0xe3, 0x15, 0xff, 0x2f, 0xe1, 0x3c, 0x00, 0x00, 0x00,
152 0x14, 0x00, 0x0f, 0xc8, 0x00, 0x00, 0x0d, 0xc8, 0x00, 0x00, 0x0b, 0xc8, 0x10, 0x00, 0x0f, 0xc8,
153 0x00, 0x00, 0x07, 0xc8
144}; 154};
145unsigned char dualboot_fuzev2[236] = { 155unsigned char dualboot_fuzev2[236] = {
146 0xd4, 0xf0, 0x9f, 0xe5, 0xfe, 0xff, 0xff, 0xea, 0xfe, 0xff, 0xff, 0xea, 0xfe, 0xff, 0xff, 0xea, 156 0xd4, 0xf0, 0x9f, 0xe5, 0xfe, 0xff, 0xff, 0xea, 0xfe, 0xff, 0xff, 0xea, 0xfe, 0xff, 0xff, 0xea,
diff --git a/rbutil/mkamsboot/dualboot.h b/rbutil/mkamsboot/dualboot.h
index 57306def10..cada57559f 100644
--- a/rbutil/mkamsboot/dualboot.h
+++ b/rbutil/mkamsboot/dualboot.h
@@ -7,5 +7,5 @@ extern unsigned char dualboot_c200v2[336];
7extern unsigned char dualboot_m200v4[212]; 7extern unsigned char dualboot_m200v4[212];
8extern unsigned char dualboot_fuze[236]; 8extern unsigned char dualboot_fuze[236];
9extern unsigned char dualboot_clipv2[280]; 9extern unsigned char dualboot_clipv2[280];
10extern unsigned char dualboot_clipplus[216]; 10extern unsigned char dualboot_clipplus[372];
11extern unsigned char dualboot_fuzev2[236]; 11extern unsigned char dualboot_fuzev2[236];
diff --git a/rbutil/mkamsboot/dualboot/dualboot.S b/rbutil/mkamsboot/dualboot/dualboot.S
index 8bb2059d78..309aa67742 100644
--- a/rbutil/mkamsboot/dualboot/dualboot.S
+++ b/rbutil/mkamsboot/dualboot/dualboot.S
@@ -26,6 +26,7 @@
26.set GPIOB, 0xC80C0000 26.set GPIOB, 0xC80C0000
27.set GPIOC, 0xC80D0000 27.set GPIOC, 0xC80D0000
28.set GPIOD, 0xC80E0000 28.set GPIOD, 0xC80E0000
29.set CGU_PROC, 0xC80F0010
29.set CGU_PERI, 0xC80F0014 30.set CGU_PERI, 0xC80F0014
30.set I2C_BASE, 0xC8070000 31.set I2C_BASE, 0xC8070000
31.set I2C_DATA, 0x00 32.set I2C_DATA, 0x00
@@ -239,6 +240,68 @@ uclcopy:
239 240
240 cmp r2, #0 @ test input from pins 241 cmp r2, #0 @ test input from pins
241 bne boot_of @ branch directly to OF if either pin high 242 bne boot_of @ branch directly to OF if either pin high
243
244
245 @ check USB connection
246
247 ldr r0, =CGU_PROC
248 mov r1, #0
249 str r1, [r0] @ fclk = 24MHz
250
251 ldr r0, =CGU_PERI
252 ldr r1, [r0]
253 /* enable i2c audio master clock */
254 orr r1, r1, #(1<<17)
255 /* pclk = fclk = 24MHz */
256 bic r1, r1, #0x7f
257 str r1, [r0]
258
259 ldr r0, =I2C_BASE
260 /* disable i2c interrupts */
261 mov r1, #0
262 str r1, [r0, #I2C_IMR]
263 /* setup prescaler */
264 mov r1, #I2C_PRESCALER_LOW
265 str r1, [r0, #I2C_CPSR0]
266 mov r1, #I2C_PRESCALER_HIGH
267 str r1, [r0, #I2C_CPSR1]
268 /* setup i2c slave address */
269 mov r1, #(AS3514_I2C_ADDR << 1)
270 str r1, [r0, #I2C_SLAD0]
271 mov r2, #0x51
272 str r2, [r0, #I2C_CNTRL]
273
274 /* wait for not busy */
2751:
276 ldr r1, [r0, #I2C_SR]
277 tst r1, #1
278 bne 1b
279
280 /* wait a bit (~100ms) else detection fails */
281 mov r1, #0x80000
2821: subs r1, r1, #1
283 bne 1b
284
285 /* start read of irq_enrd0 */
286 mov r1, #AS3514_IRQ_ENRD0
287 str r1, [r0, #I2C_SADDR]
288 orr r2, r2, #(1 << 1)
289 str r2, [r0, #I2C_CNTRL]
290 mov r1, #1
291 str r1, [r0, #I2C_DACNT]
292
293 /* wait for transfer to finish */
2941:
295 ldr r1, [r0, #I2C_DACNT]
296 cmp r1, #0
297 bne 1b
298
299 /* load result and test USB_STATUS bit */
300 ldr r1, [r0, #I2C_DATA]
301 tst r1, #(1 << 3)
302 bne boot_of
303
304
242#elif defined(SANSA_C200V2) 305#elif defined(SANSA_C200V2)
243 /* check for RIGHT on C6, should changed to LEFT as soon as it 306 /* check for RIGHT on C6, should changed to LEFT as soon as it
244 * known in which pin that is in order for consistency */ 307 * known in which pin that is in order for consistency */