Development: Toolchain - themactep/thingino-firmware GitHub Wiki

Development: Toolchain

This section explains the toolchain, which is a set of tools used to compile (build) the firmware. Buildroot handles compiling this toolchain automatically as part of the firmware-building process. It's set up using these specific settings in the Buildroot configuration file:

BR2_TOOLCHAIN_BUILDROOT_VENDOR="thingino"
BR2_TOOLCHAIN_BUILDROOT_MUSL=y
BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_3_10=y
BR2_BINUTILS_VERSION_2_44_X=y
BR2_GCC_VERSION_14_X=y
BR2_TOOLCHAIN_BUILDROOT_CXX=y

Speeding Up the Build Process

To make building faster, you can compile the toolchain once and reuse it for future builds. This saves a lot of time because you don't have to recompile it every time.

Here's how:

  1. Run this command to create a toolchain bundle (called an SDK):

    make sdk
    

    The resulting bundle will reside in the images subdirectory, e.g. ~/output/images/mipsel-thingino-linux-musl_sdk-buildroot.tar.gz

  2. Extract the bundle to a local directory and update the toolchain for the new path.

    mkdir -p ~/opt/toolchains/thingino-musl-gcc14
    cd ~/opt/toolchains/thingino-musl-gcc14
    tar xvf ~/output/images/mipsel-thingino-linux-musl_sdk-buildroot.tar.gz
    ./relocate-sdk.sh
    
  3. Update your Buildroot configuration to use this pre-compiled toolchain. Add or change these lines:

    BR2_TOOLCHAIN_EXTERNAL=y
    BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y
    BR2_TOOLCHAIN_EXTERNAL_PATH="/opt/toolchains/thingino-musl-gcc14"
    BR2_TOOLCHAIN_EXTERNAL_PREFIX="mipsel-linux"
    BR2_TOOLCHAIN_EXTERNAL_GCC_14=y
    BR2_TOOLCHAIN_EXTERNAL_HEADERS_3_10=y
    BR2_TOOLCHAIN_EXTERNAL_CUSTOM_UCLIBC=y
    # BR2_TOOLCHAIN_EXTERNAL_HAS_THREADS_DEBUG is not set
    # BR2_TOOLCHAIN_EXTERNAL_CXX=n
    
  • The BR2_TOOLCHAIN_EXTERNAL_PATH points to where the SDK is installed on your machine (you might need to adjust the path).

Sharing the Toolchain Across Machines

If you want to use the same toolchain on multiple computers, you can upload the SDK bundle to a shared location (like a server or file host) and tell Buildroot to download it from there.

Update your Buildroot configuration like this:

BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y
BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y
BR2_TOOLCHAIN_EXTERNAL_URL="http://192.168.1.61/thingino-toolchain-musl-gcc14.tar.gz"
BR2_TOOLCHAIN_EXTERNAL_HEADERS_3_10=y
BR2_TOOLCHAIN_EXTERNAL_CUSTOM_MUSL=y
BR2_TOOLCHAIN_EXTERNAL_GCC_14=y
#BR2_TOOLCHAIN_EXTERNAL_CXX=y
BR2_INSTALL_LIBSTDCPP=n
  • Replace the BR2_TOOLCHAIN_EXTERNAL_URL with the actual web address where you've uploaded the toolchain file.
  • This way, Buildroot will download and use the toolchain automatically during the build.