我正在尝试在U-boot中测试ECC(纠错码)。为此,我想使用U-boot在NAND闪存中翻转一下而不重写CRC。然后,当我重新启动处理器时,我希望看到U-boot使用ECC纠正该位。
问题是如何在不编写新CRC的情况下使用U-boot将新位,字节或页写入内存?
答案 0 :(得分:3)
使用 nand biterr 来模拟在偏移处翻转的位。
例如,第二个块中字节69 [0x45]的第3位= 0x20000
U-Boot> nand biterr 0x20045 3
Erasing at 0x20000 -- 100% complete.
toggling bit 3 in byte 45 in block 20000 00 ->08
byte offset 0x00020045 toggled bit 3
参考:
答案 1 :(得分:2)
从未找到过具有苦味实现的u-boot,源代码通常如下所示:
if (strcmp(cmd, "biterr") == 0) {
/* todo */
return 1;
}
在这种情况下,前进的方式稍微复杂一些。由于我花了一些时间来发现如何做到这一点,我相信其他人可能会对此处描述的手动过程有所帮助。
nand read ${ram_addr1} ${sector_addr} ${sector_size}
nand read.oob ${ram_addr2} ${sector_addr} ${oob_size}
nand erase ${sector_addr} ${sector_size}
nand write ${ram_addr1} ${sector_addr_plus_page_size} ${sector_size_minus_page_size}
cp ${ram_addr2} ${ram_addr1} ${oob_size}
mm ${ram_addr1_plus_biterr_offset}
#modify a single bit of the referred data
nand write.raw ${ram_addr1} ${sector_addr} 1
检查是否收到了bitflip错误消息:
nand read ${ram_addr1} ${sector_addr} ${sector_size}
请注意,您可以将环境设置为按原样运行此命令,或替换原始值的${}
指令。只要ram_addr1
ram_addr2
和ram_addr2 - ram_addr1 > sector_size
可能是任何可用的ram地址
答案 2 :(得分:1)
您可以使用nand read.raw和nand write.raw将写入传递给OOB。
答案 3 :(得分:0)
要简化@ Jonatan-Goebel的答案,只要您只清除位,就可以避免很多步骤,因为这不需要擦除nand。
=> setenv ram_addr1 $loadaddr
=> setenv page_addr 0
=> setenv page_size 1000
# Make sure there is actually something in nand
=> nand erase.chip && mw.b $loadaddr ff 40000 && load mmc 0 $loadaddr MLO && nand write.i $loadaddr $page_addr $filesize
# Read one raw page
=> nand read.raw ${ram_addr1} ${page_addr} 1
# Clear x number of bits
=> mm $ram_addr1
83000000: 00000040 ?
...
83000018: 4e495454 ?
8300001c: 00005347 ?
83000020: ffffffff ? efffffff
83000024: ffffffff ? => <INTERRUPT>
# Write back page
=> nand write.raw ${ram_addr1} ${page_addr} 1
# Read the page
=> nand read ${ram_addr1} ${page_addr} ${page_size}
NAND read: device 0 offset 0x0, size 0x40000
elm_config: 2
nand: bit-flip corrected @data=35
262144 bytes read: OK
请确保您尝试使用太多的位翻转,以确保其失败
...
=> mm $ram_addr1
...
83000020: cccccccc ? 8ccccccc
83000024: ffffffff ? => <INTERRUPT>
=> nand write.raw ${ram_addr1} ${page_addr} 1
NAND write: 4320 bytes written: OK
=> nand read ${ram_addr1} ${page_addr} ${page_size}
NAND read: device 0 offset 0x0, size 0x40000
elm_config: 2
omap-elm: uncorrectable ECC errors
NAND read from offset 0 failed -74
0 bytes read: ERROR