W806內部FLASH讀取問題

發布於 2022-04-17 20:31:19

SDK裡面wm_flash_demo.c自帶的flash程序,燒錄芯片測試錯誤,讀取有問題。
有遇到這個問題的小夥伴嗎,怎麼解決啊

下面是官方代碼

int flash_demo(void)
{
    u8 *write_buf = NULL;
    u8 *read_buf = NULL;
    u16 i;

    tls_fls_init();                                    //initialize flash driver

    write_buf = tls_mem_alloc(TEST_FLASH_BUF_SIZE);
    if (NULL == write_buf)
    {
        printf("\nmalloc write buf error\n");
        return WM_FAILED;
    }

    for (i = 0; i < TEST_FLASH_BUF_SIZE; i ++)
    {
        write_buf[i] = i + 1;
    }

    tls_fls_write(0x1F0303, write_buf, 1247);            /**verifying cross sector writing*/
    tls_fls_write(0x1F0303 + 1247, write_buf + 1247, 2571);
    tls_fls_write(0x1F0303 + 1247 + 2571, write_buf + 1247 + 2571, 182);

    read_buf = tls_mem_alloc(TEST_FLASH_BUF_SIZE);
    if (NULL == read_buf)
    {
        printf("\nmalloc read buf error\n");
        tls_mem_free(write_buf);
        return WM_FAILED;
    }
    memset(read_buf, 0, TEST_FLASH_BUF_SIZE);
    tls_fls_read(0x1F0303, read_buf, TEST_FLASH_BUF_SIZE);

    if (0 == memcmp(write_buf, read_buf, TEST_FLASH_BUF_SIZE))
    {
        printf("\nsuccess\n");
    }
    else
    {
        printf("\nfail\n");
    }

    tls_mem_free(write_buf);
    tls_mem_free(read_buf);

    return WM_SUCCESS;
}

查看更多

關注者
0
被浏覽
2.5k
大信
大信 認證專家 2022-04-18
硬件開發,軟件開發,系統開發,工程架構,方案設計

tls_fls_write(0x1F0303, write_buf, 1247); 第一個參數是相對 0x8000000基地址的偏移量,因此你直接放一個在存儲容量範圍內的地址,不和ROM沖突的即可,比如 0x5000.

3 個回答
Mrzhao
Mrzhao 認證專家 2022-04-18
一個嵌入式愛好者。CSDN主頁:https://blog.csdn.net/qq_37280428?spm=1011.2415.3001.5343

請詳細描述你的問題,出現的現象,你做過哪些嘗試,否者別人不是很懂你想表達什麼

zhihang9122
zhihang9122 2022-04-20
這家夥很懶,什麼也沒寫!

搞定了,通過讀寫返回號判斷哪裡出了問題

撰寫答案

請登錄後再發布答案,點擊登錄

發布
問題

分享
好友

手機
浏覽

掃碼手機浏覽