nand flash的时序一般都是一样的,都有可能,楼主可以试试下面的测试程序,在offset 2的地方测一下,flash可能是内部颗粒出问题,这是常有的事,再分析一下。 #include <stdio.h> #include <sys/alt_flash.h> #include "system.h" #include <unistd.h> #define DATA_OFFSET 0x300000 int main(void) { alt_flash_fd* flash_handle; FILE *uart; char write_data = 0; char read_data = 0; write_data = 100; uart = fopen(UART_NAME,"w"); flash_handle = alt_flash_open_dev(CFI_FLASH_NAME); fprintf(uart, "open flash device...\n"); usleep(10000); if (flash_handle) { fprintf(uart, "open flash device successed!!!\n"); usleep(10000); alt_write_flash(flash_handle, DATA_OFFSET, &write_data, 1); fprintf(uart, "wirte_data = %d\n", write_data); usleep(10000); alt_read_flash(flash_handle, DATA_OFFSET, &read_data, 1); fprintf(uart, "read_data = %d\n", read_data); usleep(10000); if(read_data == write_data) { fprintf(uart, "flash write and read successed!!!\n"); usleep(10000); } else { fprintf(uart, "flash write or read failed!!!\n"); usleep(10000); } alt_flash_close_dev(flash_handle); fprintf(uart, "close flash device...\n"); usleep(10000); } else { fprintf(uart, "open flash device failed!!!\n"); usleep(10000); } }
[此贴子已经被作者于2008-9-21 8:36:34编辑过] |