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
diff --git a/rbutil/mkamsboot/Makefile b/rbutil/mkamsboot/Makefile
index a4bb0dc..d62e7eb 100644
--- a/rbutil/mkamsboot/Makefile
+++ b/rbutil/mkamsboot/Makefile
@@ -8,8 +8,8 @@ LIBUCL=../../tools/ucl/src/libucl.a
 # adding a new target.  mkamsboot.c also needs to be edited to refer to these
 # new images.

-BOOTIMAGES = dualboot_clip.o dualboot_e200v2.o dualboot_c200v2.o dualboot_m200v4.o dualboot_fuze.o dualboot_clipv2.o
-BOOTHEADERS = dualboot_clip.h dualboot_e200v2.h dualboot_c200v2.h dualboot_m200v4.h dualboot_fuze.h dualboot_clipv2.h
+BOOTIMAGES = dualboot_clip.o dualboot_e200v2.o dualboot_c200v2.o dualboot_m200v4.o dualboot_fuze.o dualboot_clipv2.o dualboot_fuzev2.o
+BOOTHEADERS = dualboot_clip.h dualboot_e200v2.h dualboot_c200v2.h dualboot_m200v4.h dualboot_fuze.h dualboot_clipv2.h dualboot_fuzev2.h

 CLIPFILES = dualboot_clip.arm-o dualboot_clip.o dualboot_clip.c dualboot_clip.h

@@ -26,6 +26,8 @@ C200V2FILES = dualboot_c200v2.arm-o dualboot_c200v2.o dualboot_c200v2.c \

 FUZEFILES = dualboot_fuze.arm-o dualboot_fuze.o dualboot_fuze.c dualboot_fuze.h

+FUZEV2FILES = dualboot_fuzev2.arm-o dualboot_fuzev2.o dualboot_fuzev2.c dualboot_fuzev2.h
+
 all: mkamsboot

 # Dualboot bootloaders
@@ -48,6 +50,9 @@ dualboot_m200v4.arm-o: dualboot.S
 dualboot_c200v2.arm-o: dualboot.S
 	arm-elf-gcc -DSANSA_C200V2 -c -o dualboot_c200v2.arm-o dualboot.S

+dualboot_fuzev2.arm-o: dualboot.S
+	arm-elf-gcc -DSANSA_FUZEV2 -c -o dualboot_fuzev2.arm-o dualboot.S
+
 # Rules for the ucl unpack function
 nrv2e_d8.arm-o: nrv2e_d8.S
 	arm-elf-gcc -DPURE_THUMB -c -o nrv2e_d8.arm-o nrv2e_d8.S
@@ -92,4 +97,4 @@ clean:
 	rm -f mkamsboot mkamsboot.o nrv2e_d8.arm-o nrv2e_d8.arm-elf \
 	nrv2e_d8.arm-bin *~ bin2c nrv2e_d8.c nrv2e_d8.h nrv2e_d8.o md5.o \
 	$(BOOTIMAGES) $(CLIPFILES) $(E200V2FILES) $(M200V4FILES) $(FUZEFILES) \
-	$(C200V2FILES) $(CLIPV2FILES)
+	$(C200V2FILES) $(CLIPV2FILES) $(FUZEV2FILES)
diff --git a/rbutil/mkamsboot/dualboot.S b/rbutil/mkamsboot/dualboot.S
index 0530969..9c9748c 100644
--- a/rbutil/mkamsboot/dualboot.S
+++ b/rbutil/mkamsboot/dualboot.S
@@ -21,7 +21,7 @@

 .text

- #if defined(SANSA_CLIPV2)
+ #if defined(SANSA_CLIPV2) || defined(SANSA_FUZEV2)
 .set RAM_SIZE, 0x100000 /* Use 1MB of SDRAM on V2 models (bigger firmwares) */
 #else
 .set RAM_SIZE, 0x50000  /* Use full IRAM on V1 models */
@@ -136,6 +136,23 @@ uclcopy:

         cmp   r1, #0
         beq   boot_of
+#elif defined(SANSA_FUZEV2)
+        ldr   r0, =GPIOA
+        @ldr   r0, =GPIOB
+        @ldr   r0, =GPIOC
+        @ldr   r0, =GPIOD
+
+.set pin, 0 @ 1, 2, 3, 4, 5, 6, 7
+        ldr   r0, [r0, #(4*(1<<pin))]
+        cmp   r0, #0
+        beq   boot_of   @ if the pin is unset, boot immediately
+                        @ else, boot after a noticeable delay
+
+delay:  mov   r0, #0x100000
+1:      subs  r0, r0, #1
+        bne   1b
+
+        b     boot_of
 #elif defined(SANSA_E200V2) || defined(SANSA_FUZE)
         /* LEFT button */
         ldr   r0, =GPIOC
diff --git a/rbutil/mkamsboot/mkamsboot.c b/rbutil/mkamsboot/mkamsboot.c
index 4c1d65e..b76f1da 100644
--- a/rbutil/mkamsboot/mkamsboot.c
+++ b/rbutil/mkamsboot/mkamsboot.c
@@ -96,6 +96,7 @@ execution to the uncompressed firmware.
 #include "dualboot_fuze.h"
 #include "dualboot_m200v4.h"
 #include "dualboot_c200v2.h"
+#include "dualboot_fuzev2.h"

 /* Win32 compatibility */
 #ifndef O_BINARY
@@ -115,6 +116,7 @@ enum
     MODEL_E200V2,
     MODEL_M200V4,
     MODEL_C200V2,
+    MODEL_FUZEV2,
 };

 static const char* model_names[] = 
@@ -124,7 +126,8 @@ static const char* model_names[] =
     "Clip V2",
     "e200 v2",
     "m200 v4",
-    "c200 v2"
+    "c200 v2",
+    "Fuze v2"
 };

 static const unsigned char* bootloaders[] = 
@@ -135,6 +138,7 @@ static const unsigned char* bootloaders[] =
     dualboot_e200v2,
     dualboot_m200v4,
     dualboot_c200v2,
+    dualboot_fuzev2,
 };

 static const int bootloader_sizes[] = 
@@ -145,6 +149,7 @@ static const int bootloader_sizes[] =
     sizeof(dualboot_e200v2),
     sizeof(dualboot_m200v4),
     sizeof(dualboot_c200v2),
+    sizeof(dualboot_fuzev2),
 };

 /* Model names used in the Rockbox header in ".sansa" files - these match the
@@ -157,6 +162,7 @@ static const char* rb_model_names[] =
     "e2v2",
     "m2v4",
     "c2v2",
+    "fuz2",
 };

 /* Model numbers used to initialise the checksum in the Rockbox header in
@@ -168,7 +174,8 @@ static const int rb_model_num[] =
     66,
     41,
     42,
-    44
+    44,
+    67
 };

 struct md5sums {