Rockbox Development > New Ports

SanDisk Sansa c200v2, m200v4, clipv1, clipv2, clip+, and fuzev2

<< < (285/386) > >>

FlynDice:
@funman:

I think the GPIOB(0) only needs to be set in order to read D6 (power).  Here's my commented disassembly: http://pastie.org/823431.

The OF appears to set B0, read D6, unset B0, read the rest of the pins & set flags in r0 if pin is set,  and finally reads pin D6 again only if it was set from the first read.  I guess this is the way to detect the long press.  I've not quite finished but the rest appears to be simply shifting the flags around to frame the return.  And of course there could be another gotcha in another section of code....

Comments welcomed as usual!

EDIT:  Updated disassembly pastie
EDIT2:  Updated disassembly pastie

EDIT3:  It appears the OF returns from the button reads without resetting GPIOB_DIR(0) or GPIOB_DIR(6)to input.

I also just noticed at 7a54 sets pin B6 to output (but doesn't set the pin) before the second D6 button read.

ranma:
Damn, I bricked my C240v2 while playing with dualboot.S...
dualboot.S is not at fault, but rather I forgot to copy dualboot.h in addition to dualboot.c and so mkamsboot copied only part of dualboot into the new firmware. :P
I tried shorting the flash so it'll boot the 'USB boot promer', which makes it show up on usb.
However it reports lun 0 as a single 512 byte sector (Sense Key : Medium Error, Add. Sense: Recorded entity not found) and lun 1 as 'not present', so doesn't help.

[edit3]
FWIW, this is my dualboot.S modification, trying to use the audio master i2c to read irq_enrd0 for usb status... Doesn't work, but should have let me recover because it's after the normal button check.


--- Code: ---Index: rbutil/mkamsboot/dualboot/dualboot.S
===================================================================
--- rbutil/mkamsboot/dualboot/dualboot.S (revision 24590)
+++ rbutil/mkamsboot/dualboot/dualboot.S (working copy)
@@ -28,11 +28,12 @@
 #endif
 
 /* AS3525 hardware registers */
-.set GPIOA,     0xC80B0000
-.set GPIOB,     0xC80C0000
-.set GPIOC,     0xC80D0000
-.set GPIOD,     0xC80E0000
-.set CGU_PERI,  0xC80F0014
+.set GPIOA,          0xC80B0000
+.set GPIOB,          0xC80C0000
+.set GPIOC,          0xC80D0000
+.set GPIOD,          0xC80E0000
+.set CGU_PERI,       0xC80F0014
+.set I2C_AUDIO_BASE, 0xC8070000
 
 
 /* Vectors */
@@ -93,12 +94,14 @@
 #endif
 
 #ifdef USB_PIN  /* TODO : remove this check when we'll have an USB driver */
+/*
         ldr     r0, =GPIOA
         mov     r1, #0
         str     r1, [r0, #0x400]
         ldr     r1, [r0, #(4*(1<<USB_PIN))]
         cmp     r1, #0
         bne     boot_of
+*/
 #endif
 
         /* Here are model specific tests, for dual boot without a computer */
@@ -186,15 +189,18 @@
         cmp     r2, #0              @ test input from pins
         bne     boot_of             @ branch directly to OF if either pin high
 #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  */
+        /* check for LEFT or RIGHT on C6 */
         ldr     r0, =GPIOC
         mov     r1, #0
-        str     r1, [r0, #0x400]      /* set pin to output */
+        str     r1, [r0, #0x400]      /* set all GPIOC to input */
 
         ldr     r1, [r0, #256]        /* 1<<(6+2) */
-        cmp     r1, #0                /* C6 low means button pressed */
+        cmp     r1, #0                /* C6 low means r-button pressed */
         beq     boot_of
+
+//        ldr     r1, [r0, #16]         /* 1<<(2+2) */
+//        cmp     r1, #0                /* C2 low means l-button pressed */
+//        beq     boot_of
 #elif defined(SANSA_M200V4)
 .set row, (1<<5) /* enable output on A5 */
 .set col, (1<<0) /* read keyscan column A0 */
@@ -213,7 +219,59 @@
         #error No target-specific key check defined!
 #endif
 
+        /* enable i2c audio master clock */
+        ldr     r0, =CGU_PERI
+        ldr     r1, [r0]
+        orr     r1, r1, #(1<<17)
+        str     r1, [r0]
 
+.set pclk, 62000000
+.set i2c_clk, 400000
+.set i2c_prescaler, ((pclk + i2c_clk -1) / i2c_clk)
+.set I2C2_DATA,  0x00
+.set I2C2_SLAD0, 0x04
+.set I2C2_CNTRL, 0x0c
+.set I2C2_DACNT, 0x10
+.set I2C2_CPSR0, 0x1c
+.set I2C2_CPSR1, 0x20
+.set I2C2_SR,    0x30
+.set I2C2_SADDR, 0x44
+.set AS3514_I2C_ADDR, 0x46
+.set AS3514_IRQ_ENRD0, 0x25
+        ldr     r0, =I2C_AUDIO_BASE
+        /* setup prescaler */
+        ldr     r1, =i2c_prescaler
+        str     r1, [r0, #I2C2_CPSR0]
+        mov     r1, r1, lsr #8
+        str     r1, [r0, #I2C2_CPSR1]
+        /* setup i2c slave address */
+        mov     r1, #(AS3514_I2C_ADDR << 1)
+        str     r1, [r0, #I2C2_SLAD0]
+        mov     r2, #0x51
+        str     r2, [r0, #I2C2_CNTRL]
+
+        /* wait for not busy */
+i2c_busywait:
+        ldr     r1, [r0, #I2C2_SR]
+        tst     r1, #1
+        bne i2c_busywait
+
+        /* read irq_enrd0 */
+        mov     r1, #AS3514_IRQ_ENRD0
+        str     r1, [r0, #I2C2_SADDR]
+        orr     r2, r2, #(1 << 1)
+        str     r2, [r0, #I2C2_CNTRL]
+        mov     r1, #1
+        str     r1, [r0, #I2C2_DACNT]
+i2c_wait:
+        ldr     r1, [r0, #I2C2_DACNT]
+        cmp     r1, #0
+        bne     i2c_wait
+
+        ldr     r1, [r0, #I2C2_DATA]
+        tst     r1, #(1 << 3)
+        bne     boot_of
+
         /* The dualboot button was not held, so we boot rockbox */
         ldr     r0, ucl_rb_end      /* Address of compressed image */
         ldr     r1, ucl_rb_size     /* Compressed size */

--- End code ---
[/edit3]

[edit]
I hereby request this small change that would have protected me from this mistake by making
gcc bail if dualboot.h and dualboot.c are mismatched:

CC dualboot.c
dualboot.c:63: error: conflicting types for ‘dualboot_c200v2’
dualboot.h:6: error: previous declaration of ‘dualboot_c200v2’ was here
make: *** [build/dualboot.o] Error 1


--- Code: ---Index: mkamsboot/dualboot/bin2c.c
===================================================================
--- mkamsboot/dualboot/bin2c.c (revision 24590)
+++ mkamsboot/dualboot/bin2c.c (working copy)
@@ -90,6 +90,7 @@
     }
 
     fprintf(cfile,"/* Generated by bin2c */\n\n");
+    fprintf(cfile,"#include \"%s\"\n\n", hfilename);
     fprintf(hfile,"/* Generated by bin2c */\n\n");
 
     for(i=0; i < argc - 2; i++) {

--- End code ---
[/edit]

[edit2]
Opened tracker item: http://www.rockbox.org/tracker/task/11009
[/edit2]

mtee:

--- Quote from: funman on February 12, 2010, 03:28:20 PM ---mt do you still have the clppa.bin you copied on your clip+ ?

btw the delay to power off is longer on Clipv2/+ than Clipv1 and closer to 15/20 seconds.

If you're sure it is dead, could you open it and try the e200v2 recovery trick ?

--- End quote ---

The image I used is here : mtarek.com/rockbox/output.rar

I have tried that recovery method but it still didn't work. There's the solution of attaching an external card reader to the NAND flash and writing the OF image back onto it, but I'm not sure if it would work, plus I don't think it would save me much compared to just buying another clip+.

FlynDice:
I checked to see if the second D6 read would somehow catch the USB presence for clip+ but I'm not able to find a difference. :(

ranma:
I'm going to try to find out the JTAG pinout on my C240v2.
Here is what I've got so far (measured voltages and on the supply pads also the resistance to make sure they are supply pads. At about 0.5 Ohms I'm pretty sure they are :)):


--- Code: ---USB

    1 GND
 F  2 2.4V
 L  3 2.4V
 A  4 2.4V
 S  5 2.4V
 H  6 0V (TRST?)
    7 VCC

RAM

--- End code ---

And I soldered wires to the pads:
http://uguu.de/~ranma/S6000731.JPG

Now I have to figure out how to best proceed in testing the pins...

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version