diff options
author | Jörg Hohensohn <hohensoh@rockbox.org> | 2003-05-17 20:40:30 +0000 |
---|---|---|
committer | Jörg Hohensohn <hohensoh@rockbox.org> | 2003-05-17 20:40:30 +0000 |
commit | ceba6f863eb876ca3452f7c5f1d705cae4ccea7b (patch) | |
tree | 00c48f282575639ffc179d1ee0c1fce70da94547 /apps/debug_menu.c | |
parent | 67bea32c0827db96e1daa47d2efb63903360dc42 (diff) | |
download | rockbox-ceba6f863eb876ca3452f7c5f1d705cae4ccea7b.tar.gz rockbox-ceba6f863eb876ca3452f7c5f1d705cae4ccea7b.zip |
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)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3679 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/debug_menu.c')
-rw-r--r-- | apps/debug_menu.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c index 887af34814..8895c71bca 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c | |||
@@ -188,6 +188,42 @@ bool dbg_mpeg_thread(void) | |||
188 | } | 188 | } |
189 | #endif | 189 | #endif |
190 | 190 | ||
191 | /* Tool function to read the flash manufacturer and type, if available. | ||
192 | Only chips which could be reprogrammed in system will return values. | ||
193 | (The mode switch addresses vary between flash manufacturers, hence addr1/2) */ | ||
194 | bool dbg_flash_id(unsigned* p_manufacturer, unsigned* p_device, unsigned addr1, unsigned addr2) | ||
195 | { | ||
196 | unsigned not_manu, not_id; /* read values before switching to ID mode */ | ||
197 | unsigned manu, id; /* read values when in ID mode */ | ||
198 | volatile unsigned char* flash = (unsigned char*)0x2000000; /* flash mapping */ | ||
199 | |||
200 | not_manu = flash[0]; /* read the normal content */ | ||
201 | not_id = flash[1]; /* should be 'A' (0x41) and 'R' (0x52) from the "ARCH" marker */ | ||
202 | |||
203 | flash[addr1] = 0xAA; /* enter command mode */ | ||
204 | flash[addr2] = 0x55; | ||
205 | flash[addr1] = 0x90; /* ID command */ | ||
206 | sleep(HZ/50); /* Atmel wants 20ms pause here */ | ||
207 | |||
208 | manu = flash[0]; /* read the IDs */ | ||
209 | id = flash[1]; | ||
210 | |||
211 | flash[0] = 0xF0; /* reset flash (back to normal read mode) */ | ||
212 | sleep(HZ/50); /* Atmel wants 20ms pause here */ | ||
213 | |||
214 | /* I assume success if the obtained values are different from | ||
215 | the normal flash content. This is not perfectly bulletproof, they | ||
216 | could theoretically be the same by chance, causing us to fail. */ | ||
217 | if (not_manu != manu || not_id != id) /* a value has changed */ | ||
218 | { | ||
219 | *p_manufacturer = manu; /* return the results */ | ||
220 | *p_device = id; | ||
221 | return true; /* success */ | ||
222 | } | ||
223 | return false; /* fail */ | ||
224 | } | ||
225 | |||
226 | |||
191 | #ifdef HAVE_LCD_BITMAP | 227 | #ifdef HAVE_LCD_BITMAP |
192 | bool dbg_hw_info(void) | 228 | bool dbg_hw_info(void) |
193 | { | 229 | { |
@@ -200,6 +236,8 @@ bool dbg_hw_info(void) | |||
200 | unsigned char sec, sec2; | 236 | unsigned char sec, sec2; |
201 | unsigned long tick; | 237 | unsigned long tick; |
202 | bool is_12mhz; | 238 | bool is_12mhz; |
239 | unsigned manu, id; /* flash IDs */ | ||
240 | bool got_id; /* flag if we managed to get the flash IDs */ | ||
203 | 241 | ||
204 | if(PADR & 0x400) | 242 | if(PADR & 0x400) |
205 | usb_polarity = 0; /* Negative */ | 243 | usb_polarity = 0; /* Negative */ |
@@ -224,6 +262,11 @@ bool dbg_hw_info(void) | |||
224 | 262 | ||
225 | is_12mhz = (current_tick - tick > HZ); | 263 | is_12mhz = (current_tick - tick > HZ); |
226 | 264 | ||
265 | /* get flash ROM type */ | ||
266 | got_id = dbg_flash_id(&manu, &id, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */ | ||
267 | if (!got_id) | ||
268 | got_id = dbg_flash_id(&manu, &id, 0x555, 0x2AA); /* try AMD, Macronix */ | ||
269 | |||
227 | lcd_setmargins(0, 0); | 270 | lcd_setmargins(0, 0); |
228 | lcd_setfont(FONT_SYSFIXED); | 271 | lcd_setfont(FONT_SYSFIXED); |
229 | lcd_clear_display(); | 272 | lcd_clear_display(); |
@@ -248,6 +291,12 @@ bool dbg_hw_info(void) | |||
248 | snprintf(buf, 32, "Freq: %s", is_12mhz?"12MHz":"11.0592MHz"); | 291 | snprintf(buf, 32, "Freq: %s", is_12mhz?"12MHz":"11.0592MHz"); |
249 | lcd_puts(0, 6, buf); | 292 | lcd_puts(0, 6, buf); |
250 | 293 | ||
294 | if (got_id) | ||
295 | snprintf(buf, 32, "Flash: M=%02x D=%02x", manu, id); | ||
296 | else | ||
297 | snprintf(buf, 32, "Flash: M=?? D=??"); /* unknown, sorry */ | ||
298 | lcd_puts(0, 7, buf); | ||
299 | |||
251 | lcd_update(); | 300 | lcd_update(); |
252 | 301 | ||
253 | while(1) | 302 | while(1) |