logo       
Google Custom Search
    AddThis Social Bookmark Button
-->

cvs: apps debug_menu.c,1.44,1.45: msg#00052

Subject: cvs: apps debug_menu.c,1.44,1.45
Update of /cvsroot/rockbox/apps
In directory sc8-pr-cvs1:/tmp/cvs-serv16035

Modified Files:
        debug_menu.c 
Log Message:
Flash Manufacturer/ID in Debug->View HW Info, if this gives valid info you have 
an in-system programmable Flash (pre-study for Rockbox in Flash)

Index: debug_menu.c
===================================================================
RCS file: /cvsroot/rockbox/apps/debug_menu.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -b -r1.44 -r1.45
--- debug_menu.c        9 Apr 2003 23:17:35 -0000       1.44
+++ debug_menu.c        17 May 2003 20:40:30 -0000      1.45
@@ -188,6 +188,42 @@
 }
 #endif
 
+/* Tool function to read the flash manufacturer and type, if available.
+   Only chips which could be reprogrammed in system will return values.
+   (The mode switch addresses vary between flash manufacturers, hence addr1/2) 
*/
+bool dbg_flash_id(unsigned* p_manufacturer, unsigned* p_device, unsigned 
addr1, unsigned addr2)
+{
+    unsigned not_manu, not_id; /* read values before switching to ID mode */
+    unsigned manu, id; /* read values when in ID mode */
+    volatile unsigned char* flash = (unsigned char*)0x2000000; /* flash 
mapping */
+
+    not_manu = flash[0]; /* read the normal content */
+    not_id   = flash[1]; /* should be 'A' (0x41) and 'R' (0x52) from the 
"ARCH" marker */
+
+    flash[addr1] = 0xAA; /* enter command mode */
+    flash[addr2] = 0x55;
+    flash[addr1] = 0x90; /* ID command */
+    sleep(HZ/50); /* Atmel wants 20ms pause here */
+
+    manu = flash[0]; /* read the IDs */
+    id   = flash[1];
+
+    flash[0] = 0xF0; /* reset flash (back to normal read mode) */
+    sleep(HZ/50); /* Atmel wants 20ms pause here */
+
+    /* I assume success if the obtained values are different from
+        the normal flash content. This is not perfectly bulletproof, they 
+        could theoretically be the same by chance, causing us to fail. */
+    if (not_manu != manu || not_id != id) /* a value has changed */
+    {
+        *p_manufacturer = manu; /* return the results */
+        *p_device = id;
+        return true; /* success */
+    }
+    return false; /* fail */
+}
+
+
 #ifdef HAVE_LCD_BITMAP
 bool dbg_hw_info(void)
 {
@@ -200,6 +236,8 @@
     unsigned char sec, sec2;
     unsigned long tick;
     bool is_12mhz;
+    unsigned manu, id; /* flash IDs */
+    bool got_id; /* flag if we managed to get the flash IDs */
 
     if(PADR & 0x400)
         usb_polarity = 0; /* Negative */
@@ -224,6 +262,11 @@
 
     is_12mhz = (current_tick - tick > HZ);
     
+    /* get flash ROM type */
+    got_id = dbg_flash_id(&manu, &id, 0x5555, 0x2AAA); /* try SST, Atmel, 
NexFlash */
+    if (!got_id)
+        got_id = dbg_flash_id(&manu, &id, 0x555, 0x2AA); /* try AMD, Macronix 
*/
+    
     lcd_setmargins(0, 0);
     lcd_setfont(FONT_SYSFIXED);
     lcd_clear_display();
@@ -247,6 +290,12 @@
     
     snprintf(buf, 32, "Freq: %s", is_12mhz?"12MHz":"11.0592MHz");
     lcd_puts(0, 6, buf);
+    
+    if (got_id)
+        snprintf(buf, 32, "Flash: M=%02x D=%02x", manu, id);
+    else
+        snprintf(buf, 32, "Flash: M=?? D=??"); /* unknown, sorry */
+    lcd_puts(0, 7, buf);
     
     lcd_update();
 




<Prev in Thread] Current Thread [Next in Thread>