基于荔枝派Lichee Nano(f1c100s)的u-boot移植
说明:在编译过程中,有可能遇到一些报错,大概率是缺少了一些链接库,需要根据对应的错误进行安装。
1.安装交叉编译链
1.新建文件夹:mkdir f1c100s 并进入:cd f1c100s
2.下载编译链:wget https://releases.linaro.org/components/toolchain/binaries/7.2-2017.11/arm-linux-gnueabi/gcc-linaro-7.2.1-2017.11-x86_64_arm-linux-gnueabi.tar.xz
说明:如果有的对应的交叉编译器压缩包,自行拷贝到对应的目录下解压即可。
3.解压 :xz -d file.tar.xz 再次解压: tar -xvf file.tar
4.拷贝到对应的目录下(我这里放到了/usr/local/arm-gcc/,可以根据自己选择路径,等会需要用到)
5.打开.bashrc:vim .bashrc 添加编译链的bin文件路径 ( 类似windows下的添加环境变量 ):
在文件末尾 添加以下内容
PATH="$PATH:/usr/local/arm-gcc/gcc-linaro-7.2.1-2017.11-x86_64_arm-linux-gnueabi/bin/"
然后保存退出,最后更新环境变量:source .bashrc
2.编译 u-boot
1.进入f1c100s目录:cd f1c100s
2.拉取代码,从github上拉取对 Nano 进行了适配的 u-boot(如果没有git请先安装):git clone https://github.com/Lichee-Pi/u-boot.git
3.进入改目录:cd u-boot
4.查看分支:git branch -a
5.切换到 Nano 分支:git checkout nano-v2018.01 (说明:如果有uboot源码包直接解压即可)
3.开始配置uboot相关信息
1.此处告知make采用arm-linux-gnueabi下的所有交叉编译工具,目标架构为Arm,设定各项默认配置为 nano 的spiflash支持版
使用命令:
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- licheepi_nano_spiflash_defconfig
若不带spi-flash的板子,请换成 licheepi_nano_defconfig:
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- licheepi_nano_defconfig
2.进行可视化配置(make menuconfig),可使用命令:make ARCH=arm menuconfig
4.配置uboot传递参数,从nor flash启动内核。
1.需要从flash启动linux修改 include/configs/suniv.h,添加以下内容:(不推荐使用这种方式,看第二种方式)
//============================ 方式一 =================================
#define CONFIG_BOOTCOMMAND "sf probe 0 50000000; " \
"sf read 0x80C00000 0x100000 0x4000; " \
"sf read 0x80008000 0x110000 0x400000; " \
"bootz 0x80008000 - 0x80C00000"
#define CONFIG_BOOTARGS "console=ttyS0,115200 panic=5 rootwait " \
" mtdparts=spi32766.0:1M(uboot),64k(dtb),4M(kernel),-(rootfs) " \
" root=/dev/mtdblock3 rw rootfstype=jffs2 "
//============================ 方式二 =================================
2.使用make ARCH=arm menuconfig进入配置界面:
2.1)添加参数:console=ttyS0,115200 panic=5 rootwait root=/dev/mtdblock3 rw rootfstype=jffs2
[*] Enable boot arguments
(console=ttyS0,115200 panic=5 rootwait root=/dev/mtdblock3 rw rootfstype=jffs2) Boot arguments
2.2)添加参数:console=ttyS0,115200 panic=5 rootwait root=/dev/mtdblock3 rw rootfstype=jffs2
[*] Enable a default value for bootcmd
(sf probe 0 50000000; sf read 0x80C00000 0x100000 0x4000; sf read 0x80008000 0x110000 0x400000; bootz 0x80008000 - 0x80C00000) Boot bootcmd
//==================================================================
5.增加了u-boot对spi flash的识别。
1.修改uboot源码下的:drivers/mtd/spi_spi_flash_ids.c,增加一行内容:
{"xt25f128", INFO(0x0b4018, 0x0, 64*1024, 256, 0)},
6.开始编译
1.使用命令:make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- -j8
2.编译完成后,可一看到目录下多了一堆以u-boot带头的文件,我们只需取 u-boot-sunxi-with-spl.bin 即可
基于荔枝派Lichee Nano(全志f1c100s)的kernel移植(二)
链接: link.(https://blog.youkuaiyun.com/qq_39721016/article/details/123396573)