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
这家伙很懒,什么也没写!

搞定了,通过读写返回号判断哪里出了问题

撰写答案

请登录后再发布答案,点击登录

发布
问题

分享
好友

手机
浏览

扫码手机浏览