我对flash循环写,循环写第一条成功后,i>1后写操作失败。循环还未结束程序就卡死了!请问这个是什么原因导致的?如何解决呢?
//擦除x选中整块flash ioctl(test_file, FLASH_IOCTL_ENABLE_SECTOR_CACHE, NULL); /*Unprotecting the the FLASH might be required */ ioctl(test_file, FLASH_IOCTL_WRITE_PROTECT, NULL); /*Move STRING_SIZE Bytes back */ fseek(test_file, -100*1024, IO_SEEK_END); //初始化flash数值 len= write(test_file, "", 100*1024); char buf[10]={0,1,2,3,4,5,6,7,8,9}; for(i=1;i<=20;i++) { /* Enable sector cache */ ioctl(test_file, FLASH_IOCTL_ENABLE_SECTOR_CACHE, NULL); /* Move STRING_SIZE Bytes back */ fseek(test_file, -((i*sizeof(buf))), IO_SEEK_END); /* Unprotecting the the FLASH might be required */ ioctl(test_file, FLASH_IOCTL_WRITE_PROTECT, NULL); //写入索引表 len = write(test_file, buf, sizeof(buf)); //fflush(data_file_file); if (len != sizeof(buf)) { printf("\nwriting to flash. Error code: %d",i,_io_ferror(test_file)); }else{ printf("write success %d ",i); } }
最佳答案
[attach]440507[/attach]
K64的FLASH编程应该是只支持8字节对齐的写入操作,你一次写入10个,第二次应该就不是8字节对齐了,你改为写8字节的倍数试试看
|