# LicheePiZero启动镜像 **Repository Path**: sin_-team/lichee-pi-zero-start-image ## Basic Information - **Project Name**: LicheePiZero启动镜像 - **Description**: LicheePiZero启动镜像,包含uboot.bin,设备树(dtb),zImage和rootfs - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 3 - **Forks**: 1 - **Created**: 2021-02-01 - **Last Updated**: 2022-08-02 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # LicheePiZero启动镜像 ### 介绍 LicheePiZero启动镜像,包含uboot.bin,设备树(dtb),zImage和rootfs ### u-boot 获取u-boot源码 ``` git clone https://github.com/Lichee-Pi/u-boot.git -b v3s-current ``` 修改 include/configs/sun8i.h, 使u-boot可以直接从tf卡启动 ``` #define CONFIG_BOOTCOMMAND "setenv bootm_boot_mode sec; " \ "load mmc 0:1 0x41000000 zImage; " \ "load mmc 0:1 0x41800000 sun8i-v3s-licheepi-zero-dock.dtb; " \ "bootz 0x41000000 - 0x41800000;" #define CONFIG_BOOTARGS "console=ttyS0,115200 panic=5 rootwait root=/dev/mmcblk0p2 earlyprintk rw vt.global_cursor_default=0" ``` 编译 ``` cd u-boot ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make LicheePi_Zero_800x480LCD_defconfig (群主网店5寸屏) ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make LicheePi_Zero_480x272LCD_defconfig (通用4.3寸屏) ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make LicheePi_Zero_defconfig (默认) ARCH=arm make menuconfig ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make ``` ### Linux内核 安装交叉编译器 ``` wget https://releases.linaro.org/components/toolchain/binaries/latest/arm-linux-gnueabihf/gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf.tar.xz tar xvf gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf.tar.xz mv gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf /opt/ vim /etc/bash.bashrc # 添加: PATH="$PATH:/opt/gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf/bin" arm-linux-gnueabihf-gcc -v ``` 下载编译linux源码 ``` git clone https://github.com/Lichee-Pi/linux.git -b zero-4.14.y cd linux make ARCH=arm licheepi_zero_defconfig make ARCH=arm menuconfig #add bluethooth, etc. make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j16 make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j16 INSTALL_MOD_PATH=out modules make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j16 INSTALL_MOD_PATH=out modules_install ``` ### Debian 准备工作: ``` sudo apt install qemu-user-static -y sudo apt install debootstrap -y sudo su mkdir rootfs ``` debootstrap ``` debootstrap --foreign --verbose --arch=armhf stretch rootfs http://ftp2.cn.debian.org/debian ``` 挂载 ``` cd rootfs mount --bind /dev dev/ mount --bind /sys sys/ mount --bind /proc proc/ mount --bind /dev/pts dev/pts/ cd .. ``` ``` cp /usr/bin/qemu-arm-static rootfs/usr/bin/ chmod +x rootfs/usr/bin/qemu-arm-static ``` 解压 ``` LC_ALL=C LANGUAGE=C LANG=C chroot rootfs /debootstrap/debootstrap --second-stage --verbose ``` 在rootfs/lib文件夹下放入r8723bs.ko文件 在rootfs/lib/firmware/rtlwifi文件夹(新建一个)下放入rtl8723bs_nic.bin文件 安装东西 ``` LC_ALL=C LANGUAGE=C LANG=C chroot rootfs apt install net-tools apt install udhcpc sudo apt-get install wpasupplicant ``` ``` passwd #设置root密码 exit rm rootfs/usr/bin/qemu-arm-static umount dev/pts/ umount dev/ umount proc/ umount sys/ ``` 在rootfs下面 运行`tar cvzf ../debian9.9.rootfs.gz .`可以生成包 解压到文件系统`sudo tar -xzvf debian9.9.rootfs.gz` ### 烧录 使用Gparted对SD卡进行分区 进入软件后先在右上角选择SD卡,进入后默认是Ubuntu系统的分区。 ![choose sd](https://gitee.com/sin_-team/lichee-pi-zero-start-image/raw/master/images/choose_sd.png) 卸载并删除SD卡所有分区,并新建两个分区 建立第一个分区,大小32M,格式fat16,命名kernel ![choose sd](https://gitee.com/sin_-team/lichee-pi-zero-start-image/raw/master/images/partition1.png) 建立第二个分区,用尽剩余空间,格式ext4,命名rootfs ![choose sd](https://gitee.com/sin_-team/lichee-pi-zero-start-image/raw/master/images/partition2.png) 建好后如下 ![choose sd](https://gitee.com/sin_-team/lichee-pi-zero-start-image/raw/master/images/finish.png) `sudo fdisk -l`查看设备 ![choose sd](https://gitee.com/sin_-team/lichee-pi-zero-start-image/raw/master/images/dev.png) 将uboot写入到SD卡8k偏移处(必须8K偏移) cd ./u-boot sudo dd if=u-boot-sunxi-with-spl.bin of=/dev/sdb bs=1024 seek=8 #先确认盘符是否为sdb 复制kernel和根文件系统 把zImage, sun8i-v3s-licheepi-zero-dock.dtb拷贝到第一个分区 cp linux/arch/arm/boot/zImage /media/bk/KERNAL cp linux/arch/arm/boot/dts/sun8i-v3s-licheepi-zero-dock.dtb /media/bk/KERNAL 注意:一定要用cp指令进行拷贝,千万别图省事就直接在桌面系统下直接进行复制粘贴操作。 把根文件系统解压到第二个分区 sudo tar -xzvf debian9.9.rootfs.gz -C /media/bk/rootfs