测试代码如下:
const uint32_t test_buf=0x30000-0x1000;
uint32_t *p;
printf("Erase...n");
FLASH_ROM_ERASE(test_buf, 4096);
p=(uint32_t*)test_buf;
printf("%8X,",*p); p++;
printf("%8X,",*p); p++;
printf("%8X,",*p); p++;
printf("%8X,",*p); p++;
printf("%8X,",*p); p++;
printf("%8X,",*p); p++;
printf("%8X,",*p); p++;
printf("%8X,",*p); p++;
printf("n");
p=(uint32_t*)test_buf;
printf("write:n");
p=(uint32_t*)test_buf;
dat=1;FLASH_ROM_WRITE((uint32_t)p,&dat,4);p++;
dat=2;FLASH_ROM_WRITE((uint32_t)p,&dat,4);p++;
dat=4;FLASH_ROM_WRITE((uint32_t)p,&dat,4);p++;
dat=8;FLASH_ROM_WRITE((uint32_t)p,&dat,4);p++;
dat=0x10;FLASH_ROM_WRITE((uint32_t)p,&dat,4);p++;
p=(uint32_t*)test_buf;
printf("%8X,",*p); p++;
printf("%8X,",*p); p++;
printf("%8X,",*p); p++;
printf("%8X,",*p); p++;
printf("%8X,",*p); p++;
printf("%8X,",*p); p++;
printf("%8X,",*p); p++;
printf("%8X,",*p); p++;
printf("n");
printf("write2:n");
p=(uint32_t*)test_buf;
dat=2;FLASH_ROM_WRITE((uint32_t)p,&dat,4);p++;
dat=4;FLASH_ROM_WRITE((uint32_t)p,&dat,4);p++;
dat=8;FLASH_ROM_WRITE((uint32_t)p,&dat,4);p++;
dat=0x10;FLASH_ROM_WRITE((uint32_t)p,&dat,4);p++;
dat=0x20;FLASH_ROM_WRITE((uint32_t)p,&dat,4);p++;
p=(uint32_t*)test_buf;
printf("%8X,",*p); p++;
printf("%8X,",*p); p++;
printf("%8X,",*p); p++;
printf("%8X,",*p); p++;
printf("%8X,",*p); p++;
printf("%8X,",*p); p++;
printf("%8X,",*p); p++;
printf("%8X,",*p); p++;
printf("n");
结果打印:
Erase...
F5F9BDA9,F5F9BDA9,F5F9BDA9,F5F9BDA9,F5F9BDA9,F5F9BDA9,F5F9BDA9,F5F9BDA9,
write:
1, 2, 4, 8, 10,F5F9BDA9,F5F9BDA9,F5F9BDA9,
write2:
2, 4, 8, 10, 20,F5F9BDA9,F5F9BDA9,F5F9BDA9,
为什么flash擦除后读取到的不是0xffffffff而是F5F9BDA9 ?烧录EVT的示例代码也是这个结果,反而EEPROM_READ操作可以读到0xFFFFFFFF。
连续两次写入相同地址后,并没有相与的效果,貌似做了擦除后重新写入的,这样每写一个字节就扇区擦除一次是否会缩短寿命?
2022-7-27 09:50:11
因为Flash是加扰的,只擦以后,flash实际是0xffffffff,但是经过内核加扰读出来是0xF5F9BDA9,目的是为了防止flash内容被简单读取。造成固件被盗取。flash可以校验。
dataflash是不加扰的
因为Flash是加扰的,只擦以后,flash实际是0xffffffff,但是经过内核加扰读出来是0xF5F9BDA9,目的是为了防止flash内容被简单读取。造成固件被盗取。flash可以校验。
dataflash是不加扰的
举报