bin檔案燒入flash后再從flash讀出來,發現從32768個int開始與原檔案內容不一致?這是為什么,我在下面的代碼中已經做判斷了,如果不一致那就擦除重新寫入
//now begin write 因為存在寫入flash的程式與原bin檔案不一致的問題,所以在此寫一次后馬上讀一次,看一次讀寫時候相同
write_selector_number = length / WRITE_READ_ONCE_SIZE + 1;//256
int all_selector_write = write_selector_number - 1;
int finally_size = length % WRITE_READ_ONCE_SIZE;
printf("now begin write , write_selector_number = %d\n", write_selector_number);
int tempa_write, tempb_write, tempc_write, tempd_write = 0, write_times = 0;
for(int i = 0; i < write_selector_number; i++){
tempa_write = i / 65536; //65536 = 256 * 256
tempb_write = (i % 65536) / 256;
tempc_write = (i % 65536) % 256;
if(i < all_selector_write){
//寫完一次后緊跟著讀,并且判斷該次的讀寫256個字符是否一致,如果不一致,那就重復寫讀五遍,若五遍還不一致直接退出
for(int j = 0; j < 5; j++){
write_spiflash(fd, filebuf, i * 256, tempa_write, tempb_write, tempc_write, tempd_write);
read_spiflash(fd, tempa_write, tempb_write, tempc_write, tempd_write);
if(!isWriteReadEqual(filebuf, i * 256))
{
printf("the %dth selector %dth time write read not equal\n", i, j);
dis_array("bin源檔案內容:", filebuf + i * 256, 256);
dis_array("flash程式內容:", buf, 256);
//先擦除然后再次寫讀比較
selector_erase(fd, tempa_write, tempb_write, tempc_write, tempd_write);
}
//若相等,直接退出本次回圈,進行下一個selector的寫讀比較
else
{
printf("the %dth selector %dth time write read equal\n", i, j);
dis_array("bin源檔案內容:", filebuf + i * 256, 256);
dis_array("flash程式內容:", buf, 256);
break;
}
}
}else{
write_spiflash_finally(fd, filebuf, i * 256, finally_size, tempa_write, tempb_write, tempc_write, tempd_write);
}
write_times++;
}
printf("writed done, write_times = %d\n", write_times);
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/94639.html
標籤:驅動程序開發區
上一篇:opencv移植 報.so cannot open shared object file
下一篇:前輩們,怎么查看linux系統平臺的設備為什么在一個時間段內,突然之間有一個兩秒的間隔,就是有兩條log資訊,這兩條log資訊是緊挨著輸出的
