buildrootlayeredinitramfs

Buildroot configuration layering


I'm coming from yocto world, trying to experiment with buildroot for my small project. I would like to have configuration:

With yocto, you state initramfs image configuration, change configuration with the board to build it for - you will have both initramfs and main root images built for specific architecture.

I want to use similar approach for buildroot, according to buildroot documentation 9.1.1, there is support for layered configuration. I've tried following:

make initramfs_defconfig raspberrypi4_64_defconfig 
#
# configuration written to /home/buildroot/.config
#
#
# configuration written to /home/buildroot/.config
#

Only the last defconfig configuration is applied.

I see several potential options to solve it right away:

Both options would required creating some customization script, and explaining that custom steps for potential users. But maybe there is some way to make it working the way I want using built-in functionality? Because it seems like pretty basic requirement.

I believe it should work like this:

make initramfs_defconfig raspberrypi4_64_defconfig 
make

make mainroot_defconfig raspberrypi4_64_defconfig
make

Where mainroot_defconfig is configuration for all the packages I require to be installed, to avoid using menuconfig and doing it manually.


Solution

  • One solution to this problem you mentioned "using a custom merge script". This concept works.

    For example, the buildroot.rockchip repo supports many boards. They each have their own setupBoardName.sh script. Each of the boards have their own BSP configs and after that you can apply a common config.

    For example a setup file can be specified as follows, where br_defconfig will be the taget defconfig file to use with buildroot's make :

    ########## Begin external/setupBoardName.sh ###################
    # define the target defconfig, the common and SBC's BSP or "BOARD" defconfig
    BR_DEFCONFIG='br_defconfig'
    BR_COMMON_DEFCONFIG='common_defconfig'
    BR_BOARD_DEFCONFIG=boardName_defconfig
    
    # path buildroot to use the external dir which this setup script resides in
    DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
    CUSTOM_PATH=$DIR
    
    # concatenate defconfig files into the target BR_DEFCONFIG
    echo "###### DON'T EDIT THIS FILE, EDIT $BR_BOARD_DEFCONFIG or $BR_COMMON_DEFCONFIG INSTEAD" > $CUSTOM_PATH/configs/$BR_DEFCONFIG
    cat $BR_REPO_PATH/configs/$BR_COMMON_DEFCONFIG >> $CUSTOM_PATH/configs/$BR_DEFCONFIG
    cat $CUSTOM_PATH/configs/$BR_BOARD_DEFCONFIG >> $CUSTOM_PATH/configs/$BR_DEFCONFIG
    
    make BR2_EXTERNAL=$DIR $BR_DEFCONFIG
    ########## End external/setupBoardName.sh ###################
    

    Note, you should run the setupBoardName.sh script like so :

    source /fullPathTo1/setupBoardName.sh /fullPathTo2/buildroot
    

    Running the above command will land you in the fullPathTo/buildroot.Then you can make :

    make
    

    Your directory structure should be like so :

    /fullPathTo1/external :
      setupBoardName.sh
      configs/
      board/
      overlays/
      package/
    

    You will clone buildroot to the following location :

    /fullPathTo2/buildroot
    

    Some good examples of this type of buildroot external structure can be seen here buildroot.rockchip.