从0开玩lichee zero-1-uboot篇

·## 准备工作
sudo apt-get install gcc-arm-linux-gnueabihf
sudo apt-get install git
sudo apt-get install Python2

uboot

git clone https://github.com/Lichee-Pi/u-boot.git -b v3s-current

config SD TF

修改u-boot/include/configs/sun8i.h文件 加入:

#define CONFIG_BOOTCOMMAND   "setenv bootm_boot_mode sec; " \
                            "load mmc 0:1 0x41000000 zImage; "  \
                            "load mmc 0:1 0x41800000 sun8i-v3s-licheepi-zero.dtb; " \
                            "bootz 0x41000000 - 0x41800000;"

#define CONFIG_BOOTARGS      "console=ttyS0,115200 panic=5 rootwait root=/dev/mmcblk0p2 earlyprintk rw  vt.global_cursor_default=0"

config spi flash

git clone -b v3s-spi-experimental https://github.com/Lichee-Pi/u-boot.git

配置Flash支持型号

执行 make ARCH=arm menuconfig 打开uboot菜单配置,进入到 Device Drivers ‣ SPI Flash Support

注意看一下自己flash的厂家名称,例如选上Macronix SPI flash support用来支持测试用的flash:MX25L25645G。

如果使用的是16MB以上的flash,需要勾选flash bank支持选项,否则最多只能读到16MB: CONFIG_SPI_FLASH_BAR

spi 分区

这里 使用 MX25L25645G, 32M SPI flash 作为启动介质,规划分区如下:

分区序号 分区大小 分区作用 地址空间及分区名
mtd0 1MB spl+uboot 0x0000000-0x0100000 : "uboot"
mtd1 64KB dtb文件 0x0100000-0x0110000: "dtb"
mtd2 4MB linux内核 0x0110000-0x0510000 : "kernel"
mtd3 剩余 根文件系统 0x0510000-0x2000000 : "rootfs"
 #define CONFIG_BOOTCOMMAND   "sf probe 0; "                           \
                             "sf read 0x41800000 0x100000 0x10000; "  \
                             "sf read 0x41000000 0x110000 0x400000; " \
                             "bootz 0x41000000 - 0x41800000"

 #define CONFIG_BOOTARGS      "console=ttyS0,115200 earlyprintk panic=5 rootwait " \
                             "mtdparts=spi32766.0:1M(uboot)ro,64k(dtb)ro,4M(kernel)ro,-(rootfs) root=31:03 rw rootfstype=jffs2"

make

ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make LicheePi_Zero_defconfig
ARCH=arm make menuconfig
ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make

编译完成后,在当前目录下生成了u-boot-sunxi-with-spl.bin,可以烧录到TF卡8K偏移处启动

注意:对于大于16M的flash,需要在menuconfig中开 CONFIG_SPI_FLASH_BAR

烧录

sd

sudo dd if=u-boot-sunxi-with-spl.bin of=/dev/sdb bs=1024 seek=8

troubleshoot

  1. <command-line>: fatal error: curses.h: No such file or directory
    解决:sudo apt-get install libncurses5-dev libncursesw5-dev

  2. Your dtc is too old, please upgrade to dtc 1.4 or newer
    解决:apt-get install device-tree-compiler

reg :https://licheezero.readthedocs.io/zh/latest/%E7%B3%BB%E7%BB%9F%E5%BC%80%E5%8F%91/SPI_flash_build.html#uboot

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注