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      浏览:14964 | 回复: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
回复

使用道具 举报

428

积分

0

威望

0

贡献

技术达人

Rank: 2

积分
428
发表于 2018-9-21 11:19:48        只看该作者  沙发
{:4_131:}
回复

使用道具 举报

24

积分

0

威望

0

贡献

技术小白

积分
24
发表于 2018-9-30 00:43:25        只看该作者  板凳
能否实现自动扩展根目录呢?
回复

使用道具 举报

54

积分

0

威望

0

贡献

技术小白

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

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

使用道具 举报

31

积分

0

威望

0

贡献

技术小白

积分
31
发表于 2018-10-22 09:49:11        只看该作者  5#

你好, 我的uboot起不来是怎么回事呢?
log显示 DRAM的大小都读取不到?
DDR version 1.06 20170424
In
DDR3
786MHz
Bus Width=32 Col=10 Bank=8 Row=15/15 CS=2 Die Bus-Width=16 Size=2048MB
ddrconfig:6
OUT
Boot1 Release Time: 2017-05-18, version: 2.43
ChipType = 0x11, 125
SdmmcInit=2 0
BootCapSize=2000
UserCapSize=14910MB
FwPartOffset=2000 , 2000
SdmmcInit=0 2
StorageInit ok = 20770
Raw SecureMode = 0
SecureInit read PBA: 0x4
SecureInit read PBA: 0x404
SecureInit read PBA: 0x804
SecureInit read PBA: 0xc04
SecureInit read PBA: 0x1004
SecureInit ret = 0, SecureMode = 0
LoadTrustBL
No find bl30.bin
No find bl32.bin
Load uboot, ReadLba = 2000
Load OK, addr=0x200000, size=0xa7fec
RunBL31 0x10000
NOTICE:  BL31: v1.3(debug):f947c7e
NOTICE:  BL31: Built : 09:28:45, May 31 2017
NOTICE:  BL31:Rockchip release version: v1.3
INFO:    ARM GICv2 driver initialized
INFO:    Using opteed sec cpu_context!
INFO:    boot cpu mask: 1
INFO:    plat_rockchip_pmu_init: pd status 0xe
INFO:    BL31: Initializing runtime services
WARNING: No OPTEE provided by BL2 boot loader, Booting device without OPTEE initialization. SMC`s destined for OPTEE will return SMC_UNK
ERROR:   Error initializing runtime service opteed_fast
INFO:    BL31: Preparing for EL3 exit to normal world
INFO:    Entry point address = 0x200000
INFO:    SPSR = 0x3c9


U-Boot 2017.09-gc58a816-dirty (Oct 19 2018 - 00:39:34 +0800)

Model: Firefly ROC-RK3328-CC
DRAM:  
回复

使用道具 举报

58

积分

0

威望

0

贡献

技术小白

积分
58
发表于 2018-12-19 00:20:45        只看该作者  6#
楼主这个方法您确认是成功的吗?18.04连网络配置方式都不对哦
回复

使用道具 举报

31

积分

0

威望

0

贡献

技术小白

积分
31
发表于 2018-12-23 17:37:20        只看该作者  7#
我按照你这样 系统是烧好了,但是串口无法调试,反复提示输入用户名密码,但是又无法输去

ZFJ login:
Ubuntu 16.04.5 LTS ZFJ ttyFIQ0

ZFJ login:
Ubuntu 16.04.5 LTS ZFJ ttyFIQ0

ZFJ login:
Ubuntu 16.04.5 LTS ZFJ ttyFIQ0

ZFJ login:
Ubuntu 16.04.5 LTS ZFJ ttyFIQ0

ZFJ login:
Ubuntu 16.04.5 LTS ZFJ ttyFIQ0

ZFJ login:
Ubuntu 16.04.5 LTS ZFJ ttyFIQ0

ZFJ login:
Ubuntu 16.04.5 LTS ZFJ ttyFIQ0

ZFJ login:


回复

使用道具 举报

5

积分

0

威望

0

贡献

吃瓜的群众

积分
5
发表于 2018-12-25 09:33:26        只看该作者  8#
回复

使用道具 举报

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

本版积分规则

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