[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Can't write in flash from boot loader!



Hi,

Flashes requires special unlock sequences before you can write to
them and you must poll the flash for completion after each write. 
This is normally handled by the MTD framework.

Refer to e.g. tools/e100boot/cbl or flash data sheets.

/Mikael

-----Original Message-----
From: owner-dev-etrax@xxxxxxx.com]On">mailto:owner-dev-etrax@xxxxxxx.com]On
Behalf Of Jonas Aaberg
Sent: Thursday, May 17, 2001 8:42 AM
To: dev-etrax
Subject: Can't write in flash from boot loader!



Hi,

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 */
#include <asm/mmu.h>

#ifdef CONFIG_CRIS_LOW_MAP
#define FLASH_UNCACHED_ADDR  KSEG_8
#define FLASH_CACHED_ADDR    KSEG_5
#else
#define FLASH_UNCACHED_ADDR  KSEG_E
#define FLASH_CACHED_ADDR    KSEG_F
#endif

/* 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");
	i=flash_read32(PTABLE_START);
	puts("\nRead:     0x");
	putx(i);
	puts("\nWrite:    0x77777777\n");
	flash_write32(PTABLE_START, (unsigned int) 0x77777777);
	i=flash_read32(PTABLE_START);
	puts("Read again: 0x");
	putx(i);
	if(i==0x77777777) puts("\nWritten value is equal to newly read
value\n");
	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:     0xf025050f
Write:    0x77777777
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!

Regards,
 Jonas




-- 
Jonas Aaberg               Email: aberg@xxxxxxx.ch
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