首页 > 编程知识 正文

八字分析详解案例,buildroot命令集

时间:2023-05-03 13:30:02 阅读:171003 作者:3228

buildroot是用于构建嵌入式Linux系统的Linux平台上的框架。

整个Buildroot由makefile脚本和Kconfig配置文件组成。

与编译Linux内核类似,通过修改buildroot配置和menuconfig,可以将计算机上运行的Linux系统软件(boot、kernel、rootfs和rootfs )的各种库和APP

您还可以通过配置和使用交叉编译链工具来单独创建Linux文件系统。

buildroot准备工作http://www.Sina.com/: http://buildroot.uclibc.org/download.html,

3359 github.com/buildroot/buildroot (github )。

下载地址: Linux系统的电脑或安装了Linux虚拟机的电脑。

硬件支持

选择相应的目录,然后将下载的压缩包放在其下进行解压缩。 tar-xzvf buildroot-2017.02.9.tar.gz 3358 www.Sina.com /

选择defconfig; 根据需要配置buildroot; 编译buildroot; 在目标板上运行用buildroot构建的系统。 在buildroot目录中介绍解压缩后,可以看到以下目录情况。

arch:包含与CPU体系结构相关的配置脚本,如arm/mips/x86。 在创建工具链和编译uboot和kernel时,这些与CPU相关的配置很重要。 Board中保存着一些默认开发板的配置补丁等。 bootchangesconfig.inconfig.in.legacyconfig.in.legacy。 PERSdl:中存储了下载的源代码和APP应用软件的压缩包。 docs:存储了相关的参考文件。 fs:包含各种文件系统的源代码。 Linux3360包含Linux kernel的自动生成脚本。 Gacyoutput:是编译后的输出文件夹。 (((() ) )build:中保存着解压后的各种软件包编译完成的现场。 (((((()host:中保管着制作的编译工具链。 例如,gcc、arm-linux-gcc等工具。 ((——images :存储编译后的uboot.ysdlr、zImage、rootfs等镜像文件,可以刻录在板上,运行linux系统。 (() () ) ) ) )中包含Linux系统的基本目录结构以及已编译的APP应用程序库和ysdlr可执行文件。 (buildroot根据用户的部署将. ko .so .ysdlr文件安装在相应的目录中,并根据用户的部署安装指定的位置。 ( package )在下面放置APP应用程序的配置文件。 每个APP应用程序的配置文件包括Config.in和soft_name.mk。 现在,soft_name.mk (实际上是makefile的自动生成脚本)文件可以下载APP应用包。 自述- -支持- -系统(-- toolchain buildroot配置在make xxx_defconfig中选择defconfig。 此文件位于config目录下。

然后在make menuconfig中进行配置。

目标选项- -选择目标板体系结构的特性。 Build options ---设置编译选项。 toolchain-- -设置是使用buildroot工具链,还是由外部提供。 系统配置---系统配置Kernel ---内核target packages-- -文件系统映像---文件系统引导加载- -硬件在分析make help中,可以查看make在buildroot中的使用细节,包括package、uclibc、busybox、linux和文档生成等配置。

cleaning 3360 clean---- deleteallfilescreatedbybuild-----------------------------deletealllllllfilescrescreatescreateatedbybutedbybuild

- make world----------------------------------------------编译整个系统 toolchain - build toolchain------------------------------------------编译工具链Configuration: menuconfig - interactive curses-based configurator--------------------------------对整个buildroot进行配置 savedefconfig - Save current config to BR2_DEFCONFIG (minimal config)----------------保存menuconfig的配置Package-specific:-------------------------------------------------------------------------------对package配置 <pkg> - Build and install <pkg> and all its dependencies---------------------单独编译对应APP <pkg>-source - Only download the source files for <pkg> <pkg>-extract - Extract <pkg> sources <pkg>-patch - Apply patches to <pkg> <pkg>-depends - Build <pkg>'s dependencies <pkg>-configure - Build <pkg> up to the configure step <pkg>-build - Build <pkg> up to the build step <pkg>-show-depends - List packages on which <pkg> depends <pkg>-show-rdepends - List packages which have <pkg> as a dependency <pkg>-graph-depends - Generate a graph of <pkg>'s dependencies <pkg>-graph-rdepends - Generate a graph of <pkg>'s reverse dependencies <pkg>-dirclean - Remove <pkg> build directory-----------------------------------------清除对应APP的编译目录 <pkg>-reconfigure - Restart the build from the configure step <pkg>-rebuild - Restart the build from the build step--------------------------------单独重新编译对应APPbusybox: busybox-menuconfig - Run BusyBox menuconfiguclibc: uclibc-menuconfig - Run uClibc menuconfiglinux: linux-menuconfig - Run Linux kernel menuconfig-----------------------------------------配置Linux并保存设置 linux-savedefconfig - Run Linux kernel savedefconfig linux-update-defconfig - Save the Linux configuration to the path specified by BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILEDocumentation: manual - build manual in all formats manual-pdf - build manual in PDF graph-build - generate graphs of the build times----------------------------------对编译时间、编译依赖、文件系统大小生成图标 graph-depends - generate graph of the dependency tree graph-size - generate stats of the filesystem size buildroot工作原理

  Buildroot原则上是一个自动构建框架,虽然说u-boot、linux kernel这些经典的开源软件包的构建脚本,官方社区都在帮你实现了,但是有时候你还是需要加入你自己特有的app_pkg软件包,用以构建自己的应用。

  buildroot的编译流程是先从dl/xxx.tar下解压出源码到output/build/xxx,然后它利用本身的配置文件(如果有的话)覆盖output/build/xxx下的配置文件,在开始编译连接完成后安装到output/相应文件夹下。

  Buildroot提供了函数框架和变量命令框架,采用它的框架编写的app_pkg.mk这种Makefile格式的自动构建脚本,将被package/pkg-generic.mk 这个核心脚本展开填充到buildroot主目录下的Makefile中去。最后make all执行Buildroot主目录下的Makefile,生成你想要的image。

  package/pkg-generic.mk中通过调用同目录下的pkg-download.mk、pkg-utils.mk文件,已经帮你自动实现了下载、解压、依赖包下载编译等一系列机械化的流程。你只要需要按照格式写Makefile脚app_pkg.mk,填充下载地址,链接依赖库的名字等一些特有的构建细节即可。

  总而言之,Buildroot本身提供构建流程的框架,开发者按照格式写脚本,提供必要的构建细节,配置整个系统,最后自动构建出你的系统。
  
  buildroot/packages里面有丰富的应用软件的配置文件,可以通过make menuconfig,出现图形化界面进行选择丰富的开源软件包的编译和构建。
  对buildroot的配置通过Config.in串联起来,起点在根目录Config.in中:

配置选项Config.in位置Target optionsarch/Config.inBuild optionsConfig.inToolchaintoolchain/Config.inSystem configurationsystem/Config.inKernellinux/Config.inTarget packagespackage/Config.inTargetpackages->BusyboxFilesystem imagesfs/Config.inBootloadersboot/Config.inHost utilitiespackage/Config.in.hostLegacy config optionsConfig.in.legacy配置Kernel内核

  对Linux内核的配置包括两部分:通过make menuconfig进入Kernel对内核进行选择,通过make linux-menuconfig对内核内部进行配置。

内核配置

  进入buildroot目录,输入make menuconfig,选然后选择Kernel进行配置,如图:

“Kernel version”选择内核的版本;“Defconfig name”选择内核config文件;“Kernel ysdlrary formant”选择内核格式;“Device tree source file names”选择DT文件;“Linux Kernel Tools”中选择内核自带的工具,比如perf;可以选择“Custom Git repository”来指定自己的Git库,在“Custom repository version”中指定branch名称。选择“Using an in-tree defconfig file”,在“Defconfig name”中输入defconfig名称,注意不需要末尾_defconfig。选择“Use a device tree present in the kernel”,在“Device Tree Source file names”中输入dts名称,不需要.dts扩展名。“Kernel ysdlrary format”可以选择vmlinux或者uImage。
uImage是uboot专用的映像文件,它是在zImage之前加上一个长度为64字节的“头”,说明这个内核的版本、加载位置、生成时间、大小等信息;其0x40之后与zImage没区别。
zImage是ARM Linux常用的一种压缩映像文件,uImage是U-boot专用的映像文件,它是在zImage之前加上一个长度为0x40的“头”,说明这个映像文件的类型、加载位置、生成时间、大小等信息。
vmlinux编译出来的最原始的内核elf文件,未压缩。
zImage是vmlinux经过objcopy gzip压缩后的文件, objcopy实现由vmlinux的elf文件拷贝成纯二进制数据文件。
uImage是U-boot专用的映像文件,它是在zImage之前加上一个长度为0x40的tag。
选择vmlinux和uImage的区别在于: PATH="/ysdlr..." BR_BINARIES_DIR=/home/.../output/images /usr/ysdlr/make -j9 HOSTCC="/usr/ysdlr/gcc" HOSTCFLAGS="" ARCH=csky INSTALL_MOD_PATH=/home/.../output/target CROSS_COMPILE="/home/.../output/host/ysdlr/csky-abiv2-linux-" DEPMOD=/home/.../output/host/sysdlr/depmod INSTALL_MOD_STRIP=1 -C /home/.../linux uImage

  如果是vmlinux,在结尾就是vmlinux。

内核内部配置

  通过make linux-menuconfig可以对内核内部细节进行配置。
  让Linux内核带符号表:

CONFIG_COMPILE_TEST is not set CONFIG_DEBUG_INFO=y 配置文件系统 对目标板文件系统内容进行配置主要通过make menuconfig进入Target packages进行。在Filesystem images中配置文件系统采用的格式,以及是否使用RAM fs。 配置Uboot

  使用uboot作为bootloader,需要进行一些配置。
  在选中U-boot作为bootloader之后,会弹出一系列相关配置。

“U-Boot board name”配置configs的defconfig名称。“U-Boot Version”选择Custom Git repository,然后在“URL of custom repository”中选择自己的git地址,并在“Custom repository version”中选择git的分支。在“U-Boot ysdlrary format”中选择想要输出的image格式,比如u-boot.img或者u-image.ysdlr。还可以选择“Intall U-Boot SPL ysdlrary image”,选择合适的SPL。

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。