首页 > 其他分享 >Buildroot使用记录

Buildroot使用记录

时间:2023-04-23 17:13:43浏览次数:38  
标签:Buildroot 记录 BR2 file 使用 DEVICE TABLE DIR ROOTFS

 关键词:rootfs、BR2_EXTERNAL等等。

 记录buildroot使用各种方法,以及解决的问题。

1 定制文件系统方法

1.1 根文件系统覆盖(BR2_ROOTFS_OVERLAY)

将BR2_ROOTFS_OVERLAY指向的目录覆盖到output/target根文件系统。还可以通过都好间隔,指定多个目录。

配置方式:

System configuration
    ->Root filesystem overlay directories

1.2 post-build脚本处理(BR2_ROOTFS_POST_BUILD_SCRIPT)

post-build脚本在所有buildroot编译结束之后,文件系统打包之前被调用。可以通过此脚本删除或者修改目标文件系统内容。

如果post-build脚本需要传入参数,可以通过BR2_ROOTFS_POST_SCRIPT_ARGS指定。

对其配置如下:

System configuration
    ->Custom scripts to run before creating filesystem images
    ->Extra arguments passed to custom scripts

在脚本中可能需要使用如下环境变量:

BR2_CONFIG: the path to the Buildroot .config file
CONFIG_DIR: the directory containing the .config file, and therefore the top-level Buildroot Makefile to use (which is correct for both in-tree and out-of-tree builds)
HOST_DIR, STAGING_DIR, TARGET_DIR: see Section 18.6.2, “generic-package reference”
BUILD_DIR: the directory where packages are extracted and built
BINARIES_DIR: the place where all binary files (aka images) are stored
BASE_DIR: the base output directory

1.3 rootfs skeleton

根文件系统是从一个skeleton开始的,然后逐渐将package编译结果安装到output/target中。

buildroot提供一个默认skeleton,以及增加自定义skeleton的方式。

System configuration
    ->Root FS skeleton
        ->default target skeleton
        ->custom target skeleton(BR2_ROOTFS_SKELETON_CUSTOM BR2_ROOTFS_SKELETON_CUSTOM_PATH )

1.4 创建设备以及设置文件权限和所属

1.4.1 BR2_ROOTFS_DEVICE_TABLE

BR2_ROOTFS_DEVICE_TABLE中定义了待执行的设备文件权限列表,多个列表可以通过逗号间隔:

System configuration
  ->/dev management
    ->Dynamic using devtmpfs + mdev(BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_MDEV) ->Path to the permission tables(BR2_ROOTFS_DEVICE_TABLE)

BR2_ROOTFS_DEVICE_TABLE的配置文件会被makedevs调用:

# See package/makedevs/README for details
#
# This device table is used to assign proper ownership and permissions
# on various files. It doesn't create any device file, as it is used
# in both static device configurations (where /dev/ is static) and in
# dynamic configurations (where devtmpfs, mdev or udev are used).
#
# <name>                <type>    <mode>    <uid>    <gid>    <major>    <minor>    <start>    <inc>    <count>
/dev                    d    755    0    0    -    -    -    -    -
/tmp                    d    1777    0    0    -    -    -    -    -
/etc                    d    755    0    0    -    -    -    -    -
/root                    d    700    0    0    -    -    -    -    -
/var/www                d    755    33    33    -    -    -    -    -
/etc/shadow                f    600    0    0    -    -    -    -    -
/etc/passwd                f    644    0    0    -    -    -    -    -
/etc/network/if-up.d            d    755    0    0    -    -    -    -    -
/etc/network/if-pre-up.d        d    755    0    0    -    -    -    -    -
/etc/network/if-down.d            d    755    0    0    -    -    -    -    -
/etc/network/if-post-down.d        d    755    0    0    -    -    -    -    -
/dev/null                c    666    0    0    1    3    -    -    -

在fs/common.mk中rootfs-common编译子命令将ROOTFS_DEVICE_TABLES内容写到ROOTFS_FULL_DEVICES_TABLE中:

