Altera_Forum
Honored Contributor
11 years agoNAND flash programming model
Hi
I use Cyclone V HPS on our custom board and try to work with NAND flash controller. The application is baremetal and hwlib is used. For now I can read device and manufacturer ID and do initialization. I can't perform read/write operation: I've done erasing-writing-reading but I've got zeroes. Here is my code:
uint32_t address = 0x10050000;
char testdatain = {1, 2, 3, 4};
char testdataout = { 0 };
if (status == ALT_E_SUCCESS)
{
printf("INFO: NAND initialization\n");
status = alt_nand_flash_init(false, false, NULL, NULL);
}
if (status == ALT_E_SUCCESS)
{
status = alt_nand_flash_block_erase(address, NULL, NULL);
}
if (status == ALT_E_SUCCESS)
{
status = alt_nand_flash_page_write(address, 1, testdatain, sizeof(testdatain));
}
if (status == ALT_E_SUCCESS)
{
status = alt_nand_flash_page_read(address, 1, testdataout, sizeof(testdataout));
if (status == ALT_E_SUCCESS)
{
for (int i=0; i<sizeof(testdataout); i++)
{
printf("byte# %d = %d\n", i, testdataout);
}
}
} My point is it's someting wrong with addressing, because if I set address to 0x0, it is ok. Has anybody some working examples for NAND? Or some useful link? I can't find Altera examples on this topic. The only reference is function descriptions in alt_nand_flash.h file. Thanks in advance.