buildroot使用记录.

2024-08-28 06:58
文章标签 使用 记录 buildroot

本文主要是介绍buildroot使用记录.,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

集成的开发环境

靠 config.in 串联起来

 

         举例添加lighttpd web server

  1. Make menuconfig

 

 

 

 

Make help

 

 

Cleaning:

  clean                  - delete all files created by build

  distclean              - delete all non-source files (including .config)

 

Build:

  all                    - make world

  toolchain              - build toolchain

  sdk                    - build relocatable SDK

 

Configuration:

  menuconfig             - interactive curses-based configurator

  nconfig                - interactive ncurses-based configurator

  xconfig                - interactive Qt-based configurator

  gconfig                - interactive GTK-based configurator

  oldconfig              - resolve any unresolved symbols in .config

  silentoldconfig        - Same as oldconfig, but quietly, additionally update deps

  olddefconfig           - Same as silentoldconfig but sets new symbols to their default value

  randconfig             - New config with random answer to all options

  defconfig              - New config with default answer to all options;

                             BR2_DEFCONFIG, if set on the command line, is used as input

  savedefconfig          - Save current config to BR2_DEFCONFIG (minimal config)

  allyesconfig           - New config where all options are accepted with yes

  allnoconfig            - New config where all options are answered with no

  alldefconfig           - New config where all options are set to default

  randpackageconfig      - New config with random answer to package options

  allyespackageconfig    - New config where pkg options are accepted with yes

  allnopackageconfig     - New config where package options are answered with no

 

Package-specific:

  <pkg>                  - Build and install <pkg> and all its dependencies

  <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

  <pkg>-reconfigure      - Restart the build from the configure step

  <pkg>-rebuild          - Restart the build from the build step

 

busybox:

  busybox-menuconfig     - Run BusyBox menuconfig

 

uclibc:

  uclibc-menuconfig      - Run uClibc menuconfig

 

uboot:

  uboot-menuconfig       - Run U-Boot menuconfig

  uboot-savedefconfig    - Run U-Boot savedefconfig

  uboot-update-defconfig - Save the U-Boot configuration to the path specified

                             by BR2_TARGET_UBOOT_CUSTOM_CONFIG_FILE

 

linux:

  linux-menuconfig       - Run Linux kernel menuconfig

  linux-savedefconfig    - Run Linux kernel savedefconfig

  linux-update-defconfig - Save the Linux configuration to the path specified

                             by BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE

 

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)

 

Miscellaneous:

  source                 - download all sources needed for offline-build

  external-deps          - list external packages used

  legal-info             - generate info about license compliance

  printvars              - dump all the internal variables

 

  make V=0|1             - 0 => quiet build (default), 1 => verbose build

  make O=dir             - Locate all output files in "dir", including .config

 

make linux-rebuild

make uboot-rebuild

make linux-rebuild all

make <package> -rebuild

make <package> -reconfigure

make <package>

 

make --debug=all

 

make -p MAKE_LOCAL

 

make libopenssl-rebuild

 

 

make source:只载以前在配置器(menuconfig,nconfig,xconfig或gconfig)中选择的所有源

模块编译裁剪举例(openssl)

       在嵌入式平台上,如果使用openssl的标准方法,编译出来的libcrypto.solibssl.so会比较大,大约为2.1M多和436K,为了节省空间,可以使用如下方法进行裁剪:
 

1、静态库:
./config--prefix=/home/zqjun/openssl5350 no-shared no-zlib no-asm no-threads no-sse2no-compno-dso no-gmp no-rfc3779 no-krb5 no-rc5 no-zlib-dynamic
 no-hw no-cipherno-md2 no-md4 no-mdc2 no-rc2 no-idea no-camellia no-ec no-ecdsa no-ecdhno-store no-ripemd no-des no-rc4 no-bf no-cast no-dsa no-dh no-ssl no-ssl2 no-ssl3 no-tls no-perlasm
 
2
、动态库:
.config--prefic=/home/zqjun/openssl5350
shared no-zlib no-asm no-threads no-sse2 no-compno-gmp no-rfc3779 no-krb5 no-rc5 no-zlib-dynamic no-hw no-cipher no-md2 no-md4 no-mdc2no-rc2 no-idea no-camellia no-ec no-ecdsa no-ecdh no-store no-ripemd no-des no-rc4no-bf no-cast no-dsa no-dh no-ssl
 no-ssl2 no-ssl3 no-tls no-perlasm

注意:
1、动态编译时不能出现no-dso参数,因为编译过程中有些函数需要链接相应动态库。
2、编译完成后使用XXX-strip把相应的符号去掉,安装后的库会更小一些。
创建出Makefile后,再按照上面编译时的修改方法修改makefile中相应的参数值就可以了

 

 

修改libopenssl.mk

 

补丁文件的生成:

diff -uprN  a/xxx.h b/xxx.h > xxx.patch

 

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 options  arch/Config.in

Build options   Config.in

Toolchain toolchain/Config.in

System configuration  system/Config.in

Kernel linux/Config.in

Target packages package/Config.in

Target packages->Busybox

Filesystem images  fs/Config.in

Bootloaders  boot/Config.in

Host utilities  package/Config.in.host

Legacy config options Config.in.legacy

配置Kernel内核

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

 

内核配置

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

 

 

“Kernel version”选择内核的版本;

“Defconfig name”选择内核config文件;

