Forum Discussion
Altera_Forum
Honored Contributor
21 years agohelp me about cfi
i am a beginner of this field. so many problems block me. i have a ep1s80 dev board and a ep1s25 dev board.but i can't program flash on these board. the preset of the cfi does't support...
Altera_Forum
Honored Contributor
21 years agohello rugbybloke,
firstly,i set a break point at alt_flash_cfi_init( alt_flash_cfi_dev* flash ) in altera_avalon_cfi_flash .c then execute : alt_read_cfi_width( flash ); i step into the function. then execut : alt_write_flash_command_8bit(flash->dev.base_addr, 0x55, QUERY_MODE); i can't trace at this sentence : IOWR_8DIRECT(base_addr, offset, value); int alt_read_cfi_width(alt_flash_cfi_dev* flash) { int i; alt_u8 byte_id[12]; alt_u8 byte_iface; alt_u16 half_word_iface; alt_u32 full_word_iface; int ret_code = 0; alt_write_flash_command_8bit(flash->dev.base_addr, 0x55, QUERY_MODE); for(i=0;i<3;i++) { byte_id = iord_8direct(flash->dev.base_addr, 0x10+i);}
if ((byte_id[0] == 'q') &&
(byte_id[1] == 'r') &&
(byte_id[2] == 'y'))
{
flash->native_word_size = 1;
byte_iface = iord_8direct(flash->dev.base_addr, 0x28);
byte_iface += 1;
if (!(byte_iface & 0x1))
{
ret_code = -enodev;
}
}
else
{
/*
* put the device back into read array mode
*
* not strictly necessary i think
*/
alt_write_flash_command_8bit(flash->dev.base_addr, 0x55, read_array_mode);
/*
* try to put the device into query mode
*/
alt_write_flash_command_16bit(flash->dev.base_addr, 0x55, query_mode);
for(i=0;i<6;i++)
{
byte_id = IORD_8DIRECT(flash->dev.base_addr, 0x20+i); } if ((byte_id[0] == 'Q') && (byte_id[1] == '\0') && (byte_id[2] == 'R') && (byte_id[3] == '\0') && (byte_id[4] == 'Y') && (byte_id[5] == '\0')) { flash->native_word_size = 2; half_word_iface = IORD_16DIRECT(flash->dev.base_addr, 0x28*2); half_word_iface += 1; if (!(half_word_iface & 0x2)) { ret_code = -ENODEV; } } else if ((byte_id[0] == 'Q') && (byte_id[1] == 'Q') && (byte_id[2] == 'R') && (byte_id[3] == 'R') && (byte_id[4] == 'Y') && (byte_id[5] == 'Y')) { flash->native_word_size = 2; half_word_iface = IORD_16DIRECT(flash->dev.base_addr, 0x28*2); half_word_iface += 1; if (!(half_word_iface & 0x2)) { ret_code = -ENODEV; } } else { /* * Put the device back into Read Array Mode */ alt_write_flash_command_16bit(flash->dev.base_addr, 0x55, READ_ARRAY_MODE); /* * Try to put the device into Query mode */ alt_write_flash_command_32bit(flash->dev.base_addr, 0x55, QUERY_MODE); for(i=0;i<12;i++) { byte_id[i] = IORD_8DIRECT(flash->dev.base_addr, 0x40+i); } if ((byte_id[0] == 'Q') && (byte_id[1] == '\0') && (byte_id[2] == '\0') && (byte_id[3] == '\0') && (byte_id[4] == 'R') && (byte_id[5] == '\0') && (byte_id[6] == '\0') && (byte_id[7] == '\0') && (byte_id[8] == 'Y') && (byte_id[9] == '\0') && (byte_id[10] == '\0') && (byte_id[11] == '\0')) { flash->native_word_size = 4; full_word_iface = IORD_32DIRECT(flash->dev.base_addr, 0x28*4); full_word_iface += 1; if (!(full_word_iface & 0x4)) { ret_code = -ENODEV; } } else if ((byte_id[0] == 'Q') && (byte_id[1] == '\0') && (byte_id[2] == 'Q') && (byte_id[3] == '\0') && (byte_id[4] == 'R') && (byte_id[5] == '\0') && (byte_id[6] == 'R') && (byte_id[7] == '\0') && (byte_id[8] == 'Y') && (byte_id[9] == '\0') && (byte_id[10] == 'Y') && (byte_id[11] == '\0')) { flash->native_word_size = 2; full_word_iface = IORD_32DIRECT(flash->dev.base_addr, 0x28*4); full_word_iface += 1; if (!(full_word_iface & 0x4)) { ret_code = -ENODEV; } } else if ((byte_id[0] == 'Q') && (byte_id[1] == 'Q') && (byte_id[2] == 'Q') && (byte_id[3] == 'Q') && (byte_id[4] == 'R') && (byte_id[5] == 'R') && (byte_id[6] == 'R') && (byte_id[7] == 'R') && (byte_id[8] == 'Y') && (byte_id[9] == 'Y') && (byte_id[10] == 'Y') && (byte_id[11] == 'Y')) { flash->native_word_size = 1; full_word_iface = IORD_32DIRECT(flash->dev.base_addr, 0x28*4); full_word_iface += 1; if (!(full_word_iface & 0x4)) { ret_code = -ENODEV; } } else { ret_code = -enodev;// the ret_code get -19 at this place } /* * Put the device back into Read Array Mode */ alt_write_flash_command_32bit(flash->dev.base_addr, 0x55, READ_ARRAY_MODE); } } return ret_code; }