Skip to content

geftactics/buildroot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Buildroot

A Docker image for using Buildroot. It can be found on Docker Hub.

Quick Setup

Before start, be sure to set Docker Engine configuration on the host allows enough the disk space, processors and other resources. Number of processors and memory have a huge impact on the speed completion of the builds.

  1. Get a clone of this repo at your host:
git clone https://github.com/vidalastudillo/docker-buildroot
  1. Build the Docker image.
docker build -t buildroot .
  1. Create a data-only container to use as build and download cache and to store your build products.
docker run -i --name buildroot_output buildroot /bin/echo "Data only."

This container has 2 volumes at /root/buildroot/dl and /buildroot_output.

Buildroot downloads al data to the first volume, the last volume is used as build cache, cross compiler and build results.

Usage

A small script has been provided to make using the container a little easier.

It's located at scripts/run.sh. Instructions below show how to build a kernel for the Raspberry Pi using the a defconfig provided by Buildroot.

./scripts/run.sh make raspberrypi2_defconfig menuconfig
./scripts/run.sh make

Build products are stored inside the container at /buildroot_output/images. Because run.sh mounts the local folder images/ at this place the build products are also stored on the host.

External tree

To use the custom external tree using the mechanism described in the documentation related to the BR2_EXTERNAL environment variable, the following is required to be called once.

./scripts/run.sh make BR2_EXTERNAL=/root/buildroot/buildroot-external menuconfig

From now on, the menuconfig will be aware of the content of the external tree and its identification (By reading the external.desc content).

To verify the current settings, an inspection of the internal br2-external.mk can be done like this:

./scripts/run.sh make

And once inside the container:

cat /buildroot_output/.br2-external.mk

The mechanism related to BR2_EXTERNAL is helpful to reference the content of the tree in configuration files. For example, if the name defined in external.desc is MYRPI2CFG, then the BR2_EXTERNAL_MYRPI2CFG_PATH can be used to reference absolute paths.

This is useful to tell buildroot where to save the configuration selecting something like this in the menuconfig (Assuming the previous defined MYRPI2CFG name):

--> Build options --> Location to save buildroot config: $(BR2_EXTERNAL_MYRPI2CFG_PATH)/configs/my_defconfig
Exit menuconfig (choose yes to Save) and do:

To remove the external tree, an empty value can be used like this:

./scripts/run.sh make BR2_EXTERNAL='' menuconfig

Build with existing config

Once the external tree has been configured as described in the previous section (in order to make buildroot be aware of it), the available configurations can be queried like this:

./scripts/run.sh make list-defconfigs

To demonstrate its use, this repository contains a configuration to build a minimal root filesystem, with Python 3. This config is located at external/configs/docker_python3_defconfig.

Selecting that custom config, cleaning a previous build and making it can be accomplished like this:

./scripts/run.sh make docker_python3_defconfig
./scripts/run.sh make clean all
./scripts/run.sh make

A modified configuration can be saved using something like this (replacing the text 'mycustom'):

./scripts/run.sh make BR2_DEFCONFIG=/root/buildroot/buildroot-external/configs/mycustom_defconfig savedefconfig

Docker image from root filesystem

Import the root filesystem in to Docker to create an image run it and start a container.

docker import - dietfs < images/rootfs.tar
docker run --rm -ti dietfs sh

Creating packages from private git repositories:

The .mk can be defined like this when using Github:

THETEST_VERSION = main
THETEST_SITE = [email protected]:<your user name>/<repo name>
THETEST_SITE_METHOD = git

Refrain to use main on the final version, to prevent issues explained on the documentation.

To make that work, the container has to be able to connect through SSH to GitHub:

  1. Follow the documentation from GitHub about it.
  2. Place a folder named .ssh on the host computer with the generated identification and .PUB files to make those available to the container.

To test this, get into the container:

./scripts/run.sh make

Once there, you have to get successful responses to commands like this:

ssh [email protected]
git clone [email protected]:<your user name>/<repo name>

This has been produced thanks to the invaluable support of y_morin and troglobit from the #buildroot IRC Channel.

Tips

License

This software is licensed under Mozilla Public License. It is based on the original work by: © 2017 Auke Willem Oosterhoff and Advanced Climate Systems. It has been modified and extended by Mauricio Vidal from VIDAL & ASTUDILLO Ltda.

About

Buildroot OS, built inside docker environment

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published