“Kernel binary 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 binary 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="/bin..."

   BR_BINARIES_DIR=/home/.../output/images /usr/bin/make -j9

   HOSTCC="/usr/bin/gcc"

   HOSTCFLAGS=""

   ARCH=csky

   INSTALL_MOD_PATH=/home/.../output/target

   CROSS_COMPILE="/home/.../output/host/bin/csky-abiv2-linux-"

   DEPMOD=/home/.../output/host/sbin/depmod

   INSTALL_MOD_STRIP=1 -C /home/.../linux uImage

1

 

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

 

内核内部配置

  通过make linux-menuconfig可以对内核内部细节进行配置。

  让Linux内核带符号表:

 

    CONFIG_COMPILE_TEST is not set

    CONFIG_DEBUG_INFO=y

1

2

配置文件系统

对目标板文件系统内容进行配置主要通过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 binary format”中选择想要输出的image格式,比如u-boot.img或者u-image.bin。

还可以选择“Intall U-Boot SPL binary image”,选择合适的SPL。

 

buildroot编译出来的目标文件大多是stripped的。

buildroot/Config.in

注意 BR2_STRIP_strip 默认是选中的

makemenuconfig 可以看到选项情况

第3行定义 BR2_STRIP_strip ,你的buildroot使能了strip

第4行定义 BR2_STRIP_EXCLUDE_DIRS , test目录是strip的例外目录

 

编译时判断的6个标识文件,需要重新执行对应步骤时删除。

.stamp_built

.stamp_configured

.stamp_downloaded

.stamp_extracted

.stamp_patched

.stamp_target_installed

 

这篇关于buildroot使用记录.的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1114050

相关文章

Java中String字符串使用避坑指南

《Java中String字符串使用避坑指南》Java中的String字符串是我们日常编程中用得最多的类之一,看似简单的String使用,却隐藏着不少“坑”,如果不注意,可能会导致性能问题、意外的错误容... 目录8个避坑点如下:1. 字符串的不可变性:每次修改都创建新对象2. 使用 == 比较字符串,陷阱满

Python使用国内镜像加速pip安装的方法讲解

《Python使用国内镜像加速pip安装的方法讲解》在Python开发中,pip是一个非常重要的工具,用于安装和管理Python的第三方库,然而,在国内使用pip安装依赖时,往往会因为网络问题而导致速... 目录一、pip 工具简介1. 什么是 pip?2. 什么是 -i 参数?二、国内镜像源的选择三、如何

使用C++实现链表元素的反转

《使用C++实现链表元素的反转》反转链表是链表操作中一个经典的问题,也是面试中常见的考题,本文将从思路到实现一步步地讲解如何实现链表的反转,帮助初学者理解这一操作,我们将使用C++代码演示具体实现,同... 目录问题定义思路分析代码实现带头节点的链表代码讲解其他实现方式时间和空间复杂度分析总结问题定义给定

Linux使用nload监控网络流量的方法

《Linux使用nload监控网络流量的方法》Linux中的nload命令是一个用于实时监控网络流量的工具,它提供了传入和传出流量的可视化表示,帮助用户一目了然地了解网络活动,本文给大家介绍了Linu... 目录简介安装示例用法基础用法指定网络接口限制显示特定流量类型指定刷新率设置流量速率的显示单位监控多个

JavaScript中的reduce方法执行过程、使用场景及进阶用法

《JavaScript中的reduce方法执行过程、使用场景及进阶用法》:本文主要介绍JavaScript中的reduce方法执行过程、使用场景及进阶用法的相关资料,reduce是JavaScri... 目录1. 什么是reduce2. reduce语法2.1 语法2.2 参数说明3. reduce执行过程

如何使用Java实现请求deepseek

《如何使用Java实现请求deepseek》这篇文章主要为大家详细介绍了如何使用Java实现请求deepseek功能,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 目录1.deepseek的api创建2.Java实现请求deepseek2.1 pom文件2.2 json转化文件2.2

python使用fastapi实现多语言国际化的操作指南

《python使用fastapi实现多语言国际化的操作指南》本文介绍了使用Python和FastAPI实现多语言国际化的操作指南,包括多语言架构技术栈、翻译管理、前端本地化、语言切换机制以及常见陷阱和... 目录多语言国际化实现指南项目多语言架构技术栈目录结构翻译工作流1. 翻译数据存储2. 翻译生成脚本

C++ Primer 多维数组的使用

《C++Primer多维数组的使用》本文主要介绍了多维数组在C++语言中的定义、初始化、下标引用以及使用范围for语句处理多维数组的方法,具有一定的参考价值,感兴趣的可以了解一下... 目录多维数组多维数组的初始化多维数组的下标引用使用范围for语句处理多维数组指针和多维数组多维数组严格来说,C++语言没

在 Spring Boot 中使用 @Autowired和 @Bean注解的示例详解

《在SpringBoot中使用@Autowired和@Bean注解的示例详解》本文通过一个示例演示了如何在SpringBoot中使用@Autowired和@Bean注解进行依赖注入和Bean... 目录在 Spring Boot 中使用 @Autowired 和 @Bean 注解示例背景1. 定义 Stud

使用 sql-research-assistant进行 SQL 数据库研究的实战指南(代码实现演示)

《使用sql-research-assistant进行SQL数据库研究的实战指南(代码实现演示)》本文介绍了sql-research-assistant工具,该工具基于LangChain框架,集... 目录技术背景介绍核心原理解析代码实现演示安装和配置项目集成LangSmith 配置(可选)启动服务应用场景