Для доступа к CFI памяти в SOPC builder необходимо наличие (ug_nios2_flash_programmer.pdf):
Nios II Processor, with Joint Text Action Group (JTAG) debug module level 1 or greater
Avalon-MM Tristate Bridge
Flash Memory (Common Flash Interface)
На плате Altera DE2 (я с ней работал) установлена CFI флеш память фирмы SPANSION объемом 4МБ, которая имеет 22 адресных линии и 8 данных. Тайминги при работе были выставлены 70-100-70 нс (с другими значениями не известно).
Особенностью является установка в Quartus II пина (FL_RST_N) как входного, хотя как пин от флеш памяти не присутствует, но есть в Pin Planner при импорте всех пинов. Без установки этого пина как входного (VCC) память работать не будет.
Для чтения/записи, вы должны использовать API HAL, чтобы и читать и писать данные. Про HAL функции здесь (n2sw_nii5v2.pdf, раздел 6-16; раздел 12). Функции API определены в sys/alt_flash.h (подключается в программе для NIOS).
Для примера
Код
#include <stdio.h>
#include "sys/alt_flash.h"
#include "system.h"
int main ()
{ alt_flash_fd* fd;
int ret_code;
flash_region* regions;
int number_of_regions;
fd = alt_flash_open_dev("/dev/cfi_flash");
if (fd)
{ ret_code = alt_get_flash_info(fd, ®ions, &number_of_regions);
if (!ret_code)
{
printf("Offset of this region from start of the flash - %d \n", regions->offset);
printf("Size of this erase region - %d \n", regions->region_size);
printf("Number of blocks in this region - %d \n", regions->number_of_blocks);
printf("Size of each block in this erase region - %d byte \n", regions->block_size);
printf("The number of erase regions in the flash - %d \n", number_of_regions);
};
alt_flash_close_dev(fd);
}
else
{
printf("Can’t open cfi_flash\n");
}
return 0;
}