From 7d5b1b46708bb1d89a60a3977bb5acec0380dc2d Mon Sep 17 00:00:00 2001 From: lindongping Date: Thu, 7 Dec 2023 19:19:17 +0800 Subject: [PATCH 1/4] synchronize the content from gitlab to gitee --- Makefile | 2 +- README.md | 53 ++++++- board/phytium/common/post-build.sh | 127 +++++++++++++++ ...1.sh => post-custom-skeleton-debian-11.sh} | 149 ------------------ board/phytium/dd_and_checkMD5.sh | 124 +++++++++++++++ configs/phytiumpi_defconfig | 9 +- configs/phytiumpi_desktop_defconfig | 7 +- package/igh-ethercat/igh-ethercat.mk | 4 +- package/phytium-tools/phytium-tools.mk | 1 + .../src/runtime_replaceBootloader.sh | 55 +++++++ package/skeleton-custom/skeleton-custom.mk | 26 +-- system/Config.in | 65 +++----- toolchain/helpers.mk | 4 +- 13 files changed, 407 insertions(+), 219 deletions(-) create mode 100755 board/phytium/common/post-build.sh rename board/phytium/common/{post-custom-skeleton-debian-base-11.sh => post-custom-skeleton-debian-11.sh} (54%) create mode 100755 board/phytium/dd_and_checkMD5.sh create mode 100755 package/phytium-tools/src/runtime_replaceBootloader.sh diff --git a/Makefile b/Makefile index 9d671571..2c52670f 100644 --- a/Makefile +++ b/Makefile @@ -732,6 +732,7 @@ target-finalize: $(PACKAGES) $(TARGET_DIR) host-finalize @$(call MESSAGE,"Finalizing target directory") $(call per-package-rsync,$(sort $(PACKAGES)),target,$(TARGET_DIR)) $(foreach hook,$(TARGET_FINALIZE_HOOKS),$($(hook))$(sep)) +ifeq ($(BR2_ROOTFS_SKELETON_DEFAULT),y) rm -rf $(TARGET_DIR)/usr/include $(TARGET_DIR)/usr/share/aclocal \ $(TARGET_DIR)/usr/lib/pkgconfig $(TARGET_DIR)/usr/share/pkgconfig \ $(TARGET_DIR)/usr/lib/cmake $(TARGET_DIR)/usr/share/cmake \ @@ -760,7 +761,6 @@ endif $(STRIP_FIND_CMD) | xargs -0 $(STRIPCMD) 2>/dev/null || true $(STRIP_FIND_SPECIAL_LIBS_CMD) | xargs -0 -r $(STRIPCMD) $(STRIP_STRIP_DEBUG) 2>/dev/null || true -ifeq ($(BR2_ROOTFS_SKELETON_DEFAULT),y) test -f $(TARGET_DIR)/etc/ld.so.conf && \ { echo "ERROR: we shouldn't have a /etc/ld.so.conf file"; exit 1; } || true test -d $(TARGET_DIR)/etc/ld.so.conf.d && \ diff --git a/README.md b/README.md index fe6a8c8d..59d09f98 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ phytiumpi_desktop_defconfig 生成的根文件系统、内核、sdcard.img 镜像位于output/images目录。 #### phytiumpi img 镜像 -目前buildroot支持编译phytiumpi img 镜像(sdcard.img),生成的phytiumpi img 镜像位于output/images目录。sdcard.img 镜像包含了根文件系统、内核、设备树。 +目前phytiumpios支持编译phytiumpi img 镜像(sdcard.img),生成的phytiumpi img 镜像位于output/images目录。sdcard.img 镜像包含了根文件系统、内核、设备树。 使用sdcard.img 镜像安装系统,不需要像之前那样将存储设备手动分区再拷贝文件,只需要将sdcard.img文件写入存储设备即可。 ### 更换文件系统的linux内核版本 @@ -156,17 +156,62 @@ RG200U-CN MINIPCIE 5G模块上网,需要重新编译生成SD卡镜像。 (2)`$ make distclean` 重置buildroot,删除所有编译结果、下载目录以及配置。 +## 树外构建 +默认情况下,phytiumpios生成的所有内容都存储在buildroot源码目录的output目录,然而,phytiumpios也支持树外构建。树外构建允许使用除output以外的其他输出目录。使用树外构建时,phytiumpios的.config和临时文件也存储在输出目录中。这意味着使用相同的phytiumpios源码树,只要使用不同的输出目录,可以并行运行多个构建。 +使用树外构建进行配置的方式有以下三种: +(1)在phytiumpios源码目录运行,使用O变量指定输出目录: +`$ make O=xxx/foo-output phytiumpi_xxx_defconfig` +(2)在一个空的输出目录运行,需要指定O变量和phytiumpios源码树的路径: +`$ mkdir xxx/foo-output` +`$ cd xxx/foo-output` +`$ make -C xxx/phytiumpios/ O=$(pwd) phytiumpi_xxx_defconfig` +(3)对于使用merge_config.sh合并配置文件的情况,在phytiumpios源码目录运行: +`$ mkdir xxx/foo-output` +`$ ./support/kconfig/merge_config.sh -O xxx/foo-output configs/phytiumpi_xxx_defconfig configs/phytiumpi_xxx.config` + +运行上述命令之一,phytiumpios会在输出目录中创建一个Makefile,所以在输出目录中再次运行make时,不再需要指定O变量和phytiumpios源码树的路径。 +因此配置完成后,编译的命令为: +`$ cd xxx/foo-output` +`$ make` + +## phytiumpios中修改内核进行编译 +phytiumpios中编译内核源码的目录是`output/build/linux-`,如果在该目录对内核进行了修改(例如修改内核配置或源码), +当运行`make clean`后该目录会被删除,所以在该目录中直接修改内核是不合适的。 +因此,phytiumpios对于这种情况提供了一种机制:`_OVERRIDE_SRCDIR`机制。 +操作方法是,创建一个叫做local.mk的文件,其内容是: +``` +$ cat local.mk +LINUX_OVERRIDE_SRCDIR = /home/xxx/linux-kernel +``` +将local.mk文件和phytiumpios的.config文件放在同一目录下,对于树内构建是buildroot顶层源码目录,对于树外构建是树外构建的输出目录。 +LINUX_OVERRIDE_SRCDIR指定了一个本地的内核源码目录,这样phytiumpios就不会去下载、解压、打补丁内核源码了,而是使用LINUX_OVERRIDE_SRCDIR +指定的内核源码目录。 +这样开发人员首先在LINUX_OVERRIDE_SRCDIR指定的目录对内核进行修改,然后运行`make linux-rebuild`或者 `make linux-reconfigure`即可。 +该命令首先将LINUX_OVERRIDE_SRCDIR中的内核源码同步到`output/build/linux-custom`目录,然后进行配置、编译、安装。 +如果想要编译、安装内核,并重新生成系统镜像,请运行`make linux-rebuild all`。 + # 在开发板上启动文件系统 ## 在phytiumpi开发板上启动文件系统 ### 使用U-Boot启动文件系统(使用phytiumpi img 镜像) (1)将phytiumpi img 镜像(sdcard.img)写入sd卡: -`$ sudo dd if=xxx/phytium-pi-os/output/images/sdcard.img of=/dev/sdb bs=1M` +`$ sudo dd if=xxx/phytium-pi-os/output/images/sdcard.img of=/dev/sdb bs=1M` +本项目还提供了将img镜像烧录进sd卡并进行md5值校验的脚本,确保烧录正确。该脚本需在顶层目录下执行,用法为以下其中之一: +`$ sudo ./board/phytium/dd_and_checkMD5.sh /dev/sdx desktop` +`$ sudo ./board/phytium/dd_and_checkMD5.sh /dev/sdx no_desktop` +其中,/dev/sdx表示sd卡对应的设备节点名称; +如果编译的是phytium_desktop_defconfig,使用第一条命令; +如果编译的是phytium_defconfig,使用第二条命令。 (2)SD卡接到开发板,启动开发板电源,启动文件系统 - (3) 登陆开发板,执行lsblk 命令查看磁盘分区信息,SD 卡对应盘符为 /dev/mmcblk0. +(3)登陆开发板,执行lsblk 命令查看磁盘分区信息,SD 卡对应盘符为 /dev/mmcblk0. 需要将根目录分区 /dev/mmcblk0p1 进行扩容: `$ source /usr/bin/resize.sh` - 需重启生效 + 需重启生效 +(4)开发板运行时,如果需要更换uboot、Image和dtb,本项目提供了对应脚本,用法如下: +`$ sudo runtime_replaceBootloader.sh all` +`$ sudo runtime_replaceBootloader.sh uboot` +`$ sudo runtime_replaceBootloader.sh image` +以上三条命令分别实现了更换uboot+image+dtb、更换uboot和更换image+dtb的功能,要求当前目录下有fip-all.bin和fitImage文件。 # 系统支持linux-headers linux-headers包含构建内核外部模块所需的头文件,编译defconfig会生成linux-headers。 diff --git a/board/phytium/common/post-build.sh b/board/phytium/common/post-build.sh new file mode 100755 index 00000000..f385ec2d --- /dev/null +++ b/board/phytium/common/post-build.sh @@ -0,0 +1,127 @@ +#!/usr/bin/env bash + +deploy_kernel_headers_510 () { + topdir=$(pwd) + pdir=$1 + version=$2 + srctree=$pdir/lib/modules/$version/source + objtree=$pdir/lib/modules/$version/build + cd $objtree + mkdir debian + + ( + cd $srctree + find . arch/arm64 -maxdepth 1 -name Makefile\* + find include scripts -type f -o -type l + find arch/arm64 -name Kbuild.platforms -o -name Platform + find $(find arch/arm64 -name include -o -name scripts -type d) -type f + ) > debian/hdrsrcfiles + + { + if grep -q "^CONFIG_STACK_VALIDATION=y" include/config/auto.conf; then + echo tools/objtool/objtool + fi + + find arch/arm64/include Module.symvers include scripts -type f + + if grep -q "^CONFIG_GCC_PLUGINS=y" include/config/auto.conf; then + find scripts/gcc-plugins -name \*.so + fi + } > debian/hdrobjfiles + + destdir=$pdir/usr/src/linux-headers-$version + mkdir -p $destdir + tar -c -f - -C $srctree -T debian/hdrsrcfiles | tar -xf - -C $destdir + tar -c -f - -T debian/hdrobjfiles | tar -xf - -C $destdir + rm -rf debian + + # copy .config manually to be where it's expected to be + cp .config $destdir/.config + find $destdir -name "*.o" -type f -exec rm -rf {} \; + cd $topdir + # cp -r board/phytium/common/linux-5.10/scripts $destdir + + rm -rf $srctree + rm -rf $objtree + ln -s /usr/src/linux-headers-$version $pdir/lib/modules/$version/build +} + +deploy_kernel_headers_419 () { + topdir=$(pwd) + pdir=$1 + version=$2 + srctree=$pdir/lib/modules/$version/source + objtree=$pdir/lib/modules/$version/build + cd $objtree + mkdir debian + + (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl) > "$objtree/debian/hdrsrcfiles" + (cd $srctree; find arch/*/include include scripts -type f -o -type l) >> "$objtree/debian/hdrsrcfiles" + (cd $srctree; find arch/arm64 -name module.lds -o -name Kbuild.platforms -o -name Platform) >> "$objtree/debian/hdrsrcfiles" + (cd $srctree; find $(find arch/arm64 -name include -o -name scripts -type d) -type f) >> "$objtree/debian/hdrsrcfiles" + if grep -q '^CONFIG_STACK_VALIDATION=y' .config ; then + (cd $objtree; find tools/objtool -type f -executable) >> "$objtree/debian/hdrobjfiles" + fi + (cd $objtree; find arch/arm64/include Module.symvers include scripts -type f) >> "$objtree/debian/hdrobjfiles" + if grep -q '^CONFIG_GCC_PLUGINS=y' .config ; then + (cd $objtree; find scripts/gcc-plugins -name \*.so -o -name gcc-common.h) >> "$objtree/debian/hdrobjfiles" + fi + destdir=$pdir/usr/src/linux-headers-$version + mkdir -p "$destdir" + (cd $srctree; tar -c -f - -T -) < "$objtree/debian/hdrsrcfiles" | (cd $destdir; tar -xf -) + (cd $objtree; tar -c -f - -T -) < "$objtree/debian/hdrobjfiles" | (cd $destdir; tar -xf -) + (cd $objtree; cp .config $destdir/.config) # copy .config manually to be where it's expected to be + (cd $srctree; cp --parents tools/include/tools/be_byteshift.h $destdir) + (cd $srctree; cp --parents tools/include/tools/le_byteshift.h $destdir) + find $destdir -name "*.o" -type f -exec rm -rf {} \; + cd $topdir + # cp -r board/phytium/common/linux-4.19/scripts $destdir + rm -rf "$objtree/debian" + + rm -rf $srctree + rm -rf $objtree + ln -sf "/usr/src/linux-headers-$version" "$pdir/lib/modules/$version/build" +} + +main() +{ + # $1 - the current rootfs directory, skeleton-custom or target + + if [ ! -d $1/lib/modules ]; then + make linux-rebuild ${O:+O=$O} + fi + + KERNELVERSION=`ls $1/lib/modules` + if grep -Eq "^BR2_ROOTFS_LINUX_HEADERS=y$" ${BR2_CONFIG} && [ -L $1/lib/modules/${KERNELVERSION}/source ]; then + if [[ ${KERNELVERSION} = 5.10* ]];then + deploy_kernel_headers_510 $1 ${KERNELVERSION} + elif [[ ${KERNELVERSION} = 4.19* ]];then + deploy_kernel_headers_419 $1 ${KERNELVERSION} + else + echo "error: linux kernel version is neither 4.19 nor 5.10." + fi + fi + + if grep -Eq "^BR2_ROOTFS_CHOWN=y$" ${BR2_CONFIG}; then + sudo chroot ${1} systemctl enable systemd-rootfs-chown.service + fi + + if grep -Eq "^BR2_PACKAGE_PHYTIUM_OPTEE=y$" ${BR2_CONFIG}; then + # add tee-supplicant systemd service + cp -dpf package/phytium-optee/phytium-tee-supplicant.service $1/lib/systemd/system/phytium-tee-supplicant.service + # default set start tee-supplicant + ln -sf /lib/systemd/system/phytium-tee-supplicant.service $1/etc/systemd/system/sysinit.target.wants/phytium-tee-supplicant.service + fi + + # change the priority order of the shared library directories + if ! grep -q "/usr/local/lib" $1/etc/ld.so.conf; then + sed -i '1 i /usr/local/lib' $1/etc/ld.so.conf + sudo chroot $1 ldconfig + sudo chown -R $USER:$GROUPS $1/etc/ld.so.cache + sudo chown -R $USER:$GROUPS $1/var/cache/ldconfig/aux-cache + fi + + exit $? +} + +main $@ diff --git a/board/phytium/common/post-custom-skeleton-debian-base-11.sh b/board/phytium/common/post-custom-skeleton-debian-11.sh similarity index 54% rename from board/phytium/common/post-custom-skeleton-debian-base-11.sh rename to board/phytium/common/post-custom-skeleton-debian-11.sh index 18d21043..9b6df10c 100755 --- a/board/phytium/common/post-custom-skeleton-debian-base-11.sh +++ b/board/phytium/common/post-custom-skeleton-debian-11.sh @@ -185,89 +185,6 @@ full_rtf() fi } -deploy_kernel_headers_510 () { - pdir=$1 - version=$2 - srctree=$pdir/lib/modules/$version/source - objtree=$pdir/lib/modules/$version/build - cd $objtree - mkdir debian - - ( - cd $srctree - find . arch/arm64 -maxdepth 1 -name Makefile\* - find include scripts -type f -o -type l - find arch/arm64 -name Kbuild.platforms -o -name Platform - find $(find arch/arm64 -name include -o -name scripts -type d) -type f - ) > debian/hdrsrcfiles - - { - if grep -q "^CONFIG_STACK_VALIDATION=y" include/config/auto.conf; then - echo tools/objtool/objtool - fi - - find arch/arm64/include Module.symvers include scripts -type f - - if grep -q "^CONFIG_GCC_PLUGINS=y" include/config/auto.conf; then - find scripts/gcc-plugins -name \*.so - fi - } > debian/hdrobjfiles - - destdir=$pdir/usr/src/linux-headers-$version - mkdir -p $destdir - tar -c -f - -C $srctree -T debian/hdrsrcfiles | tar -xf - -C $destdir - tar -c -f - -T debian/hdrobjfiles | tar -xf - -C $destdir - rm -rf debian - - # copy .config manually to be where it's expected to be - cp .config $destdir/.config - find $destdir -name "*.o" -type f -exec rm -rf {} \; - cd $pdir - cd ../.. - # cp -r board/phytium/common/linux-5.10/scripts $destdir - - rm -rf $srctree - rm -rf $objtree - ln -s /usr/src/linux-headers-$version $pdir/lib/modules/$version/build -} - -deploy_kernel_headers_419 () { - pdir=$1 - version=$2 - srctree=$pdir/lib/modules/$version/source - objtree=$pdir/lib/modules/$version/build - cd $objtree - mkdir debian - - (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl) > "$objtree/debian/hdrsrcfiles" - (cd $srctree; find arch/*/include include scripts -type f -o -type l) >> "$objtree/debian/hdrsrcfiles" - (cd $srctree; find arch/arm64 -name module.lds -o -name Kbuild.platforms -o -name Platform) >> "$objtree/debian/hdrsrcfiles" - (cd $srctree; find $(find arch/arm64 -name include -o -name scripts -type d) -type f) >> "$objtree/debian/hdrsrcfiles" - if grep -q '^CONFIG_STACK_VALIDATION=y' .config ; then - (cd $objtree; find tools/objtool -type f -executable) >> "$objtree/debian/hdrobjfiles" - fi - (cd $objtree; find arch/arm64/include Module.symvers include scripts -type f) >> "$objtree/debian/hdrobjfiles" - if grep -q '^CONFIG_GCC_PLUGINS=y' .config ; then - (cd $objtree; find scripts/gcc-plugins -name \*.so -o -name gcc-common.h) >> "$objtree/debian/hdrobjfiles" - fi - destdir=$pdir/usr/src/linux-headers-$version - mkdir -p "$destdir" - (cd $srctree; tar -c -f - -T -) < "$objtree/debian/hdrsrcfiles" | (cd $destdir; tar -xf -) - (cd $objtree; tar -c -f - -T -) < "$objtree/debian/hdrobjfiles" | (cd $destdir; tar -xf -) - (cd $objtree; cp .config $destdir/.config) # copy .config manually to be where it's expected to be - (cd $srctree; cp --parents tools/include/tools/be_byteshift.h $destdir) - (cd $srctree; cp --parents tools/include/tools/le_byteshift.h $destdir) - find $destdir -name "*.o" -type f -exec rm -rf {} \; - cd $pdir - cd ../.. - # cp -r board/phytium/common/linux-4.19/scripts $destdir - rm -rf "$objtree/debian" - - rm -rf $srctree - rm -rf $objtree - ln -sf "/usr/src/linux-headers-$version" "$pdir/lib/modules/$version/build" -} - main() { # $1 - the current rootfs directory, skeleton-custom or target @@ -283,72 +200,6 @@ main() echo 127.0.0.1 $(plat_name) | sudo tee -a ${1}/etc/hosts 1>/dev/null fi - if [ ! -d $1/lib/modules ]; then - make linux-rebuild ${O:+O=$O} - fi - - KERNELVERSION=`ls $1/lib/modules` - if grep -Eq "^BR2_ROOTFS_LINUX_HEADERS=y$" ${BR2_CONFIG}; then - if [[ ${KERNELVERSION} = 5.10* ]];then - deploy_kernel_headers_510 $1 ${KERNELVERSION} - elif [[ ${KERNELVERSION} = 4.19* ]];then - deploy_kernel_headers_419 $1 ${KERNELVERSION} - else - echo "error: linux kernel version is neither 4.19 nor 5.10." - fi - fi - - if grep -Eq "^BR2_PACKAGE_XORG_ROGUE_UMLIBS=y$" ${BR2_CONFIG}; then - make xorg-rogue-umlibs-rebuild ${O:+O=$O} - fi - - if grep -Eq "^BR2_PACKAGE_ROOTFS_CHOWN=y$" ${BR2_CONFIG}; then - make rootfs-chown-rebuild ${O:+O=$O} - sudo chroot ${1} systemctl enable systemd-rootfs-chown.service - fi - - if grep -Eq "^BR2_PACKAGE_VPU_LIB=y$" ${BR2_CONFIG}; then - make vpu-lib-rebuild ${O:+O=$O} - fi - - if grep -Eq "^BR2_PACKAGE_FFMPEG=y$" ${BR2_CONFIG}; then - make ffmpeg-rebuild ${O:+O=$O} - fi - - if grep -Eq "^BR2_PACKAGE_PHYUBOOT=y$" ${BR2_CONFIG}; then - make phyuboot-rebuild ${O:+O=$O} - fi - - if grep -Eq "^BR2_PACKAGE_PHYTIUM_TOOLS=y$" ${BR2_CONFIG}; then - make phytium-tools-rebuild ${O:+O=$O} - fi - - if grep -Eq "^BR2_PACKAGE_PHYTIUM_OPTEE=y$" ${BR2_CONFIG}; then - make phytium-optee-rebuild ${O:+O=$O} - # add tee-supplicant systemd service - cp -dpf package/phytium-optee/phytium-tee-supplicant.service $RFSDIR/lib/systemd/system/phytium-tee-supplicant.service - # default set start tee-supplicant - ln -sf /lib/systemd/system/phytium-tee-supplicant.service $RFSDIR/etc/systemd/system/sysinit.target.wants/phytium-tee-supplicant.service - fi - - if grep -Eq "^BR2_PACKAGE_XENOMAI=y$" ${BR2_CONFIG}; then - make xenomai-rebuild ${O:+O=$O} - fi - - if grep -Eq "^BR2_PACKAGE_IGH_ETHERCAT=y$" ${BR2_CONFIG}; then - make igh-ethercat-rebuild ${O:+O=$O} - fi - - if grep -Eq "^BR2_PACKAGE_OPEN62541=y$" ${BR2_CONFIG}; then - make open62541-rebuild ${O:+O=$O} - fi - - # change the priority order of the shared library directories - sed -i '1 i /usr/local/lib' $1/etc/ld.so.conf.d/aarch64-linux-gnu.conf - sudo chroot $1 ldconfig - sudo chown -R $USER:$GROUPS $1/etc/ld.so.cache - sudo chown -R $USER:$GROUPS $1/var/cache/ldconfig/aux-cache - exit $? } diff --git a/board/phytium/dd_and_checkMD5.sh b/board/phytium/dd_and_checkMD5.sh new file mode 100755 index 00000000..43b38fe0 --- /dev/null +++ b/board/phytium/dd_and_checkMD5.sh @@ -0,0 +1,124 @@ +#!/bin/bash +# dd_and_checkMD5.sh - To dd sdcard.img into the disk and verify the MD5 valuses that +# ensure sdcard.img is correctly written into the disk. +# dd_and_checkMD5.sh is suitable for the phytiumpi file system compiled from Phytium-Pi-OS and phytium-linux-buildroot. +# phytium-linux-buildroot Repository address: https://gitlab.phytium.com.cn/embedded/linux/phytium-linux-buildroot. +# Phytium-Pi-OS Repository address: https://gitlab.phytium.com.cn/embedded/linux/phytiumpios. + +usage() { + echo "Usage: sudo ./board/phytium/dd_and_checkMD5.sh [Disk_name] [Type_of_file_system]" + echo " Disk_name: the disk you want to dd to. Such as /dev/sdb" + echo " Type_of_file_system:" + echo " desktop: phytium_xxx_desktop_defconfig from phytium-linux-buildroot or Phytium-Pi-OS" + echo " no_desktop: phytium_defconfig from Phytium-Pi-OS" + echo " busybox: phytium_defconfig from phytium-linux-buildroot" + echo " For examples: $0 /dev/sdb desktop" +} + +while true; do + case $1 in + "-h") + usage + exit + ;; + *) + break + ;; + esac +done + +check_args() +{ + if [[ ! $1 =~ ^/dev/sd[b-z]$ ]]; then + echo "Parameter 1 does not meet the requirements." + exit 1 + fi + + if [[ $2 != "desktop" && $2 != "no_desktop" && $2 != "busybox" ]]; then + echo "Parameter 2 does not meet the requirements." + exit 1 + fi +} + +check_disk_device() +{ + + correct_permission="brw-rw----" + current_permission=$(stat -c %A $1) + + max_attemps=3 + delay=1 + attemp=1 + + if [ "$?" != "0" ]; then + echo "error: no $1 found!" + exit 1 + fi + + if [ "$current_permission" != "$correct_permission" ]; then + echo "$1 node error, please reboot your computer" + exit 1 + fi + + if mount | grep "$1" &> /dev/null; then + while [ $attemp -le $max_attemps ] + do + umount $11 > /dev/null 2>&1 + if [ $? -eq 0 ]; then + break + else + if [ $attemp -lt $max_attemps ]; then + echo "umount $11 failed. Retrying in $delay second..." + sleep $delay + else + echo "Failed to umount $11, $(umount -v $11 2>&1)" + exit 1 + fi + fi + attemp=$((attemp+1)) + done + fi +} + +# The size of phytiumpi file system with or without a desktop may vary. +if [ "$2" == "desktop" ]; then + count=15424 +elif [ "$2" == "no_desktop" ]; then + count=6208 +else + count=2112 +fi + +main() +{ + check_args $1 $2 + check_disk_device $1 + echo "----------------------------$(date)-----------------------" >> dd.log + dd if=./output/images/sdcard.img of=$1 bs=1M count=$count >> dd.log 2>&1 + if [ "$?" != "0" ]; then + echo "dd to $1 failed" + exit 1 + fi + + dd if=$1 of=tmp.img bs=1M count=$count >> dd.log 2>&1 + if [ "$?" != "0" ]; then + echo "dd to tmp.img failed" + exit 1 + fi + + pre_md5value=$(md5sum ./output/images/sdcard.img | awk '{print $1}') && echo "sdcard_img_md5value is $pre_md5value" >> dd.log + cur_md5value=$(md5sum tmp.img | awk '{print $1}') && echo "img_from_disk_md5value is $cur_md5value" >> dd.log + + echo "--------------------------------------------------------------------" >> dd.log + + if [ "$pre_md5value" = "$cur_md5value" ]; then + echo "dd and md5_check success" + else + echo "md5_check failed" + fi + + rm -f tmp.img +} + +main $@ + diff --git a/configs/phytiumpi_defconfig b/configs/phytiumpi_defconfig index 1d7ea49f..5be7e711 100644 --- a/configs/phytiumpi_defconfig +++ b/configs/phytiumpi_defconfig @@ -10,8 +10,12 @@ BR2_ROOTFS_POST_IMAGE_SCRIPT="board/phytium/post-image.sh support/scripts/genima BR2_ROOTFS_POST_SCRIPT_ARGS="-c board/phytium/genimage-phytiumpi.cfg" # custom skeleton -BR2_ROOTFS_POST_BUILD_SCRIPT="board/phytium/common/post-custom-skeleton-debian-base-11.sh" +BR2_ROOTFS_SKELETON_CUSTOM=y +BR2_ROOTFS_SKELETON_DEBIAN=y +BR2_ROOTFS_POST_CUSTOM_SKELETON_SCRIPT="board/phytium/common/post-custom-skeleton-debian-11.sh" +BR2_ROOTFS_POST_BUILD_SCRIPT="board/phytium/common/post-build.sh" BR2_INIT_NONE=y +BR2_ENABLE_LOCALE_PURGE=n #BR2_ROOTFS_CHOWN=y # Hostname and issue @@ -61,3 +65,6 @@ BR2_PACKAGE_PHYUBOOT=y # FFmpeg BR2_PACKAGE_FFMPEG=y + +# Phytium_tools +BR2_PACKAGE_PHYTIUM_TOOLS=y diff --git a/configs/phytiumpi_desktop_defconfig b/configs/phytiumpi_desktop_defconfig index 7454ab65..f41f822c 100644 --- a/configs/phytiumpi_desktop_defconfig +++ b/configs/phytiumpi_desktop_defconfig @@ -10,8 +10,13 @@ BR2_ROOTFS_POST_IMAGE_SCRIPT="board/phytium/post-image.sh support/scripts/genima BR2_ROOTFS_POST_SCRIPT_ARGS="-c board/phytium/genimage-phytiumpi.cfg" # custom skeleton -BR2_ROOTFS_POST_BUILD_SCRIPT="board/phytium/common/post-custom-skeleton-debian-base-11.sh" +BR2_ROOTFS_SKELETON_CUSTOM=y +BR2_ROOTFS_SKELETON_DEBIAN=y +BR2_ROOTFS_POST_CUSTOM_SKELETON_SCRIPT="board/phytium/common/post-custom-skeleton-debian-11.sh" +BR2_ROOTFS_POST_BUILD_SCRIPT="board/phytium/common/post-build.sh" BR2_INIT_NONE=y +BR2_ENABLE_LOCALE_PURGE=n +#BR2_ROOTFS_CHOWN=y # Hostname and issue BR2_TARGET_GENERIC_HOSTNAME="phytiumpi" diff --git a/package/igh-ethercat/igh-ethercat.mk b/package/igh-ethercat/igh-ethercat.mk index 88766bb8..0bd2f35a 100644 --- a/package/igh-ethercat/igh-ethercat.mk +++ b/package/igh-ethercat/igh-ethercat.mk @@ -4,8 +4,8 @@ # ################################################################################ -IGH_ETHERCAT_VERSION = stable-1.5-rt_2023-v1.0-GA -IGH_ETHERCAT_SITE = ssh://git@gitlab.phytium.com.cn:12022/embedded/linux/ethercat.git +IGH_ETHERCAT_VERSION = stable-1.5-rt_v1.1 +IGH_ETHERCAT_SITE = https://gitee.com/phytium_embedded/ether-cat.git IGH_ETHERCAT_SITE_METHOD = git IGH_ETHERCAT_AUTORECONF = YES diff --git a/package/phytium-tools/phytium-tools.mk b/package/phytium-tools/phytium-tools.mk index a8254b87..a224a395 100644 --- a/package/phytium-tools/phytium-tools.mk +++ b/package/phytium-tools/phytium-tools.mk @@ -23,6 +23,7 @@ define PHYTIUM_TOOLS_INSTALL_TARGET_CMDS $(INSTALL) -m 755 -D $(@D)/rtk_hciattach $(TARGET_DIR)/usr/bin/ $(INSTALL) -m 755 -D $(@D)/resize.sh $(TARGET_DIR)/usr/bin/ $(INSTALL) -m 644 -D $(@D)/systemd-hciattach.service $(TARGET_DIR)/lib/systemd/system/ + $(INSTALL) -m 755 -D $(@D)/runtime_replaceBootloader.sh $(TARGET_DIR)/usr/bin/ endef $(eval $(generic-package)) diff --git a/package/phytium-tools/src/runtime_replaceBootloader.sh b/package/phytium-tools/src/runtime_replaceBootloader.sh new file mode 100755 index 00000000..89fc9c62 --- /dev/null +++ b/package/phytium-tools/src/runtime_replaceBootloader.sh @@ -0,0 +1,55 @@ +#!/bin/bash +# runtime_replaceBootloader.sh - Providing the method for performing runtime replacement of the bootloader for phytiumpi. + +usage() +{ + echo "Usage: sudo $0 [Option]" + echo " [Option] can be: " + echo " all: replace uboot+Image+dtb" + echo " uboot: replace uboot" + echo " image: replace Image+dtb" + echo " For example: $0 all" + echo " Please make sure that the current directory contains fitImage or fip-all.bin that you want to replace." +} + +while true; do + case $1 in + "-h") + usage + exit + ;; + *) + break + ;; + esac +done + +main() +{ + echo "-------------------------------$(date)-------------------------------" >> replace.log + if [ "$1" == "all" ]; then + #to preserve the partition table. + dd if=/dev/mmcblk0 of=start.img bs=512 count=1 >> replace.log 2>&1 + dd if=fip-all.bin of=/dev/mmcblk0 bs=1M count=4 >> replace.log 2>&1 + dd if=start.img of=/dev/mmcblk0 bs=512 count=1 >> replace.log 2>&1 + dd if=fitImage of=/dev/mmcblk0 bs=1M seek=4 count=60 >> replace.log 2>&1 + rm -f start.img + elif [ "$1" == "uboot" ]; then + #to preserve the partition table. + dd if=/dev/mmcblk0 of=start.img bs=512 count=1 >> replace.log 2>&1 + dd if=fip-all.bin of=/dev/mmcblk0 bs=1M count=4 >> replace.log 2>&1 + dd if=start.img of=/dev/mmcblk0 bs=512 count=1 >> replace.log 2>&1 + elif [ "$1" == "image" ]; then + dd if=fitImage of=/dev/mmcblk0 bs=1M seek=4 count=60 >> replace.log 2>&1 + else + echo "args error, exit" + fi + + if [ "$?" != "0" ]; then + echo "dd to /dev/mmcblk0 failed" + exit 1 + fi + echo "--------------------------------------------------------------------------" >> replace.log +} + +main $@ diff --git a/package/skeleton-custom/skeleton-custom.mk b/package/skeleton-custom/skeleton-custom.mk index 9d1302c4..5cba0a4d 100644 --- a/package/skeleton-custom/skeleton-custom.mk +++ b/package/skeleton-custom/skeleton-custom.mk @@ -16,18 +16,11 @@ SKELETON_CUSTOM_PROVIDES = skeleton SKELETON_CUSTOM_INSTALL_STAGING = YES -ifneq ($(call qstrip,$(BR2_ROOTFS_SKELETON_CUSTOM_SITE)),) -SKELETON_CUSTOM_SITE = $(call qstrip,$(BR2_ROOTFS_SKELETON_CUSTOM_SITE)) -SKELETON_CUSTOM_SOURCE = $(call qstrip,$(BR2_ROOTFS_SKELETON_CUSTOM_SOURCE)) -SKELETON_CUSTOM_SITE_METHOD = $(call qstrip,$(BR2_ROOTFS_SKELETON_CUSTOM_SITE_METHOD)) -SKELETON_CUSTOM_EXTRACT = $(call qstrip,$(BR2_ROOTFS_SKELETON_CUSTOM_EXTRACT)) - -define SKELETON_CUSTOM_EXTRACT_CMDS - if [ $(BR2_ROOTFS_SKELETON_CUSTOM_EXTRACT_IGNORE_ERROR) = y ]; then \ - cd $(@D) && $(SKELETON_CUSTOM_EXTRACT) $(DL_DIR)/skeleton-custom/$(SKELETON_CUSTOM_SOURCE) || true; \ - else \ - cd $(@D) && $(SKELETON_CUSTOM_EXTRACT) $(DL_DIR)/skeleton-custom/$(SKELETON_CUSTOM_SOURCE); \ - fi +ifeq ($(BR2_ROOTFS_SKELETON_DEBIAN),y) +define SKELETON_CUSTOM_BUILD_CMDS + $(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_CUSTOM_SKELETON_SCRIPT)), \ + @$(call MESSAGE,"Executing post-skeleton-custom scripts $(s)")$(sep) \ + $(EXTRA_ENV) $(s) $(@D) $(call qstrip,$(BR2_ROOTFS_POST_SCRIPT_ARGS))$(sep)) endef define SKELETON_CUSTOM_INSTALL_TARGET_CMDS @@ -42,6 +35,15 @@ define SKELETON_CUSTOM_INSTALL_STAGING_CMDS cd $(STAGING_DIR)/var && rm run && ln -sf ../run run && rm lock && ln -sf ../run/lock lock endef +define SKELETON_CUSTOM_REMOVE_PERMISSION_FOR_SSH_FILES + if [ -d $(TARGET_DIR)/etc/ssh ]; then \ + chmod go-r $(TARGET_DIR)/etc/ssh/ssh_host_ecdsa_key; \ + chmod go-r $(TARGET_DIR)/etc/ssh/ssh_host_ed25519_key; \ + chmod go-r $(TARGET_DIR)/etc/ssh/ssh_host_rsa_key; \ + fi +endef +SKELETON_CUSTOM_POST_INSTALL_TARGET_HOOKS += SKELETON_CUSTOM_REMOVE_PERMISSION_FOR_SSH_FILES + else SKELETON_CUSTOM_PATH = $(call qstrip,$(BR2_ROOTFS_SKELETON_CUSTOM_PATH)) diff --git a/system/Config.in b/system/Config.in index 37ad61ce..d4bc995e 100644 --- a/system/Config.in +++ b/system/Config.in @@ -26,11 +26,22 @@ endchoice if BR2_ROOTFS_SKELETON_CUSTOM +choice + prompt "Choose Ubuntu or Debian" + default BR2_ROOTFS_SKELETON_UBUNTU + config BR2_ROOTFS_SKELETON_UBUNTU bool "custom target skeleton is ubuntu" help Custom target skeleton is ubuntu. +config BR2_ROOTFS_SKELETON_DEBIAN + bool "custom target skeleton is debian" + help + Custom target skeletom is debian. + +endchoice + config BR2_PACKAGE_ROOTFS_DESKTOP bool "debian desktop" help @@ -50,66 +61,26 @@ config BR2_ROOTFS_LINUX_HEADERS help Custom target skeleton is ubuntu -config BR2_ROOTFS_SKELETON_CUSTOM_PATH - string "custom target skeleton path" - help - Path to custom target skeleton. - -menu "Custom skeleton via network" -config BR2_ROOTFS_SKELETON_CUSTOM_SITE - string "custom target skeleton site" - help - Site where the custom target skeleton can be obtained - via network. - -config BR2_ROOTFS_SKELETON_CUSTOM_SOURCE - string "name of custom target skeleton" - help - The file name of the custom target skeleton. - -config BR2_ROOTFS_SKELETON_CUSTOM_SITE_METHOD - string "method obtain custom target skeleton from the site" - default "wget" - help - How to obtain the custom target skeleton via network. - -config BR2_ROOTFS_SKELETON_CUSTOM_EXTRACT - string "how to extract the custom target skeleton" - default "tar zxvf" - help - How to extract the custom target skeleton. - The custom skeleton will be extracted to the directory: - output/build/skeleton/custom/ - -config BR2_ROOTFS_SKELETON_CUSTOM_EXTRACT_IGNORE_ERROR - bool "ignore the extract error" - help - Sometimes the extract will return error which is nothing - else matters. Fox example, some filesystem will make link - to the host directory (but it is useless for the target) - and it will be fail due to the permission. The error will - stop the compilation. - -config BR2_ROOTFS_SKELETON_CUSTOM_FULL_RFS - bool "Full RootFS for skeleton custon (Ubuntu)" - -endmenu - config BR2_ROOTFS_POST_CUSTOM_SKELETON_SCRIPT string "Custom scripts to run before using custom skeleton" default "" help Specify a space-separated list of scripts to be run after the download - and unzip has finished and before OpenIL starts using the custom skeleton. + and unzip has finished and before Buildroot starts using the custom skeleton. This gives users the opportunity to do board/skeleton specific configuration, add-ons and the like, so the generated files can be used directly without further processing. - These scripts are called with the unzipped custom skeleton directory name + These scripts are called with the build directory name as first argument. Make sure the exit code of those scripts are 0, otherwise make will stop after calling them. +config BR2_ROOTFS_SKELETON_CUSTOM_PATH + string "custom target skeleton path" + help + Path to custom target skeleton. + endif if BR2_ROOTFS_SKELETON_DEFAULT diff --git a/toolchain/helpers.mk b/toolchain/helpers.mk index ef8e9a5f..c799d06c 100644 --- a/toolchain/helpers.mk +++ b/toolchain/helpers.mk @@ -109,11 +109,11 @@ copy_toolchain_sysroot = \ continue ; \ fi ; \ if [ "$$i" = "usr" ]; then \ - rsync -au --chmod=u=rwX,go=rX --exclude 'locale/' \ + rsync -a --chmod=u=rwX,go=rX --exclude 'locale/' \ --include '/libexec*/' --exclude '/lib*/' \ $${ARCH_SYSROOT_DIR}/$$i/ $(STAGING_DIR)/$$i/ ; \ else \ - rsync -au --chmod=u=rwX,go=rX --exclude 'locale/' \ + rsync -a --chmod=u=rwX,go=rX --exclude 'locale/' \ $${ARCH_SYSROOT_DIR}/$$i/ $(STAGING_DIR)/$$i/ ; \ fi ; \ done ; \ -- Gitee From 02deb826bd5baa61e522f9c31c065e240ba5ca4b Mon Sep 17 00:00:00 2001 From: lindongping Date: Fri, 8 Dec 2023 11:12:33 +0800 Subject: [PATCH 2/4] README:change buildroot to phytium-pi-os --- README.md | 62 +++++++++++++++++++++++++++---------------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 59d09f98..0121a28b 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ # 开发环境 ## 系统要求 Buildroot被设计为在x86 Linux系统上运行,我们只支持在ubuntu20.04、ubuntu22.04、debian11这三种主机系统上运行phytium-pi-os,不支持其他系统。 -首先,Buildroot需要主机系统上安装如下Linux程序,请检查是否已安装: +首先,phytium-pi-os需要主机系统上安装如下Linux程序,请检查是否已安装: ``` • Build tools: – which @@ -41,12 +41,12 @@ Buildroot被设计为在x86 Linux系统上运行,我们只支持在ubuntu20.04 # 查看支持的defconfig 为飞腾派构建的文件系统的配置文件位于configs目录。 -在phytiumpios根目录下执行`$ make list-defconfigs`,返回configs目录中的defconfig配置文件。 +在phytium-pi-os根目录下执行`$ make list-defconfigs`,返回configs目录中的defconfig配置文件。 ``` -$ cd xxx/phytiumpios +$ cd xxx/phytium-pi-os $ make list-defconfigs ``` -其中以phytium开头的为飞腾相关的defconfig配置文件,包含: +其中以phytiumpi开头的为飞腾相关的defconfig配置文件,包含: ``` phytiumpi_defconfig - Build for phytiumpi phytiumpi_desktop_defconfig - Build for phytiumpi with desktop @@ -68,7 +68,7 @@ phytiumpi_desktop_defconfig 生成的根文件系统、内核、sdcard.img 镜像位于output/images目录。 #### phytiumpi img 镜像 -目前phytiumpios支持编译phytiumpi img 镜像(sdcard.img),生成的phytiumpi img 镜像位于output/images目录。sdcard.img 镜像包含了根文件系统、内核、设备树。 +目前phytium-pi-os支持编译phytiumpi img 镜像(sdcard.img),生成的phytiumpi img 镜像位于output/images目录。sdcard.img 镜像包含了根文件系统、内核、设备树。 使用sdcard.img 镜像安装系统,不需要像之前那样将存储设备手动分区再拷贝文件,只需要将sdcard.img文件写入存储设备即可。 ### 更换文件系统的linux内核版本 @@ -154,37 +154,37 @@ RG200U-CN MINIPCIE 5G模块上网,需要重新编译生成SD卡镜像。 (1)`$ make clean` 删除所有编译结果,包括output目录下的所有内容。当编译完一个文件系统后,编译另一个文件系统前,需要执行此命令。 (2)`$ make distclean` -重置buildroot,删除所有编译结果、下载目录以及配置。 +重置phytium-pi-os,删除所有编译结果、下载目录以及配置。 ## 树外构建 -默认情况下,phytiumpios生成的所有内容都存储在buildroot源码目录的output目录,然而,phytiumpios也支持树外构建。树外构建允许使用除output以外的其他输出目录。使用树外构建时,phytiumpios的.config和临时文件也存储在输出目录中。这意味着使用相同的phytiumpios源码树,只要使用不同的输出目录,可以并行运行多个构建。 +默认情况下,phytium-pi-os生成的所有内容都存储在phytium-pi-os源码目录的output目录,然而,phytium-pi-os也支持树外构建。树外构建允许使用除output以外的其他输出目录。使用树外构建时,phytium-pi-os的.config和临时文件也存储在输出目录中。这意味着使用相同的phytium-pi-os源码树,只要使用不同的输出目录,可以并行运行多个构建。 使用树外构建进行配置的方式有以下三种: -(1)在phytiumpios源码目录运行,使用O变量指定输出目录: +(1)在phytium-pi-os源码目录运行,使用O变量指定输出目录: `$ make O=xxx/foo-output phytiumpi_xxx_defconfig` -(2)在一个空的输出目录运行,需要指定O变量和phytiumpios源码树的路径: +(2)在一个空的输出目录运行,需要指定O变量和phytium-pi-os源码树的路径: `$ mkdir xxx/foo-output` `$ cd xxx/foo-output` -`$ make -C xxx/phytiumpios/ O=$(pwd) phytiumpi_xxx_defconfig` -(3)对于使用merge_config.sh合并配置文件的情况,在phytiumpios源码目录运行: +`$ make -C xxx/phytium-pi-os/ O=$(pwd) phytiumpi_xxx_defconfig` +(3)对于使用merge_config.sh合并配置文件的情况,在phytium-pi-os源码目录运行: `$ mkdir xxx/foo-output` `$ ./support/kconfig/merge_config.sh -O xxx/foo-output configs/phytiumpi_xxx_defconfig configs/phytiumpi_xxx.config` -运行上述命令之一,phytiumpios会在输出目录中创建一个Makefile,所以在输出目录中再次运行make时,不再需要指定O变量和phytiumpios源码树的路径。 +运行上述命令之一,phytium-pi-os会在输出目录中创建一个Makefile,所以在输出目录中再次运行make时,不再需要指定O变量和phytium-pi-os源码树的路径。 因此配置完成后,编译的命令为: `$ cd xxx/foo-output` `$ make` -## phytiumpios中修改内核进行编译 -phytiumpios中编译内核源码的目录是`output/build/linux-`,如果在该目录对内核进行了修改(例如修改内核配置或源码), +## phytium-pi-os中修改内核进行编译 +phytium-pi-os中编译内核源码的目录是`output/build/linux-`,如果在该目录对内核进行了修改(例如修改内核配置或源码), 当运行`make clean`后该目录会被删除,所以在该目录中直接修改内核是不合适的。 -因此,phytiumpios对于这种情况提供了一种机制:`_OVERRIDE_SRCDIR`机制。 +因此,phytium-pi-os对于这种情况提供了一种机制:`_OVERRIDE_SRCDIR`机制。 操作方法是,创建一个叫做local.mk的文件,其内容是: ``` $ cat local.mk LINUX_OVERRIDE_SRCDIR = /home/xxx/linux-kernel ``` -将local.mk文件和phytiumpios的.config文件放在同一目录下,对于树内构建是buildroot顶层源码目录,对于树外构建是树外构建的输出目录。 -LINUX_OVERRIDE_SRCDIR指定了一个本地的内核源码目录,这样phytiumpios就不会去下载、解压、打补丁内核源码了,而是使用LINUX_OVERRIDE_SRCDIR +将local.mk文件和phytium-pi-os的.config文件放在同一目录下,对于树内构建是phytium-pi-os顶层源码目录,对于树外构建是树外构建的输出目录。 +LINUX_OVERRIDE_SRCDIR指定了一个本地的内核源码目录,这样phytium-pi-os就不会去下载、解压、打补丁内核源码了,而是使用LINUX_OVERRIDE_SRCDIR 指定的内核源码目录。 这样开发人员首先在LINUX_OVERRIDE_SRCDIR指定的目录对内核进行修改,然后运行`make linux-rebuild`或者 `make linux-reconfigure`即可。 该命令首先将LINUX_OVERRIDE_SRCDIR中的内核源码同步到`output/build/linux-custom`目录,然后进行配置、编译、安装。 @@ -200,8 +200,8 @@ LINUX_OVERRIDE_SRCDIR指定了一个本地的内核源码目录,这样phytiump `$ sudo ./board/phytium/dd_and_checkMD5.sh /dev/sdx desktop` `$ sudo ./board/phytium/dd_and_checkMD5.sh /dev/sdx no_desktop` 其中,/dev/sdx表示sd卡对应的设备节点名称; -如果编译的是phytium_desktop_defconfig,使用第一条命令; -如果编译的是phytium_defconfig,使用第二条命令。 +如果编译的是phytiumpi_desktop_defconfig,使用第一条命令; +如果编译的是phytiumpi_defconfig,使用第二条命令。 (2)SD卡接到开发板,启动开发板电源,启动文件系统 (3)登陆开发板,执行lsblk 命令查看磁盘分区信息,SD 卡对应盘符为 /dev/mmcblk0. 需要将根目录分区 /dev/mmcblk0p1 进行扩容: @@ -219,7 +219,7 @@ linux-headers包含构建内核外部模块所需的头文件,编译defconfig ## 交叉编译内核模块 编译phytiumpi_xxx_defconfig,会在`output/target/usr/src`目录中安装linux-headers-version。 -使用buildroot的工具链来交叉编译内核模块,buildroot工具链位于`output/host/bin`,工具链的sysroot为 +使用phytium-pi-os的工具链来交叉编译内核模块,phytium-pi-os工具链位于`output/host/bin`,工具链的sysroot为 `output/host/aarch64-buildroot-linux-gnu/sysroot`。 交叉编译内核外部模块的命令为: @@ -232,7 +232,7 @@ modules ``` ## 开发板上编译内核模块 -buildroot将linux-headers-version安装在根文件系统的`/usr/src`目录下, +phytium-pi-os将linux-headers-version安装在根文件系统的`/usr/src`目录下, 并为它创建了一个软链接`/lib/modules/version/build`。 注意,由于linux-headers是在x86-64主机交叉编译生成的,在开发板上直接使用它编译内核模块会报错: `/bin/sh: 1: scripts/basic/fixdep: Exec format error`。 @@ -245,26 +245,26 @@ buildroot将linux-headers-version安装在根文件系统的`/usr/src`目录下 在开发板上编译内核外部模块的命令为: `make -C /lib/modules/5.10.153-phytium-embeded/build M=$PWD modules` -# buildroot编译新的应用软件 -本节简单介绍如何通过buildroot交叉编译能运行在开发板上的应用软件,完整的教程请参考buildroot用户手册manual.pdf。 -## buildroot软件包介绍 -buildroot中所有用户态的软件包都在package目录,每个软件包有自己的目录`package/`,其中``是小写的软件包名。这个目录包含: +# phytium-pi-os编译新的应用软件 +本节简单介绍如何通过phytium-pi-os交叉编译能运行在开发板上的应用软件,完整的教程请参考用户手册manual.pdf。 +## phytium-pi-os软件包介绍 +phytium-pi-os中所有用户态的软件包都在package目录,每个软件包有自己的目录`package/`,其中``是小写的软件包名。这个目录包含: (1)`Config.in`文件,用Kconfig语言编写,描述了包的配置选项。 (2)`.mk`文件,用make编写,描述了包如何构建,即从哪里获取源码,如何编译和安装等。 (3)`.hash`文件,提供hash值,检查下载文件的完整性,如检查下载的软件包源码是否完整,这个文件是可选的。 (4)`*.patch`文件,在编译之前应用于源码的补丁文件,这个文件是可选的。 (5)可能对包有用的其他文件。 -## 编写buildroot软件包 +## 编写phytium-pi-os软件包 首先创建软件包的目录`package/`,然后编写该软件包中的文件。 -buildroot中的软件包基本上由`Config.in`和`.mk`两个文件组成。关于如何编写这两个文件,大家可以参考`package/`和 -buildroot用户手册,这里简单概括一下。 +phytium-pi-os中的软件包基本上由`Config.in`和`.mk`两个文件组成。关于如何编写这两个文件,大家可以参考`package/`和 +用户手册manual.pdf,这里简单概括一下。 (1)`Config.in`文件中必须包含启用或禁用该包的选项,而且必须命名为`BR2_PACKAGE_`,其中``是大写的软件包名,这个选项的值是布尔类型。 也可以定义其他功能选项来进一步配置该软件包。然后还必须在`package/Config.in`文件中包含该文件: `source "package//Config.in"` (2)`.mk`文件看起来不像普通的Makefile文件,而是一连串的变量定义,而且必须以大写的包名作为变量的前缀。最后以调用软件包的基础结构(package infrastructure)结束。变量告诉软件包的基础结构要做什么。 对于使用手写Makefile来编译的软件源码,在`.mk`中调用generic-package基础结构。generic-package基础结构实现了包的下载、提取、打补丁。 -而配置、编译和安装由`.mk`文件描述。`.mk`文件中可以设置的变量及其含义,请参考buildroot用户手册。 +而配置、编译和安装由`.mk`文件描述。`.mk`文件中可以设置的变量及其含义,请参考用户手册manual.pdf。 ## 编译软件包 (1)单独编译软件包 ``` @@ -275,8 +275,8 @@ $ make (2)将软件包编译进根文件系统 ``` -在phytium_xxx_defconfig中添加一行BR2_PACKAGE_=y -$ make phytium_xxx_defconfig +在phytiumpi_xxx_defconfig中添加一行BR2_PACKAGE_=y +$ make phytiumpi_xxx_defconfig $ make ``` -- Gitee From dfbc6164750bd7af899786ef544b9699e2c57fc1 Mon Sep 17 00:00:00 2001 From: lindongping Date: Wed, 13 Dec 2023 14:25:44 +0800 Subject: [PATCH 3/4] modify the description about phytium-pi-os for README and rename runtime_replaceBootloader.sh to runtime_replace_bootloader.sh --- README.md | 68 +++++++++---------- ...oader.sh => runtime_replace_bootloader.sh} | 0 2 files changed, 34 insertions(+), 34 deletions(-) rename package/phytium-tools/src/{runtime_replaceBootloader.sh => runtime_replace_bootloader.sh} (100%) diff --git a/README.md b/README.md index 0121a28b..16ac2626 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,14 @@ # Phytium Pi OS 飞腾派OS(Phytium Pi OS)是运行在飞腾派开发板上的深度定制的Linux系统(基于Debian11)。它针对飞腾派开发板的硬件定制了内核配置,不同的软件包,可以更好的适应不同的场景。 它可以烧录在SD卡中,作为飞腾派开发板的启动系统。 -飞腾派OS是由Buildroot生成的, buildroot是一种简单、高效且易于使用的工具,可以通过交叉编译生成嵌入式Linux系统。Buildroot的用户手册位于docs/manual/manual.pdf。 +飞腾派OS由Buildroot生成,获取更多Buildroot的信息,可参考用户手册docs/manual/manual.pdf。 # 开发环境 ## 系统要求 -Buildroot被设计为在x86 Linux系统上运行,我们只支持在ubuntu20.04、ubuntu22.04、debian11这三种主机系统上运行phytium-pi-os,不支持其他系统。 -首先,phytium-pi-os需要主机系统上安装如下Linux程序,请检查是否已安装: +Buildroot被设计为在x86 Linux系统上运行,结合其他因素,本仓库只支持在ubuntu20.04、ubuntu22.04、debian11这三种x86系统上进行开发,不支持其他系统。 +首先,Buildroot需要主机系统上安装如下Linux程序,请检查是否已安装: ``` -• Build tools: +• Build tools:主机 – which – sed – make (version 3.81 or any later) @@ -38,10 +38,10 @@ Buildroot被设计为在x86 Linux系统上运行,我们只支持在ubuntu20.04 ## 下载Phytium Pi OS `$ git clone https://gitee.com/phytium_embedded/phytium-pi-os` - +克隆后,将会生成phytium-pi-os目录,我们称之为源码根目录,若无另外说明,下面的操作命令都是基于该源码根目录进行描述的 # 查看支持的defconfig 为飞腾派构建的文件系统的配置文件位于configs目录。 -在phytium-pi-os根目录下执行`$ make list-defconfigs`,返回configs目录中的defconfig配置文件。 +执行`$ make list-defconfigs`,返回configs目录中的defconfig配置文件。 ``` $ cd xxx/phytium-pi-os $ make list-defconfigs @@ -68,8 +68,8 @@ phytiumpi_desktop_defconfig 生成的根文件系统、内核、sdcard.img 镜像位于output/images目录。 #### phytiumpi img 镜像 -目前phytium-pi-os支持编译phytiumpi img 镜像(sdcard.img),生成的phytiumpi img 镜像位于output/images目录。sdcard.img 镜像包含了根文件系统、内核、设备树。 -使用sdcard.img 镜像安装系统,不需要像之前那样将存储设备手动分区再拷贝文件,只需要将sdcard.img文件写入存储设备即可。 +支持编译phytiumpi img 镜像(sdcard.img),生成的phytiumpi img 镜像位于output/images目录。sdcard.img 镜像包含了根文件系统、内核、设备树。 +使用sdcard.img 镜像安装系统,不需要将存储设备手动分区再拷贝文件,只需要将sdcard.img文件写入存储设备即可。 ### 更换文件系统的linux内核版本 defconfig中的内核版本默认是linux 5.10。我们支持在编译文件系统时将内核版本更换为linux 4.19,linux 4.19 rt,linux 5.10 rt。 @@ -154,37 +154,37 @@ RG200U-CN MINIPCIE 5G模块上网,需要重新编译生成SD卡镜像。 (1)`$ make clean` 删除所有编译结果,包括output目录下的所有内容。当编译完一个文件系统后,编译另一个文件系统前,需要执行此命令。 (2)`$ make distclean` -重置phytium-pi-os,删除所有编译结果、下载目录以及配置。 +重置源码根目录,删除所有编译结果、下载目录以及配置。 ## 树外构建 -默认情况下,phytium-pi-os生成的所有内容都存储在phytium-pi-os源码目录的output目录,然而,phytium-pi-os也支持树外构建。树外构建允许使用除output以外的其他输出目录。使用树外构建时,phytium-pi-os的.config和临时文件也存储在输出目录中。这意味着使用相同的phytium-pi-os源码树,只要使用不同的输出目录,可以并行运行多个构建。 -使用树外构建进行配置的方式有以下三种: -(1)在phytium-pi-os源码目录运行,使用O变量指定输出目录: +默认情况下,编译生成的所有内容都存储在output目录,然而,树外构建允许使用除output以外的其他输出目录。使用树外构建时,全局配置文件.config和临时文件也存储在输出目录中。这意味着使用相同的源码树,只要使用不同的输出目录,就可以并行运行多个构建。 +使用树外构建进行配置的方式有以下三种可供选择: +(1)在源码根目录下,使用O变量指定输出目录: `$ make O=xxx/foo-output phytiumpi_xxx_defconfig` -(2)在一个空的输出目录运行,需要指定O变量和phytium-pi-os源码树的路径: +(2)在一个空的输出目录运行,指定O变量和源码根目录的路径: `$ mkdir xxx/foo-output` `$ cd xxx/foo-output` `$ make -C xxx/phytium-pi-os/ O=$(pwd) phytiumpi_xxx_defconfig` -(3)对于使用merge_config.sh合并配置文件的情况,在phytium-pi-os源码目录运行: +(3)对于使用merge_config.sh合并配置文件的情况,在源码根目录运行: `$ mkdir xxx/foo-output` `$ ./support/kconfig/merge_config.sh -O xxx/foo-output configs/phytiumpi_xxx_defconfig configs/phytiumpi_xxx.config` -运行上述命令之一,phytium-pi-os会在输出目录中创建一个Makefile,所以在输出目录中再次运行make时,不再需要指定O变量和phytium-pi-os源码树的路径。 +运行上述命令之一,会在输出目录中创建一个Makefile,所以在输出目录中再次运行make时,不再需要指定O变量和源码根目录的路径。 因此配置完成后,编译的命令为: `$ cd xxx/foo-output` `$ make` -## phytium-pi-os中修改内核进行编译 -phytium-pi-os中编译内核源码的目录是`output/build/linux-`,如果在该目录对内核进行了修改(例如修改内核配置或源码), +## 修改内核进行编译 +默认的内核源码目录是`output/build/linux-`,如果在该目录对内核进行了修改(例如修改内核配置或源码), 当运行`make clean`后该目录会被删除,所以在该目录中直接修改内核是不合适的。 -因此,phytium-pi-os对于这种情况提供了一种机制:`_OVERRIDE_SRCDIR`机制。 +因此,对于这种情况提供了一种机制:`_OVERRIDE_SRCDIR`机制。 操作方法是,创建一个叫做local.mk的文件,其内容是: ``` $ cat local.mk LINUX_OVERRIDE_SRCDIR = /home/xxx/linux-kernel ``` -将local.mk文件和phytium-pi-os的.config文件放在同一目录下,对于树内构建是phytium-pi-os顶层源码目录,对于树外构建是树外构建的输出目录。 -LINUX_OVERRIDE_SRCDIR指定了一个本地的内核源码目录,这样phytium-pi-os就不会去下载、解压、打补丁内核源码了,而是使用LINUX_OVERRIDE_SRCDIR +将local.mk文件和.config文件放在同一目录下,对于树内构建是源码根目录,对于树外构建是树外构建的输出目录。 +LINUX_OVERRIDE_SRCDIR指定了一个本地的内核源码目录,这样就不会去下载、解压、打补丁内核源码了,而是使用LINUX_OVERRIDE_SRCDIR 指定的内核源码目录。 这样开发人员首先在LINUX_OVERRIDE_SRCDIR指定的目录对内核进行修改,然后运行`make linux-rebuild`或者 `make linux-reconfigure`即可。 该命令首先将LINUX_OVERRIDE_SRCDIR中的内核源码同步到`output/build/linux-custom`目录,然后进行配置、编译、安装。 @@ -208,9 +208,9 @@ LINUX_OVERRIDE_SRCDIR指定了一个本地的内核源码目录,这样phytium- `$ source /usr/bin/resize.sh` 需重启生效 (4)开发板运行时,如果需要更换uboot、Image和dtb,本项目提供了对应脚本,用法如下: -`$ sudo runtime_replaceBootloader.sh all` -`$ sudo runtime_replaceBootloader.sh uboot` -`$ sudo runtime_replaceBootloader.sh image` +`$ sudo runtime_replace_bootloader.sh all` +`$ sudo runtime_replace_bootloader.sh uboot` +`$ sudo runtime_replace_bootloader.sh image` 以上三条命令分别实现了更换uboot+image+dtb、更换uboot和更换image+dtb的功能,要求当前目录下有fip-all.bin和fitImage文件。 # 系统支持linux-headers @@ -219,7 +219,7 @@ linux-headers包含构建内核外部模块所需的头文件,编译defconfig ## 交叉编译内核模块 编译phytiumpi_xxx_defconfig,会在`output/target/usr/src`目录中安装linux-headers-version。 -使用phytium-pi-os的工具链来交叉编译内核模块,phytium-pi-os工具链位于`output/host/bin`,工具链的sysroot为 +使用工具链来交叉编译内核模块,工具链位于`output/host/bin`,工具链的sysroot为 `output/host/aarch64-buildroot-linux-gnu/sysroot`。 交叉编译内核外部模块的命令为: @@ -232,7 +232,7 @@ modules ``` ## 开发板上编译内核模块 -phytium-pi-os将linux-headers-version安装在根文件系统的`/usr/src`目录下, +编译完成后,linux-headers-version被安装在根文件系统的`/usr/src`目录下, 并为它创建了一个软链接`/lib/modules/version/build`。 注意,由于linux-headers是在x86-64主机交叉编译生成的,在开发板上直接使用它编译内核模块会报错: `/bin/sh: 1: scripts/basic/fixdep: Exec format error`。 @@ -245,26 +245,26 @@ phytium-pi-os将linux-headers-version安装在根文件系统的`/usr/src`目录 在开发板上编译内核外部模块的命令为: `make -C /lib/modules/5.10.153-phytium-embeded/build M=$PWD modules` -# phytium-pi-os编译新的应用软件 -本节简单介绍如何通过phytium-pi-os交叉编译能运行在开发板上的应用软件,完整的教程请参考用户手册manual.pdf。 -## phytium-pi-os软件包介绍 -phytium-pi-os中所有用户态的软件包都在package目录,每个软件包有自己的目录`package/`,其中``是小写的软件包名。这个目录包含: +# 编译新的应用软件 +本节简单介绍如何交叉编译出能够运行在飞腾派开发板上的应用软件,完整的教程请参考用户手册docs/manual/manual.pdf。 +## 软件包介绍 +所有用户态的软件包都在package目录,每个软件包有自己的目录`package/`,其中``是小写的软件包名。这个目录包含: (1)`Config.in`文件,用Kconfig语言编写,描述了包的配置选项。 (2)`.mk`文件,用make编写,描述了包如何构建,即从哪里获取源码,如何编译和安装等。 (3)`.hash`文件,提供hash值,检查下载文件的完整性,如检查下载的软件包源码是否完整,这个文件是可选的。 (4)`*.patch`文件,在编译之前应用于源码的补丁文件,这个文件是可选的。 (5)可能对包有用的其他文件。 -## 编写phytium-pi-os软件包 -首先创建软件包的目录`package/`,然后编写该软件包中的文件。 -phytium-pi-os中的软件包基本上由`Config.in`和`.mk`两个文件组成。关于如何编写这两个文件,大家可以参考`package/`和 -用户手册manual.pdf,这里简单概括一下。 +## 编写软件包 +首先创建软件包的目录`package/`,然后编写该目录下的文件。 +一般情况下,`package/`下有`Config.in`和`.mk`两个文件。关于如何编写这两个文件,大家可以参考`package/`和 +用户手册docs/manual/manual.pdf,这里简单概括一下。 (1)`Config.in`文件中必须包含启用或禁用该包的选项,而且必须命名为`BR2_PACKAGE_`,其中``是大写的软件包名,这个选项的值是布尔类型。 也可以定义其他功能选项来进一步配置该软件包。然后还必须在`package/Config.in`文件中包含该文件: `source "package//Config.in"` (2)`.mk`文件看起来不像普通的Makefile文件,而是一连串的变量定义,而且必须以大写的包名作为变量的前缀。最后以调用软件包的基础结构(package infrastructure)结束。变量告诉软件包的基础结构要做什么。 对于使用手写Makefile来编译的软件源码,在`.mk`中调用generic-package基础结构。generic-package基础结构实现了包的下载、提取、打补丁。 -而配置、编译和安装由`.mk`文件描述。`.mk`文件中可以设置的变量及其含义,请参考用户手册manual.pdf。 +而配置、编译和安装由`.mk`文件描述。`.mk`文件中可以设置的变量及其含义,请参考用户手册docs/manual/manual.pdf。 ## 编译软件包 (1)单独编译软件包 ``` diff --git a/package/phytium-tools/src/runtime_replaceBootloader.sh b/package/phytium-tools/src/runtime_replace_bootloader.sh similarity index 100% rename from package/phytium-tools/src/runtime_replaceBootloader.sh rename to package/phytium-tools/src/runtime_replace_bootloader.sh -- Gitee From 6aa07db7217625988907f93d26effed510ed4867 Mon Sep 17 00:00:00 2001 From: lindongping Date: Wed, 13 Dec 2023 15:21:05 +0800 Subject: [PATCH 4/4] change README and runtime_replace_bootloader.sh --- README.md | 18 +++++++++--------- package/phytium-tools/phytium-tools.mk | 2 +- .../src/runtime_replace_bootloader.sh | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 16ac2626..02a7b8cd 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Buildroot被设计为在x86 Linux系统上运行,结合其他因素,本仓库只支持在ubuntu20.04、ubuntu22.04、debian11这三种x86系统上进行开发,不支持其他系统。 首先,Buildroot需要主机系统上安装如下Linux程序,请检查是否已安装: ``` -• Build tools:主机 +• Build tools: – which – sed – make (version 3.81 or any later) @@ -37,7 +37,7 @@ Buildroot被设计为在x86 Linux系统上运行,结合其他因素,本仓 对于debian11系统,需要设置PATH环境变量:`PATH=$PATH:/usr/sbin` ## 下载Phytium Pi OS -`$ git clone https://gitee.com/phytium_embedded/phytium-pi-os` +`$ git clone https://gitee.com/phytium_embedded/phytium-pi-os` 克隆后,将会生成phytium-pi-os目录,我们称之为源码根目录,若无另外说明,下面的操作命令都是基于该源码根目录进行描述的 # 查看支持的defconfig 为飞腾派构建的文件系统的配置文件位于configs目录。 @@ -91,13 +91,13 @@ configs/phytiumpi_linux_5.10_rt.config ### 支持Phytium-optee 本项目还支持编译Phytium-optee,关于Phytium-optee的信息请参考:`https://gitee.com/phytium_embedded/phytium-optee` -defconfig默认不编译Phytium-optee,如果需要编译Phytium-optee请执行: -(1)使用phytiumpi_xxx_defconfig作为基础配置项,合并支持optee的配置: -`$ ./support/kconfig/merge_config.sh configs/phytiumpi_xxx_defconfig configs/phytiumpi_optee.config` -(2)编译 -`$ make` -(3)镜像的输出位置 -生成的根文件系统、内核、TEE OS位于output/images目录。 +defconfig默认不编译Phytium-optee,如果需要编译Phytium-optee请执行: +(1)使用phytiumpi_xxx_defconfig作为基础配置项,合并支持optee的配置: +`$ ./support/kconfig/merge_config.sh configs/phytiumpi_xxx_defconfig configs/phytiumpi_optee.config` +(2)编译 +`$ make` +(3)镜像的输出位置 +生成的根文件系统、内核、TEE OS位于output/images目录。 后续部署及使用方法,请参考`https://gitee.com/phytium_embedded/phytium-embedded-docs/tree/master/optee` ### 支持xenomai diff --git a/package/phytium-tools/phytium-tools.mk b/package/phytium-tools/phytium-tools.mk index a224a395..5295e664 100644 --- a/package/phytium-tools/phytium-tools.mk +++ b/package/phytium-tools/phytium-tools.mk @@ -23,7 +23,7 @@ define PHYTIUM_TOOLS_INSTALL_TARGET_CMDS $(INSTALL) -m 755 -D $(@D)/rtk_hciattach $(TARGET_DIR)/usr/bin/ $(INSTALL) -m 755 -D $(@D)/resize.sh $(TARGET_DIR)/usr/bin/ $(INSTALL) -m 644 -D $(@D)/systemd-hciattach.service $(TARGET_DIR)/lib/systemd/system/ - $(INSTALL) -m 755 -D $(@D)/runtime_replaceBootloader.sh $(TARGET_DIR)/usr/bin/ + $(INSTALL) -m 755 -D $(@D)/runtime_replace_bootloader.sh $(TARGET_DIR)/usr/bin/ endef $(eval $(generic-package)) diff --git a/package/phytium-tools/src/runtime_replace_bootloader.sh b/package/phytium-tools/src/runtime_replace_bootloader.sh index 89fc9c62..a1233e67 100755 --- a/package/phytium-tools/src/runtime_replace_bootloader.sh +++ b/package/phytium-tools/src/runtime_replace_bootloader.sh @@ -1,5 +1,5 @@ #!/bin/bash -# runtime_replaceBootloader.sh - Providing the method for performing runtime replacement of the bootloader for phytiumpi. +# runtime_replace_bootloader.sh - Providing the method for performing runtime replacement of the bootloader for phytiumpi. usage() { -- Gitee