内部flash均衡擦除实现方法

描述

1 参数存储
很多时候我们的产品需要掉电存储一些重要参数,为了延长flash的寿命,我们可以在存储参数时增加均衡擦除处理

2 内部flash
以STM32F103ZET6为例可在ST官网下载文档:PM0075(STM32F10xxx Flash memory microcontrollers)

STM32

FLASH的最小擦除单位是扇区,扇区大小为2K
3 实现均衡擦除
3.1 实现原理
假设存储的起始地址为0x0807F800,存储一个uint32_t类型的数字变量,那么就需要4个字节的空间,我们以8个字节为一个数据帧,有效数据的帧头是55 AA,帧尾是AA 55,那么数据帧有三种状态:
3.1.1 未使用(可写入),
即FF FF FF FF FF FF FF FF
3.1.2 已使用(当前有效数据,只能写0),
假设当前变量值是100,那么数据帧格式就是
55 AA 00 00 00 64 AA 55
3.1.3 不可使用(不能写入),
00 00 00 00 00 00 00 00,当flash被擦除写入数据后,还可以进行写0操作,这个状态就是写入0后的状态
那么整个扇区就变成类似这样了:

STM32

3.2 实现代码
3.2.1 相关数据结构

typedef union
{
    uint64_t data;
    uint8_t buff[8];
}flash_pack_u;


typedef struct
{
    uint32_t flash_start_address;
    uint32_t current_addr;
    uint32_t new_addr;
    uint16_t page_size;
    flash_pack_u buff;
}flasher_t;


typedef union
{
    uint8_t data[4];
    uint32_t data32;
}writer_u;

3.2.2 相关API

uint64_t read_dword_from_flash(uint32_t faddr)
{
    return *(volatile uint64_t*)faddr; 
}


void find_new_entry(flasher_t *p_flash)
{
    int8_t res = 0;

    if (!p_flash)
    {
        return;
    }


    while (p_flash->current_addr < p_flash->flash_start_address+p_flash->page_size)
    {
        p_flash->buff.data = read_dword_from_flash(p_flash->current_addr);


        uint8_t idx = 0;


        if (p_flash->buff.buff[0] == 0xFF)
        {
            p_flash->new_addr = p_flash->current_addr;

            return;
        }
        else
        {
            writer_u get_val = {0};

            rt_memcpy(get_val.data,&p_flash->buff.buff[2],4);
        }

        p_flash->current_addr += 8;
    }

    if(p_flash->current_addr >= p_flash->flash_start_address+p_flash->page_size)
    {
        stm32_flash_erase(p_flash->flash_start_address,CONFIG_FLASH_SECTOR_SIZE);

        p_flash->current_addr = p_flash->flash_start_address;
        p_flash->new_addr = p_flash->flash_start_address;
    }

    return;
}


uint64_t find_used_entry(flasher_t *p_flash)
{
    if (!p_flash)
    {
        return 0;
    }

    rt_base_t level;

    level = rt_hw_interrupt_disable();


    while (p_flash->current_addr < p_flash->flash_start_address+p_flash->page_size)
    {
        p_flash->buff.data = read_dword_from_flash(p_flash->current_addr);

        if ((p_flash->buff.buff[0] == 0x55)
            && (p_flash->buff.buff[1] == 0xAA)
            && (p_flash->buff.buff[6] == 0xAA)
            && (p_flash->buff.buff[7] == 0x55))
        {
            rt_hw_interrupt_enable(level);

            return p_flash->buff.data;
        }

        p_flash->current_addr += 8;
    }

    rt_hw_interrupt_enable(level);

    return 0;
}


void write_dword_to_flash(flasher_t *p_flash,writer_u writer)
{
    if (!p_flash)
    {
        return;
    }


    flash_pack_u data_valid={0};


    data_valid.buff[0] = 0x55;
    data_valid.buff[1] = 0xAA;
    data_valid.buff[2] = writer.data[0];
    data_valid.buff[3] = writer.data[1];
    data_valid.buff[4] = writer.data[2];
    data_valid.buff[5] = writer.data[3];
    data_valid.buff[6] = 0xAA;
    data_valid.buff[7] = 0x55;


    find_new_entry(p_flash);


    if ((p_flash->new_addr-8) >= p_flash->flash_start_address)
    {
        uint8_t temp[8]={0};

        stm32_flash_write((p_flash->new_addr-8),temp,8);
    }


    stm32_flash_write(p_flash->new_addr,data_valid.buff,8);
}

