1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2008 Rafaël Carré
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
24 #if defined(SANSA_CLIPV2) || defined(SANSA_CLIPPLUS)
25 .set RAM_SIZE, 0x100000 /* Use 1MB of SDRAM on v2 firmwares (bigger firmware) */
27 .set RAM_SIZE, 0x50000 /* Use full IRAM on v1 firmwares */
30 /* AS3525 hardware registers */
31 .set GPIOA, 0xC80B0000
32 .set GPIOB, 0xC80C0000
33 .set GPIOC, 0xC80D0000
34 .set GPIOD, 0xC80E0000
35 .set CGU_PERI, 0xC80F0014
40 ldr pc, =start /* reset vector */
41 /* next vectors are unused */
50 /* These values are filled in by mkamsboot - don't move them from offset 0x20 */
52 uclunpack_end: .word 0 /* End of the ucl_unpack function */
53 uclunpack_size: .word 0 /* Size in bytes of the ucl_unpack function */
55 ucl_of_end: .word 0 /* End of the ucl-compressed OF image */
56 ucl_of_size: .word 0 /* Size in bytes of the compressed OF image */
58 ucl_rb_end: .word 0 /* End of the ucl-compressed RB image */
59 ucl_rb_size: .word 0 /* Size in bytes of the compressed RB image */
63 /* First copy the UCL unpack function to the end of RAM */
64 ldr r0, uclunpack_end /* Source */
65 ldr r1, uclunpack_size /* Source length */
66 sub r2, r0, r1 /* Source start - 1*/
68 ldr r3, =(RAM_SIZE-1) /* Destination end */
76 add r5, r3, #2 /* r5 is entry point of copy of uclunpack */
77 /* function, plus one (for thumb mode */
79 /* enable gpio clock */
87 #if defined(SANSA_C200V2)
89 #elif defined(SANSA_CLIP) || defined(SANSA_CLIPV2)
91 #elif defined(SANSA_FUZE) || defined(SANSA_E200V2)
95 #ifdef USB_PIN /* TODO : remove this check when we'll have an USB driver */
99 ldr r1, [r0, #(4*(1<<USB_PIN))]
104 /* Here are model specific tests, for dual boot without a computer */
105 /* All models use left button */
106 /* /!\ Right button for c200v2 (left button is unkwown) */
109 .set row, (1<<5) /* enable output on C5 */
110 .set col, (1<<0) /* read keyscan column B0 */
115 str r1, [r0, #(4*row)]
120 ldr r1, [r0, #(4*col)]
124 #elif defined(SANSA_CLIPV2)
125 .set row, (1<<4) /* enable output on D4 */
126 .set col, (1<<0) /* read keyscan column D0 */
129 mov r1, #((1<<5)|(1<<4)|(1<<3)) /* all rows as output */
134 str r1, [r0, #(4*(1<<3))]
136 str r1, [r0, #(4*(1<<4))]
138 str r1, [r0, #(4*(1<<5))]
140 mov r1, #0 /* button row low */
141 str r1, [r0, #(4*row)]
143 mov r1, #5 /* small delay */
147 ldr r1, [r0, #(4*col)]
151 #elif defined(SANSA_E200V2) || defined(SANSA_FUZE)
155 ldr r1, [r0, #0x20] /* read pin C3 */
157 cmp r1, #0 /* C3 = #0 means button pressed */
159 #elif defined(SANSA_CLIPPLUS)
161 mov r0, #0x500000 /* Approximately 5 seconds */
162 1: subs r0, r0, #1 /* just to prove we are running */
164 b boot_of /* branch to OF */
165 #elif defined(SANSA_C200V2)
166 /* check for RIGHT on C6, should changed to LEFT as soon as it
167 * known in which pin that is in order for consistency */
170 str r1, [r0, #0x400] /* set pin to output */
172 ldr r1, [r0, #256] /* 1<<(6+2) */
173 cmp r1, #0 /* C6 low means button pressed */
175 #elif defined(SANSA_M200V4)
176 .set row, (1<<5) /* enable output on A5 */
177 .set col, (1<<0) /* read keyscan column A0 */
182 str r1, [r0, #(4*row)]
184 ldr r2, [r0, #(4*col)]
186 /* check value read (1 means button pressed) */
190 #error No target-specific key check defined!
194 /* The dualboot button was not held, so we boot rockbox */
195 ldr r0, ucl_rb_end /* Address of compressed image */
196 ldr r1, ucl_rb_size /* Compressed size */
200 ldr r0, ucl_of_end /* Address of compressed image */
201 ldr r1, ucl_of_size /* Compressed size */
206 /* r5 = entry point (plus one for thumb) of uclunpack function */
207 /* r3 = destination_end for copy of UCL image */
208 /* r0 = source_end for UCL image to copy */
209 /* r1 = size of UCL image to copy */
211 sub r4, r3, r1 /* r4 := destination_start - 1 */
216 cmp r3, r4 /* Stop when we reached dest_start-1 */
219 /* Call the ucl decompress function, which will branch to 0x0 */
221 add r0, r3, #1 /* r0 := Start of compressed image */
222 /* r1 already contains compressed size */
223 mov r2, #0 /* r2 := Destination for unpacking */
224 bx r5 /* Branch to uclunpack, switching to thumb */
226 /* never reached : uclunpack will branch to the reset vector (0x0) */