Build NanoPi NEO Manual

最近入手了一块友善的NanoPi NEO

全志的H3芯片,512M内存,板载100M网口和USB2.0口,接口齐全。

虽然有官方提供的源码可以折腾,但还是选择从头开始。

  1. 从Linaro下载交叉编译工具
    wget https://releases.linaro.org/components/toolchain/binaries/4.9-2017.01/arm-linux-gnueabihf/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf.tar.xz

  2. 从官网克隆u-boot仓库
    git clone git://git.denx.de/u-boot.git

  3. 从官网下载最新内核
    wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.10.5.tar.xz

  4. 从官网下载ubuntu最小系统
    wget http://cdimage.ubuntu.com/ubuntu-base/releases/16.04/release/ubuntu-base-16.04-core-armhf.tar.gz

  5. 环境变量设置
    #!/bin/bash
    export PATH=/opt/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/bin:$PATH
    export ARCH=arm
    export CROSS_COMPILE=arm-linux-gnueabihf-

  6. 编译u-boot
    make nanopi_neo_defconfig
    make -j8
    成果物:u-boot-sunxi-with-spl.bin

  7. 编译内核
    make sunxi_defconfig
    make zImage dtbs modules -j8
    成果物:arch/arm/boot/zImage arch/arm/boot/dts/dts/sun8i-h3-nanopi-neo.dtb

  8. 准备TF卡
    分区:MBR+64M FAT BOOT+REMAIN XG ROOT+1G SWAP

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

  1. 准备BOOT分区

boot.cmd
setenv bootargs console=ttyS0,115200 root=/dev/mmcblk0p2 rootwait panic=10
load mmc 0:1 0x43000000 ${fdtfile} || load mmc 0:1 0x43000000 boot/${fdtfile}
load mmc 0:1 0x42000000 uImage || load mmc 0:1 0x42000000 boot/uImage
bootm 0x42000000 - 0x43000000

boot.csr
mkimage -A arm -O linux -T script -C none -n uboot -d boot.cmd boot.scr
script.bin
fex2bin nanopi_neo.fex script.bin
uImage

mkimage -A arm -O linux -T kernel -C none -a 0x40008000 -e 0x40008000 -n linux-4.10.4-image -d zImage uImage

Ram disk还没有弄好
load mmc 0:1 0x42000000 uImage || load mmc 0:1 0x42000000 boot/uImage
mkimage -A arm -O linux -T ramdisk -C none -a 0x48000000 -e 0x48000000 -n linux-4.10.4-initrd -d initrd.img uInitrd

  1. 文件系统

解压Ubuntu core到TF卡ROOT分区
sudo cp -a /usr/bin/qemu-arm-static rootfs/usr/bin/
sudo chroot rootfs/
passwd root
ln -s /lib/systemd/system/serial-getty\@.service /etc/systemd/system/getty.target.wants/serial-getty@ttyS0.service
apt install ifupdown net-tools
apt install udev

  1. 网络
    下载sun8i-emac patch
    dts添加:

    &emac {
    phy-handle = <&int_mii_phy>;
    phy-mode = "mii";
    allwinner,leds-active-low;
    status = "okay";
    };

  2. 移动硬盘
    内核编译+USB MASS Storage支持

最后贴上fex文件和网卡patch:
https://ocean.kevin125.com/cloud/index.php/s/sd7vPfd2sotuXxC