summaryrefslogtreecommitdiff
path: root/apps/debug_menu.c
diff options
context:
space:
mode:
authorJörg Hohensohn <hohensoh@rockbox.org>2004-07-19 21:21:34 +0000
committerJörg Hohensohn <hohensoh@rockbox.org>2004-07-19 21:21:34 +0000
commit5846aab6542104003bf03c29851bc3c12bc8da7a (patch)
tree1d23875002510efca078e0d5a60dc2058530ec66 /apps/debug_menu.c
parentf68e13c5b44797a2144ccd0be6d13d2d1b2926e5 (diff)
downloadrockbox-5846aab6542104003bf03c29851bc3c12bc8da7a.zip
rockbox-5846aab6542104003bf03c29851bc3c12bc8da7a.tar.gz
rockbox-5846aab6542104003bf03c29851bc3c12bc8da7a.tar.bz2
rockbox-5846aab6542104003bf03c29851bc3c12bc8da7a.tar.xz
fixed the flash ID query, prevent this code to eventually run from ROM
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4895 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/debug_menu.c')
-rw-r--r--apps/debug_menu.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index e7c2923..f1645bf 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -240,25 +240,39 @@ unsigned short crc_16(unsigned char* buf, unsigned len)
/* 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)
+ /* In IRAM to avoid problems when running directly from Flash */
+bool dbg_flash_id(unsigned* p_manufacturer, unsigned* p_device,
+ unsigned addr1, unsigned addr2)
+ __attribute__ ((section (".icode")));
+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 */
+ int old_level; /* saved interrupt level */
not_manu = flash[0]; /* read the normal content */
not_id = flash[1]; /* should be 'A' (0x41) and 'R' (0x52) from the "ARCH" marker */
+ /* disable interrupts, prevent any stray flash access */
+ old_level = set_irq_level(HIGHEST_IRQ_LEVEL);
+
flash[addr1] = 0xAA; /* enter command mode */
flash[addr2] = 0x55;
flash[addr1] = 0x90; /* ID command */
- sleep(HZ/50); /* Atmel wants 20ms pause here */
+ /* Atmel wants 20ms pause here */
+ /* sleep(HZ/50); no sleeping possible while interrupts are disabled */
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 */
+ /* Atmel wants 20ms pause here */
+ /* sleep(HZ/50); no sleeping possible while interrupts are disabled */
+
+ set_irq_level(old_level); /* enable interrupts again */
/* I assume success if the obtained values are different from
the normal flash content. This is not perfectly bulletproof, they