Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
21584 Discussions

Arria V GX configuation issues

mtwieghr
Beginner
483 Views

Hello, was hoping for some help with some configuration problems we've been having.

Our design (5AGXMB3G4) has a Nios II with an EPCS controller (altera_avalon_epcs_flash_controller) to interface to our configuration device (MT25QL256, using AS x1). Using quartus standard 18.1.1

We have noticed that the configuration in flash becomes corrupted over time. If we "examine" the flash with the quartus programmer, and compare the resulting jic file against the original jic used to program the flash, we generally see that the differences are very sparse, usually a few groups of four bytes set to zero near the start of the image. I've attached a screenshot where the diffs are highlighted (this is all the diffs in the entire 256Mb file).

We haven't found any hardware explanation for the corruption (supply rails all look good, sequenced properly, logic levels and pullup resistors are ok). The current theory is that the Nios is accidentally writing the flash due to some code bug (bad pointer, stack overflow, who knows). While we look for the true root cause, I wanted to also provide some protection against this accidental corruption by disabling writes to the flash outside of normal configuration operations.

We've considered using the API alt_lock_flash() to lock all sectors (bits 6,4:2 of the status register), but this operation is non-volatile and opens up some scenarios where doing remote updates might become impossible. Instead I'd like to make use of the Write Enable Latch (bit 1 of the status register).

To start with we wanted to just read the flash chip's status register so we can verify we are affecting it correctly. But we can't even get this to work. There doesn't seem to be an API for interacting with the status regsiter, but there are useful-looking macros like this:

status = IORD_ALTERA_EPCQ_CONTROLLER_STATUS(epcq_flash_info->csr_base)

But trying this yields status=0x20, which does not make sense. What are we doing wrong?

 

Regards,

Mike

Labels (1)
0 Kudos
2 Replies
Farabi
Employee
305 Views

Hello,


1- Most probably the corruption is due to NIOS II code is accidentally writing flash. Please check the pointers in your code.

a. The EPCS flash is memory-mapped via altera_avalon_epcs_flash_controller

b. There is risk when writing to memory-mapped region, the code interpreted as erase/write commands if done in specific sequence.



2- Using IORD_ALTERA_EPCQ_CONTROLLER_STATUS returns 0x20 does not corresponds to actual flash status register. Please try below:

a. The EPCQ controller in Quartus Standard does not directly exposed SPI-level operations like "read status register", instead, you need to use low-level flash driver that provides these operations. You need to include the EPCS Flash Driver. from this location <nios2_install>/components/altera_avalon_epcs_flash_controller.

b. use the "alt_epcs_flash_read_status_register()" function.

c. Use "alt_avalon_spi_command( )" with 0x05 to read Flash Status Register.


3- Protecting Flash from NIOS II writes

a. Avoid using "alt_lock_flash()" for permanent protection, please use WEL (Write Enable Latch) signal in your code:

i) every flash write or erase operation will require WEL to be set(via 0x06 WE command).

ii) if WEL is not set, write/erase will be ignored.

iii) WEL will be cleared automatically after each write/erase operation.

b. Avoid calling 0x06 (WE) unless in controlled condition in your code.


regards,

Farabi




0 Kudos
Farabi
Employee
273 Views

Hello,


I will put back the case to community. If you have new question, please raise new ticket.


regards,

Farabi


0 Kudos
Reply