一、获取源码
repo工具获取sdk
book@100ask:~$ git clone https://git.dev.tencent.com/codebug8/repo.git
book@100ask:~$ mkdir -p 100ask_firefly-rk3288 && cd 100ask_firefly-rk3288
book@100ask:~/100ask_firefly-rk3288$ ../repo/repo init -u https://dev.tencent.com/u/weidongshan/p/manifests/git -b linux-sdk -m rk3288/firefly-rk3288_linux_release.xml --no-repo-verify
book@100ask:~/100ask_firefly-rk3288$ ../repo/repo sync -j4
二、设置工具链
永久生效
如需永久修改,请修改用户配置文件, Ubuntu系统下,修改如下:
vim ~/.bashrc
在行尾添加或修改:
export ARCH=arm
export CROSS_COMPILE=arm-linux-gnueabihf-
export PATH=$PATH:/home/book/100ask_firefly-rk3288/ToolChain/gcc-linaro-6.2.1-2016.11-x86_64_arm-linux-gnueabihf/bin
三、编译uboot
准备工作
安装TFTP NFS服务请参考 Ubuntu环境配置,设置如下参数让系统通过网络挂载方式启动,方便调试。
其中TFTP目录假设为 /home/book/tftpboot NFS目录假设为 /home/book/nfs_rootfs
注意:以下操作会破坏SD卡的数据,请先进行备份。
编译Firefly-rk3288开发板uboot命令
book@100ask:~$ cd ~/100ask_firefly-rk3288/uboot2017.09
book@100ask: ~/100ask_firefly-rk3288/uboot2017.09 $ make distclean
book@100ask: ~/100ask_firefly-rk3288/uboot2017.09 $ make 100ask_firefly-rk3288_defconfig
book@100ask: ~/100ask_firefly-rk3288/uboot2017.09 $ make
book@100ask: ~/100ask_firefly-rk3288/uboot2017.09 $ ./make.sh trust
book@100ask: ~/100ask_firefly-rk3288/uboot2017.09 $ ./make.sh uboot
book@100ask: ~/100ask_firefly-rk3288/uboot2017.09 $ ./make.sh loader
四、编译linux kernel
准备工作
安装TFTP NFS服务请参考 Ubuntu环境配置,设置如下参数让系统通过网络挂载方式启动,方便调试。
其中TFTP目录假设为 /home/book/tftpboot NFS目录假设为 /home/book/nfs_rootfs
编译Firefly-rk3288开发板内核
book@100ask:~/100ask_firefly-rk3288$ cd linux-kernel
book@100ask:~/100ask_firefly-rk3288/linux-4.4$ make mrproper
book@100ask:~/100ask_firefly-rk3288/linux-4.4$ make 100ask_firefly-rk3288_defconfig
book@100ask:~/100ask_firefly-rk3288/linux-4.4$ make zImage
book@100ask:~/100ask_firefly-rk3288/linux-4.4$ make dtbs
编译内核模块
book@100ask:~/100ask_firefly-rk3288/linux-4.4$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- modules
安装内核模块到nfs根文件系统
book@100ask:~/100ask_firefly-rk3288/linux-4.4$ sudo make ARCH=arm INSTALL_MOD_PATH=/media/rootfs modules_install
uboot通过tftp方式下载内核
将编译成功的zImage文件和设备树rk3288-firefly.dtb文件,拷贝到ubuntu的/home/book/tftpboot 目录下,
用以uboot通过tftp 方式进行下载并启动系统。
编译根文件系统
准备工作
安装TFTP NFS服务请参考 Ubuntu环境配置,设置如下参数让系统通过网络挂载方式启动,方便调试。
其中TFTP目录假设为 /home/book/tftpboot NFS目录假设为 /home/book/nfs_rootfs
文件系统特征
配置文件 含义
100ask_firefly-rk3288_defconfig 文件系统版本(再默认版本支持了qt)
编译步骤
book@100ask:~/100ask_firefly-rk3288$ cd buildroot2018.02
book@100ask:~/100ask_firefly-rk3288/buildroot2018.02$ make clean
book@100ask:~/100ask_firefly-rk3288/buildroot2018.02$ make 100ask_firefly-rk3288_defconfig
book@100ask:~/100ask_firefly-rk3288/buildroot2018.02$ make menuconfig
book@100ask:~/100ask_firefly-rk3288/buildroot2018.02$ make all
注意:机器性能不同,编译时间不同。性能差的电脑,有可能需要等待1 ~ 2个小时。
编译后生成文件介绍
buildroot2018.02
├── output
├── images
├── idbloader.img <--u-boot镜像
├── nfs_rootfs <--打包并压缩的根文件系统,适用于NFSROOT启动
│ └── rootfs.tar.gz
├── rk3288-firefly.dtb <--设备树文件
├── rootfs.ext2
├── rootfs.ext4 -> rootfs.ext2 <--ext2格式根文件系统
├── rootfs.tar <--打包后的根文件系统
├── sdcard.img <--完整的SD卡系统镜像
├── trust.img <--u-boot镜像
├── u-boot.bin
├── u-boot-dtb.img
├── uboot.img <--u-boot镜像
└── zImage <--内核镜像
buildroot详细的使用介绍请参考Buildroot
解压文件系统nfs目录
把使用buildroot构建得到的根文件系统nfs_rootfs/rootfs.tar.gz,复制、解压到ubuntu的/etc/exports文件中指定的目录里,即复制到/home/book目录下,得到/home/book/nfs_rootfs下众多文件:
book@100ask:~/100ask_firefly-rk3288/buildroot2018.02/output/images$ cp -rf nfs_rootfs/ ~
book@100ask:~/100ask_firefly-rk3288/buildroot2018.02/output/images$ cd ~/nfs_rootfs
book@100ask:~/nfs_rootfs$ sudo tar -zxvf rootfs.tar.gz
五、启动rk3288开发板
1.按空格键进入uboot命令行,设置ip
=> setenv ipaddr 192.168.1.112
=> setenv serverip 192.168.1.132
=> setenv bootcmd 'tftpboot 0x01f00000 rk3288-firefly.dtb; tftpboot 0x02000000 zImage;bootz 0x02000000 - 0x01f00000'
=> setenv bootargs 'root=/dev/nfs nfsroot=192.168.124.31:/home/book/nfs_rootfs,vers=3 rw ip=dhcp'
=> saveenv
这样就每次都自动下载内核,并挂载nfs文件系统了。
无欲速,无见小利。欲速,则不达;见小利,则大事不成。