OpenEuler is an open-source operating system (OS). The current openEuler kernel is based on Linux. It fully unleashes the potential of computing chips. As an efficient, stable, and secure open-source OS built by global open-source contributors, openEuler applies to database, big data, cloud computing, and artificial intelligence (AI) scenarios.
In this document:
To run OpenEuler Embedded on TC2 Platform, perform the following steps:
The OpenEuler Kernel can be downloaded from the link kernel. OLK-6.6 is based on LTS v6.6 as an example for this usage.
To create an OpenEuler Kernel Image, perform the following steps:
Step 1: Create the workspace directory
mkdir workspace cd workspace/ mkdir kernel rootfs tool
Step 2: Download the Kernel and Toolchain
cd workspace/kernel wget https://gitee.com/openeuler/kernel/repository/archive/OLK-6.6.zip unzip OLK-6.6.zip cd ../tool/ wget https://developer.arm.com/-/media/Files/downloads/gnu/13.2.rel1/binrel/arm-gnu-toolchain-13.2.rel1-x86_64-aarch64-none-linux-gnu.tar.xz tar -xvf arm-gnu-toolchain-13.2.rel1-x86_64-aarch64-none-linux-gnu.tar.xz
Step 3: Build the Kernel Image
A. Change the kernel configuration file:
diff --git a/arch/arm64/configs/openeuler_defconfig b/arch/arm64/configs/openeuler_defconfig index f4a8a774d..a28dc8b89 100644 --- a/arch/arm64/configs/openeuler_defconfig +++ b/arch/arm64/configs/openeuler_defconfig @@ -82,14 +82,8 @@ CONFIG_ARCH_WANT_DEFAULT_BPF_JIT=y # # BPF subsystem # -CONFIG_BPF_SYSCALL=y -CONFIG_BPF_JIT=y -CONFIG_BPF_JIT_ALWAYS_ON=y -CONFIG_BPF_JIT_DEFAULT_ON=y -# CONFIG_BPF_UNPRIV_DEFAULT_OFF is not set -# CONFIG_BPF_PRELOAD is not set -CONFIG_BPF_LSM=y -CONFIG_BPF_SCHED=y +# CONFIG_BPF_SYSCALL is not set +# CONFIG_BPF_JIT is not set # end of BPF subsystem CONFIG_PREEMPT_NONE_BUILD=y @@ -2215,7 +2209,7 @@ CONFIG_ARM_SMCCC_SOC_ID=y # end of Firmware Drivers # CONFIG_GNSS is not set -CONFIG_MTD=m +CONFIG_MTD=y # CONFIG_MTD_TESTS is not set # @@ -2231,9 +2225,8 @@ CONFIG_MTD_OF_PARTS=m # # User Modules And Translation Layers # -CONFIG_MTD_BLKDEVS=m -CONFIG_MTD_BLOCK=m -# CONFIG_MTD_BLOCK_RO is not set +CONFIG_MTD_BLKDEVS=y +CONFIG_MTD_BLOCK=y # # Note that in some cases UBI block is preferred. See MTD_UBI_BLOCK. @@ -2333,7 +2326,7 @@ CONFIG_MTD_BLOCK2MTD=m # CONFIG_MTD_LPDDR is not set # end of LPDDR & LPDDR2 PCM memory drivers -CONFIG_MTD_SPI_NOR=m +CONFIG_MTD_SPI_NOR=y CONFIG_MTD_SPI_NOR_USE_4K_SECTORS=y # CONFIG_MTD_SPI_NOR_SWP_DISABLE is not set CONFIG_MTD_SPI_NOR_SWP_DISABLE_ON_VOLATILE=y @@ -2368,33 +2361,19 @@ CONFIG_PNP_DEBUG_MESSAGES=y # CONFIG_PNPACPI=y CONFIG_BLK_DEV=y -CONFIG_BLK_DEV_NULL_BLK=m +# CONFIG_BLK_DEV_NULL_BLK is not set CONFIG_CDROM=m # CONFIG_BLK_DEV_PCIESSD_MTIP32XX is not set -CONFIG_ZRAM=m -CONFIG_ZRAM_DEF_COMP_LZORLE=y -# CONFIG_ZRAM_DEF_COMP_ZSTD is not set -# CONFIG_ZRAM_DEF_COMP_LZ4 is not set -# CONFIG_ZRAM_DEF_COMP_LZO is not set -# CONFIG_ZRAM_DEF_COMP_LZ4HC is not set -CONFIG_ZRAM_DEF_COMP="lzo-rle" -CONFIG_ZRAM_WRITEBACK=y -# CONFIG_ZRAM_MEMORY_TRACKING is not set -CONFIG_ZRAM_MULTI_COMP=y -CONFIG_BLK_DEV_LOOP=m -CONFIG_BLK_DEV_LOOP_MIN_COUNT=0 -CONFIG_BLK_DEV_DRBD=m -# CONFIG_DRBD_FAULT_INJECTION is not set +# CONFIG_ZRAM is not set +CONFIG_BLK_DEV_LOOP=y +CONFIG_BLK_DEV_LOOP_MIN_COUNT=8 +# CONFIG_BLK_DEV_DRBD is not set CONFIG_BLK_DEV_NBD=m -CONFIG_BLK_DEV_RAM=m -CONFIG_BLK_DEV_RAM_COUNT=16 -CONFIG_BLK_DEV_RAM_SIZE=16384 -CONFIG_CDROM_PKTCDVD=m -CONFIG_CDROM_PKTCDVD_BUFFERS=8 -# CONFIG_CDROM_PKTCDVD_WCACHE is not set -CONFIG_ATA_OVER_ETH=m -CONFIG_VIRTIO_BLK=m -CONFIG_BLK_DEV_RBD=m +# CONFIG_BLK_DEV_RAM is not set +# CONFIG_CDROM_PKTCDVD is not set +# CONFIG_ATA_OVER_ETH is not set +CONFIG_VIRTIO_BLK=y +# CONFIG_BLK_DEV_RBD is not set # CONFIG_BLK_DEV_UBLK is not set # @@ -2441,7 +2420,7 @@ CONFIG_SENSORS_APDS990X=m # CONFIG_HMC6352 is not set # CONFIG_DS1682 is not set # CONFIG_LATTICE_ECP3_CONFIG is not set -# CONFIG_SRAM is not set +CONFIG_SRAM=y # CONFIG_DW_XDATA_PCIE is not set # CONFIG_PCI_ENDPOINT_TEST is not set # CONFIG_XILINX_SDFEC is not set @@ -6013,55 +5992,16 @@ CONFIG_TYPEC_DP_ALTMODE=m # end of USB Type-C Alternate Mode drivers CONFIG_USB_ROLE_SWITCH=y -CONFIG_MMC=m -CONFIG_PWRSEQ_EMMC=m -CONFIG_PWRSEQ_SIMPLE=m -CONFIG_MMC_BLOCK=m -CONFIG_MMC_BLOCK_MINORS=8 -CONFIG_SDIO_UART=m -# CONFIG_MMC_TEST is not set - -# -# MMC/SD/SDIO Host Controller Drivers -# -# CONFIG_MMC_DEBUG is not set -CONFIG_MMC_ARMMMCI=m -CONFIG_MMC_STM32_SDMMC=y -CONFIG_MMC_SDHCI=m -CONFIG_MMC_SDHCI_IO_ACCESSORS=y -CONFIG_MMC_SDHCI_PCI=m -CONFIG_MMC_RICOH_MMC=y -CONFIG_MMC_SDHCI_ACPI=m -CONFIG_MMC_SDHCI_PLTFM=m -# CONFIG_MMC_SDHCI_OF_ARASAN is not set -# CONFIG_MMC_SDHCI_OF_AT91 is not set -# CONFIG_MMC_SDHCI_OF_DWCMSHC is not set -CONFIG_MMC_SDHCI_CADENCE=m -# CONFIG_MMC_SDHCI_F_SDH30 is not set -# CONFIG_MMC_SDHCI_MILBEAUT is not set -# CONFIG_MMC_SDHCI_MSM is not set -CONFIG_MMC_TIFM_SD=m -CONFIG_MMC_SPI=m -CONFIG_MMC_CB710=m -CONFIG_MMC_VIA_SDMMC=m -CONFIG_MMC_DW=m -CONFIG_MMC_DW_PLTFM=m -CONFIG_MMC_DW_BLUEFIELD=m -# CONFIG_MMC_DW_EXYNOS is not set -# CONFIG_MMC_DW_HI3798CV200 is not set -# CONFIG_MMC_DW_K3 is not set -# CONFIG_MMC_DW_PCI is not set -CONFIG_MMC_VUB300=m -CONFIG_MMC_USHC=m -# CONFIG_MMC_USDHI6ROL0 is not set -# CONFIG_MMC_REALTEK_PCI is not set -# CONFIG_MMC_REALTEK_USB is not set -CONFIG_MMC_CQHCI=m -# CONFIG_MMC_HSQ is not set -CONFIG_MMC_TOSHIBA_PCI=m -CONFIG_MMC_MTK=m -CONFIG_MMC_SDHCI_XENON=m -# CONFIG_SCSI_UFSHCD is not set +# CONFIG_MMC is not set +CONFIG_SCSI_UFSHCD=y +CONFIG_SCSI_UFS_BSG=y +# CONFIG_SCSI_UFS_HWMON is not set +# CONFIG_SCSI_UFSHCD_PCI is not set +CONFIG_SCSI_UFSHCD_PLATFORM=y +# CONFIG_SCSI_UFS_CDNS_PLATFORM is not set +CONFIG_SCSI_UFS_DWC_TC_PLATFORM=y +# CONFIG_SCSI_UFS_QCOM is not set +CONFIG_SCSI_UFS_HISI=y CONFIG_MEMSTICK=m # CONFIG_MEMSTICK_DEBUG is not set @@ -6441,19 +6381,19 @@ CONFIG_VFIO_PLATFORM=m # CONFIG_VIRT_DRIVERS is not set CONFIG_VIRTIO_ANCHOR=y -CONFIG_VIRTIO=m -CONFIG_VIRTIO_PCI_LIB=m -CONFIG_VIRTIO_PCI_LIB_LEGACY=m +CONFIG_VIRTIO=y +CONFIG_VIRTIO_PCI_LIB=y +CONFIG_VIRTIO_PCI_LIB_LEGACY=y CONFIG_VIRTIO_MENU=y -CONFIG_VIRTIO_PCI=m +CONFIG_VIRTIO_PCI=y CONFIG_VIRTIO_PCI_LEGACY=y # CONFIG_VIRTIO_VDPA is not set # CONFIG_VIRTIO_PMEM is not set -CONFIG_VIRTIO_BALLOON=m -CONFIG_VIRTIO_MEM=m -CONFIG_VIRTIO_INPUT=m -CONFIG_VIRTIO_MMIO=m -# CONFIG_VIRTIO_MMIO_CMDLINE_DEVICES is not set +CONFIG_VIRTIO_BALLOON=y +CONFIG_VIRTIO_MEM=y +CONFIG_VIRTIO_INPUT=y +CONFIG_VIRTIO_MMIO=y +CONFIG_VIRTIO_MMIO_CMDLINE_DEVICES=y CONFIG_VIRTIO_DMA_SHARED_BUFFER=m CONFIG_VDPA=m # CONFIG_VDPA_USER is not set @@ -6938,12 +6878,15 @@ CONFIG_ROH_HNS=m # File systems # CONFIG_DCACHE_WORD_ACCESS=y -# CONFIG_VALIDATE_FS_PARSER is not set +CONFIG_VALIDATE_FS_PARSER=y CONFIG_FS_IOMAP=y CONFIG_BUFFER_HEAD=y CONFIG_LEGACY_DIRECT_IO=y -# CONFIG_EXT2_FS is not set -CONFIG_EXT3_FS=m +CONFIG_EXT2_FS=y +CONFIG_EXT2_FS_XATTR=y +# CONFIG_EXT2_FS_POSIX_ACL is not set +# CONFIG_EXT2_FS_SECURITY is not set +CONFIG_EXT3_FS=y # CONFIG_EXT3_FS_POSIX_ACL is not set # CONFIG_EXT3_FS_SECURITY is not set CONFIG_EXT4_FS=m
B. Build the kernel by using the command:
cd $workspace/kernel/kernel-OLK-6.6 export CROSS_COMPILE=$workspace/tool/arm-gnu-toolchain-13.2.Rel1-x86_64-aarch64-none-linux-gnu/bin/aarch64-none-linux-gnu- export ARCH=arm64 make openeuler_defconfig make -j $nproc Image
The openEuler Embedded supports multiple architectures, such as Arm64, Arm32, X86-64, and RISC-V. For the Arm64, the simualation platform supports only the QEMU platform. You can use the QEMU root filesystem, and then creates the partition image for the TC2 FVP platform.
To create the OpenEuler Root Filessystem, perform the following steps:
Step 1: Create the OpenEuler Embedded root filesystem
A. Install the dependent tools and packages
# Install necessary packages $ sudo apt-get install python3 python3-pip docker docker.io $ pip install oebuild # Configure the Docker environment $ sudo usermod -a -G docker $(whoami) $ sudo systemctl daemon-reload && sudo systemctl restart docker $ sudo chmod o+rw /var/run/docker.sock
B. Initialize the oebuild build environment
# <work_dir> is the directory to be created $ oebuild init <work_dir> # Switch to the working directory $ cd <work_dir> # Pull the build container and yocto-meta-openeuler project code $ oebuild update
C: Start building
# All build tasks need to be performed within the oebuild working directory $ cd <work_dir> # Create the configuration file compile.yaml for the openeuler-image-qemu-arm64 image $ oebuild generate -p qemu-aarch64 -d build_arm64 # Switch to the build workspace directory that contains compile.yaml, such as build/build_arm64/ $ cd build/build_arm64/ # Follow the instructions to enter the build_arm64 directory and start the build $ oebuild bitbake openeuler-image
Finally, you can see the generated root filesystem in the example drectory of work_dir/build/build_arm64/output/20240711020220 as below. The rootfs is openeuler-image-qemu-aarch64-20240711020220.rootfs.cpio.gz.
work_dir/build/build_arm64/output/20240711020220
openeuler-image-qemu-aarch64-20240711020220.rootfs.cpio.gz
Step 2: Create the partition image for TC2 FVP platform
A: Extract the root filesystem
cd $workspace/rootfs cp $worspace/openEuler-embedded-fs/work_dir/build/build_arm64/output/20240711020220/openeuler-image-qemu-aarch64-20240711020220.rootfs.cpio.gz ./ gzip -d openeuler-image-qemu-aarch64-20240711020220.rootfs.cpio.gz cpio -i < openeuler-image-qemu-aarch64-20240711020220.rootfs.cpio rm openeuler-image-qemu-aarch64-20240711020220.rootfs.cpio
B: Configure for the TC2-FVP platform
You can change the host from qemu-aarch64 to tc2-fvp as follows:
qemu-aarch64
tc2-fvp
./etc/hostname:1:tc2-fvp ./etc/hosts:9:127.0.1.1 tc2-fvp
Note: You might need to disable the etc/init.d/sshd for boot smooth in some cases.
etc/init.d/sshd
C: Create the image by using the following script:
BLOCK_SIZE=512 SEC_PER_MB=$((1024*2)) EXT3_SIZE_MB=1024 PART_START=$((1*SEC_PER_MB)) EXT3_SIZE=$((EXT3_SIZE_MB*SEC_PER_MB)) IMG_BB=../openeuler_fs.img dd if=/dev/zero of=part_table bs=$BLOCK_SIZE count=$PART_START #Space for partition table at the top cat part_table > $IMG_BB dd if=/dev/zero of=ext3_part bs=$BLOCK_SIZE count=$EXT3_SIZE mkdir -p mnt mkfs.ext3 -F ext3_part fuse-ext2 ext3_part mnt -o rw+ cp -rf rootfs/* mnt/ sync fusermount -u mnt rm -rf mnt cat ext3_part >> $IMG_BB #Space for backup partition table at the bottom (1M) cat part_table >> $IMG_BB (echo n; echo 1; echo $PART_START; echo +$((EXT3_SIZE)); echo 8300; echo w; echo y) | gdisk $IMG_BB
You can follow the User Guide to build the TC2 software Image, including RSS/SCP, AP firmware, and boot loader. You can replace only the Kernel "Image" and the root filesystem.
Step 1: Set up the TC2 software stak
In this example, you can make some changes based on buildroot build type. Follow the User Guide to download and build the images for buidroot. After the building is successful, there are the images in the directory output/buildroot/deploy/tc2 as below:
buildroot
output/buildroot/deploy/tc2
Step 2: Change the uboot bootargs for the openeuler rootfs
Change the rootfs mount device from root=/dev/mmcblk0p1 to root=/dev/vda1 as below:
root=/dev/mmcblk0p1
root=/dev/vda1
diff --git a/files/u-boot/tc2/fvp.cfg b/files/u-boot/tc2/fvp.cfg index 91b9e54..8b38b04 100644 --- a/files/u-boot/tc2/fvp.cfg +++ b/files/u-boot/tc2/fvp.cfg @@ -1,7 +1,7 @@ CONFIG_TARGET_TOTAL_COMPUTE_FVP=y CONFIG_BOOTARGS="console=ttyAMA0 debug user_debug=31 earlycon=pl011,0x2A400000 loglevel=9 androidboot.hardware=total_compute androidboot.boot_devices=1c050000.mmci ip=dhcp androidboot.selinux=permissive allow_mismatched_32bit_el0 systemd.log_level=info" -CONFIG_BOOTDELAY=1 -CONFIG_BOOTCOMMAND="virtio scan; if part number virtio 0 vbmeta is_avb; then echo virtio with vbmeta partition detected.; echo starting Android Verified boot.; avb init virtio 0; if avb verify; then set bootargs $bootargs $avb_bootargs; part start virtio 0 boot boot_start; part size virtio 0 boot boot_size; virtio read ${load_addr} ${boot_start} ${boot_size}; bootm ${load_addr} ${load_addr} ${fdt_addr_r}; else; echo AVB verification failed.; exit; fi; elif part number virtio 0 system is_non_avb_android; then echo booting non-avb android; booti ${kernel_addr_r} ${initrd_addr_r} ${fdt_addr_r};elif iminfo ${load_addr}; then echo Booting Buildroot FIT image; bootm ${load_addr} ${load_addr} ${fdt_addr_r}; else; set bootargs $bootargs root=/dev/mmcblk0p1 rw ; echo Booting Debian;booti ${kernel_addr_r} - ${fdt_addr_r}; fi;" +CONFIG_BOOTDELAY=0 +CONFIG_BOOTCOMMAND="virtio scan; if part number virtio 0 vbmeta is_avb; then echo virtio with vbmeta partition detected.; echo starting Android Verified boot.; avb init virtio 0; if avb verify; then set bootargs $bootargs $avb_bootargs; part start virtio 0 boot boot_start; part size virtio 0 boot boot_size; virtio read ${load_addr} ${boot_start} ${boot_size}; bootm ${load_addr} ${load_addr} ${fdt_addr_r}; else; echo AVB verification failed.; exit; fi; elif part number virtio 0 system is_non_avb_android; then echo booting non-avb android; booti ${kernel_addr_r} ${initrd_addr_r} ${fdt_addr_r};elif iminfo ${load_addr}; then echo Booting Buildroot FIT image; bootm ${load_addr} ${load_addr} ${fdt_addr_r}; else; set bootargs $bootargs root=/dev/vda1 rw ; echo Booting Debian;booti ${kernel_addr_r} - ${fdt_addr_r}; fi;" CONFIG_VIRTIO=y CONFIG_VIRTIO_MMIO=y CONFIG_VIRTIO_BLK=y
Note: You also change CONFIG_BOOTDELAY=0 for quick boot on the FVP, but it is not a must.
CONFIG_BOOTDELAY=0
Step 3: Rebuild for the u-boot Image
//rebuild the u-boot image ./run_docker.sh build-u-boot.sh clean ./run_docker.sh build-u-boot.sh build ./run_docker.sh build-u-boot.sh deploy //package into FIP ./run_docker.sh build-tfa.sh build //package into GPT iamge ./run_docker.sh build-flash-image.sh deploy
Step 4: Create the deploy directory and images for openeuler
A. Create the deploy directory for OpenEuler by using the following command:
cd $/tc2-workspace/output mkdir -p openeuler/deploy/tc2/ cp buildroot/deploy/tc2/* openeuler/deploy/tc2/ //remove the original kernel image rm openeuler/deploy/tc2/Image
B. Copy the OpenEuler kernel image and rootfs into tc2 deploy directory
tc2
cd $workspace //copy the OpenEuler Kernel image cp kernel/kernel-OLK-6.6/arch/arm64/boot/Image $tc2-workspace/output/openeuler/deploy/tc2/ //Copy the OpenEuler rootfs image cp rootfs/openeuler_disk_fs.img $tc2-workspace/output/openeuler/deploy/tc2/
Step 5: Change the run model script for the openeuler rootfs
You can modify the script to run for the OpenEuler filesystem
diff --git a/tc2/run_model.sh b/tc2/run_model.sh index 1fe76b0..cd7a6b6 100755 --- a/tc2/run_model.sh +++ b/tc2/run_model.sh @@ -147,7 +147,8 @@ echo "Launching model: "`basename $MODEL` $MODEL --version DEPLOY_DIR=$RUN_SCRIPTS_DIR/../../output/${DISTRO}/deploy/tc2/ DEB_MMC_IMAGE_NAME=debian_fs.img +OPENEULER_MMC_IMAGE_NAME=openeuler_fs.img check_dir_exists_and_exit $DEPLOY_DIR "firmware and kernel images" @@ -180,6 +181,15 @@ case $DISTRO in RSS_CM_PROV_BUNDLE="$DEPLOY_DIR/rss_encrypted_cm_provisioning_bundle_0.bin" RSS_DM_PROV_BUNDLE="$DEPLOY_DIR/rss_encrypted_dm_provisioning_bundle.bin" ;; + openeuler) + DISTRO_MODEL_PARAMS="--data board.dram=${DEPLOY_DIR}/Image@0x80000 \ + -C board.virtioblockdevice.image_path=$DEPLOY_DIR/$OPENEULER_MMC_IMAGE_NAME" + BL1_IMAGE_FILE="$DEPLOY_DIR/bl1-tc.bin" + FIP_IMAGE_FILE="$DEPLOY_DIR/fip_gpt-tc.bin" + RSS_ROM_FILE="$DEPLOY_DIR/rss_rom.bin" + RSS_CM_PROV_BUNDLE="$DEPLOY_DIR/rss_encrypted_cm_provisioning_bundle_0.bin" + RSS_DM_PROV_BUNDLE="$DEPLOY_DIR/rss_encrypted_dm_provisioning_bundle.bin" + ;; *) echo "bad option for distro $3"; incorrect_script_use ;;
Step 6: Run the system on the TC2 FVP platform
The TC2 FVP model can be downloaded from arm-ecosystem-fvps.
You can run the image by using the following command:
./run-scripts/tc2/run_model.sh -m /fvp/FVP_TC2_11.23_28/models/normal/FVP_TC2 -d openeuler
Then, the RSS/SCP and AP firmware are not changed, and the system is booted up as shown in the following example: