【Buildroot】基础知识:目录、根文件系统目录覆盖、编译性能分析(编译时间、目标尺寸、包依赖图) |
您所在的位置:网站首页 › linux中根目录包含哪些目录文件 › 【Buildroot】基础知识:目录、根文件系统目录覆盖、编译性能分析(编译时间、目标尺寸、包依赖图) |
文章目录
一、Buildroot目录介绍二、Finalizing target2.1 fs overlay2.2 post build2.3 post image
三、编译性能3.1 编译耗时3.2 编译依赖关系3.3 编译结果尺寸分析3.4 其他文件
buildroot官方教程
buildroot使用介绍
Buildroot官网上可以下载发布版 国内的SOC厂商Rockchip就是在Buildroot的基础上开发的SDK,类似BSP版本的Buildroot。 一、Buildroot目录介绍 . ├── arch: 存放CPU架构相关的配置脚本,如arm/mips/x86,这些CPU相关的配置,在制作工具链时,编译uboot和kernel时很关键. ├── board ├── boot ├── CHANGES ├── Config.in ├── Config.in.legacy ├── configs: 放置开发板的一些配置参数. ├── COPYING ├── DEVELOPERS ├── dl: 存放下载的源代码及应用软件的压缩包. ├── docs: 存放相关的参考文档. ├── fs: 放各种文件系统的源代码. ├── linux: 存放着Linux kernel的自动构建脚本. ├── Makefile ├── Makefile.legacy ├── output: 是编译出来的输出文件夹. │ ├── build: 存放解压后的各种软件包编译完成后的现场. │ ├── host: 存放着制作好的编译工具链,如gcc、arm-linux-gcc等工具. │ ├── images: 存放着编译好的uboot.bin, zImage, rootfs等镜像文件,可烧写到板子里, 让linux系统跑起来. │ ├── staging │ └── target: 用来制作rootfs文件系统,里面放着Linux系统基本的目录结构,以及编译好的应用库和bin可执行文件. (buildroot根据用户配置把.ko .so .bin文件安装到对应的目录下去,根据用户的配置安装指定位置) ├── package:下面放着应用软件的配置文件,每个应用软件的配置文件有Config.in和soft_name.mk。 ├── README ├── support ├── system └── toolchain 二、Finalizing target在buildroot编译的末期,需要对编译结果进行一些检查或者其他操作。 buildroot预留了两个接口: BR2_ROOTFS_OVERLAY:指向一个目录,此目录下的所有文件将会覆盖到output/target下。比如一些配置文件,或者预编译的库等可以在此阶段处理。 BR2_ROOTFS_POST_BUILD_SCRIPT:一个脚本,更加复杂的对文件进行删除、重命名、strip等等功能。 BR2_ROOTFS_POST_IMAGE_SCRIPT:对最终生成的images进行打包处理等。 2.1 fs overlay在文件系统构建过程中,有些应用或者配置不通过编译,直接采取拷贝的方式集成到rootfs中,可以设置“System configuration”->“Root filesystem overlay directories”。 比如下面就是RV1126的rootfs_overlay配置信息:
设置的目录中的内容,会对output/target进行覆盖。 相关处理在Makefile中如下: @$(foreach d, $(call qstrip,$(BR2_ROOTFS_OVERLAY)), \ $(call MESSAGE,"Copying overlay $(d)"); \ rsync -a --ignore-times --keep-dirlinks $(RSYNC_VCS_EXCLUSIONS) \ --chmod=u=rwX,go=rX --exclude .empty --exclude '*~' \ $(d)/ $(TARGET_DIR)$(sep)) 2.2 post build除了fs overlay这种方式,buildroot还提供了一个脚本进行更加复杂的处理。 可以进行文件删除、重命名,甚至对带调试信息的文件进行strip等。 @$(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_BUILD_SCRIPT)), \ $(call MESSAGE,"Executing post-build script $(s)"); \ $(EXTRA_ENV) $(s) $(TARGET_DIR) $(call qstrip,$(BR2_ROOTFS_POST_SCRIPT_ARGS))$(sep))
post image在post build之后,更倾向于生成完整的release文件。包括进行一些images打包、debug文件打包等等。 .PHONY: target-post-image target-post-image: $(TARGETS_ROOTFS) target-finalize @$(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_IMAGE_SCRIPT)), \ $(call MESSAGE,"Executing post-image script $(s)"); \ $(EXTRA_ENV) $(s) $(BINARIES_DIR) $(call qstrip,$(BR2_ROOTFS_POST_SCRIPT_ARGS))$(sep))一个范例如下,对images文件进行打包操作。 #!/bin/sh set -x -e IMG_DIR=output/images DEBUG_DIR=${IMG_DIR}/debug KERNEL_DIR=output/build/linux-master ROOTFS_CPIO=${IMG_DIR}/rootfs.cpio KERNEL_IMAGE=${IMG_DIR}/uImage SPL_IMAGE=${IMG_DIR}/u-boot-spl-bh.bin UBOOT_IMAGE=${IMG_DIR}/u-boot.bin IMG_TAR=images.tar.gz DEBUG_TAR=debug.tar.gz IMG_MD5=images.md5 rm -f ${IMG_TAR} ${DEBUG_TAR} ${IMG_MD5} mkdir -p ${DEBUG_DIR} cp -a ${KERNEL_DIR}/vmlinux ${KERNEL_DIR}/System.map ${ROOTFS_CPIO} ${DEBUG_DIR}/ tar -czf ${IMG_TAR} ${KERNEL_IMAGE} ${SPL_IMAGE} ${UBOOT_IMAGE} tar -czf ${DEBUG_TAR} -C ${IMG_DIR} debug/ md5sum ${IMG_TAR} > ${IMG_MD5} 三、编译性能需要安装: sudo apt-get install python-matplotlib python-numpy使用命令make help Documentation: manual - build manual in all formats manual-html - build manual in HTML manual-split-html - build manual in split HTML manual-pdf - build manual in PDF manual-text - build manual in text manual-epub - build manual in ePub graph-build - generate graphs of the build times graph-depends - generate graph of the dependency tree graph-size - generate stats of the filesystem size list-defconfigs - list all defconfigs (pre-configured minimal systems)还可以使用的命令: make graph-buildmake graph-dependsmake graph-size Documentation: manual - build manual in all formats manual-html - build manual in HTML manual-split-html - build manual in split HTML manual-pdf - build manual in PDF manual-text - build manual in text manual-epub - build manual in ePub graph-build - generate graphs of the build times graph-depends - generate graph of the dependency tree graph-size - generate stats of the filesystem size list-defconfigs - list all defconfigs (pre-configured minimal systems) 3.1 编译耗时使用命令:make graph-build RV1126在SDK根目录执行make graph-build会生成如下文件: liefyuan@ubuntu:~/rv1126/rp_rv1126_sdk$ make graph-build umask 0022 && make -C /home/liefyuan/rv1126/rp_rv1126_sdk/buildroot O=/home/liefyuan/rv1126/rp_rv1126_sdk/buildroot/output/rockchip_rv1126_rv1109_facial_gate graph-build ./support/scripts/graph-build-time --type=histogram --order=name --input=/home/liefyuan/rv1126/rp_rv1126_sdk/buildroot/output/rockchip_rv1126_rv1109_facial_gate/build/build-time.log --output=/home/liefyuan/rv1126/rp_rv1126_sdk/buildroot/output/rockchip_rv1126_rv1109_facial_gate/graphs/build.hist-name.pdf ./support/scripts/graph-build-time --type=histogram --order=build --input=/home/liefyuan/rv1126/rp_rv1126_sdk/buildroot/output/rockchip_rv1126_rv1109_facial_gate/build/build-time.log --output=/home/liefyuan/rv1126/rp_rv1126_sdk/buildroot/output/rockchip_rv1126_rv1109_facial_gate/graphs/build.hist-build.pdf ./support/scripts/graph-build-time --type=histogram --order=duration --input=/home/liefyuan/rv1126/rp_rv1126_sdk/buildroot/output/rockchip_rv1126_rv1109_facial_gate/build/build-time.log --output=/home/liefyuan/rv1126/rp_rv1126_sdk/buildroot/output/rockchip_rv1126_rv1109_facial_gate/graphs/build.hist-duration.pdf ./support/scripts/graph-build-time --type=pie-packages --input=/home/liefyuan/rv1126/rp_rv1126_sdk/buildroot/output/rockchip_rv1126_rv1109_facial_gate/build/build-time.log --output=/home/liefyuan/rv1126/rp_rv1126_sdk/buildroot/output/rockchip_rv1126_rv1109_facial_gate/graphs/build.pie-packages.pdf ./support/scripts/graph-build-time --type=pie-steps --input=/home/liefyuan/rv1126/rp_rv1126_sdk/buildroot/output/rockchip_rv1126_rv1109_facial_gate/build/build-time.log --output=/home/liefyuan/rv1126/rp_rv1126_sdk/buildroot/output/rockchip_rv1126_rv1109_facial_gate/graphs/build.pie-steps.pdf生成的文件目录在: /home/liefyuan/rv1126/rp_rv1126_sdk/buildroot/output/rockchip_rv1126_rv1109_facial_gate/graphs/
通过此图可以明白整个编译流程时间都耗在哪里,针对性进行分析优化,有利于提高编译效率。
命令:make graph-depends 这需要安装graphviz sudo apt-get install graphviz生成的文件地址还是在: /home/liefyuan/rv1126/rp_rv1126_sdk/buildroot/output/rockchip_rv1126_rv1109_facial_gate/graphs/graph-depends.pdf 命令:make graph-size 生成的文件地址还是在: /home/liefyuan/rv1126/rp_rv1126_sdk/buildroot/output/rockchip_rv1126_rv1109_facial_gate/graphs/graph-size.pdf file-size-stats.csv文件的部分内容:
|
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |