Nios® II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Announcements
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.
12409 Discussions

can not write USM of max10 onchip flash

Altera_Forum
Honored Contributor II
1,186 Views

hi everyone, i meet some problems in max10 onchip flash UFM write and read 

this is my code, it is only a test code, i want to test the write and read of UFM in debug mode. 

 

# include "alt_types.h"# include "altera_avalon_pio_regs.h"# include "system.h"# include <stdio.h># include <unistd.h> 

 

 

int main() 

alt_u32 i=0; 

alt_u32 flash_status_reg1=0; 

alt_u32 flash_control_reg1=0; 

alt_u32 flash_data_reg1=0; 

alt_u16 j=0; 

 

 

alt_u16 a=0; 

while (1) 

 

 

flash_status_reg1=IORD_32DIRECT(ONCHIP_FLASH_0_CSR_BASE,0x0); //read flash status it shows 0xfffffc00, which means the flash in idle, read 

failed, write failed, erase failed, and all the sectors pretection bit is 0(no protection) 

flash_data_reg1=IORD_32DIRECT(ONCHIP_FLASH_0_DATA_BASE,0x4000); //read UFM0's first 32bit, it shows 0xffffffff, (this may be right because i have erased the UFM0,UFM1 successful last time, ) 

flash_status_reg1=IORD_32DIRECT(ONCHIP_FLASH_0_CSR_BASE,0x0); //read flash status it shows 0xfffffc00, which means the flash in idle, read 

failed, write failed, erase failed, and all the sectors pretection bit is 0(no protection), does this shows the data read failed? why? 

 

flash_data_reg1=IORD_32DIRECT(ONCHIP_FLASH_0_DATA_BASE,0x4); //read UFM1's second 32bit, it shows 0xffffffff, (this may be right because i have erased the UFM0,UFM1 successful last time, ) 

 

 

flash_status_reg1=IORD_32DIRECT(ONCHIP_FLASH_0_CSR_BASE,0x0); //read flash status it shows 0xfffffc00, which means the flash in idle, read 

failed, write failed, erase failed, and all the sectors pretection bit is 0(no protection), does this shows the data read failed? why?  

flash_data_reg1=IORD_32DIRECT(ONCHIP_FLASH_0_DATA_BASE,0x8);//read UFM1's third 32bit, it shows 0xffffffff, (this may be right because i have erased the UFM0,UFM1 successful last time, ) 

flash_status_reg1=IORD_32DIRECT(ONCHIP_FLASH_0_CSR_BASE,0x0);//read flash status it shows 0xfffffc00, which means the flash in idle, read 

failed, write failed, erase failed, and all the sectors pretection bit is 0(no protection), does this shows the data read failed? why?  

flash_control_reg1=IORD_32DIRECT(ONCHIP_FLASH_0_CSR_BASE,0x4);//read flash control register it shows 0x3fffffff, 

IOWR_32DIRECT(ONCHIP_FLASH_0_CSR_BASE,0x4,flash_control_reg1&0x3f7fffff); // write to flash control register, disable the write protection of UFM1 

flash_control_reg1=IORD_32DIRECT(ONCHIP_FLASH_0_CSR_BASE,0x4); //read flash control register it shows 0x3f7fffff, so write to flash control register successful 

IOWR_32DIRECT(ONCHIP_FLASH_0_DATA_BASE,0x0,0xab); // write to flash UFM1's first 32 bit ,  

flash_status_reg1=IORD_32DIRECT(ONCHIP_FLASH_0_CSR_BASE,0x0); // check the status, it shows write failed or stuck in busy_write.... 

 

 

 

why this happen?is there any reference design about how to use the UFM? 

 

thanks! 

 

0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
165 Views

Hi, 

 

here's a reference design for UFM for MAX 10 

https://cloud.altera.com/devstore/platform/14.0.2/putting-altera-max-series-in-hibernation-using-use... 

 

Also, which version of quartus are you using?
Altera_Forum
Honored Contributor II
165 Views

quartus 14.1  

i have downloaded an547, i am trying to open it...
Altera_Forum
Honored Contributor II
165 Views

i have downloaded an547 many weeks before, i tried for many times, can not open the reference design 

i install the reference design, but i can not find the quartus project files in the folder.  

i have installed many reference designs, but i can not figure out this one. 

by the way, i have seen the folder, the m10_int_flash_mem.qsys just have a flash, no nios processor. 

i have read the max 10 user flash memory user guide.pdf, it do not tell me how to use the ufm in nios.
Reply