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

相关文章

Python使用FastAPI实现大文件分片上传与断点续传功能

《Python使用FastAPI实现大文件分片上传与断点续传功能》大文件直传常遇到超时、网络抖动失败、失败后只能重传的问题,分片上传+断点续传可以把大文件拆成若干小块逐个上传,并在中断后从已完成分片继... 目录一、接口设计二、服务端实现(FastAPI)2.1 运行环境2.2 目录结构建议2.3 serv

Spring Security简介、使用与最佳实践

《SpringSecurity简介、使用与最佳实践》SpringSecurity是一个能够为基于Spring的企业应用系统提供声明式的安全访问控制解决方案的安全框架,本文给大家介绍SpringSec... 目录一、如何理解 Spring Security?—— 核心思想二、如何在 Java 项目中使用?——

springboot中使用okhttp3的小结

《springboot中使用okhttp3的小结》OkHttp3是一个JavaHTTP客户端,可以处理各种请求类型,比如GET、POST、PUT等,并且支持高效的HTTP连接池、请求和响应缓存、以及异... 在 Spring Boot 项目中使用 OkHttp3 进行 HTTP 请求是一个高效且流行的方式。

Java使用Javassist动态生成HelloWorld类

《Java使用Javassist动态生成HelloWorld类》Javassist是一个非常强大的字节码操作和定义库,它允许开发者在运行时创建新的类或者修改现有的类,本文将简单介绍如何使用Javass... 目录1. Javassist简介2. 环境准备3. 动态生成HelloWorld类3.1 创建CtC

使用Python批量将.ncm格式的音频文件转换为.mp3格式的实战详解

《使用Python批量将.ncm格式的音频文件转换为.mp3格式的实战详解》本文详细介绍了如何使用Python通过ncmdump工具批量将.ncm音频转换为.mp3的步骤,包括安装、配置ffmpeg环... 目录1. 前言2. 安装 ncmdump3. 实现 .ncm 转 .mp34. 执行过程5. 执行结

Java使用jar命令配置服务器端口的完整指南

《Java使用jar命令配置服务器端口的完整指南》本文将详细介绍如何使用java-jar命令启动应用,并重点讲解如何配置服务器端口,同时提供一个实用的Web工具来简化这一过程,希望对大家有所帮助... 目录1. Java Jar文件简介1.1 什么是Jar文件1.2 创建可执行Jar文件2. 使用java

C#使用Spire.Doc for .NET实现HTML转Word的高效方案

《C#使用Spire.Docfor.NET实现HTML转Word的高效方案》在Web开发中,HTML内容的生成与处理是高频需求,然而,当用户需要将HTML页面或动态生成的HTML字符串转换为Wor... 目录引言一、html转Word的典型场景与挑战二、用 Spire.Doc 实现 HTML 转 Word1

Java中的抽象类与abstract 关键字使用详解

《Java中的抽象类与abstract关键字使用详解》:本文主要介绍Java中的抽象类与abstract关键字使用详解,本文通过实例代码给大家介绍的非常详细,感兴趣的朋友跟随小编一起看看吧... 目录一、抽象类的概念二、使用 abstract2.1 修饰类 => 抽象类2.2 修饰方法 => 抽象方法,没有

MyBatis ParameterHandler的具体使用

《MyBatisParameterHandler的具体使用》本文主要介绍了MyBatisParameterHandler的具体使用,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参... 目录一、概述二、源码1 关键属性2.setParameters3.TypeHandler1.TypeHa

Spring 中的切面与事务结合使用完整示例

《Spring中的切面与事务结合使用完整示例》本文给大家介绍Spring中的切面与事务结合使用完整示例,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友参考... 目录 一、前置知识:Spring AOP 与 事务的关系 事务本质上就是一个“切面”二、核心组件三、完