rootfs-common: $(ROOTFS_COMMON_DEPENDENCIES) target-finalize
    @$(call MESSAGE,"Generating root filesystems common tables")
    rm -rf $(FS_DIR)
    mkdir -p $(FS_DIR)

    $(call PRINTF,$(PACKAGES_USERS)) >> $(ROOTFS_FULL_USERS_TABLE)
ifneq ($(ROOTFS_USERS_TABLES),)
    cat $(ROOTFS_USERS_TABLES) >> $(ROOTFS_FULL_USERS_TABLE)
endif

    $(call PRINTF,$(PACKAGES_PERMISSIONS_TABLE)) > $(ROOTFS_FULL_DEVICES_TABLE)
ifneq ($(ROOTFS_DEVICE_TABLES),)
    cat $(ROOTFS_DEVICE_TABLES) >> $(ROOTFS_FULL_DEVICES_TABLE)
endif
ifeq ($(BR2_ROOTFS_DEVICE_CREATION_STATIC),y)
    $(call PRINTF,$(PACKAGES_DEVICES_TABLE)) >> $(ROOTFS_FULL_DEVICES_TABLE)
endif

1.4.2 makedevs

makedevs使用方法:

makedevs: [-d device_table] rootdir

Creates a batch of special files as specified in a device table.
Device table entries take the form of:
name type mode user group major minor start increment count

Where name is the file name,  type can be one of:
      f       A regular file
      d       Directory
      r       Directory recursively
      c       Character special device file
      b       Block special device file
      p       Fifo (named pipe)
uid is the user id for the target file, gid is the group id for the target file.
The rest of the entries (major, minor, etc) apply to to device special files.
A '-' may be used for blank entries.

1.4.3 fakeroot调用makedevs

在fakeroot脚本中调用makedevs生成根文件系统:

/xxx/output/host/bin/makedevs -d /xxx/output/build/buildroot-fs/full_devices_table.txt /xxx/output/build/buildroot-fs/cpio/target

1.5 创建用户

BR2_ROOTFS_USERS_TABLES 配置用户列表,makeusers命令进行创建。配置方法:

System configuration
    ->Path to the users tables

1.6 post-image脚本

post-image脚本由BR2_ROOTFS_POST_IMAGE_SCRIPT 指定,在镜像生成之后执行。

配置方法:

System configuration
    ->Custom scripts to run after creating filesystem images

1.7 文件系统类型选择

进入make menuconfig->Filesystem images配置文件系统类型:

2 BR2_EXTERNAL

在Makefile中增加BR2_EXTERNAL定义,buildroot则会使用manu-folder中的配置:

export BR2_EXTERNAL=manu-folder

manu-folder中必须包含如下三个文件:

external.desc
external.mk
Config.in

external.desc中填写name和desc两个值:

name: xxx
desc: xxx board config

external.mk中定义了external的mk文件,可以通过include包括各package:

