Altera_Forum
Honored Contributor
10 years agocan not write USM of max10 onchip flash
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!