diff --git "a/documents/\347\221\236\350\212\257\345\276\256\347\255\211\345\274\200\345\217\221\346\235\277.md" "b/documents/\347\221\236\350\212\257\345\276\256\347\255\211\345\274\200\345\217\221\346\235\277.md" index f01a4e35552a8df9797bae6b57332489cd6b1ace..097c67eefe8cf526dbd4eb45b95bd7187fdbd789 100644 --- "a/documents/\347\221\236\350\212\257\345\276\256\347\255\211\345\274\200\345\217\221\346\235\277.md" +++ "b/documents/\347\221\236\350\212\257\345\276\256\347\255\211\345\274\200\345\217\221\346\235\277.md" @@ -45,7 +45,7 @@ >![](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。 ->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。 >如果构建包含 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 版本。 @@ -54,7 +54,11 @@ ### 准备环境 - 操作系统: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)。 @@ -332,3 +336,10 @@ - [使用 Docker 构建镜像(推荐)](rockchip/使用Docker构建镜像.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 软件仓库。 + diff --git a/scripts/rockchip/bin/linux-firmware/bcmdhd/fw_bcm43752a2_ag.bin b/scripts/rockchip/bin/linux-firmware/bcmdhd/fw_bcm43752a2_ag.bin index f94ce50b064373c69d37816e28a1a8a367a227c7..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 Binary files a/scripts/rockchip/bin/linux-firmware/bcmdhd/fw_bcm43752a2_ag.bin and b/scripts/rockchip/bin/linux-firmware/bcmdhd/fw_bcm43752a2_ag.bin differ diff --git a/scripts/rockchip/bin/qemu-user-static-aarch64-x86_64.rpm b/scripts/rockchip/bin/qemu-user-static-aarch64-x86_64.rpm new file mode 100644 index 0000000000000000000000000000000000000000..9b70dae6f0838debf4c6045a3bf3a9a4b6c684bf Binary files /dev/null and b/scripts/rockchip/bin/qemu-user-static-aarch64-x86_64.rpm differ diff --git a/scripts/rockchip/boards/firefly-itx-3588j.conf b/scripts/rockchip/boards/firefly-itx-3588j.conf index d4bc5a0bca43c38fde7b1838a016e8ef378b7f2b..3bbd138d5e3bc7da955e510b0ae2a21444b75ffb 100644 --- a/scripts/rockchip/boards/firefly-itx-3588j.conf +++ b/scripts/rockchip/boards/firefly-itx-3588j.conf @@ -3,6 +3,7 @@ local_uboot_dir=${nonfree_bin_dir}/u-boot/firefly-rk3588 dtb_name=rk3588-firefly-itx-3588j platform=rockchip soc_name=rk3588 +arch=arm64 POST_BOARD_OVERLAY() { echo "Put ${board} firmware into rootfs..." diff --git a/scripts/rockchip/boards/firefly-rk3399.conf b/scripts/rockchip/boards/firefly-rk3399.conf index 99c72d2d3cd84c5b1f38adcb1efb40f2e146e1f1..8e27e4eaf8166b412387787407caf3f732325f4d 100644 --- a/scripts/rockchip/boards/firefly-rk3399.conf +++ b/scripts/rockchip/boards/firefly-rk3399.conf @@ -2,6 +2,7 @@ ubootconfig=firefly-rk3399_defconfig dtb_name=rk3399-firefly platform=rockchip soc_name=rk3399 +arch=arm64 POST_BOARD_OVERLAY() { echo "Put ${board} firmware into rootfs..." diff --git a/scripts/rockchip/boards/firefly-roc-rk3566-pc.conf b/scripts/rockchip/boards/firefly-roc-rk3566-pc.conf index 1ec0b4eda473e14200fae96510e271888fc34e2f..d7cbfbafa7177b2222b331d6918653367e00a262 100644 --- a/scripts/rockchip/boards/firefly-roc-rk3566-pc.conf +++ b/scripts/rockchip/boards/firefly-roc-rk3566-pc.conf @@ -3,6 +3,7 @@ local_uboot_dir=${nonfree_bin_dir}/u-boot/firefly-rk3566 dtb_name=rk3566-roc-pc platform=rockchip soc_name=rk3566 +arch=arm64 POST_BOARD_OVERLAY() { echo "Put ${board} firmware into rootfs..." diff --git a/scripts/rockchip/boards/firefly-roc-rk3568-pc-se.conf b/scripts/rockchip/boards/firefly-roc-rk3568-pc-se.conf index d0309cccfcfcc331b533a5f0cf2a2b6ae3319995..ddb2326f958335157dfceccd361ee1e9c5771282 100644 --- a/scripts/rockchip/boards/firefly-roc-rk3568-pc-se.conf +++ b/scripts/rockchip/boards/firefly-roc-rk3568-pc-se.conf @@ -3,6 +3,7 @@ local_uboot_dir=${nonfree_bin_dir}/u-boot/firefly-rk3568 dtb_name=rk3568-roc-pc-se platform=rockchip soc_name=rk3568 +arch=arm64 POST_BOARD_OVERLAY() { echo "Put ${board} firmware into rootfs..." diff --git a/scripts/rockchip/boards/firefly-roc-rk3588s-pc.conf b/scripts/rockchip/boards/firefly-roc-rk3588s-pc.conf index 9464ca65934b2f3f93d82b9a0dff9f5f4d3f6bc6..4691d44e3d0ebb50ba5116238fcd7ddb834ee786 100644 --- a/scripts/rockchip/boards/firefly-roc-rk3588s-pc.conf +++ b/scripts/rockchip/boards/firefly-roc-rk3588s-pc.conf @@ -3,6 +3,7 @@ local_uboot_dir=${nonfree_bin_dir}/u-boot/firefly-rk3588 dtb_name=rk3588s-roc-pc platform=rockchip soc_name=rk3588 +arch=arm64 POST_BOARD_OVERLAY() { echo "Put ${board} firmware into rootfs..." diff --git a/scripts/rockchip/boards/phytiumpi-4gb.conf b/scripts/rockchip/boards/phytiumpi-4gb.conf index 6b5c2e50d432ec67daea5291b62cb3d3adfa2602..6bbb230d50c571e56b5ddd7b79d4cd82679ff08e 100644 --- a/scripts/rockchip/boards/phytiumpi-4gb.conf +++ b/scripts/rockchip/boards/phytiumpi-4gb.conf @@ -3,6 +3,7 @@ local_uboot_dir=${nonfree_bin_dir}/u-boot/phytiumpi dtb_name=phytiumpi_firefly platform=phytium soc_name=e2000q +arch=arm64 POST_BOARD_OVERLAY() { echo "Put ${board} firmware into rootfs..." diff --git a/scripts/rockchip/boards/radxa-rock5b.conf b/scripts/rockchip/boards/radxa-rock5b.conf index 20001cbd4ff77b359b7bbcef0eb6684d64b51481..0ae3cc9d1b240a3dd8fe87cc824b15566ad9641d 100644 --- a/scripts/rockchip/boards/radxa-rock5b.conf +++ b/scripts/rockchip/boards/radxa-rock5b.conf @@ -3,6 +3,7 @@ local_uboot_dir=${nonfree_bin_dir}/u-boot/radxa-rock5b dtb_name=rk3588-rock-5b platform=rockchip soc_name=rk3588 +arch=arm64 POST_BOARD_OVERLAY() { echo "Put ${board} firmware into rootfs..." diff --git a/scripts/rockchip/boards/radxa-rockpi-4a.conf b/scripts/rockchip/boards/radxa-rockpi-4a.conf index 7a5a46fa69c66bf0bd99914c6ebb7499c6353cf7..d3bae4eb720539e4ce71fceab0fa4f1134ac3faf 100644 --- a/scripts/rockchip/boards/radxa-rockpi-4a.conf +++ b/scripts/rockchip/boards/radxa-rockpi-4a.conf @@ -2,6 +2,7 @@ ubootconfig=rock-pi-4-rk3399_defconfig dtb_name=rk3399-rock-pi-4a platform=rockchip soc_name=rk3399 +arch=arm64 POST_BOARD_OVERLAY() { echo "Put ${board} firmware into rootfs..." diff --git a/scripts/rockchip/boards/sample.conf b/scripts/rockchip/boards/sample.conf index 0212dba542f61a4949628f2c4a6492bbc654330b..87481911cd2488933da7b69f2a65c339b214e8a6 100644 --- a/scripts/rockchip/boards/sample.conf +++ b/scripts/rockchip/boards/sample.conf @@ -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. platform=rockchip #Required! The platform of target board, which defaults to rockchip. soc_name=rk3399 +arch=arm64 POST_BOARD_OVERLAY() { echo "Put ${board} firmware into rootfs..." diff --git a/scripts/rockchip/build.sh b/scripts/rockchip/build.sh index 21a02187e668f17ae4c4c91efd97b65f227ad414..60c7e819e0c93f846e1e98f363eea94453d83be5 100755 --- a/scripts/rockchip/build.sh +++ b/scripts/rockchip/build.sh @@ -66,7 +66,7 @@ kernel_url=$kernel_url spec_param=$spec_param" > $workdir/.param } -deppkg_install() { +oe_deppkg_install() { 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 } @@ -133,14 +133,14 @@ LOG(){ echo `date` - INFO, $* | tee -a ${log_dir}/${builddate}.log } -cur_dir=$(cd $(dirname $0);pwd) +source ${cur_dir}/boards/${board}.conf default_param parseargs "$@" || help $? LOG "Selected board: ${board}." -source ${cur_dir}/boards/${board}.conf +cur_dir=$(cd $(dirname $0);pwd) LOG "Board config: ${board}." LOG "U-Boot config: ${ubootconfig}." @@ -151,6 +151,12 @@ used_param if [ ! -d $workdir ]; then mkdir $workdir 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 log_dir=${workdir}/log if [ ! -d ${log_dir} ];then mkdir -p ${log_dir}; fi @@ -165,20 +171,32 @@ if [ -f $workdir/.done ];then touch $workdir/.done fi 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 fi 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 if [[ $(cat $workdir/.done | grep bootimg) != "bootimg" ]];then - bash $cur_dir/build_boot.sh + bash ${cur_dir}/build_boot.sh fi 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 -bash $cur_dir/gen_image.sh --board ${board} +bash ${cur_dir}/gen_image.sh -n ${name} --board ${board} diff --git a/scripts/rockchip/build_boot.sh b/scripts/rockchip/build_boot.sh index f51072ba2ca7ccbd0f3800277cc9b96c8b9bb54d..8c648b65fada8a32e0dea3d24b43d552317dd3a5 100755 --- a/scripts/rockchip/build_boot.sh +++ b/scripts/rockchip/build_boot.sh @@ -166,6 +166,10 @@ make_kernel(){ fi kernel_defconfig=arch/arm64/configs/${kernel_defconfig} fi + + if [ ! -z "${cross_compile}" ]; then + export CROSS_COMPILE=${cross_compile} + fi make distclean cp ${kernel_defconfig} .config make ARCH=arm64 olddefconfig @@ -186,6 +190,10 @@ install_kernel() { mkdir -p ${boot_dir} mkdir -p $workdir/kernel/kernel-modules 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 modules_install INSTALL_MOD_PATH=$workdir/kernel/kernel-modules LOG "device tree name is ${dtb_name}.dtb" @@ -261,6 +269,16 @@ elif [ -f $default_defconfig ]; then kernel_defconfig=${workdir}/${default_defconfig##*/} 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 mkdir $workdir fi diff --git a/scripts/rockchip/build_rootfs.sh b/scripts/rockchip/build_rootfs.sh index 5c4c18e3e52374734709bde8018b300f69d64c9a..78787539b514b9bf817107bd2d165b43d2ffbdeb 100755 --- a/scripts/rockchip/build_rootfs.sh +++ b/scripts/rockchip/build_rootfs.sh @@ -26,6 +26,7 @@ default_param() { tmp_dir=${workdir}/tmp workdir=$cur_dir/build branch=openEuler-20.03-LTS + rootfs_arch=aarch64 nonfree_bin_dir=${workdir}/../bin rootfs_dir=${workdir}/rootfs log_dir=${workdir}/log @@ -128,9 +129,11 @@ root_need() { } INSTALL_PACKAGES(){ + tmp_repo_info=$2 + chroot ${rootfs_dir}/ dnf ${tmp_repo_info} --disablerepo="*" makecache --nogpgcheck for item in $(cat $1) 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 LOG install $item. else @@ -219,7 +222,7 @@ build_rootfs() { done 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 ERROR "Fail to download ${os_release_name}!" exit 2 @@ -232,17 +235,30 @@ build_rootfs() { LOG "Success to download ${os_release_name}." 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 chmod a+rX ${rootfs_dir}/etc/rpm 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 + + 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 - echo " nameserver 8.8.8.8 - nameserver 114.114.114.114" > "${rootfs_dir}/etc/resolv.conf" + for dns in $default_dns + 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 echo " TYPE=Ethernet PROXY_METHOD=none @@ -263,10 +279,6 @@ build_rootfs() { 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 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. } +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 mkdir $workdir fi diff --git a/scripts/rockchip/build_u-boot.sh b/scripts/rockchip/build_u-boot.sh index f303489273d74446b2fd3185a9aa12b694bca029..04267744caade2c7678eeaaf0c84bb21dabcf5a4 100755 --- a/scripts/rockchip/build_u-boot.sh +++ b/scripts/rockchip/build_u-boot.sh @@ -103,7 +103,11 @@ build_u-boot() { ERROR "arm-trusted-firmware(bl31.elf) can not be found!" exit 2 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 u-boot.itb -j${make_cores} LOG "make u-boot done." @@ -140,6 +144,16 @@ default_param local_param 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 mkdir $workdir fi diff --git a/scripts/rockchip/configs/Dockerfile b/scripts/rockchip/configs/Dockerfile index 1f6ecaac5ba6bcbb40c3132eb216b40552e80912..677cdfc3f0cea03c92e4d364fcd5c8b1c8385620 100644 --- a/scripts/rockchip/configs/Dockerfile +++ b/scripts/rockchip/configs/Dockerfile @@ -13,6 +13,8 @@ RUN dnf clean expire-cache ENV SHELL=/bin/bash +RUN dnf install sudo -y + RUN echo "cd /work && bash build.sh \ --board ${board} \ -n ${name} \