完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
概述
buildroot用于嵌入式开发的整体编译环境,可以根据用户的配置,编译kernel,uboot,rootfs,用户的app等。并通过包含外部的Config.in,获取外部自定义的编译规则,进行编译。 网上大多数资料,均是在buildroot内部配置kernel、uboot、app,实际情况是,为了和buildroot源码独立开,自己的、或公司的代码均需要放在buildroot源码外部,本文即说明如果在buidlroot外部放置自己的代码及编译规则,并通过buildroot单编或整编。 配置 添加配置文件 法1:在configs下添加以_defconfig结尾的文件 编译: make xxx_defconfig 法2:直接拷贝自己的buildroot.config到buildroot/.config 编译:make 常用配置项说明 以下为常用的buildroot配置项: 1、BR2_TARGET_ROOTFS_XXXX:指定文件系统类型 例如BR2_TARGET_ROOTFS_JFFS2、BR2_TARGET_ROOTFS_EXT2 2、BR2_ROOTFS_OVERLAY:rootfs覆盖 该目录存放自己定制的rootfs,在buildroot制作完rootfs后,将拷贝overlay目录替换output下的部分文件。 3、BR2_TOOLCHAIN_EXTERNAL_PATH:指定交叉编译链路径 编译buildroot目录外的代码 目的: 创建两个目录:app, platform APP目录 app:存放buildroot,和平台无关的应用程序。 app目录结构体: app$ tree -L 1 . ├── buildroot ├── build.sh ├── Config.in ├── external.desc ├── external.mk ├── my_package ├── my_source ├── prebuilts └── rootfs_overlay buildroot: buildroot源码 build.sh:提供给外部调用(platform),最终进入buildroot make my_package: 放置自己包的编译规则 my_source: 放置自己包的源码 buildroot编译放在它的目录之外的源码时,需要提供以下几个文件: external.desc、external.desc、external.mk external.desc 指定外部编译的顶层目录 book@suns:~/ss_sdk/app$ cat external.desc name: MY_APP desc: my app external tree 其中,name是必须写出的,external.desc将导致buildroot/.config生成BR2_EXTERNAL_MY_APP_PATH BR2_EXTERNAL_MY_APP_PATH的值,是由:在app目录下执行: make -C ./buildroot/ BR2_EXTERNAL=/home/book/ss_sdk/app 得到的,即最终.config会写入: BR2_EXTERNAL_MY_APP_PAT Config.in 包含子目录的Config.in book@suns:~/ss_sdk/app$ cat ./Config.in source "$BR2_EXTERNAL_MY_APP_PATH/my_package/sstest/Config.in" external.mk 包含子目录的编译规则 book@suns:~/ss_sdk/app$ cat external.mk include $(sort $(wildcard $(BR2_EXTERNAL_MY_APP_PATH)/my_package/*/*.mk)) my_package 包含自己的包的编译规则 该目录下的子目录名字,必须buildroot.config中的BR2_PACKAGE_XXXX中的XXXX一致(大写变小写) 目录结构: book@suns:~/ss_sdk/app/my_package$ tree . └── sstest ├── Config.in └── sstest.mk 1 directory, 2 files 其中,sstest文件夹是我们需要添加的一个进程对应的编译规则。 Config.in: 告诉buildroot,本目录是BR2_PACKAGE_SSTEST对应的编译规则的目录。 book@suns:~/ss_sdk/app/koal_package/sstest$ cat Config.in config BR2_PACKAGE_SSTEST bool "sstest" help ss test module .mk book@suns:~/ss_sdk/app/koal_package/sstest$ cat sstest.mk ################################################################################ # # SSTEST # ################################################################################ SSTEST_VERSION = 1.0 SSTEST_SITE_METHOD = local SSTEST_SITE = $(BR2_EXTERNAL_MY_APP_PATH)/my_source/sstest SSTEST_LICENSE = Custom SSTEST_LICENSE_FILES = license.txt # Installs only a static library and a header file SSTEST_INSTALL_STAGING = YES SSTEST_INSTALL_TARGET = NO define SSTEST_BUILD_CMDS $(TARGET_MAKE_ENV) $(MAKE) -C $(@D) endef define SSTEST_INSTALL_STAGING_CMDS $(TARGET_CONFIGURE_OPTS) $(MAKE) PREFIX=$(STAGING_DIR) -C $(@D) install endef $(eval $(generic-package)) my_source 该目录下的子目录名字,必须buildroot.config中的BR2_PACKAGE_XXXX中的XXXX一致(大写变小写) 目录结构: book@suns:~/ss_sdk/app/koal_source$ tree . └── sstest ├── main.c └── Makefile 1 directory, 2 files platform目录 存放平台相关的代码,例如工具链、kernel、uboot的patch文件及配置文件等等。 外部交叉编译工具链 目的:使用外部的已经制作好的交叉编译工具链。 将工具链放在platfrom文件夹中,在buildroot配置文件中配置工具链。 buildroot配置 需要根据toolchain的规格进行配置,例如是glibc(较省flash)还是libc,工具链版本等等。 # # Toolchain # BR2_TOOLCHAIN=y BR2_TOOLCHAIN_USES_GLIBC=y # BR2_TOOLCHAIN_BUILDROOT is not set BR2_TOOLCHAIN_EXTERNAL=y # # Toolchain External Options # # BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_MIPS is not set # BR2_TOOLCHAIN_EXTERNAL_CODESCAPE_MTI_MIPS is not set # BR2_TOOLCHAIN_EXTERNAL_MUSL_CROSS is not set BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y # BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD is not set BR2_TOOLCHAIN_EXTERNAL_PREINSTALLED=y BR2_TOOLCHAIN_EXTERNAL_PATH="$(TOPDIR)/../prebuilts/toolchains/mips-gcc520-glibc222" BR2_TOOLCHAIN_EXTERNAL_CUSTOM_PREFIX="mips-linux-gnu" BR2_TOOLCHAIN_EXTERNAL_PREFIX="mips-linux-gnu" BR2_TOOLCHAIN_EXTERNAL_GLIBC=y # BR2_TOOLCHAIN_EXTERNAL_GCC_6 is not set BR2_TOOLCHAIN_EXTERNAL_GCC_5=y # BR2_TOOLCHAIN_EXTERNAL_GCC_4_9 is not set # BR2_TOOLCHAIN_EXTERNAL_GCC_4_8 is not set # BR2_TOOLCHAIN_EXTERNAL_GCC_4_7 is not set # BR2_TOOLCHAIN_EXTERNAL_GCC_4_6 is not set # BR2_TOOLCHAIN_EXTERNAL_GCC_4_5 is not set # BR2_TOOLCHAIN_EXTERNAL_GCC_4_4 is not set # BR2_TOOLCHAIN_EXTERNAL_GCC_4_3 is not set # BR2_TOOLCHAIN_EXTERNAL_HEADERS_4_8 is not set # BR2_TOOLCHAIN_EXTERNAL_HEADERS_4_7 is not set # BR2_TOOLCHAIN_EXTERNAL_HEADERS_4_6 is not set # BR2_TOOLCHAIN_EXTERNAL_HEADERS_4_5 is not set # BR2_TOOLCHAIN_EXTERNAL_HEADERS_4_4 is not set # BR2_TOOLCHAIN_EXTERNAL_HEADERS_4_3 is not set BR2_TOOLCHAIN_EXTERNAL_HEADERS_4_2=y # BR2_TOOLCHAIN_EXTERNAL_HEADERS_4_1 is not set # BR2_TOOLCHAIN_EXTERNAL_HEADERS_4_0 is not set # BR2_TOOLCHAIN_EXTERNAL_HEADERS_3_19 is not set # BR2_TOOLCHAIN_EXTERNAL_HEADERS_3_18 is not set # BR2_TOOLCHAIN_EXTERNAL_HEADERS_3_17 is not set # BR2_TOOLCHAIN_EXTERNAL_HEADERS_3_16 is not set # BR2_TOOLCHAIN_EXTERNAL_HEADERS_3_15 is not set # BR2_TOOLCHAIN_EXTERNAL_HEADERS_3_14 is not set # BR2_TOOLCHAIN_EXTERNAL_HEADERS_3_13 is not set # BR2_TOOLCHAIN_EXTERNAL_HEADERS_3_12 is not set # BR2_TOOLCHAIN_EXTERNAL_HEADERS_3_11 is not set # BR2_TOOLCHAIN_EXTERNAL_HEADERS_3_10 is not set # BR2_TOOLCHAIN_EXTERNAL_HEADERS_3_9 is not set # BR2_TOOLCHAIN_EXTERNAL_HEADERS_3_8 is not set # BR2_TOOLCHAIN_EXTERNAL_HEADERS_3_7 is not set # BR2_TOOLCHAIN_EXTERNAL_HEADERS_3_6 is not set # BR2_TOOLCHAIN_EXTERNAL_HEADERS_3_5 is not set # BR2_TOOLCHAIN_EXTERNAL_HEADERS_3_4 is not set # BR2_TOOLCHAIN_EXTERNAL_HEADERS_3_3 is not set # BR2_TOOLCHAIN_EXTERNAL_HEADERS_3_2 is not set # BR2_TOOLCHAIN_EXTERNAL_HEADERS_3_1 is not set # BR2_TOOLCHAIN_EXTERNAL_HEADERS_3_0 is not set # BR2_TOOLCHAIN_EXTERNAL_HEADERS_REALLY_OLD is not set # BR2_TOOLCHAIN_EXTERNAL_CUSTOM_UCLIBC is not set BR2_TOOLCHAIN_EXTERNAL_CUSTOM_GLIBC=y # BR2_TOOLCHAIN_EXTERNAL_CUSTOM_MUSL is not set BR2_TOOLCHAIN_EXTERNAL_HAS_SSP=y BR2_TOOLCHAIN_EXTERNAL_INET_RPC=y BR2_TOOLCHAIN_EXTERNAL_CXX=y # BR2_TOOLCHAIN_EXTERNAL_FORTRAN is not set BR2_TOOLCHAIN_EXTRA_EXTERNAL_LIBS="" # BR2_TOOLCHAIN_EXTERNAL_GDB_SERVER_COPY is not set 注意: 1、BR2_TOOLCHAIN_EXTERNAL_GCC_5:gcc版本号5开头,根据自己实际去配置 2、BR2_TOOLCHAIN_EXTERNAL_HAS_SSP:堆栈粉碎保护(Stack Smashing Protection) 3、BR2_TOOLCHAIN_EXTERNAL_INET_RPC:是否支持RPC,远程过程调用,主要用于NFS kernel源码编译 目的,使用外部的kernel源码进行编译。 kernel配置文件放在外部。 主要包括: 1、修改buildroot中kernel相关的配置项 2、开始进入buildroot编译前,将kernel源码拷贝到dl目录下 buildroot中对kernel的配置 buildroot.conf中kernel相关的配置如下: # # Kernel # BR2_LINUX_KERNEL=y # BR2_LINUX_KERNEL_LATEST_VERSION is not set BR2_LINUX_KERNEL_CUSTOM_VERSION=y # BR2_LINUX_KERNEL_CUSTOM_TARBALL is not set # BR2_LINUX_KERNEL_CUSTOM_GIT is not set # BR2_LINUX_KERNEL_CUSTOM_HG is not set # BR2_LINUX_KERNEL_CUSTOM_SVN is not set BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="linux" BR2_LINUX_KERNEL_VERSION="3.10.14" BR2_LINUX_KERNEL_PATCH="n" # BR2_LINUX_KERNEL_USE_DEFCONFIG is not set # BR2_LINUX_KERNEL_USE_ARCH_DEFAULT_CONFIG is not set BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="../../platform/configs/kernel.config" BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="" BR2_LINUX_KERNEL_UBOOT_IMAGE=y BR2_LINUX_KERNEL_UIMAGE=y # BR2_LINUX_KERNEL_VMLINUX_BIN is not set # BR2_LINUX_KERNEL_VMLINUX is not set # BR2_LINUX_KERNEL_VMLINUZ is not set # BR2_LINUX_KERNEL_VMLINUZ_BIN is not set # BR2_LINUX_KERNEL_IMAGE_TARGET_CUSTOM is not set # BR2_LINUX_KERNEL_GZIP is not set # BR2_LINUX_KERNEL_LZ4 is not set # BR2_LINUX_KERNEL_LZMA is not set # BR2_LINUX_KERNEL_LZO is not set # BR2_LINUX_KERNEL_XZ is not set # BR2_LINUX_KERNEL_DTS_SUPPORT is not set # BR2_LINUX_KERNEL_USE_INTREE_DTS is not set # BR2_LINUX_KERNEL_USE_CUSTOM_DTS is not set BR2_LINUX_KERNEL_INTREE_DTS_NAME="" # BR2_LINUX_KERNEL_INSTALL_TARGET is not set 其中: BR2_LINUX_KERNEL:决定是否编译kernel BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE:指定外部配置文件路径 BR2_LINUX_KERNEL_UIMAGE:编译出uImage BR2_LINUX_KERNEL_VERSION: 必须指定kernel版本号 BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE:该值-版本号就是dl下kernel源码包的名字,buildroot根据这个名字去dl下找源码包,并解压编译。 自定义编译规则 kernel的编译规则在buildroot/linux/linux.mk文件中指定 修改源码包的压缩格式 在linux.mk中找LINUX_SOURCE修改后缀。 uboot源码编译 待续。。。。 |
|
|
|
只有小组成员才能发言,加入小组>>
771 浏览 0 评论
1148 浏览 1 评论
2527 浏览 5 评论
2858 浏览 9 评论
移植了freeRTOS到STMf103之后显示没有定义的原因?
2709 浏览 6 评论
keil5中manage run-time environment怎么是灰色,不可以操作吗?
1058浏览 3评论
189浏览 2评论
453浏览 2评论
365浏览 2评论
M0518 PWM的电压输出只有2V左右,没有3.3V是怎么回事?
449浏览 1评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-19 06:01 , Processed in 1.029800 second(s), Total 50, Slave 41 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号