1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
diff --git a/bootloader/sansa_as3525.c b/bootloader/sansa_as3525.c
index 9248921..cc1a918 100644
--- a/bootloader/sansa_as3525.c
+++ b/bootloader/sansa_as3525.c
@@ -37,6 +37,13 @@

 int show_logo(void);

+
+int bl_delay(int x)
+{
+    int _x = x * 1000;
+    while (--_x);
+}
+
 void main(void) __attribute__((noreturn));
 void main(void)
 {
@@ -44,18 +51,61 @@ void main(void)
     int buffer_size;
     void(*kernel_entry)(void);
     int ret;
-
+    GPIOA_DIR |= (1<<5);
+    GPIOA_PIN(5) = (1<<5);  /* set pin a5 high */
+    GPIOD_DIR |= (1<<7);
+    GPIOD_PIN(7) = (1<<7);  /* set pin a5 high */
+/*
     system_init();
+
+    button_init_device();
+    buttonlight_on();
+*/
+
+
+/*
+    int write = 255;
+    write <<= 24;
+    write >>= 24;
+    ascodec_write(27, 0x80|0x1f);
+    ascodec_write(27, write);
+*/
+    ascodec_init();
+    ascodec_write(0x25, ascodec_read(0x25) | 2);    /* lcd power */
+    ascodec_write(0x1c, 8|1);
+    ascodec_write(27, 0x80|0xff);
+    while(1)
+    {
+        int i = 0;
+        while (++i < 0xff)
+        {
+            bl_delay(1000);
+            ascodec_write(27, i|0x80);
+        }
+        while (--i > 0)
+        {
+            bl_delay(1000);
+            ascodec_write(27, i|0x80);
+        }
+    }
+
     kernel_init();

     enable_irq();

+/*
     lcd_init();
     show_logo();
+*/

+/*
+    ascodec_write(0x1b, 0x80);
+*/
     backlight_init();

+/*
     button_init_device();
+*/
     int btn = button_read_device();

 #if !defined(SANSA_FUZE) && !defined(SANSA_CLIP) && !defined(SANSA_CLIPV2) \
diff --git a/rbutil/mkamsboot/dualboot.c b/rbutil/mkamsboot/dualboot.c
index 32dad00..7fcf794 100644
--- a/rbutil/mkamsboot/dualboot.c
+++ b/rbutil/mkamsboot/dualboot.c
@@ -136,3 +136,21 @@ unsigned char dualboot_clipplus[216] = {
     0x00, 0x20, 0xa0, 0xe3, 0x15, 0xff, 0x2f, 0xe1, 0x3c, 0x00, 0x00, 0x00, 0x14, 0x00, 0x0f, 0xc8,
     0x00, 0x00, 0x0d, 0xc8, 0x00, 0x00, 0x0b, 0xc8
 };
+unsigned char dualboot_fuzev2[252] = {
+    0xe4, 0xf0, 0x9f, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x00, 0x1f, 0xe5,
+    0x24, 0x10, 0x1f, 0xe5, 0x01, 0x20, 0x40, 0xe0, 0x18, 0x30, 0x1f, 0xe5, 0x01, 0x40, 0x50, 0xe4,
+    0x01, 0x40, 0x43, 0xe4, 0x00, 0x00, 0x52, 0xe1, 0xfb, 0xff, 0xff, 0x1a, 0x2c, 0x30, 0x0f, 0xe5,
+    0x88, 0x00, 0x9f, 0xe5, 0x00, 0x10, 0x90, 0xe5, 0x01, 0x18, 0x81, 0xe3, 0x00, 0x10, 0x80, 0xe5,
+    0x7c, 0x00, 0x9f, 0xe5, 0x00, 0x10, 0xa0, 0xe3, 0x00, 0x14, 0x80, 0xe5, 0x20, 0x10, 0x90, 0xe5,
+    0x00, 0x00, 0x51, 0xe3, 0x0c, 0x00, 0x00, 0x1a, 0x68, 0x00, 0x9f, 0xe5, 0x00, 0x10, 0xa0, 0xe3,
+    0x00, 0x14, 0x80, 0xe5, 0x20, 0x10, 0x90, 0xe5, 0x00, 0x00, 0x51, 0xe3, 0x02, 0x00, 0x00, 0x0a,
+    0x01, 0x16, 0xa0, 0xe3, 0x01, 0x10, 0x51, 0xe2, 0xfc, 0xff, 0xff, 0x1a, 0x02, 0x00, 0x00, 0xea,
+    0x88, 0x00, 0x1f, 0xe5, 0x88, 0x10, 0x1f, 0xe5, 0x01, 0x00, 0x00, 0xea, 0x9c, 0x00, 0x1f, 0xe5,
+    0x9c, 0x10, 0x1f, 0xe5, 0x94, 0x30, 0x1f, 0xe5, 0x02, 0x50, 0x83, 0xe2, 0x01, 0x40, 0x43, 0xe0,
+    0x01, 0x20, 0x50, 0xe4, 0x01, 0x20, 0x43, 0xe4, 0x04, 0x00, 0x53, 0xe1, 0xfb, 0xff, 0xff, 0x1a,
+    0x01, 0x00, 0x83, 0xe2, 0x00, 0x20, 0xa0, 0xe3, 0x15, 0xff, 0x2f, 0xe1, 0x3c, 0x00, 0x00, 0x00,
+    0x14, 0x00, 0x0f, 0xc8, 0x00, 0x00, 0x0b, 0xc8, 0x00, 0x00, 0x0d, 0xc8
+};
diff --git a/rbutil/mkamsboot/dualboot.h b/rbutil/mkamsboot/dualboot.h
index 28139ae..5acdd5a 100644
--- a/rbutil/mkamsboot/dualboot.h
+++ b/rbutil/mkamsboot/dualboot.h
@@ -8,3 +8,4 @@ extern unsigned char dualboot_m200v4[212];
 extern unsigned char dualboot_fuze[236];
 extern unsigned char dualboot_clipv2[280];
 extern unsigned char dualboot_clipplus[216];
+extern unsigned char dualboot_fuzev2[252];
diff --git a/rbutil/mkamsboot/dualboot/Makefile b/rbutil/mkamsboot/dualboot/Makefile
index 8a441c9..cc788f1 100644
--- a/rbutil/mkamsboot/dualboot/Makefile
+++ b/rbutil/mkamsboot/dualboot/Makefile
@@ -4,8 +4,8 @@ CC=gcc
 # adding a new target.  mkamsboot.c also needs to be edited to refer to these
 # new images.

-BOOTOBJS = nrv2e_d8.o dualboot_clip.o dualboot_e200v2.o dualboot_c200v2.o dualboot_m200v4.o dualboot_fuze.o dualboot_clipv2.o dualboot_clipplus.o
-BOOTBINS = nrv2e_d8.arm-bin dualboot_clip.arm-bin dualboot_e200v2.arm-bin dualboot_c200v2.arm-bin dualboot_m200v4.arm-bin dualboot_fuze.arm-bin dualboot_clipv2.arm-bin dualboot_clipplus.arm-bin
+BOOTOBJS = nrv2e_d8.o dualboot_clip.o dualboot_e200v2.o dualboot_c200v2.o dualboot_m200v4.o dualboot_fuze.o dualboot_clipv2.o dualboot_clipplus.o dualboot_fuzev2.o
+BOOTBINS = nrv2e_d8.arm-bin dualboot_clip.arm-bin dualboot_e200v2.arm-bin dualboot_c200v2.arm-bin dualboot_m200v4.arm-bin dualboot_fuze.arm-bin dualboot_clipv2.arm-bin dualboot_clipplus.arm-bin dualboot_fuzev2.arm-bin

 all: ../dualboot.h ../dualboot.c

@@ -32,6 +32,9 @@ dualboot_clipv2.o: dualboot.S
 dualboot_clipplus.o: dualboot.S
   arm-elf-gcc -DSANSA_CLIPPLUS -c -o dualboot_clipplus.o dualboot.S

+dualboot_fuzev2.o: dualboot.S
+  arm-elf-gcc -DSANSA_FUZEV2 -c -o dualboot_fuzev2.o dualboot.S
+
 # Rules for the ucl unpack function
 nrv2e_d8.o: nrv2e_d8.S
   arm-elf-gcc -DPURE_THUMB -c -o nrv2e_d8.o nrv2e_d8.S
diff --git a/rbutil/mkamsboot/dualboot/dualboot.S b/rbutil/mkamsboot/dualboot/dualboot.S
index a27ab34..74ce740 100644
--- a/rbutil/mkamsboot/dualboot/dualboot.S
+++ b/rbutil/mkamsboot/dualboot/dualboot.S
@@ -83,7 +83,7 @@ uclcopy:
 #define USB_PIN 1   /* FIXME: not correct on some c200v2s */
 #elif defined(SANSA_CLIP) || defined(SANSA_CLIPV2)
 #define USB_PIN 6
-#elif defined(SANSA_FUZE) || defined(SANSA_E200V2)
+#elif defined(SANSA_FUZE) || defined(SANSA_E200V2) || defined(SANSA_FUZEV2)
 #define USB_PIN 3
 #endif

@@ -151,6 +151,20 @@ uclcopy:

         cmp     r1, #0             /* C3 = #0 means button pressed */
         beq     boot_of
+#elif defined(SANSA_FUZEV2)
+        ldr     r0, =GPIOC
+        mov     r1, #0
+        str     r1, [r0, #0x400]
+        ldr     r1, [r0, #0x20]    /* read pin C3 */
+
+        cmp     r1, #0             /* C3 = #0 means button pressed */
+        beq     10f                 /* skip delay */
+1:
+        mov     r1, #0x1000
+        subs    r1, r1, #1
+        bne     1b
+10:
+        b       boot_of
 #elif defined(SANSA_CLIPPLUS)
         @ read pins
         ldr     r0, =GPIOC
diff --git a/rbutil/mkamsboot/mkamsboot.c b/rbutil/mkamsboot/mkamsboot.c
index 9e0099d..7e25021 100644
--- a/rbutil/mkamsboot/mkamsboot.c
+++ b/rbutil/mkamsboot/mkamsboot.c
@@ -118,6 +118,7 @@ const unsigned short hw_revisions[] = {
     [MODEL_M200V4]  = 4,
     [MODEL_C200V2]  = 2,
     [MODEL_CLIPPLUS]= 1,
+    [MODEL_FUZEV2]  = 2,
 };

 /* version 2 is used in Clipv2, Clip+ and Fuzev2 firmwares */
@@ -129,6 +130,7 @@ const unsigned short fw_revisions[] = {
     [MODEL_M200V4]  = 1,
     [MODEL_C200V2]  = 1,
     [MODEL_CLIPPLUS]= 2,
+    [MODEL_FUZEV2]  = 2,
 };

 /* Descriptive name of these models */
@@ -140,6 +142,7 @@ const char* model_names[] = {
     [MODEL_E200V2]  = "e200",
     [MODEL_M200V4]  = "m200",
     [MODEL_C200V2]  = "c200",
+    [MODEL_FUZEV2]  = "Fuze",
 };

 /* Dualboot functions for these models */
@@ -151,6 +154,7 @@ static const unsigned char* bootloaders[] = {
     [MODEL_M200V4]  = dualboot_m200v4,
     [MODEL_C200V2]  = dualboot_c200v2,
     [MODEL_CLIPPLUS]= dualboot_clipplus,
+    [MODEL_FUZEV2]  = dualboot_fuzev2,
 };

 /* Size of dualboot functions for these models */
@@ -162,6 +166,7 @@ const int bootloader_sizes[] = {
     [MODEL_M200V4]  = sizeof(dualboot_m200v4),
     [MODEL_C200V2]  = sizeof(dualboot_c200v2),
     [MODEL_CLIPPLUS]= sizeof(dualboot_clipplus),
+    [MODEL_FUZEV2]  = sizeof(dualboot_fuzev2),
 };

 /* Model names used in the Rockbox header in ".sansa" files - these match the
@@ -174,6 +179,7 @@ static const char* rb_model_names[] = {
     [MODEL_M200V4]  = "m2v4",
     [MODEL_C200V2]  = "c2v2",
     [MODEL_CLIPPLUS]= "cli+",
+    [MODEL_FUZEV2]  = "fuz2",
 };

 /* Model numbers used to initialise the checksum in the Rockbox header in
@@ -186,6 +192,7 @@ static const int rb_model_num[] = {
     [MODEL_M200V4]  = 42,
     [MODEL_C200V2]  = 44,
     [MODEL_CLIPPLUS]= 66,
+    [MODEL_FUZEV2]  = 68,
 };

 /* Checksums of unmodified original firmwares - for safety, and device
@@ -223,6 +230,10 @@ static struct md5sums sansasums[] = {
     { MODEL_CLIPV2, "2.01.32", "0ad3723e52022509089d938d0fbbf8c5" },

     { MODEL_CLIPPLUS, "01.02.09", "656d38114774c2001dc18e6726df3c5d" },
+    { MODEL_CLIPV2, "2.01.32", "0ad3723e52022509089d938d0fbbf8c5" },
+
+    { MODEL_FUZEV2, "2.01.17", "8b85fb05bf645d08a4c8c3e344ec9ebe" },
+    { MODEL_FUZEV2, "2.02.26", "d4f6f85c3e4a8ea8f2e5acc421641801" },
 };

 #define NUM_MD5S (sizeof(sansasums)/sizeof(sansasums[0]))
@@ -324,6 +335,8 @@ static int get_model(int model_id)
             return MODEL_CLIPV2;
         case 0x28:
             return MODEL_CLIPPLUS;
+        case 0x70:
+            return MODEL_FUZEV2;
     }

     return MODEL_UNKNOWN;
diff --git a/rbutil/mkamsboot/mkamsboot.h b/rbutil/mkamsboot/mkamsboot.h
index cf5628a..835d024 100644
--- a/rbutil/mkamsboot/mkamsboot.h
+++ b/rbutil/mkamsboot/mkamsboot.h
@@ -42,6 +42,7 @@ enum {
     MODEL_M200V4,
     MODEL_C200V2,
     MODEL_CLIPPLUS,
+    MODEL_FUZEV2,
 };