Firefly开源社区

打印 上一主题 下一主题

[Linux] 构建ROC-RK3328-CC固件(Ubuntu 18.04.1)

54

积分

0

威望

0

贡献

技术小白

积分
54

构建ROC-RK3328-CC固件(Ubuntu 18.04.1)

发表于 2018-9-17 00:33:39      浏览:15370 | 回复:7        打印     [复制链接] 楼主
本帖最后由 topillar 于 2019-10-25 10:42 编辑

8G存储卡
Ubuntu 18.04.1 LTS
VMWARE + WINDOWS10

一、 安装编译包:

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

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

二、下载 Linux SDK

# create project dir
mkdir ~/roc-rk3328-cc
cd ~/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
# Build
git clone -b debian https://github.com/FireflyTeam/build
# Rkbin
git clone -b master https://github.com/FireflyTeam/rkbin


三、编译 U-Boot
(1)编译 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
• rk3328_loader_ddr786_v1.06.243.bin: DDR 初始化文件。
• idbloader.img: DDR 初始化与 miniloader 结合的文件。
• trust.img: ARM trusted 固件。
• uboot.img: U-Boot映像文件。
(2)相关文件:
• configs/roc-rk3328-cc_defconfig: 默认 U-Boot 配置
四、编译 Kernel
(1)自定义内核配置和更新默认配置:(不执行这一步编译内核会出错)
# 这非常重要!
export ARCH=arm64
cd kernel
# 首先使用默认配置
make fireflyrk3328_linux_defconfig
# 自定义你的 kernel 配置
make menuconfig
   特别说明:
Device Drivers > Network device support > Wireless LAN > Rockchip Wireless LAN support
   > Rockchip Wireless LAN support  下的除“*”其他都去掉


evice Drivers > Network device support > Wireless LAN > Realtek rtlwifi family of devices
  > Realtek rtlwifi family of devices 下的都去掉

# 保存为默认配置
make savedefconfig
cp defconfig arch/arm64/configs/fireflyrk3328_linux_defconfig

(2)编译 kernel:
./build/mk-kernel.sh roc-rk3328-cc
输出:
out/
├── boot.img
└── kernel
    ├── Image
    └── rk3328-roc-cc.dtb
• boot.img: 包含 Image and rk3328-roc-cc.dtb 的映像文件, 为 fat32 文件系统格式。
• Image: 内核映像。
• rk3328-roc-cc.dtb: 设备树 blob。
(3)相关文件:
• arch/arm64/configs/fireflyrk3328_linux_defconfig: 默认内核配置。
• arch/arm64/boot/dts/rockchip/rk3328-roc-cc.dts: 开发板设备树描述。
• arch/arm64/boot/dts/rockchip/rk3328.dtsi: CPU 设备树描述。

五、编译根文件系统
(1)下载Ubuntu root 包
wget -c https://mirrors.tuna.tsinghua.ed ... 1-base-arm64.tar.gz
(2)创建一个大小为 1000M 的根文件系统映像文件(可以根据需要调整大小),并使用 Ubuntu 的基础包去初始化:
dd if=/dev/zero of=rootfs.img bs=1M count=0 seek=1000      注:官方的fallocate法不好使
sudo mkfs.ext4 -F -L ROOTFS rootfs.img
mkdir mnt
sudo mount rootfs.img mnt
sudo tar -xzvf ubuntu-base-18.04.1-base-arm64.tar.gz -C mnt/
sudo cp -a /usr/bin/qemu-aarch64-static mnt/usr/bin/
注:qemu-aarch64-static是其中的关键,能在 x86_64 主机系统下 chroot 到 arm64 文件系统
(3)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 $HOST" >> /etc/hosts
echo "127.0.0.1 localhost.localdomain localhost" > /etc/hosts
echo "a.b.c.d  proxy">>  /etc/hosts  注:有代理的需要在这里处理下
mkdir /etc/network
mkdir /etc/network/interfaces.d  注:这两行是官方没有的,需要加上
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
echo "nameserver 8.8.8.8 " >> /etc/resolv.conf  注:需要加域名解析,否则无法执行后面的操作


# 安装包
apt-get update
apt-get upgrade
apt-get install ifupdown net-tools network-manager
apt-get install udev sudo ssh
apt-get install nano

dpkg --add-architecture armhf 注:增加 armhf支持,稍后测试过,但未在此处测试,待验证
apt-get update
apt-get install libc6:armhf

# 使能串口  注:与官方指南不同,这步到这里才行得通
ln -s /lib/systemd/system/serial-getty\@.service /etc/systemd/system/getty.target.wants/serial-getty@ttyS0.service
exit  注:官方没写出来
sudo sync
# <enter user password>
sudo umount mnt/

六、打包原始固件
把你的 Linux 根文件系统映像文件放在 out/rootfs.img
mv rootfs.img out/
out 目录将包含以下文件:
$ 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
2 directories, 8 files
打包原始固件:
./build/mk-image.sh -c rk3328 -t system -r out/rootfs.img
这条命令根据《存储映射》所描述的布局,将分区映像文件写到指定位置,最终打包成 out/system.img,
七、烧写原始固件
    参考官方方法使用SDCard Installer烧写。
    烧写完成后使用Live版GParted调整一下分区

八、享用roc-rk3328-cc
     推荐体验seafiel、frp等。

https://www.jianshu.com/p/9c629fdd2566
回复

使用道具 举报

54

积分

0

威望

0

贡献

技术小白

积分
54
发表于 2018-10-11 11:06:30      沙发
我没掌握自动调整的技术。所以
“烧写完成后使用Live版GParted调整一下分区”

个人觉得可控度更高。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

友情链接 : 爱板网 电子发烧友论坛 云汉电子社区 粤ICP备14022046号-2
快速回复 返回顶部 返回列表