从 运行 linux 系统替换 sama5d3 上的引导加载程序

Replace bootloader on sama5d3 from the running linux system

我想在基于 sama5d36 的系统上替换 nand 闪存中的第一阶段引导加载程序 运行 4.1.0-linux4sam_5.1buildroot-2016.02.

我可以用 flashcp 替换内核映像就好了,但是当我用引导加载程序尝试它时, flashcp 运行没有错误,但是系统之后没有启动,停留在ROMBOOT提示。

buildroot:~# flashcp -v at91bootstrap.bin /dev/mtd0
Erasing block: 1/1 (100%) 
Writing kb: 14/14 (100%) 
Verifying kb: 14/14 (100%) 
buildroot:~# reboot
[...]
Sent SIGKILL to all processes
Requesting system reboot
�RomBOOTRestarting system

那我写一个和sam-ba一样的bootloader镜像就可以开机了,镜像还是不错的。如何在没有用户干预的情况下在 Linux 中闪烁?

flash 开头的实际引导代码之前应该有一个 208 字节 header。

来自 SAMA5D3 数据表(我应该在发布问题之前阅读)

After Initialization and Reset command, the Boot Program reads the first page without an ECC check, to determine if the NAND parameter header is present. The header is made of 52 times the same 32-bit word (for redundancy reasons) which must contain NAND and PMECC parameters used to correctly perform the read of the rest of the data in the NAND.

当我转储引导扇区的内容时,header当然在那里

buildroot:~# hd < /dev/mtd0 | head -4
00000000  05 24 90 c0 05 24 90 c0  05 24 90 c0 05 24 90 c0  |.$...$...$...$..|
*
000000d0  0e 00 00 ea 05 00 00 ea  05 00 00 ea 05 00 00 ea  |................|
000000e0  05 00 00 ea cc 3b 00 00  06 00 00 ea 06 00 00 ea  |.....;..........|

前四个字节一遍遍重复,ARM跳转table从偏移量0xD0(=208=52 * 4)

开始

sam-ba 在写入引导扇区时会处理此 header,但是 Linux mtd driver 和flashcp 把它当作普通数据,所以我应该提供它。