Buildroot cheatsheet

Just some of my notes...

I'll keep it updated with my notes when playing with buildroot.

How to properly store project-specific, non-mainline configs and such?

Use external tree.

How to add custom make target (eg. felboot)?

Put it in Common variables, such as $(BINARIES_DIR) are available there.

How to handle image configuration/customization?

Copy some defconfig you'd like to base on to your external tree configs/ directory, run make BOARD_defconfig in your build tree, use make menuconfig as you like, and then just make savedefconfig - this should update config you previously selected.

How to build specific kernel branch/commit?

Just like that:


How to use custom kernel configuration?

make linux-menuconfig does what it suggests.

make linux-savedefconfig will save current defconfig into build/linux-*/defconfig file. You can then use it with BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG, or clean it up by diffing it against arch/*/configs/, getting rid of some buildroot-internal changes and store it as BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES (this is what some default boards use)

How to use custom u-boot configuration?

Use BR2_TARGET_UBOOT_USE_CUSTOM_CONFIG and BR2_TARGET_UBOOT_CUSTOM_CONFIG_FILE, make uboot-defconfig should work as expected.

(Useful) Package-specific build targets

U-Boot FIT images?

Flattened Image Tree - These are essentially single-blob images containing multiple blobs that can be loaded by U-Boot, describe using Device Tree description language. These can be loaded from any storage device U-Boot supports (eg. MMC), and support many cool features, such as checksums, RSA signatures and multiple predefined "configs" (pick-and-match multiple sets of different images depending on running board and such...)

This requires CONFIG_FIT uboot configuration, as well as CONFIG_FIT_SIGNATURE, if using signatures. You'll most likely have to change default bootcmd, becuase boot.scr (legacy script) files are no longer recognized, as they can't be signed.

For plain FIT image builds just use this recipe. (copy these over to your board/*/ directory and set BR2_ROOTFS_POST_IMAGE_SCRIPT to its path.

For FIT with signatures use this one. Keep in mind this runs make uboot-rebuild at the end to rebuild uboot with public key embedded into its device tree blob. This is horrible and not really needed on every build, but works

You may have to modify uboot version in ${BUILD_DIR} path somewhere in that script.

To load these use something like:

load mmc 0 $ramdisk_addr_r image.itb
bootm $ramdisk_addr_r

To create keypair for signing (${KEYS_DIR}) use:

openssl genrsa -F4 -out keys/dev.key 2048
openssl req -batch -new -x509 -key keys/dev.key -out keys/dev.crt