This project is an infrastructure to help you manage a firmware project based on buildroot while respecting the best practices of configuration management with git.
If your project has no variants (you target only a single type of hardware), starting a new project is pretty simple:
git init
to initialize your new git repositorygit add common.mk Config.in external.mk Makefile LICENSE
git submodule add git://git.buildroot.net/buildroot buildroot
to clone buildroot in the proper subdirectory.cd buildroot
git checkout <version tag>
cd ..
git add buildroot
git commit
You now have an infrastructure that allows you to work on a project based on buildroot but that allows you to keep your changes cleanly separated from changes to buildroot itself.
All these mechanism are standard buildroot features that have been properly configured for you. Please refer to the buildroot documentation to learn more about them.
It is possible to have multiple projects built in the same directory using buildroot-submodule.
<new makefile>
)make -f <new makefile> <target>
to run make on that targetBy default, variants will share
But they will not share
Most of these choices are set via normal buildroot configuration options that you can override via menuconfig.
It is common, when developing a buildroot-based project, that you need to update some package provided by buildroot. buildroot-submodule tries to ease that process by separating buildroot changes from your code. The buildroot subdirectory is a normal buildroot clone on which you can work on upstreamable changes following best practices described in the buildroot documentation.
If the infrastructure provided by buildroot-submodule does not satify your use-case, you can change the infrastructure and we will gladly look at your changes and upstream them if they are good.
Note that the normal method of deploying buildroot-submodule does not clone buildroot-submodule. Cloning buildroot-submodule is a bad idea for normal developement because the git history of buildroot-submodule would pollute your own project's history.
buildroot-submodule is provided under the GPLv3 or later. The licence is provided in the LICENCE file. Note that this licence only covers the files provided by buildroot-submodule. It does not cover buildroot (which is GPLv2 or later) nor any software installed by buildroot (they have their own licences) nor your own code (which you are free to licence as you want).
One of the best ways to speed-up buildroot builds is to build the toolchain separately. buildroot-submodule can be used to simplify that process while still allowing you to build your toolchain using buildroot and using git to make sure all users of your project have the same toolchain configuration.
The idea is to make two variants of the same project, one to build the toolchain and one for the target filesystem, the second variant using the first one as an external toolchain
cp Makefile Makefile.toolchain
make -f Makefile.toolchain menuconfig
make -f Makefile.toolchain toolchain
make toolchain
you can now build your normal project and make clean won't erase the compiler entirely
The configuration decribed above does not include GDB in the toolchain, if you need it, follow the extra steps bellow (it can be done direcly).
make -f Makefile.toolchain menuconfig
make -f Makefile.toolchain
(note the full build: you need to build the gdb-server target package)make toolchain
One of the design goals of buildroot-submodule is to keep buildroot's absolutely rebuildable philosophy.
To properly use buildroot-submodule it is important to keep all relevant files under git. This includes
It is a highly recommanded practice to regularly rebuild your project from scratch
The following section is a simplified summary of the different ways to customize a buildroot build. Please refer to the buildroot documentation for more details
Buildroot provides a way to easily add or replace a file on the target filesystem. Adding the file in the overlay subdirectory will add the file to the target filesystem. For instance, adding a file overaly/etc/inittab will replace the inittab provided by buildroot with your custom version.
This is the recommended way to add custom configuration files to the target
If one of the packages provided by buildroot has a bug and you find a patch fixing the bug that hasn't been commited upstream (or that is only available in unreleased builds), you will want to have buildroot apply the patch automatically:
This is the recommanded way to integrate external patches. You should always consider the upstream status of patches and if upstreaming is possible.
If you need to add a package that is not part of buildroot you can do that externally to buildroot. There are a few cases where you might want to do that
If you are not in one of those cases, you probably want to upstream your changes to buildroot and work directly in the buildroot subdirectory.
To add a custom package
The new package and its options will appear in menuconfig.
Note that buildroot will usually fetch sources from version control servers, but is also able to fetch sources from a local directory or tarball. See the buildroot documentation for details.
If you need to modify the source code of a package provided by buildroot it is handy to have buildroot use a local, uncompressed copy of the sources instead of fetching from the internet.
This only applies for packages that are managed by buildroot proper. If the package is a custom package, you probably want to set the fetch method to local instead.
<packagename>_OVERRIDE_SRCDIR=$(BR2_EXTERNAL_BUILDROOT_SUBMODULE_PATH)/path/to/source
The variable _$(BR2_EXTERNAL_BUILDROOT_SUBMODULEPATH) will expand to the toplevel directory of your project. Note that packagename should be all cap here.
Buildroot will use these source instead of the version recommande by its own configuration but will still use its internal knowledge of the package to compile it.
Once your changes are ready you can regenerate the patch serie, including the patches Buildroot already integrates using git format patch
Usually, you want to customize your target filesystem by ovelaying files as described above in this document. But in some case it is not possible to use static files and running a shell script on the generated filesystem can be very handy.
Buildroot has a very complete infrastructure to generate documentation based on asciidoc This infrastructure can easily be reused to create your own documents. As per usual, please refer to the buildroot documentation for all the details. Here is a quick run-through
################################################################################
#
# foo-document
#
################################################################################
FOO_SOURCES = $(sort $(wildcard $(BR2_EXTERNAL_BUILDROOT_SUBMODULE_PATH)/foo/*))
$(eval $(call asciidoc-document))