基于cubietruck的嵌入式系统移植
- 前期准备
PC端:安装ubuntu16.04 LTS;
开发板:Allwinner A20,双核ARM® ACortex™-A7的cubietruck。
首先下载必要工具:
$ apt-get install build-essential libncurses5-dev deboostrap\ u-boot-tools qemu-user-static\
git binfmt-support libusb-1.0-0-dev pkg-config
$ apt-get install gcc-arm-linux-gnueabihf
$ apt-get install gcc-4.9-arm-linux-gnueabihf #本人使用4.9的交叉编译,使用arm-linux-gnueabihf-gcc -v查看版本
2.设置工作目录并下载配置u-boot
$ mkdir ~/cubietruck #工作目录
$ git clone -b sunxi https://github.com/linux-sunxi/u-boot-sunxi.git
$ git branch -a #使用u-boot 2014版本
* remotes/origin/sunxi
sunxi
remotes/origin/HEAD -> origin/mirror/next
...
# git checkout 用于切换git分支
$ cd u-boot-sunxi
$ make distclean CROSS_COMPILE=arm-linux-gnueabihf-
$ make CROSS_COMPILE=arm-linux-gnueabihf- {TARGET}_config #{TARGET} 查找"include/configs/<board_name>.h" cubietruck or
#grep sunxi boards.cfg |awk '{print $7}'
$ make CROSS_COMPILE=arm-linux-gnueabihf-
$ /home/user/dir/sunxi-tools/fex3bin <your_device>.fex script.bin #fex2bin 文件能把 *.fex 文件生成 *.bin 文件<your_device>查看ls device ~/cubieboard/sunxi-boards/sys_config/a20
如果遇到:make CROSS_COMPILE=arm-linux-gnueabihf-
make: /usr/bin/arm-linux-gnueabihf-gcc: Command not found
/bin/sh: 1: /usr/bin/arm-linux-gnueabihf-gcc: not found
添加$PATH的方法#注引用网址:http://blog.chinaunix.net/uid-21161467-id-108114.html
解决:$ ll /usr/bin/arm-linux-gnueabihf-
$ ln -s arm-linux-gnueabihf-gcc-4.9 arm-linux-gnueabihf-gcc
- 内核
wo使用linux-4.9.38内核
$ make ARCH=arm sunxi_defconfig
$ make ARCH=arm menuconfig
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-\
LOADADDR=0x40008000 uImage //dtbs
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- modules
4.nfs和tftp搭建
tftp服务器的搭建:http://blog.csdn.net/tuwenqi2013/article/details/54986056
http://blog.csdn.net/wj2030/article/details/37498493
nfs服务器的搭建:http://linux-sunxi.org/How_to_boot_the_A10_or_A20_over_the_network
/rootos *(rw,sync,no_root_squash)
# mount -t nfs -o nolock 192.168.0.123:/home/allen/nfsrootfs /mnt/
uboot通过nfs无法启动:http://www.cubie.cc/forum.php?mod=viewthread&tid=1418&highlight=u-boot
5. SD卡
umount /dev/sdb1 //注意,ubuntu 系统默认有 TF 插入后会自动 mount,请弹出不要挂载目录,以免无法进行以下操作。
$ dd if=/dev/zero of=/dev/sdb bs=1M count=1 //bs=1024 seek=544 count=128
$ sudo fdisk ${card}
$ sudo mkfs.vfat ${card}${p}1
$ sudo mkfs.ext4 ${card}${p}2
$ sudo dd if=u-boot-sunxi-with-spl.bin of=/dev/sdb bs=1024 seek=8
6.rootfs
$ cp $WORK_DIR/linux-sunxi/arch/arm/boot/uImage boot/
$ make -C $WORK_DIR/linux-sunxi INSTALL_MOD_PATH=`pwd`\
ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-\
modules_install