[EN]
This projects aims to provide examples for building your project with Buildroot, adding custom packages inside and outside Buildroot's tree. For test purposes, qemu is used as the build target.
Instructions in english
NOTE: This should be always up to date. All the changes must be reflected AT LEAST on this README and on as many of the other languages as possible. Always update the hash/tag on README when making changes.
[BR] Esse projeto provê exemplos para adicionar seus projetos ao buildroot, tanto modificando diretamente a árvore do buildroot quanto fora dela, utilizando o qemu como plataforma. Instruções em português
NOTA: As instruções em BR podem estar desatualizadas. A página em EN deve ser a referência oficial. Verifique o hash/tag que o README aponta. Sempre que forem feitas mudanças, atualize o hash/tag caso o README também tenha sido atualizado.
Regardless of the approach to be used, buildroot needs to be cloned. If you do not wish to clone it inside this directory, change the paths accordingly.
- Clone buildroot from the oficial repository or from github mirror:
git clone https://git.buildroot.net/buildroot/ buildrootOR
git clone https://github.com/buildroot/buildroot.git buildroot- It is recommended to use the LTS version, rather than the most recent version as it may be unstable (check the LTS at the time):
cd buildroot
git checkout 2021.02.3 -b simon_game_buildroot
cd -There are two approaches one can use when building a Linux system with Buildroot. Its manual makes it clear that both options are valid and it is up to the user to chose the one which suits better its needs.
Both approaches assume the current directory is the root directory for this repository and setup was done as described on previous step.
-
Building with package inside Buildroot's tree is (IMO) the simplest form of adding a custom package to be compiled with Buildroot. This means cloning, copying or downloading Buildroot's source code and change its content to add the desired package, opposed to what is done when building using a package from outside BR's tree.
-
Building using a package outside Buildroot's tree means to have a custom package added to buildroot but do not need to change any folder inside Buildroot source itself, as opposed to what is done when building with a custom package inside BR's tree. This method is presented on Buildroot's manual section 9.2.
- Copy the directory
package/simon-game/intobuildroot/package.
cp -r package/simon-game/ buildroot/package/- Move into the
buildroot/directory.
cd buildroot-
Edit the file
package/Config.in, addingsource "package/simon-game/Config.in"under themenu "Games"list. -
Create the base configuration for qemu.
make qemu_x86_64_defconfig- Open the interactive menu to configure the custom options.
make menuconfig-
Add the
simon-gamepackage, navigate toTarget packages > Gamesand selectsimon-game. -
Set the image size by moving back to the inicial page (press esc twice to go back one page) and entering
Filesystem images > exact sizeand set to120M. -
Build the distribution.
makeThe build process takes some time (a few hours), once it is done check the Run/Flash imagee section.
- Move into the
buildroot/directory.
cd buildroot- Create the base configuration for qemu.
make qemu_x86_64_defconfig- Open the interactive menu to configure the custom options with the flag
BR2_EXTERNALpointing to the path where the external package files are located. In this example, they are located one level abovebuildroot/. IMPORTANT: If using different paths than setup, updateConfig.in,external.mkfiles and theBR2_EXTERNALflag on below command as appropriate.
make BR2_EXTERNAL=.. menuconfig-
Add the
simon-gamepackage, navigate toTarget packages > Gamesand selectsimon-game. -
Set the image size by moving back to the inicial page (press esc twice to go back one page) and entering
Filesystem images > exact sizeand set to120M. -
Build the distribution.
makeThe build process takes some time (a few hours), once it is done check the Run/Flash imagee section.
The image will be available under output/images directory. See the buildroot manual for additional instructions.
To run on qemu (which was the defconfig used on this tutorial), it is necessary to have the tool installed. On Ubuntu and other Debian based systems:
sudo apt install qemuThe image already provides a bash script to run qemu:
./output/images/start-qemu.shOnce qemu starts, it will load the environment and prompt to a login screen. The default login is root and no password is required.
Welcome to Buildroot
buildroot login:
Start the game. It is located on /usr/local/bin/simon-game-<PACKAGE_VERSION>/simon.py.
# python /usr/local/bin/simon-game-1.0.1/simon.py
If some other defconfig was used, i.e., a different board was the build target, a .iso file will be generated and can be copied to the device using dd.
NOTE: Replace <image_name> with the appropriate name of the file.
NOTE2: Replace <device_path> with the appropriate path to the USB device to be flased. Usually the device USB device is mounted under /dev/sdX where X is one of b, c, d... (DO NOT USE sda as this is usually the mount point for your sistem) or /dev/mmcblkN where N is one of 0, 1, 2....
dd if=output/images/<image_name>.iso of=<device_path>