Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++

Flash device driver

Altera_Forum
Honored Contributor II
909 Views

Hi everybody. 

 

I am developing a solution using the Nios Development Kit Cyclone Edition that is fitted with an EP1C20 and an AM29LV065D 8MB flash chip. 

 

I am using the flash and successfully writing and reading data to and from it. My problem is that sometimes writing data to it can take very long. I use the standard functions provided by the NIOS II cpu, and this is the only way of accessing the flash that I know of. 

 

I service up to 30 UARTs as well as comms with a server in a single threaded fashion, obviously using statemachines. The problem comes when wirting to the flash on behalf of one of the UARTs, and it takes up to 2500ms, I miss other events that occur in the mean time as I cannot service the other state machines. 

 

I have written a little "torture test" procedure to make sure about my facts, and what I have done is to sit in a loop and write 0xAA to address 0x5A0000 -> 0x5AFFFF, then write 0x55 to 0x5A0000 -> 0x5AFFFF. Once this is done, I increment my address by 0x10000 and continue doing this until I get to 0x790000, where I reset my address to 0x5A0000. 

Each of the write operations takes around 2500ms which then confirms my suspition that the flash is taking up the time.  

 

The procedure to write is as explained in the NIOS II Software Handbook. 

 

flashdevid = alt_flash_open_dev(flash_dev_name); 

record my millisecond timer counter here 

alt_write_flash(flashdevid,flashaddr,&temp_flashspace[0],0xffff); 

record my millisecond counter again and take the difference. 

this then ensures that i measure only the time that it takes to write the data. 

alt_flash_close_dev(flashdevid); 

 

I need to be able to give the data to a procedure that then writes it for me (like an ISR) and I can then poll its status to see if it is finished. This way I'll be able to continue servicing the rest of my applications statemachines. 

 

Please provide any comments or help. 

 

Regards, 

Tyrone
0 Kudos
1 Reply
Altera_Forum
Honored Contributor II
233 Views

 

--- Quote Start ---  

originally posted by gizmo@May 31 2006, 04:00 AM 

hi everybody. 

 

i am developing a solution using the nios development kit cyclone edition that is fitted with an ep1c20 and an am29lv065d 8mb flash chip. 

 

i am using the flash and successfully writing and reading data to and from it. my problem is that sometimes writing data to it can take very long. i use the standard functions provided by the nios ii cpu, and this is the only way of accessing the flash that i know of. 

 

i service up to 30 uarts as well as comms with a server in a single threaded fashion, obviously using statemachines. the problem comes when wirting to the flash on behalf of one of the uarts, and it takes up to 2500ms, i miss other events that occur in the mean time as i cannot service the other state machines. 

 

i have written a little "torture test" procedure to make sure about my facts, and what i have done is to sit in a loop and write 0xaa to address 0x5a0000 -> 0x5affff, then write 0x55 to 0x5a0000 -> 0x5affff. once this is done, i increment my address by 0x10000 and continue doing this until i get to 0x790000, where i reset my address to 0x5a0000. 

each of the write operations takes around 2500ms which then confirms my suspition that the flash is taking up the time.  

 

the procedure to write is as explained in the nios ii software handbook. 

 

FlashDevID = alt_flash_open_dev(FLASH_DEV_NAME); 

Record my millisecond timer counter here 

alt_write_flash(FlashDevID,FlashAddr,&Temp_FlashSpace[0],0xFFFF); 

Record my millisecond counter again and take the difference. 

This then ensures that I measure only the time that it takes to write the data. 

alt_flash_close_dev(FlashDevID);[/b] 

 

I need to be able to give the data to a procedure that then writes it for me (like an ISR) and I can then poll its status to see if it is finished. This way I'll be able to continue servicing the rest of my applications statemachines. 

 

Please provide any comments or help. 

 

Regards, 

Tyrone 

<div align='right'><{post_snapback}> (index.php?act=findpost&pid=15717) 

--- Quote End ---  

[/b] 

--- Quote End ---  

 

 

It sounds like you want an Asynchronous function to write to flash, your problem is the interface to flash chips. The problem is that the flash chips are designed to be polled, as you will see if you look in the datasheet, specifically look at Figure 4. Whilst I&#39;m sure you could poll this off a timer interrupt you need to re-write the flash software, and be very careful that none of your other code access any address that is mapped to flash whilst this is going on, because once the flash is in programming mode you can read status information not memory depending upon the internal state of the chip, and any writes could adversely affect the programming algorithm.
0 Kudos
Reply