Buildroot是一个简单、高效且易于使用的工具,集成了很多第三方软件的编译,可以很方便的生成嵌入式Linux的文件系统及SDK。
Buildroot是一个用于构建整个嵌入式Linux系统的工具,它可以包括BusyBox,但还提供了更多的自定义和配置选项,以满足特定的嵌入式系统需求。
看到了一个友商的提供的buildroot定制工具包,因此学习一下。
系统打包命令:
cd buildroot-2022.02.06
make clean
make htnice_gt675x_defconfig
make menuconfig
Target packages中可以选择需要打包的软件,并保存退出。
修改完后,执行make命令即可自动编译并生成文件系统。
编译完成后,buildroot目录下的output/imags/rootfs.tar.gz文件就是我们定制的文件系统压缩包,更新到嵌入式计算机即可。
初步观察来看,configs目录文件配置硬件主板的信息,配置见下:
\buildroot_htnice.tar\buildroot_htnice\buildroot-2022.02.6\configs\htnice_gt675x_defconfig配置:
BR2_aarch64=y
BR2_cortex_a35=y
BR2_PRIMARY_SITE="http://sources.buildroot.net"
BR2_TOOLCHAIN_BUILDROOT_VENDOR="htnice"
BR2_TOOLCHAIN_BUILDROOT_GLIBC=y
BR2_KERNEL_HEADERS_5_10=y
BR2_TOOLCHAIN_BUILDROOT_CXX=y
BR2_PACKAGE_HOST_GDB=y
BR2_TOOLCHAIN_GLIBC_GCONV_LIBS_COPY=y
BR2_TARGET_GENERIC_HOSTNAME="HTNICE"
BR2_TARGET_GENERIC_ROOT_PASSWD="htnice"
BR2_ROOTFS_POST_BUILD_SCRIPT="board/htnice/gt675x/aarch64/post-build.sh"
BR2_PACKAGE_BUSYBOX_SHOW_OTHERS=y
BR2_PACKAGE_MEMTESTER=y
BR2_PACKAGE_USB_MODESWITCH=y
BR2_PACKAGE_PYTHON3=y
BR2_PACKAGE_PYTHON3_2TO3=y
BR2_PACKAGE_PYTHON3_BERKELEYDB=y
BR2_PACKAGE_PYTHON3_BZIP2=y
BR2_PACKAGE_PYTHON3_CODECSCJK=y
BR2_PACKAGE_PYTHON3_CURSES=y
BR2_PACKAGE_PYTHON3_DECIMAL=y
BR2_PACKAGE_PYTHON3_OSSAUDIODEV=y
BR2_PACKAGE_PYTHON3_READLINE=y
BR2_PACKAGE_PYTHON3_SQLITE=y
BR2_PACKAGE_PYTHON3_XZ=y
BR2_PACKAGE_PYTHON_PIP=y
BR2_PACKAGE_LIBOPENSSL_BIN=y
BR2_PACKAGE_ICU=y
BR2_PACKAGE_HOSTAPD=y
# BR2_PACKAGE_IFUPDOWN_SCRIPTS is not set
BR2_PACKAGE_IPERF3=y
BR2_PACKAGE_IPTABLES=y
BR2_PACKAGE_LRZSZ=y
BR2_PACKAGE_NTP=y
# BR2_PACKAGE_NTP_NTPD is not set
BR2_PACKAGE_NTP_NTPDATE=y
BR2_PACKAGE_OPENSSH=y
# BR2_PACKAGE_OPENSSH_SANDBOX is not set
BR2_PACKAGE_TCPDUMP=y
BR2_PACKAGE_VSFTPD=y
BR2_PACKAGE_WIRELESS_TOOLS=y
BR2_PACKAGE_WPA_SUPPLICANT=y
BR2_PACKAGE_WPA_SUPPLICANT_WEXT=y
BR2_PACKAGE_WPA_SUPPLICANT_CLI=y
BR2_PACKAGE_WPA_SUPPLICANT_PASSPHRASE=y
BR2_PACKAGE_BASH=y
BR2_PACKAGE_HTOP=y
BR2_TARGET_ROOTFS_TAR_GZIP=y
初步观察来看,post-build.sh是主板定制程序的处理命令,配置见下:
\buildroot_htnice.tar\buildroot_htnice\buildroot-2022.02.6\board\htnice\gt675x\aarch64\post-build.sh文件内容:
#!/bin/sh
ROOTFS_DIR=board/htnice/gt675x/aarch64/rootfs
install -d -m 755 $TARGET_DIR/mnt/sd
install -d -m 755 $TARGET_DIR/mnt/udisk
install -d -m 755 $TARGET_DIR/mnt/tmp
install -d -m 755 $TARGET_DIR/lib/modules
cp -r ${ROOTFS_DIR}/lib/modules/* ${TARGET_DIR}/lib/modules/
cp -r ${ROOTFS_DIR}/lib/firmware ${TARGET_DIR}/lib/
cp ${ROOTFS_DIR}/lib/libht98sc2.so ${TARGET_DIR}/lib/
cp -r ${ROOTFS_DIR}/etc/* ${TARGET_DIR}/etc/
cp ${ROOTFS_DIR}/usr/sbin/* ${TARGET_DIR}/usr/sbin/
if [ ! -d "${TARGET_DIR}/usr/share/udhcpc" ];then
install -d -m 755 ${TARGET_DIR}/usr/share/udhcpc
fi
cp ${ROOTFS_DIR}/usr/share/udhcpc/* ${TARGET_DIR}/usr/share/udhcpc