我在程序中读写flash,用debug模式可以正确读写flash,当把程序烧入到flash中,然后启动这段程序,运行结过就是读写flash出错,请问这是什么问题? 有谁遇到吗? 我的读写flash的代码如下: #include <stdio.h> #include <sys/alt_flash.h> #include "system.h" #define DATA_OFFSET 0x300000 void main(void) { alt_flash_fd* flash_handle; FILE *uart; char write_data = 0; char read_data = 0; write_data = 100; uart = fopen(UART_0_NAME,"w"); flash_handle = alt_flash_open_dev(CFI_FLASH_0_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); } } 我想这个问题解决了,我读写文件系统的问题就会解决,帮忙分析下啊! |