include $(sort $(wildcard $(BR2_EXTERNAL_XXX_PATH)/package/*/*.mk))

Config.in中提供了宏定义和选择。可以通过source将子目录Config.in包含:

source "package1/Config.in"
Source "package2/Config.in"

在make menuconfig的External options中进行配置选择。

除了以上三个文件,还可能包括如下目录:

board--存放不同board特有配置。
configs--存放defconfig。
package--存放新增package配置。

编译问题解决

问题1 Incorrect selection of kernel headers

>> toolchain-external-custom  Patching
>>> toolchain-external-custom  Configuring
Incorrect selection of kernel headers: expected 5.4.x, got 4.20.x
make[1]: *** [package/pkg-generic.mk:283: /xxx/output/build/toolchain-external-custom/.stamp_configured] Error 1
make: *** [Makefile:84: _all] Error 2

解决方法:

Toolchain->External toolchain kernel headers series->4.20.x

或者修改工具链的libc/usr/include/linux/version.h文件:

#define LINUX_VERSION_CODE 267277
#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))

 

比如所需要的版本为5.4.31,那么对应的16进制应为0x5041f,改成如下:

#define LINUX_VERSION_CODE 328735
#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))

 

标签:Buildroot,记录,BR2,file,使用,DEVICE,TABLE,DIR,ROOTFS
From: https://www.cnblogs.com/arnoldlu/p/17339727.html

相关文章

  • 一统天下 flutter - widget Sliver: SliverGrid - 网格(需要在 CustomScrollView 中使
    源码https://github.com/webabcd/flutter_demo作者webabcd一统天下flutter-widgetSliver:SliverGrid-网格(需要在CustomScrollView中使用)示例如下:lib\widget\sliver\sliver_grid.dart/**SliverGrid-网格(需要在CustomScrollView中使用)*/import'dart:......
  • 一统天下 flutter - widget Sliver: SliverAppBar/FlexibleSpaceBar - 可展开/收缩的
    源码https://github.com/webabcd/flutter_demo作者webabcd一统天下flutter-widgetSliver:SliverAppBar/FlexibleSpaceBar-可展开/收缩的标题栏(需要在CustomScrollView中使用)示例如下:lib\widget\sliver\sliver_app_bar.dart/**SliverAppBar/FlexibleSpaceBar......
  • springboot使用mybatis应用clickhouse
    一、clickhouse,说白了还是数据库,不一样的是clickhouse是列式存储,和传统的MySQL行式存储不同的地方在于,查询和所储。1)查询,行式和列式的区别,图形说明说明:理解上来说,行式对于一条数据的完整性索引会更快。而列式对于统计和查询指定数据会更加块。2)数据......
  • jQuery Ajax 实例 详细介绍$.ajax、$.post、$.get的使用
    Jquery在异步提交方面封装的很好,直接用AJAX非常麻烦需要处理浏览器之间的兼容问题,Jquery大大简化了我们的这些操作操作,不用在考虑浏览器这方面的问题,可以直接使用!$.post、$.get是一些简单的方法,如果要处理复杂的逻辑,还是需要用到jQuery.ajax() 一、$.ajax的一般格式$.ajax({......
  • Cookie禁用使用Session值方法
    Cookie禁用使用Session值方法:首先:    PHP中的Session在默认情况下是使用客户端的Cookie来保存SessionID的,所以当客户端的cookie出现问题的时候就会影响Session了。必须注意的是:Session不一定必须依赖Cookie,这也是Session相比Cookie的实用之处。当客户端的Cookie被禁用或出......
  • apisix网关使用自研插件流程
    1. 关于apisix网关插件apisix插件分为内置插件和自编插件,本文主要介绍使用自研插件的流程,内置插件使用方法参考官方文档内置插件官方文档:https://apisix.apache.org/zh/docs/apisix/plugins/batch-requests/2. 使用自研插件的实现步骤apisix支持多种语言自研插件,本文主要介......
  • 修改Git全部Commit提交记录的用户名Name和邮箱Email
    当我们换邮箱了,想把已经提交过的commit的邮箱和用户名改成新的时候。先把本地配置成新的gitconfiguser.name'丁少华'gitconfiguser.email'新邮箱@xx.com'这时候就可以用下面的脚本代码了在项目根目录下创建email.sh写入下面这段代码#!/bin/shgitfilter-branch......
  • 在C#中使用SQLite数据库
    轻量级桌面程序数据库不太适合用SQLServer、MySQL之类的重量级数据库,嵌入式数据库更好。在对比Access、SQLite、Firebird数据库后发现SQLite较另外两个有较多优点。环境:.NETFramework3.5、windows1164位、VisualStudio2010.C#使用SQLite需要从SQLite官网下载DLL组件。我是......
  • 04-23: dataclasses使用方法
    vehicle_seeds:List[int]=dataclasses.field(default_factory=list)dataclasses模块提供了一种简洁的方式来定义Python类在上面的代码中,使用dataclasses.field()函数为vehicle_seeds提供了一个默认工厂函数,该函数用于生成一个空的整数列表,即当vehicle_seeds没有被指......
  • 【c&c++】std::string::npos的使用
    std::string::nposstd::string::npos是一个常数,它等于size_type类型可以表示的最大值,用来表示一个不存在的位置,类型一般是std::container_type::size_type。定义staticconstsize_typenpos=-1;#include<iostream>intmain(intargc,char*argv[]){size_ta=-1......