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

Re: [microblaze-uclinux] Memec P160 : Flash



Hi Fabrice,

fabrice derrien wrote:
> Hi John,
> 
> I'm trying to get the Flash on the Memec/Insight boards working with the 
> external controller peripheral. I follow your advice, on the Xilinx's 
> Forum and it seems to work (CFI query command : OK). 

That's a good start!

> However, I did 
> manage to write bytes in the Flash and after read them back.

I think you maybe have a small misunderstanding of how the flash write 
process works - see my comments below:

> 
>   flash_location = 0xFF001000;
>   flash_data_read = *flash_location;  -------> it contains 0x00FF00FF
>   *flash_location = 0x5555;    // write

To do a write, you must first put the flash into "write mode".  (These 
codes I got from the data sheet for the flash/sram part)

// set the flash part base address
flash_base = 0xFF000000;

// Enable fast program mode
*(flash_base + 0x555*2) = 0x00AA00AA;
*(flash_base + 0x2AA*2) = 0x00550055;
*(flash_base + 0x555*2) = 0x00200020;

// Program some data
*(flash_base) = 0x00A000A0
*flash_location = 0xDEADBEEF

*(flash_base) = 0x00A000A0
*(flash_location+1) = 0x01020304

... and so on

// terminate fast program mode
*(flash_base) = 0x00900090
*(flash_base) = 0x00F000F0

The trick with flash is that it only behaves like an sram in read mode 
(ie put an address one the bus, assert OE, and read what comes off the 
data).  when writing, it's a more complex state machine, and you use the 
address and data buses as control inputs to the state machine, thus 
writing the words to get it into program mode, and the line

*(flash_base) = 0x00A000A0

before each write, which says to the flash "ok here comes another word".

My development machine is out of action at the moment as I am making the 
switch to Linux, so I haven't actually tested the sequence I've 
described above, however it is similar to that which I have used 
previously.  When my machine is up and running AGAIN I'll try to get a 
working example for you to play with.

Regards,

John