4 测试
4.1 应用代码

#define new_flasher(start_address,page_size){ \\
        start_address,start_address,start_address,page_size,{0} \\
}


volatile flasher_t g_flasher_test = new_flasher(CONFIG_FLASH_ADDRESS_USER_PARAMETERS,CONFIG_FLASH_SECTOR_SIZE);


int cmd_flash_test(int argc, char **argv)
{
    if (4 == argc)
    {
        uint32_t get_type = atoi(argv[1]);


        if (0 == get_type)
        {
            uint32_t get_val = atoi(argv[2]);

            uint32_t get_cnt = atoi(argv[3]);

            writer_u writer;
            writer_u reader;

            uint32_t idx=0;

            rt_kprintf("get_val=%d\\n",get_val);
            rt_kprintf("get_cnt=%d\\n",get_cnt);


            for (idx=0; idx

4.2 测试记录

擦除整个扇区
flash 0
读取整个扇区数据
flash 1 255 0
read_tempbuffer addr[807f800][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f808][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f810][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f818][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f820][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f828][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f830][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f838][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f840][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f848][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f850][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f858][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f860][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f868][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f870][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f878][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f880][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f888][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f890][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f898][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f8a0][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f8a8][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f8b0][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f8b8][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f8c0][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f8c8][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f8d0][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f8d8][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f8e0][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f8e8][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f8f0][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f8f8][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f900][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f908][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f910][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f918][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f920][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f928][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f930][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f938][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f940][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f948][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f950][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f958][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f960][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f968][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f970][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f978][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f980][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f988][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f990][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f998][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f9a0][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f9a8][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f9b0][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f9b8][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f9c0][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f9c8][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f9d0][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f9d8][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f9e0][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f9e8][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f9f0][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807f9f8][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fa00][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fa08][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fa10][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fa18][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fa20][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fa28][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fa30][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fa38][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fa40][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fa48][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fa50][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fa58][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fa60][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fa68][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fa70][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fa78][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fa80][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fa88][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fa90][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fa98][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807faa0][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807faa8][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fab0][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fab8][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fac0][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fac8][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fad0][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fad8][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fae0][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fae8][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807faf0][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807faf8][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fb00][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fb08][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fb10][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fb18][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fb20][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fb28][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fb30][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fb38][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fb40][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fb48][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fb50][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fb58][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fb60][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fb68][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fb70][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fb78][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fb80][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fb88][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fb90][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fb98][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fba0][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fba8][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fbb0][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fbb8][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fbc0][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fbc8][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fbd0][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fbd8][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fbe0][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fbe8][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fbf0][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fbf8][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fc00][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fc08][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fc10][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fc18][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fc20][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fc28][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fc30][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fc38][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fc40][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fc48][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fc50][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fc58][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fc60][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fc68][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fc70][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fc78][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fc80][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fc88][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fc90][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fc98][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fca0][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fca8][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fcb0][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fcb8][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fcc0][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fcc8][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fcd0][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fcd8][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fce0][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fce8][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fcf0][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fcf8][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fd00][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fd08][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fd10][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fd18][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fd20][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fd28][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fd30][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fd38][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fd40][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fd48][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fd50][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fd58][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fd60][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fd68][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fd70][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fd78][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fd80][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fd88][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fd90][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fd98][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fda0][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fda8][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fdb0][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fdb8][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fdc0][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fdc8][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fdd0][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fdd8][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fde0][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fde8][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fdf0][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fdf8][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fe00][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fe08][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fe10][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fe18][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fe20][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fe28][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fe30][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fe38][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fe40][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fe48][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fe50][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fe58][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fe60][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fe68][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fe70][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fe78][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fe80][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fe88][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fe90][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fe98][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fea0][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fea8][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807feb0][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807feb8][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fec0][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fec8][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fed0][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fed8][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fee0][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fee8][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fef0][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fef8][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807ff00][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807ff08][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807ff10][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807ff18][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807ff20][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807ff28][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807ff30][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807ff38][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807ff40][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807ff48][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807ff50][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807ff58][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807ff60][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807ff68][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807ff70][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807ff78][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807ff80][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807ff88][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807ff90][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807ff98][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807ffa0][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807ffa8][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807ffb0][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807ffb8][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807ffc0][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807ffc8][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807ffd0][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807ffd8][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807ffe0][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807ffe8][ff ff ff ff ff ff ff ff ]
read_tempbuffer addr[807fff0][ff ff ff ff ff ff ff ff ]
写入0-2048个数据,从10开始写
flash 0 10 2048 
查看整个扇区的数据
msh />flash 1 255 0
read_tempbuffer addr[807f800][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f808][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f810][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f818][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f820][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f828][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f830][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f838][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f840][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f848][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f850][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f858][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f860][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f868][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f870][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f878][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f880][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f888][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f890][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f898][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f8a0][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f8a8][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f8b0][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f8b8][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f8c0][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f8c8][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f8d0][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f8d8][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f8e0][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f8e8][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f8f0][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f8f8][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f900][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f908][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f910][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f918][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f920][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f928][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f930][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f938][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f940][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f948][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f950][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f958][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f960][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f968][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f970][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f978][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f980][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f988][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f990][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f998][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f9a0][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f9a8][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f9b0][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f9b8][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f9c0][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f9c8][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f9d0][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f9d8][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f9e0][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f9e8][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f9f0][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807f9f8][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fa00][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fa08][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fa10][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fa18][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fa20][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fa28][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fa30][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fa38][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fa40][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fa48][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fa50][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fa58][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fa60][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fa68][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fa70][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fa78][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fa80][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fa88][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fa90][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fa98][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807faa0][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807faa8][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fab0][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fab8][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fac0][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fac8][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fad0][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fad8][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fae0][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fae8][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807faf0][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807faf8][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fb00][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fb08][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fb10][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fb18][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fb20][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fb28][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fb30][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fb38][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fb40][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fb48][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fb50][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fb58][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fb60][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fb68][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fb70][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fb78][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fb80][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fb88][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fb90][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fb98][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fba0][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fba8][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fbb0][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fbb8][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fbc0][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fbc8][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fbd0][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fbd8][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fbe0][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fbe8][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fbf0][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fbf8][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fc00][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fc08][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fc10][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fc18][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fc20][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fc28][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fc30][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fc38][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fc40][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fc48][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fc50][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fc58][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fc60][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fc68][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fc70][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fc78][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fc80][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fc88][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fc90][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fc98][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fca0][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fca8][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fcb0][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fcb8][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fcc0][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fcc8][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fcd0][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fcd8][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fce0][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fce8][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fcf0][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fcf8][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fd00][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fd08][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fd10][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fd18][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fd20][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fd28][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fd30][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fd38][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fd40][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fd48][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fd50][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fd58][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fd60][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fd68][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fd70][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fd78][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fd80][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fd88][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fd90][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fd98][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fda0][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fda8][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fdb0][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fdb8][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fdc0][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fdc8][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fdd0][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fdd8][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fde0][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fde8][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fdf0][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fdf8][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fe00][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fe08][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fe10][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fe18][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fe20][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fe28][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fe30][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fe38][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fe40][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fe48][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fe50][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fe58][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fe60][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fe68][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fe70][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fe78][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fe80][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fe88][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fe90][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fe98][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fea0][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fea8][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807feb0][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807feb8][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fec0][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fec8][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fed0][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fed8][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fee0][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fee8][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fef0][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fef8][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807ff00][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807ff08][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807ff10][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807ff18][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807ff20][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807ff28][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807ff30][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807ff38][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807ff40][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807ff48][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807ff50][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807ff58][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807ff60][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807ff68][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807ff70][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807ff78][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807ff80][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807ff88][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807ff90][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807ff98][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807ffa0][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807ffa8][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807ffb0][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807ffb8][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807ffc0][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807ffc8][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807ffd0][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807ffd8][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807ffe0][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807ffe8][00 00 00 00 00 00 00 00 ]
read_tempbuffer addr[807fff0][55 aa 09 08 00 00 aa 55 ]

5 总结
如果数据量比较大,这种均衡擦除算法就显得比较笨重了,最好是使用ESP8266的键值对的方式来存储参数,并且支持均衡擦除。

打开APP阅读更多精彩内容
声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉

全部0条评论

快来发表一下你的评论吧 !

×
20
完善资料,
赚取积分