Ubuntu16.04编译roc-rk3328-cc

安装以下包:

sudo apt-get install bc bison build-essential curl \
     device-tree-compiler dosfstools flex gcc-aarch64-linux-gnu \
     gcc-arm-linux-gnueabihf gdisk git gnupg gperf libc6-dev \
     libncurses5-dev libpython-dev libssl-dev libssl1.0.0 \
     lzop mtools parted repo swig tar zip

创建工程目录:

mkdir ~/proj/roc-rk3328-cc
cd ~/proj/roc-rk3328-cc

下载 Linux SDK:

# U-Boot
git clone -b roc-rk3328-cc https://github.com/FireflyTeam/u-boot
# Kernel
git clone -b roc-rk3328-cc https://github.com/FireflyTeam/kernel --depth=1
# Build
git clone -b debian https://github.com/FireflyTeam/build
# Rkbin
git clone -b master https://github.com/FireflyTeam/rkbin

开发板编译配置在:

build/board_configs.sh

编译 U-Boot:

./build/mk-uboot.sh roc-rk3328-cc

输出:

out/u-boot/
├── idbloader.img
├── rk3328_loader_ddr786_v1.06.243.bin
├── trust.img
└── uboot.img

编译 kernel:

./build/mk-kernel.sh roc-rk3328-cc

输出:

out/
├── boot.img
└── kernel
    ├── Image
    └── rk3328-roc-cc.dtb

自定义内核配置和更新默认配置:

# 这非常重要!
export ARCH=arm64
cd kernel
# 首先使用默认配置
make fireflyrk3328_linux_defconfig
# 自定义你的 kernel 配置
make menuconfig
# 保存为默认配置
make savedefconfig
cp defconfig arch/arm64/configs/fireflyrk3328_linux_defconfig

编译Ubuntu根文件系统
安装依赖包:

sudo apt-get install qemu qemu-user-static binfmt-support debootstrap

下载 Ubuntu core:

wget -c http://cdimage.ubuntu.com/ubuntu-base/releases/16.04.1/release/ubuntu-base-16.04.1-base-arm64.tar.gz

创建一个大小为 1000M 的根文件系统映像文件,并使用 Ubuntu 的基础包去初始化:

fallocate -l 1000M rootfs.img
sudo mkfs.ext4 -F -L ROOTFS rootfs.img
mkdir mnt
sudo mount rootfs.img mnt
sudo tar -xzvf ubuntu-base-16.04.1-base-arm64.tar.gz -C mnt/
sudo cp -a /usr/bin/qemu-aarch64-static mnt/usr/bin/

Chroot 到新的文件系统中去并初始化:(可先不修改本快内容)

sudo chroot mnt/
# 这里可以修改设置
USER=firefly
HOST=firefly
# 创建用户
useradd -G sudo -m -s /bin/bash $USER
passwd $USER
# 输入密码

# 设置主机名和以太网
echo $HOST > /etc/hostname
echo "127.0.0.1    localhost.localdomain localhost" > /etc/hosts
echo "127.0.0.1    $HOST" >> /etc/hosts
echo "auto eth0" > /etc/network/interfaces.d/eth0
echo "iface eth0 inet dhcp" >> /etc/network/interfaces.d/eth0
echo "nameserver 127.0.1.1" > /etc/resolv.conf
# 使能串口
ln -s /lib/systemd/system/serial-getty\@.service /etc/systemd/system/getty.target.wants/[email protected]
# 安装包
apt-get update
apt-get upgrade
apt-get install ifupdown net-tools network-manager
apt-get install udev sudo ssh
apt-get install vim-tiny

卸载文件系统:

sudo umount rootfs/

打包原始固件
目录将包含以下文件:

$ tree out
out
├── boot.img
├── kernel
│   ├── Image
│   └── rk3328-roc-cc.dtb
├── rootfs.img
└── u-boot
    ├── idbloader.img
    ├── rk3328_loader_ddr786_v1.06.243.bin
    ├── trust.img
    └── uboot.img

打包原始固件:

./build/mk-image.sh -c rk3328 -t system -r out/rootfs.img

最终打包成 out/system.img

参考文档:http://wiki.t-firefly.com/zh_CN/ROC-RK3328-CC/intro.html

你可能感兴趣的:(Ubuntu16.04编译roc-rk3328-cc)