参考:http://zero.lichee.pro/系统开发/SPI_flash_build.html#linux
本文以型号为MX25L12805、MX25L25635F为例,flash大小分别为16M、32M。
首先规划flash分区,规划如下:
分区序号 | 分区大小 | 分区作用 | 地址空间及分区名 |
---|---|---|---|
mtd0 | 1MB | spl+uboot | 0x0000000-0x0100000 : “uboot” |
mtd1 | 64KB | dtb文件 | 0x0100000-0x0110000: “dtb” |
mtd2 | 4MB | 内核 | 0x0110000-0x0510000 : “kernel” |
mtd3 | 剩余 | 根文件系统 | 0x0510000-0x2000000 : “rootfs” |
1、U-Boot编译配置
1.1 准备uboot源码
下载包含spi驱动的体验版本uboot,该驱动目前尚未合并到主线
git clone -b v3s-spi-experimental https://github.com/Lichee-Pi/u-boot.git
如果下载速度较慢的话,可以下载我上传的资源文件:https://download.youkuaiyun.com/download/qq_40860568/11655959
1.2 配置
执行
make ARCH=arm menuconfig
进入uboot 菜单配置,然后进入到Device Drivers > SPI Flash Support
注意看一下自己flash的厂家名称,这里我选上Macronix SPI flash support
,用来支持我测试用的flash:MX25L12805和MX25L25635。
如果使用的是16M以上的Flash,需要勾选SPI flash Bank/Extended address register support
,否则只能读取到16M。
执行gedit include/configs/sun8i.h
在文件include/configs/sun8i.h中添加默认bootcmd和bootargs的环境变量设置,注意添加的位置在“#include