Thank you to anyone who has already donated - your generous donations helped make three months of treatment possible.

My brother Nate continues to fight stage IV Hodgkin's lymphoma. He's just 31, with a wife and baby girl. They have no active income (since he's been unable to return to work), no insurance, and cannot afford the treatment he needs. Nate and his family need your help. Please consider a donation, every dollar helps. Thanks.


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
diff --git a/rbutil/mkamsboot/dualboot/dualboot.S b/rbutil/mkamsboot/dualboot/dualboot.S
index 5210ba5..30afa5e 100644
--- a/rbutil/mkamsboot/dualboot/dualboot.S
+++ b/rbutil/mkamsboot/dualboot/dualboot.S
@@ -34,6 +34,9 @@
 .set GPIOD,     0xC80E0000
 .set CGU_PERI,  0xC80F0014

+.set CGU_DBOP,  0xC80F0038
+.set DBOP,      0xC8120000
+

 /* Vectors */

@@ -157,14 +160,56 @@ uclcopy:
         cmp     r1, #0             /* C3 = #0 means button pressed */
         beq     boot_of
 #elif defined(SANSA_C200V2)
-        /* check for RIGHT on C6, should changed to LEFT as soon as it
-         * known in which pin that is in order for consistency  */
-        ldr     r0, =GPIOC
-        mov     r1, #0
-        str     r1, [r0, #0x400]      /* set pin to output */
+        ldr     r0, =CGU_DBOP
+        mov     r1, #(1<<3)         @ no divider
+        str     r1, [r0]

-        ldr     r1, [r0, #256]        /* 1<<(6+2) */
-        cmp     r1, #0                /* C6 low means button pressed */
+        ldr     r0, =DBOP
+        ldr     r1, =0xe167e167
+        str     r1, [r0]            @ DBOP_TIMPOL_01
+        ldr     r1, =0xe167006e
+        str     r1, [r0, #4]        @ DBOP_TIMPOL_23
+
+        ldr     r2, =GPIOB
+        mov     r1, #0xc
+        str     r1, [r2, #0x420]    @ GPIOB_AFSEL
+        ldr     r2, =GPIOC
+        mov     r1, #0xff
+        str     r1, [r2, #0x420]    @ GPIOC_AFSEK
+
+        ldr     r1, =0x6006e
+        str     r1, [r0, #4]        @ DBOP_TIMPOL_23
+        ldr     r1, =0x52008
+        str     r1, [r0, #8]        @ DBOP_CTRL
+        ldr     r1, =0x6e167
+        str     r1, [r0]            @ DBOP_TIMPOL_01
+        ldr     r1, =0xa167e06f
+        str     r1, [r0, #4]        @ DBOP_TIMPOL_23
+
+1:      ldr     r1, [r0, #0xc]      @ DOBP_STAT
+        orrs    r1, r1, #(1<<10)
+        beq     1b                  @ make sure fifo is empty
+
+        ldr     r1, =0xe167e167
+        str     r1, [r0, #4]        @ DBOP_TIMPOL_23
+        mov     r1, #(1<<16)        @ enable write
+        orr     r1, r1, #(1<<12)    @ 16 bit data width
+        str     r1, [r0, #8]        @ DBOP_CTRL
+        mvn     r1, #0              @ 0xffff
+        strh    r1, [r0, #0x10]     @ DBOP_DOUT
+
+1:      ldr     r1, [r0, #0xc]      @ DOBP_STAT
+        orrs    r1, r1, #(1<<10)
+        beq     1b                  @ make sure fifo is empty
+
+        mov     r1, #31
+        orr     r1, r1, #(1<<12)    @ 16 bit data width
+        orr     r1, r1, #(1<<15)    @ start read
+        str     r1, [r0, #8]        @ DBOP_CTRL
+
+        ldrh    r1, [r0, #0x14]     @ DBOP_DIN
+
+        ands    r1, r1, #(1<<2)     @ button left
         beq     boot_of
 #elif defined(SANSA_M200V4)
 .set row, (1<<5) /* enable output on A5 */