4. Building Buildroot Packages

This document provides a step-by-step guide to building a Buildroot package. There are two ways you can build a package in buildroot.

  • Add existing Buildroot Packages

  • Add custom Packages

4.1. Adding Existing Buildroot Packages

4.1.1. Set Up Your Environment

Ensure you have the Buildroot repository and the buildroot-external-TI tree set up as described here Setting up the External Tree.

4.1.2. Enable Packages in the Buildroot Configuration

Run make menuconfig to enable the packages you have added in the Buildroot configuration.

$ make menuconfig
../_images/buildroot_menuconfig.png

Navigate to the relevant package categories and enable the desired packages. For nano and htop, you would typically find them under the Target packages menu.

  1. Go to Target packages.

  2. Navigate to Text editors and viewers and enable nano.

  3. Navigate to System tools and enable htop.

  4. Save and exit the menuconfig interface.

4.1.3. Build the Image

With the packages configured, you can now build the image. Buildroot will download, compile, and include the specified packages in the build process.

$ make

The build process can take some time, depending on your system’s resources and the complexity of the configuration.

4.1.4. Verify the Packages

After the build process is complete, verify that the packages are included in the output image. You can check the presence of the package binaries in the root filesystem.

$ find output/target -name nano
$ find output/target -name htop

You should see the paths to your package binaries, indicating that they were successfully included in the build.

By following these steps, you can add existing Buildroot packages. This approach allows you to leverage the extensive package repository of Buildroot.

4.2. Adding Custom Packages

4.2.1. Set Up Your Environment

Ensure you have the Buildroot repository and the buildroot-external-TI tree set up as described here Setting up the External Tree.

4.2.2. Understand the Package Directory Structure

In Buildroot, packages are typically organized into categories under the package/directory. When using an external tree, you can add new packages under the package/directory of the external tree.

4.2.3. Create the Package Directory

Inside the buildroot-external-TI directory, create a new directory for your package. For example, if you want to add a package named myapp:

$ cd buildroot-external-TI/
$ mkdir -p package/myapp

4.2.4. Create the Package Files

In the myapp directory, you need to create several files:

  • Config.in: Describes the configuration options for the package.

  • myapp.mk: Contains the build instructions for the package.

Example Config.in:

config BR2_PACKAGE_MYAPP
bool "myapp"
help
  MyApp is an example application.

Example myapp.mk

MYAPP_VERSION = 1.0
MYAPP_SITE = http://example.com/downloads
MYAPP_SOURCE = myapp-$(MYAPP_VERSION).tar.gz

define MYAPP_BUILD_CMDS
$(MAKE) -C $(@D)
endef

define MYAPP_INSTALL_TARGET_CMDS
$(INSTALL) -D -m 0755 $(@D)/myapp $(TARGET_DIR)/usr/bin/myapp
endef

$(eval $(generic-package))

4.2.5. Add the Package to Buildroot Configuration

Edit the Config.in file in the buildroot-external-TI directory to include your new package. Add the following line:

$ source "$BR2_EXTERNAL_TI_PATH/package/myapp/Config.in"

Also edit external.mk to include package mk file

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

4.2.6. Enable the Package in the Configuration

Run make menuconfig in the buildroot directory to enable your new package in the Buildroot configuration.

$ cd buildroot/
$ make menuconfig

Navigate to your package in the External Options menu and enable it. Save and exit the menuconfig interface.

../_images/buildroot_custom_package.png

4.2.7. Build the Package

With your package configuration set, build the image. Buildroot will download, compile, and include your new package in the build process.

$ make

4.2.8. Verify the Package

After the build process completes, verify that your package is included in the output image. You can check the presence of your package’s binaries in the root filesystem.

$ find output/target -name myapp

You should see the path to your package’s binary, indicating that it was successfully included in the build.

By following these steps, you can add and build custom packages in Buildroot using the buildroot-external-TI tree. This method provides a structured way to extend the functionality of Buildroot-based systems while keeping customizations organized and separate from the main Buildroot source.

For more detailed information and advanced package options, refer to the Buildroot manual. Buildroot manual.