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
diff --git a/rbutil/mkamsboot/dualboot.c b/rbutil/mkamsboot/dualboot.c
index 32dad00..527850d 100644
--- a/rbutil/mkamsboot/dualboot.c
+++ b/rbutil/mkamsboot/dualboot.c
@@ -136,3 +136,20 @@ 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[236] = {
+    0xd4, 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,
+    0x78, 0x00, 0x9f, 0xe5, 0x00, 0x10, 0x90, 0xe5, 0x01, 0x18, 0x81, 0xe3, 0x00, 0x10, 0x80, 0xe5,
+    0x6c, 0x00, 0x9f, 0xe5, 0x00, 0x10, 0xa0, 0xe3, 0x00, 0x14, 0x80, 0xe5, 0x20, 0x10, 0x90, 0xe5,
+    0x00, 0x00, 0x51, 0xe3, 0x08, 0x00, 0x00, 0x1a, 0x58, 0x00, 0x9f, 0xe5, 0x00, 0x10, 0xa0, 0xe3,
+    0x00, 0x14, 0x80, 0xe5, 0x20, 0x10, 0x90, 0xe5, 0x00, 0x00, 0x51, 0xe3, 0x02, 0x00, 0x00, 0x1a,
+    0x78, 0x00, 0x1f, 0xe5, 0x78, 0x10, 0x1f, 0xe5, 0x01, 0x00, 0x00, 0xea, 0x8c, 0x00, 0x1f, 0xe5,
+    0x8c, 0x10, 0x1f, 0xe5, 0x84, 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..d67ad2b 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[236];
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..84d2fce 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

@@ -143,14 +143,20 @@ uclcopy:

         cmp     r1, #0
         beq     boot_of
-#elif defined(SANSA_E200V2) || defined(SANSA_FUZE)
+#elif defined(SANSA_E200V2) || defined(SANSA_FUZE) || 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 */
+#ifdef SANSA_FUZEV2
+        /* the logic is reversed on the fuzev2 */
+        bne     boot_of
+#else
         beq     boot_of
+#endif /* SANSA_FUZEV2 */
+
 #elif defined(SANSA_CLIPPLUS)
         @ read pins
         ldr     r0, =GPIOC
diff --git a/rbutil/mkamsboot/mkamsboot.c b/rbutil/mkamsboot/mkamsboot.c
index 9e0099d..4cf1bcd 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,9 @@ static struct md5sums sansasums[] = {
     { MODEL_CLIPV2, "2.01.32", "0ad3723e52022509089d938d0fbbf8c5" },

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

 #define NUM_MD5S (sizeof(sansasums)/sizeof(sansasums[0]))
@@ -324,6 +334,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,
 };