设置buildroot overlays, buildroot自动生成的rootfs目录下, 通过overlay下的文件自动覆盖rootfs里的文件
设置 BR2_ROOTFS_OVERLAY:
Type : string Prompt: Root filesystem overlay directories Defined at system/Config.in:256 Location: -> System configuration
需要重新编译某个包,只需要到build/包名/.stamp_任务
$ ls build/busybox-1.21.1/.stamp_* build/busybox-1.21.1/.stamp_built build/busybox-1.21.1/.stamp_downloaded build/busybox-1.21.1/.stamp_patched build/busybox-1.21.1/.stamp_configured build/busybox-1.21.1/.stamp_extracted build/busybox-1.21.1/.stamp_target_installed
如busybox的任务,需要重新配置,删除.stamp_configured
使用out_of_build方式
首先在仓库外建立一个out_of_build/armv5te_build 目录
然后添加一个out_of_build.sh内容为
#!/bin/bash export BR_DEBUG_WRAPPER=1 export LC_ALL=C export LANG=C #export BUILDROOT_DL_DIR="下载目录位置" REPO_DIR=$(pwd)/../../buildroot_repos echo "make -C ${REPO_DIR} O=$(pwd) $@" make -C ${REPO_DIR} O=$(pwd) $@ #make manual-txt
运行 ./out_of_build.sh menuconfig 后,调用开始菜单进行配置,也可直接./out_of_build.sh help
查看现有的defconfig, 如选择 at91sam9261ek_defconfig
1. 使用 export LC_ALL=C export LANG=C 进行编译,否则会出现解压外部编译器提示错误 $(TOP_DIR)/toolchain/helpers.mk echo "External toolchain uses the unsuported OABI" ; 2. $(BASE_DIR) 为工程输出目录路径 BR2_ROOTFS_OVERLAY="$(BASE_DIR)/overlay1 $(BASE_DIR)/overlay2" BR2_ROOTFS_POST_BUILD_SCRIPT="$(BASE_DIR)/atmel/sama5d3ek_demo/post-build.sh" $(TOPDIR) 为buildroot的顶层目录 BR2_DEFCONFIG="$(CONFIG_DIR)/defconfig" 3. 排除要strip的文件或目录 BR2_STRIP_EXCLUDE_FILES="" BR2_STRIP_EXCLUDE_DIRS=""
重新构建target目录,只需要在 build目录下删除 .root 文件即可,隐藏文件
在fs/common.mk 中通过输出 buidl/_fakeroot.fs脚本,最后执行它处理makedevs等功能制作p_w_picpath
在构建目录下
$ cat .br-external
BR2_EXTERNAL ?= 绝对路径
若要切换其他EXTERNAL路径则删除些文件
添加外部扩展 BR2_EXTERNAL 目录内容, 参考rpi-buildroot Config.in 文件中添加 #-------------------------------------- menu "BR2_EXTERNAL select" source "$BR2_EXTERNAL/package/rpi/Config.in" endmenu #-------------------------------------- 在external.mk 中添加 #-------------------------------------- #include $(BR2_EXTERNAL)/*/*.mk include $(BR2_EXTERNAL)/package/*/*.mk #-------------------------------------- 在 package/rpi/Config.in 中修改 添加$BR2_EXTERNAL用于绝对路径支持找到扩展目录下的Config.in文件 #-------------------------------------- menu "Raspberry Pi" source "$BR2_EXTERNAL/package/rpi/rpi-config/Config.in" source "$BR2_EXTERNAL/package/rpi/rpi-firmware/Config.in" source "$BR2_EXTERNAL/package/rpi/rpi-userland/Config.in" source "$BR2_EXTERNAL/package/rpi/libuv/Config.in" endmenu #--------------------------------------
$(PKG)_CONF_OPT用于 configure选项
$(PKG)_CONF_ENV 区别于CONF_OPT, 用于环境变量用途
用于configure命令
define NET_TOOLS_CONFIGURE_CMDS
(cd $(@D); yes "" | ./configure.sh config.in )
endef
需要安装STAGING
$(PKG)_INSTALL_STAGING = YES
用于安装勾子
OPKG_POST_INSTALL_TARGET_HOOKS += OPKG_CREATE_LOCKDIR
补丁勾子
NTP_POST_PATCH_HOOKS += NTP_PATCH_FIXUPS
PKGCONF_POST_INSTALL_TARGET_HOOKS += PKGCONF_LINK_PKGCONFIG
HOST_PKGCONF_POST_INSTALL_HOOKS += HOST_PKGCONF_INSTALL_WRAPPER
LIBFOO_POST_DOWNLOAD_HOOKS LIBFOO_POST_EXTRACT_HOOKS LIBFOO_POST_RSYNC_HOOKS LIBFOO_PRE_PATCH_HOOKS LIBFOO_POST_PATCH_HOOKS LIBFOO_PRE_CONFIGURE_HOOKS LIBFOO_POST_CONFIGURE_HOOKS LIBFOO_POST_BUILD_HOOKS LIBFOO_POST_INSTALL_HOOKS (for host packages only) LIBFOO_POST_INSTALL_STAGING_HOOKS (for target packages only) LIBFOO_POST_INSTALL_TARGET_HOOKS (for target packages only) LIBFOO_POST_LEGAL_INFO_HOOKS
构建信息 $(TARGET_MAKE_ENV) , TARGET_AR $(@D)
define NET_TOOLS_BUILD_CMDS
$(TARGET_MAKE_ENV) AR="$(TARGET_AR)" CC="$(TARGET_CC)" \
LDFLAGS="$(NET_TOOLS_LDFLAGS)" $(MAKE) -C $(@D)
endef
$(PKG)_DEPENDENCIES += busybox 表示对应包需要的依赖
$(PKG)_CONF_ENV = \ac_cv_path_LIBGCRYPT_CONFIG=$(STAGING_DIR)/usr/bin/libgcrypt-config
$(STAGING_DIR) <<----
典型的编译helloword的示例
define DEVMEM2_EXTRACT_CMDS cp $(DL_DIR)/$($(PKG)_SOURCE) $(@D)/ endef define DEVMEM2_BUILD_CMDS $(TARGET_CONFIGURE_OPTS) $(MAKE) -C $(@D) devmem2 endef define DEVMEM2_INSTALL_TARGET_CMDS $(INSTALL) -D $(@D)/devmem2 $(TARGET_DIR)/sbin/devmem2 endef $(eval $(generic-package))
安装到STAGING的命令
define QWT_INSTALL_STAGING_CMDS $(MAKE) -C $(@D) install INSTALL_ROOT=$(STAGING_DIR) $(SED) "s%QWT_INSTALL_PREFIX = .*%QWT_INSTALL_PREFIX = $(STAGING_DIR)/usr%" \ $(STAGING_DIR)/usr/mkspecs/features/qwtconfig.pri endef
宿主机的configure参数 $(HOST_CONFIGURE_ARGS) \ $(HOST_CONFIGURE_OPTS 目标机的configure参数 $(TARGET_CONFIGURE_ARGS) \ $(TARGET_CONFIGURE_OPTS)
安装staging示例
TSLIB_AUTORECONF = YES TSLIB_INSTALL_STAGING = YES TSLIB_INSTALL_STAGING_OPT = DESTDIR=$(STAGING_DIR) LDFLAGS=-L$(STAGING_DIR)/usr/lib install
$(addprefix $(STAGING_DIR)/usr/lib/fonts/, $(addsuffix *.qpf, \ $(if $(BR2_PACKAGE_QT_FONT_MICRO),micro) \
如果选中某功能则选择安装某文件
$(PKG)_TARGETS_$(BR2_PACKAGE_ALSA_UTILS_ALSACONF) += usr/sbin/alsaconf
$(PKG)_CONFIG_SCRIPTS = imlib2-config
$(HOST_DIR)表示构建目录下宿主机工具 host/usr/bin/xxx
MKFS_JFFS2 = $(HOST_DIR)/usr/sbin/mkfs.jffs2
MTD_TARGETS_UBI_$(BR2_PACKAGE_MTD_UBIUPDATEVOL) += ubiupdatevol MTD_TARGETS_y += $(addprefix ubi-utils/,$(MTD_TARGETS_UBI_y)) MTD_TARGETS_$(BR2_PACKAGE_MTD_MKFSUBIFS) += mkfs.ubifs/mkfs.ubifs # only call make if atleast a single tool is enabled ifneq ($(MTD_TARGETS_y),) define MTD_BUILD_CMDS $(TARGET_CONFIGURE_OPTS) $(MAKE1) CROSS=$(TARGET_CROSS) \ BUILDDIR=$(@D) WITHOUT_XATTR=1 WITHOUT_LARGEFILE=1 -C $(@D) \ $(addprefix $(@D)/,$(MTD_TARGETS_y)) endef endif define MTD_INSTALL_TARGET_CMDS for f in $(MTD_TARGETS_y) ; do \ install -D -m 0755 $(@D)/$$f $(TARGET_DIR)/usr/sbin/$${f##*/} ; \ done endef
通过if来选择选项
PCRE_CONF_OPT += $(if $(BR2_PACKAGE_PCRE_16),--enable-pcre16,--disable-pcre16)
$(TARGET_CROSS)
to get the cross-compilation toolchain prefix$(SRCDIR)
: the path to the overridden source directory
LIBFOO_POST_DOWNLOAD_HOOKS LIBFOO_POST_EXTRACT_HOOKS LIBFOO_POST_RSYNC_HOOKS LIBFOO_PRE_PATCH_HOOKS LIBFOO_POST_PATCH_HOOKS LIBFOO_PRE_CONFIGURE_HOOKS LIBFOO_POST_CONFIGURE_HOOKS LIBFOO_POST_BUILD_HOOKS LIBFOO_POST_INSTALL_HOOKS (for host packages only) LIBFOO_POST_INSTALL_STAGING_HOOKS (for target packages only) LIBFOO_POST_INSTALL_TARGET_HOOKS (for target packages only) LIBFOO_POST_LEGAL_INFO_HOOKS
设置挂载位置
在/etc/fstab中添加 tmpfs /ramfs tmpfs mode=1777,size=64k 0 0
mkdir /ramfs/udisk
mkdir /ramfs/sddisk
BR_PATH为$(HOST_DIR)/usr/bin:....等组成
TARGET_MAKE_ENV=PATH=$(BR_PATH)
HOST_MAKE_ENV