!17 【已完成】添加跨架构构建支持

From: @chainsx 
Reviewed-by: @jianminw 
Signed-off-by: @jianminw
This commit is contained in:
openeuler-ci-bot 2025-05-08 09:54:38 +00:00 committed by Gitee
commit 0beb4477f1
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
17 changed files with 111 additions and 21 deletions

View File

@ -45,7 +45,7 @@
>![](public_sys-resources/icon-notice.gif) **须知:** >![](public_sys-resources/icon-notice.gif) **须知:**
>RK3399 当前支持 openEuler 版本20.03 LTS、20.03 LTS SP1、20.03 LTS SP2、20.03 LTS SP3、22.03 LTS SP2 和 22.03 LTS SP3。 >RK3399 当前支持 openEuler 版本20.03 LTS、20.03 LTS SP1、20.03 LTS SP2、20.03 LTS SP3、22.03 LTS SP2 和 22.03 LTS SP3。
>RK3566 当前支持 openEuler 版本24.03 LTS。 >RK3566/RK3568 当前支持 openEuler 版本:22.03 LTS SP2、22.03 LTS SP3 和 24.03 LTS。
>RK3588 当前支持 openEuler 版本22.03 LTS、22.03 LTS SP2 和 22.03 LTS SP3。 >RK3588 当前支持 openEuler 版本22.03 LTS、22.03 LTS SP2 和 22.03 LTS SP3。
>如果构建包含 Xfce/UKUI/DDE 桌面环境的镜像,需要注意三点: >如果构建包含 Xfce/UKUI/DDE 桌面环境的镜像,需要注意三点:
>1. 构建包含 Xfce 桌面环境的镜像,当前只支持 20.03 LTS SP2、20.03 LTS SP3、21.09、22.03 LTS、22.03 LTS SP3、24.03 LTS 版本。 >1. 构建包含 Xfce 桌面环境的镜像,当前只支持 20.03 LTS SP2、20.03 LTS SP3、21.09、22.03 LTS、22.03 LTS SP3、24.03 LTS 版本。
@ -54,7 +54,11 @@
### 准备环境 ### 准备环境
- 操作系统openEuler 、CentOS 8 - 操作系统openEuler 、CentOS 8
- 架构AArch64 ,如树莓派、 RK3399 开发板、 RK3588 开发板 - 架构:
- AArch64如树莓派、 RK3399 开发板、 RK3588 开发板
- X86_64[详细说明](#问题汇总)
**注意: 在`直接构建镜像时所使用的设备的 openEuler 版本``使用 Docker 拉取的 openEuler 版本`需要与待构建的版本相近,例如:构建适用于 RK3588 开发板的 openEuler 22.03 LTS 时可以使用 openEuler 22.03 LTS SP1、openEuler 22.03 LTS SP2、openEuler 22.03 LTS SP3 以及 openEuler 22.03 LTS SP4。**
详细过程参见 [openEuler 镜像的构建](rockchip/openEuler镜像的构建.md)。 详细过程参见 [openEuler 镜像的构建](rockchip/openEuler镜像的构建.md)。
@ -332,3 +336,10 @@
- [使用 Docker 构建镜像(推荐)](rockchip/使用Docker构建镜像.md) - [使用 Docker 构建镜像(推荐)](rockchip/使用Docker构建镜像.md)
- [设置 SELinux](rockchip/设置SELinux.md) - [设置 SELinux](rockchip/设置SELinux.md)
2. 使用 x86_64 的主机进行构建时的注意事项:
- 由于 openEuler x86_64 软件仓库没有交叉编译工具链,在使用 x86_64 进行构建时,需要从 [Firefly 的 Gitlab 仓库](https://gitlab.com/firefly-linux/prebuilts/gcc/linux-x86/aarch64/gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu.git)下载交叉编译工具链,请确保网络状态良好。
- 在使用 x86_64 进行构建时,需要构建主机支持 Qemu-User-Static 的运行条件。目前使用的 Qemu-User-Static 是基于 openEuler 24.03 LTS 预构建的软件包使用其他版本跨架构构建时可能会出现问题。openEuler 软件仓库暂时还没有引进该软件包,目前正在将该软件包添加到 openEuler 软件仓库。

View File

@ -3,6 +3,7 @@ local_uboot_dir=${nonfree_bin_dir}/u-boot/firefly-rk3588
dtb_name=rk3588-firefly-itx-3588j dtb_name=rk3588-firefly-itx-3588j
platform=rockchip platform=rockchip
soc_name=rk3588 soc_name=rk3588
arch=arm64
POST_BOARD_OVERLAY() { POST_BOARD_OVERLAY() {
echo "Put ${board} firmware into rootfs..." echo "Put ${board} firmware into rootfs..."

View File

@ -2,6 +2,7 @@ ubootconfig=firefly-rk3399_defconfig
dtb_name=rk3399-firefly dtb_name=rk3399-firefly
platform=rockchip platform=rockchip
soc_name=rk3399 soc_name=rk3399
arch=arm64
POST_BOARD_OVERLAY() { POST_BOARD_OVERLAY() {
echo "Put ${board} firmware into rootfs..." echo "Put ${board} firmware into rootfs..."

View File

@ -3,6 +3,7 @@ local_uboot_dir=${nonfree_bin_dir}/u-boot/firefly-rk3566
dtb_name=rk3566-roc-pc dtb_name=rk3566-roc-pc
platform=rockchip platform=rockchip
soc_name=rk3566 soc_name=rk3566
arch=arm64
POST_BOARD_OVERLAY() { POST_BOARD_OVERLAY() {
echo "Put ${board} firmware into rootfs..." echo "Put ${board} firmware into rootfs..."

View File

@ -3,6 +3,7 @@ local_uboot_dir=${nonfree_bin_dir}/u-boot/firefly-rk3568
dtb_name=rk3568-roc-pc-se dtb_name=rk3568-roc-pc-se
platform=rockchip platform=rockchip
soc_name=rk3568 soc_name=rk3568
arch=arm64
POST_BOARD_OVERLAY() { POST_BOARD_OVERLAY() {
echo "Put ${board} firmware into rootfs..." echo "Put ${board} firmware into rootfs..."

View File

@ -3,6 +3,7 @@ local_uboot_dir=${nonfree_bin_dir}/u-boot/firefly-rk3588
dtb_name=rk3588s-roc-pc dtb_name=rk3588s-roc-pc
platform=rockchip platform=rockchip
soc_name=rk3588 soc_name=rk3588
arch=arm64
POST_BOARD_OVERLAY() { POST_BOARD_OVERLAY() {
echo "Put ${board} firmware into rootfs..." echo "Put ${board} firmware into rootfs..."

View File

@ -3,6 +3,7 @@ local_uboot_dir=${nonfree_bin_dir}/u-boot/phytiumpi
dtb_name=phytiumpi_firefly dtb_name=phytiumpi_firefly
platform=phytium platform=phytium
soc_name=e2000q soc_name=e2000q
arch=arm64
POST_BOARD_OVERLAY() { POST_BOARD_OVERLAY() {
echo "Put ${board} firmware into rootfs..." echo "Put ${board} firmware into rootfs..."

View File

@ -3,6 +3,7 @@ local_uboot_dir=${nonfree_bin_dir}/u-boot/radxa-rock5b
dtb_name=rk3588-rock-5b dtb_name=rk3588-rock-5b
platform=rockchip platform=rockchip
soc_name=rk3588 soc_name=rk3588
arch=arm64
POST_BOARD_OVERLAY() { POST_BOARD_OVERLAY() {
echo "Put ${board} firmware into rootfs..." echo "Put ${board} firmware into rootfs..."

View File

@ -2,6 +2,7 @@ ubootconfig=rock-pi-4-rk3399_defconfig
dtb_name=rk3399-rock-pi-4a dtb_name=rk3399-rock-pi-4a
platform=rockchip platform=rockchip
soc_name=rk3399 soc_name=rk3399
arch=arm64
POST_BOARD_OVERLAY() { POST_BOARD_OVERLAY() {
echo "Put ${board} firmware into rootfs..." echo "Put ${board} firmware into rootfs..."

View File

@ -2,6 +2,7 @@ ubootconfig=firefly-rk3399_defconfig #Required! The name of defconfig file when
dtb_name=rk3399-firefly #Required! The device tree name of target board, which defaults to rk3399-firefly. dtb_name=rk3399-firefly #Required! The device tree name of target board, which defaults to rk3399-firefly.
platform=rockchip #Required! The platform of target board, which defaults to rockchip. platform=rockchip #Required! The platform of target board, which defaults to rockchip.
soc_name=rk3399 soc_name=rk3399
arch=arm64
POST_BOARD_OVERLAY() { POST_BOARD_OVERLAY() {
echo "Put ${board} firmware into rootfs..." echo "Put ${board} firmware into rootfs..."

View File

@ -66,7 +66,7 @@ kernel_url=$kernel_url
spec_param=$spec_param" > $workdir/.param spec_param=$spec_param" > $workdir/.param
} }
deppkg_install() { oe_deppkg_install() {
dnf makecache dnf makecache
dnf install git wget make gcc bison dtc m4 flex bc openssl-devel tar dosfstools rsync parted dnf-plugins-core tar kpartx diffutils dracut uboot-tools -y dnf install git wget make gcc bison dtc m4 flex bc openssl-devel tar dosfstools rsync parted dnf-plugins-core tar kpartx diffutils dracut uboot-tools -y
} }
@ -133,14 +133,14 @@ LOG(){
echo `date` - INFO, $* | tee -a ${log_dir}/${builddate}.log echo `date` - INFO, $* | tee -a ${log_dir}/${builddate}.log
} }
cur_dir=$(cd $(dirname $0);pwd) source ${cur_dir}/boards/${board}.conf
default_param default_param
parseargs "$@" || help $? parseargs "$@" || help $?
LOG "Selected board: ${board}." LOG "Selected board: ${board}."
source ${cur_dir}/boards/${board}.conf cur_dir=$(cd $(dirname $0);pwd)
LOG "Board config: ${board}." LOG "Board config: ${board}."
LOG "U-Boot config: ${ubootconfig}." LOG "U-Boot config: ${ubootconfig}."
@ -151,6 +151,12 @@ used_param
if [ ! -d $workdir ]; then if [ ! -d $workdir ]; then
mkdir $workdir mkdir $workdir
fi fi
# Firefly Toolchain Repo
aarch64_toolchain_bin_repo="https://gitlab.com/firefly-linux/prebuilts/gcc/linux-x86/aarch64/gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu.git"
host_arch=$(arch)
save_param save_param
log_dir=${workdir}/log log_dir=${workdir}/log
if [ ! -d ${log_dir} ];then mkdir -p ${log_dir}; fi if [ ! -d ${log_dir} ];then mkdir -p ${log_dir}; fi
@ -165,20 +171,32 @@ if [ -f $workdir/.done ];then
touch $workdir/.done touch $workdir/.done
fi fi
else else
deppkg_install oe_deppkg_install
if [[ "${host_arch}" == "x86_64" && "${arch}" == "arm64" ]];then
LOG "Cloning linux arm64 cross compile toolchain for x86_64..."
if [ -d ${workdir}/aarch64-toolchain ];then rm -rf ${workdir}/aarch64-toolchain; fi
git clone --depth=1 ${aarch64_toolchain_bin_repo} ${workdir}/aarch64-toolchain
else
LOG "You are running this script on a ${host_arch} mechine, progress...."
fi
touch $workdir/.done touch $workdir/.done
fi fi
if [[ $(cat $workdir/.done | grep u-boot) != "u-boot" ]];then if [[ $(cat $workdir/.done | grep u-boot) != "u-boot" ]];then
bash $cur_dir/build_u-boot.sh bash ${cur_dir}/build_u-boot.sh
fi fi
if [[ $(cat $workdir/.done | grep bootimg) != "bootimg" ]];then if [[ $(cat $workdir/.done | grep bootimg) != "bootimg" ]];then
bash $cur_dir/build_boot.sh bash ${cur_dir}/build_boot.sh
fi fi
if [[ $(cat $workdir/.done | grep rootfs) != "rootfs" ]];then if [[ $(cat $workdir/.done | grep rootfs) != "rootfs" ]];then
bash $cur_dir/build_rootfs.sh if [[ "${host_arch}" == "x86_64" && "${arch}" == "arm64" ]];then
LOG "You are running this script on a ${host_arch} mechine, installing qemu-user-static...."
sudo rpm -ivh bin/qemu-user-static-aarch64-x86_64.rpm
fi
LOG "You are running this script on a ${host_arch} mechine, start building rootfs...."
bash ${cur_dir}/build_rootfs.sh
fi fi
bash $cur_dir/gen_image.sh --board ${board} bash ${cur_dir}/gen_image.sh -n ${name} --board ${board}

View File

@ -166,6 +166,10 @@ make_kernel(){
fi fi
kernel_defconfig=arch/arm64/configs/${kernel_defconfig} kernel_defconfig=arch/arm64/configs/${kernel_defconfig}
fi fi
if [ ! -z "${cross_compile}" ]; then
export CROSS_COMPILE=${cross_compile}
fi
make distclean make distclean
cp ${kernel_defconfig} .config cp ${kernel_defconfig} .config
make ARCH=arm64 olddefconfig make ARCH=arm64 olddefconfig
@ -186,6 +190,10 @@ install_kernel() {
mkdir -p ${boot_dir} mkdir -p ${boot_dir}
mkdir -p $workdir/kernel/kernel-modules mkdir -p $workdir/kernel/kernel-modules
cd $workdir/kernel cd $workdir/kernel
if [ ! -z "${cross_compile}" ]; then
export CROSS_COMPILE=${cross_compile}
fi
make ARCH=arm64 install INSTALL_PATH=${boot_dir} make ARCH=arm64 install INSTALL_PATH=${boot_dir}
make ARCH=arm64 modules_install INSTALL_MOD_PATH=$workdir/kernel/kernel-modules make ARCH=arm64 modules_install INSTALL_MOD_PATH=$workdir/kernel/kernel-modules
LOG "device tree name is ${dtb_name}.dtb" LOG "device tree name is ${dtb_name}.dtb"
@ -261,6 +269,16 @@ elif [ -f $default_defconfig ]; then
kernel_defconfig=${workdir}/${default_defconfig##*/} kernel_defconfig=${workdir}/${default_defconfig##*/}
fi fi
cross_compile=""
host_arch=$(arch)
if [[ "${host_arch}" == "x86_64" && "${arch}" == "arm64" ]];then
LOG "You are running this script on a ${host_arch} mechine, use cross compile...."
cross_compile="${workdir}/aarch64-toolchain/bin/aarch64-none-linux-gnu-"
else
LOG "You are running this script on a ${host_arch} mechine, progress...."
fi
if [ ! -d $workdir ]; then if [ ! -d $workdir ]; then
mkdir $workdir mkdir $workdir
fi fi

View File

@ -26,6 +26,7 @@ default_param() {
tmp_dir=${workdir}/tmp tmp_dir=${workdir}/tmp
workdir=$cur_dir/build workdir=$cur_dir/build
branch=openEuler-20.03-LTS branch=openEuler-20.03-LTS
rootfs_arch=aarch64
nonfree_bin_dir=${workdir}/../bin nonfree_bin_dir=${workdir}/../bin
rootfs_dir=${workdir}/rootfs rootfs_dir=${workdir}/rootfs
log_dir=${workdir}/log log_dir=${workdir}/log
@ -128,9 +129,11 @@ root_need() {
} }
INSTALL_PACKAGES(){ INSTALL_PACKAGES(){
tmp_repo_info=$2
chroot ${rootfs_dir}/ dnf ${tmp_repo_info} --disablerepo="*" makecache --nogpgcheck
for item in $(cat $1) for item in $(cat $1)
do do
dnf ${repo_info} --disablerepo="*" --installroot=${rootfs_dir}/ install -y $item --nogpgcheck chroot ${rootfs_dir}/ dnf ${tmp_repo_info} --disablerepo="*" install -y $item --nogpgcheck
if [ $? == 0 ]; then if [ $? == 0 ]; then
LOG install $item. LOG install $item.
else else
@ -219,7 +222,7 @@ build_rootfs() {
done done
os_release_name="openEuler-release" os_release_name="openEuler-release"
dnf ${repo_info} --disablerepo="*" --downloaddir=${workdir}/ download ${os_release_name} dnf ${repo_info} --disablerepo="*" --downloaddir=${workdir}/ download ${os_release_name} --forcearch ${rootfs_arch}
if [ $? != 0 ]; then if [ $? != 0 ]; then
ERROR "Fail to download ${os_release_name}!" ERROR "Fail to download ${os_release_name}!"
exit 2 exit 2
@ -232,17 +235,30 @@ build_rootfs() {
LOG "Success to download ${os_release_name}." LOG "Success to download ${os_release_name}."
fi fi
rpm -ivh --nodeps --root ${rootfs_dir}/ ${os_release_name} rpm -ivh --nodeps --root ${rootfs_dir}/ ${os_release_name} --ignorearch
mkdir -p ${rootfs_dir}/etc/rpm mkdir -p ${rootfs_dir}/etc/rpm
chmod a+rX ${rootfs_dir}/etc/rpm chmod a+rX ${rootfs_dir}/etc/rpm
echo "%_install_langs en_US" > ${rootfs_dir}/etc/rpm/macros.image-language-conf echo "%_install_langs en_US" > ${rootfs_dir}/etc/rpm/macros.image-language-conf
INSTALL_PACKAGES $CONFIG_RPM_LIST echo ${repo_info}
dnf ${repo_info} --disablerepo="*" --installroot=${rootfs_dir}/ install -y dnf --nogpgcheck --forcearch ${rootfs_arch}
cp -L /etc/resolv.conf ${rootfs_dir}/etc/resolv.conf cp -L /etc/resolv.conf ${rootfs_dir}/etc/resolv.conf
mount --bind /dev ${rootfs_dir}/dev
mount -t proc /proc ${rootfs_dir}/proc
mount -t sysfs /sys ${rootfs_dir}/sys
INSTALL_PACKAGES ${CONFIG_RPM_LIST} "${repo_info}"
rm -rf ${rootfs_dir}/*.core
rm ${workdir}/*rpm rm ${workdir}/*rpm
echo " nameserver 8.8.8.8 for dns in $default_dns
nameserver 114.114.114.114" > "${rootfs_dir}/etc/resolv.conf" do
echo " nameserver ${dns}" >> "${rootfs_dir}/etc/resolv.conf"
done
if [ ! -d ${rootfs_dir}/etc/sysconfig/network-scripts ]; then mkdir "${rootfs_dir}/etc/sysconfig/network-scripts"; fi if [ ! -d ${rootfs_dir}/etc/sysconfig/network-scripts ]; then mkdir "${rootfs_dir}/etc/sysconfig/network-scripts"; fi
echo " TYPE=Ethernet echo " TYPE=Ethernet
PROXY_METHOD=none PROXY_METHOD=none
@ -263,10 +279,6 @@ build_rootfs() {
LOG "Configure network done." LOG "Configure network done."
mount --bind /dev ${rootfs_dir}/dev
mount -t proc /proc ${rootfs_dir}/proc
mount -t sysfs /sys ${rootfs_dir}/sys
cp $nonfree_bin_dir/../bin/extend-root.sh ${rootfs_dir}/etc/rc.d/init.d/extend-root.sh cp $nonfree_bin_dir/../bin/extend-root.sh ${rootfs_dir}/etc/rc.d/init.d/extend-root.sh
chmod +x ${rootfs_dir}/etc/rc.d/init.d/extend-root.sh chmod +x ${rootfs_dir}/etc/rc.d/init.d/extend-root.sh
@ -336,6 +348,12 @@ POST_BOARD_OVERLAY() {
echo "Initial POST_BOARD_OVERLAY function" # It will be overwritten by board.conf. echo "Initial POST_BOARD_OVERLAY function" # It will be overwritten by board.conf.
} }
if [[ "x$arch" == "arm64" ]]; then
rootfs_arch="aarch64"
fi
default_dns="8.8.8.8 8.8.4.4 114.114.114.114"
if [ ! -d $workdir ]; then if [ ! -d $workdir ]; then
mkdir $workdir mkdir $workdir
fi fi

View File

@ -103,7 +103,11 @@ build_u-boot() {
ERROR "arm-trusted-firmware(bl31.elf) can not be found!" ERROR "arm-trusted-firmware(bl31.elf) can not be found!"
exit 2 exit 2
fi fi
make ARCH=arm $ubootconfig
if [ ! -z "${cross_compile}" ]; then
export CROSS_COMPILE=${cross_compile}
fi
make ARCH=arm ${ubootconfig}
make ARCH=arm -j${make_cores} make ARCH=arm -j${make_cores}
make ARCH=arm u-boot.itb -j${make_cores} make ARCH=arm u-boot.itb -j${make_cores}
LOG "make u-boot done." LOG "make u-boot done."
@ -140,6 +144,16 @@ default_param
local_param local_param
parseargs "$@" || help $? parseargs "$@" || help $?
cross_compile=""
host_arch=$(arch)
if [[ "${host_arch}" == "x86_64" && "${arch}" == "arm64" ]];then
LOG "You are running this script on a ${host_arch} mechine, use cross compile...."
cross_compile="${workdir}/aarch64-toolchain/aarch64-none-linux-gnu-"
else
LOG "You are running this script on a ${host_arch} mechine, progress...."
fi
if [ ! -d $workdir ]; then if [ ! -d $workdir ]; then
mkdir $workdir mkdir $workdir
fi fi

View File

@ -13,6 +13,8 @@ RUN dnf clean expire-cache
ENV SHELL=/bin/bash ENV SHELL=/bin/bash
RUN dnf install sudo -y
RUN echo "cd /work && bash build.sh \ RUN echo "cd /work && bash build.sh \
--board ${board} \ --board ${board} \
-n ${name} \ -n ${name} \