[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Can't write in flash from boot loader!
I want to save some values written down in the flash memory from
my boot loader. However I make it, the values are not saved in
the flash. Does the MMU write protect the flash at boot up??
I've taken the flash_write32(), flash_read32() routines and the
definitions from arch/cris/drivers/axisflashmap.c.
Here is my code: (putx() prints out the given unsigned int as hex.
Not included here.)
/* This comes from arch/cris/drivers/axisflashmap.c */
#define FLASH_UNCACHED_ADDR KSEG_8
#define FLASH_CACHED_ADDR KSEG_5
#define FLASH_UNCACHED_ADDR KSEG_E
#define FLASH_CACHED_ADDR KSEG_F
/* I try to corrupt my own partition table */
#define P_TABLE 0x10000
/* To be added to any boot loader */
puts("\n Flash write test:\n===================\n");
flash_write32(PTABLE_START, (unsigned int) 0x77777777);
puts("Read again: 0x");
if(i==0x77777777) puts("\nWritten value is equal to newly read
puts("\nWritten value is NOT equal to read value. Error!\n");
static void flash_write32(unsigned long adr, unsigned int d)
*(unsigned int *)(FLASH_UNCACHED_ADDR + adr) = d;
static unsigned int flash_read32(unsigned long ofs)
return *(volatile unsigned int *)(FLASH_UNCACHED_ADDR + ofs);
Here is the output:
Flash write test:
Read again: 0xf025050f
Written value is NOT equal to read value. Error!
Earlier I was using the address that goes via the cache to the
flash, then the value was atleast in the cache for a while.
What am I doing wrong?
Any help would be much appreachated!
Jonas Aaberg Email: firstname.lastname@example.org
Supercomputing Systems AG Web: http://www.scs.ch
Technoparkstrasse 1 Phone: +41 (0) 1 445 16 00
CH-8005 Zuerich Fax: +41 (0) 1 445 16 10