Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,37 @@ device (SD/eMMC card or USB/SATA disk) on target board or on host machine.

## Build Environment
--------------------
- **Docker-free build** with local ARM GNU Toolchain (recommended - no Docker required!)
- Cross-build in Debian Docker container hosted on x86 Ubuntu or any other distro for arm64 target
- Cross-build on x86 host machine running Debian 12 for arm64 target
- Native-build on ARM board running Debian for arm64 target

## Host system requirement

### Docker-Free Build (Recommended)
This fork supports building without Docker by using a locally downloaded ARM GNU Toolchain.
No root access or Docker installation required!

```bash
# One-time toolchain setup (downloads ~500MB ARM GCC toolchain)
bld toolchain-setup

# Or manually:
./tools/toolchain_manager setup

# Check toolchain status
bld toolchain-check
```

The toolchain will be automatically downloaded to `flexbuild/toolchain/` directory.
Supported GCC versions: 11.x, 12.x, 13.x, 14.x (default: 13.3.rel1)

### Docker-based Build (Alternative)
- Docker hosted on Ubuntu LTS host (e.g. 22.04, 20.04) or other any distro
Refer to [docker-setup](docs/FAQ-docker-setup.md)
User can run 'bld docker' to create a Debian docker and build it in docker.
- Debian 12 host

### Debian 12 Host
Refer to [host_requirement](docs/host_requirement.md)


Expand Down Expand Up @@ -82,6 +104,7 @@ Most used example with separate command:
bld apps -r debian:server -p LS # compile NXP-specific components against the runtime dependencies of Debian Server rootfs for LS machines
bld ml [ -r <type> ] # compile NXP-specific eIQ AI/ML components against the library dependencies of Debian rootfs
bld merge-apps [ -r <type> ] # merge NXP-specific components into target Debian rootfs (Desktop by default,add '-r debian:server' for Server)
bld merge-bootpart-rfs [ -r <type> ] # merge boot partition files into target Debian rootfs
bld create_recovery_sdcard_image # Create Variscite recovery sd card (IMAGE_SIZE=5G IMAGE_NAME=example.img)
bld packrfs [ -r <type> ] # pack and compress target rootfs as rootfs_xx.tar.zst (or add '-r debian:server' for Server)
bld packapps [ -r <type> ] # pack and compress target app components as apps_xx.tar.zst (add '-p LS' for Layerscape platforms)
Expand All @@ -95,6 +118,8 @@ Most used example with separate command:
bld clean-linux # clean obsolete linux image
bld list # list enabled machines and supported various components
bld host-dep # automatically install the depended deb packages on host
bld toolchain-setup # download and setup local ARM toolchain (no Docker needed!)
bld toolchain-check # check if local toolchain is installed
```

## More info
Expand Down
14 changes: 11 additions & 3 deletions configs/sdk-var.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,16 @@ PKG_GROUPS_ROBOTICS: n
# default IMX if '-p' option is not specified, change to LS for Layerscape SoC
DEFAULT_SOC_FAMILY: IMX

# force build in docker environment
FORCE_BUILD_IN_DOCKER: y
# force build in docker environment (set to 'n' when using local toolchain)
FORCE_BUILD_IN_DOCKER: n

# Local toolchain configuration (eliminates Docker requirement)
# Run 'bld toolchain-setup' or './tools/toolchain_manager setup' to download
# Supported versions: 11.3.rel1, 12.2.rel1, 12.3.rel1, 13.2.rel1, 13.3.rel1
# NXP officially supports GCC 11.x, 12.x, 13.x - use 13.3.rel1 for best compatibility
USE_LOCAL_TOOLCHAIN: y
TOOLCHAIN_VERSION: "13.3.rel1"
TOOLCHAIN_DIR: $FBDIR/toolchain

# choose one of the 3 ways to fetch/update repo for various use cases
UPDATE_REPO_PER_TAG: y
Expand Down Expand Up @@ -82,7 +90,7 @@ repo:
# BSP component repositories
atf:
url: https://github.com/varigit/imx-atf.git
commit: bed39c167c883b335d5fc1046ce16e10a611b4c4
commit: 3b57a2b9cc3bb103f7ed5d044b1d1a8fcf3a42f6

uboot:
url: https://github.com/varigit/uboot-imx.git
Expand Down
2 changes: 1 addition & 1 deletion tools/distro_debian
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ build_distro_rfs_debian() {
fi

# clean cached packages
rm -f $RFSDIR/etc/resolv.conf
$sudopt rm -f $RFSDIR/etc/resolv.conf
$sudopt chroot $RFSDIR apt clean
$sudopt chroot $RFSDIR apt autoclean
$sudopt chroot $RFSDIR apt autoremove -y
Expand Down
96 changes: 88 additions & 8 deletions tools/flex-builder
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ Most used example with separate command:
bld packrfs [ -r <type> ] # pack and compress target rootfs as rootfs_xx.tar.zst (or add '-r debian:server' for Server)
bld packapps [ -r <type> ] # pack and compress target app components as apps_xx.tar.zst (add '-p LS' for Layerscape platforms)
bld repo-fetch [ <component> ] # fetch git repository of all or specified component from remote repos if not exist locally
bld toolchain-setup # download and setup local ARM toolchain (no Docker needed!)
bld toolchain-check # check if local toolchain is installed
bld docker # create or attach docker container to build in docker
bld docker-clean # stop and remove the docker container
bld clean # clean all obsolete firmware/linux/apps binary images except distro rootfs
Expand All @@ -65,31 +67,79 @@ EOF


check_toolchain() {
tc_version='11.x or 12.x or 13.x'
# Supported toolchain versions (local or system)
tc_version='11.x or 12.x or 13.x or 14.x'

# Check for local toolchain first (downloaded via toolchain_manager)
TOOLCHAIN_DIR="${TOOLCHAIN_DIR:-$FBDIR/toolchain}"
LOCAL_TOOLCHAIN_BIN="$TOOLCHAIN_DIR/bin"

if [ $DESTARCH = arm32 ] && [ $HOSTARCH = x86_64 -o $HOSTARCH = aarch64 -o $HOSTARCH = i686 ]; then
# Try local toolchain first
if [ -f "$LOCAL_TOOLCHAIN_BIN/arm-linux-gnueabihf-gcc" ]; then
gccversion=$("$LOCAL_TOOLCHAIN_BIN/arm-linux-gnueabihf-gcc" --version | head -1 | cut -d' ' -f4)
fbprint_n "Using local ARM32 toolchain: $gccversion"
export PATH="$LOCAL_TOOLCHAIN_BIN:$PATH"
export ARCH=arm
export CROSS_COMPILE=arm-linux-gnueabihf-
return 0
fi

# Fall back to system toolchain
[ -f /usr/bin/arm-linux-gnueabihf-gcc ] && gccversion=$(arm-linux-gnueabihf-gcc --version | head -1 | cut -d' ' -f4) || gccversion=0
if [ $gccversion = 0 ]; then
# Offer to download local toolchain instead of system install
if [ "$USE_LOCAL_TOOLCHAIN" = y ] || [ "$FORCE_LOCAL_TOOLCHAIN" = y ]; then
fbprint_w "Local toolchain not found. Run: ./tools/toolchain_manager setup"
exit 1
fi
fbprint_w "Installing toolchain for arm32 ..."
fbprint_w "TIP: For Docker-free builds, run: ./tools/toolchain_manager setup"
sudo apt-get install -y crossbuild-essential-armhf gcc-arm-linux-gnueabihf cpp-arm-linux-gnueabihf g++-arm-linux-gnueabihf
elif ! echo $tc_version | grep -q `echo $gccversion|cut -d. -f1` && [ $DISTROTYPE != buildroot ]; then
fbprint_w "Please build on Debian $DEBIAN_VERSION host or build in docker (run 'bld docker') to use the verified toolchain"
exit
fbprint_w "System toolchain version $gccversion may cause issues."
fbprint_w "TIP: For verified toolchain without Docker, run: ./tools/toolchain_manager setup"
if [ "$FORCE_LOCAL_TOOLCHAIN" = y ]; then
exit 1
fi
fi
export ARCH=arm
export CROSS_COMPILE=arm-linux-gnueabihf-

elif [ $DESTARCH = arm64 ] && [ $HOSTARCH = x86_64 -o $HOSTARCH = armv7l -o $HOSTARCH = i686 ]; then
# Try local toolchain first
if [ -f "$LOCAL_TOOLCHAIN_BIN/aarch64-linux-gnu-gcc" ]; then
gccversion=$("$LOCAL_TOOLCHAIN_BIN/aarch64-linux-gnu-gcc" --version | head -1 | cut -d' ' -f4)
fbprint_n "Using local ARM64 toolchain: $gccversion"
export PATH="$LOCAL_TOOLCHAIN_BIN:$PATH"
export ARCH=arm64
export CROSS_COMPILE=aarch64-linux-gnu-
return 0
fi

# Fall back to system toolchain
[ -f /usr/bin/aarch64-linux-gnu-gcc ] && gccversion=$(aarch64-linux-gnu-gcc --version | head -1 | cut -d' ' -f4) || gccversion=0
if [ $gccversion = 0 ]; then
# Offer to download local toolchain instead of system install
if [ "$USE_LOCAL_TOOLCHAIN" = y ] || [ "$FORCE_LOCAL_TOOLCHAIN" = y ]; then
fbprint_w "Local toolchain not found. Run: ./tools/toolchain_manager setup"
exit 1
fi
fbprint_w "Installing toolchain for arm64 ..."
fbprint_w "TIP: For Docker-free builds, run: ./tools/toolchain_manager setup"
sudo apt-get install -y crossbuild-essential-arm64 gcc-aarch64-linux-gnu g++-aarch64-linux-gnu binutils-aarch64-linux-gnu
elif ! echo $tc_version | grep -q `echo $gccversion | cut -d. -f1` && [ $DISTROTYPE != buildroot ]; then
fbprint_w "The existing toolchain version $gccversion on this host may result in build failure for some components."
fbprint_w "Please build on Debian $DEBIAN_VERSION or Ubuntu 22.04 host or build in docker (run 'bld docker') to use the verified toolchain version $tc_version"
exit
fbprint_w "System toolchain version $gccversion may cause issues."
fbprint_w "TIP: For verified toolchain without Docker, run: ./tools/toolchain_manager setup"
if [ "$FORCE_LOCAL_TOOLCHAIN" = y ]; then
exit 1
fi
fi
export ARCH=arm64
export CROSS_COMPILE=aarch64-linux-gnu-

elif [ $HOSTARCH = aarch64 -o $HOSTARCH = armv7l ]; then
# Native compilation on ARM
if [ $DESTARCH = arm32 ]; then
export ARCH=arm
elif [ $DESTARCH = arm64 ]; then
Expand Down Expand Up @@ -720,9 +770,28 @@ check_proxy() {
}

check_debian_version() {
# Skip Debian version check if local toolchain exists (regardless of USE_LOCAL_TOOLCHAIN setting)
TOOLCHAIN_DIR="${TOOLCHAIN_DIR:-$FBDIR/toolchain}"
if [ -d "$TOOLCHAIN_DIR/bin" ] && [ -f "$TOOLCHAIN_DIR/bin/aarch64-linux-gnu-gcc" ]; then
fbprint_n "Local toolchain detected, skipping Debian version check"
check_binfmt_qemu 2>/dev/null || true
return 0
fi

# Also skip if USE_LOCAL_TOOLCHAIN is set (toolchain will be downloaded on demand)
if [ "$USE_LOCAL_TOOLCHAIN" = y ]; then
fbprint_n "USE_LOCAL_TOOLCHAIN=y, toolchain will be downloaded if needed"
check_binfmt_qemu 2>/dev/null || true
return 0
fi

if [[ ! -f /etc/os-release ]] || [[ ! `cat /etc/issue | grep -iE '^Debian GNU/Linux 12'` ]]; then
if [ "$FORCE_BUILD_IN_DOCKER" = y -a "$FORCE" != y ]; then
fbprint_w "The host is not Debian 12 system, please install docker (refer to docs/FAQ-docker-setup.md) and run 'bld docker' to build in docker" && exit
fbprint_w "The host is not Debian 12 system."
fbprint_w "Options:"
fbprint_w " 1. Run 'bld toolchain-setup' to download local toolchain (no Docker needed)"
fbprint_w " 2. Install docker and run 'bld docker' to build in docker"
exit
fi
else
[ -f /usr/bin/lsb_release ] || sudo apt-get install -y lsb-release
Expand All @@ -731,7 +800,10 @@ check_debian_version() {
result=$(echo "$releaseVersion < $DEBIAN_VERSION" | bc)
if [ "$result" -eq "1" ]; then
fbprint_e "The distro version installed on this host is older than Debian $DEBIAN_VERSION"
fbprint_e "please upgrade it or install docker and run 'bld docker' to build in docker" && exit
fbprint_w "Options:"
fbprint_w " 1. Run 'bld toolchain-setup' to download local toolchain (no Docker needed)"
fbprint_w " 2. Install docker and run 'bld docker' to build in docker"
exit
else
check_binfmt_qemu
fi
Expand Down Expand Up @@ -1110,6 +1182,10 @@ elif [ "$1" = docker-clean ]; then
docker ps -a --format "{{.ID}} {{.Image}}" | grep '^.* fbdebian:' | awk '{print $1}' | xargs -r docker rm
echo "Done"
exit
elif [ "$1" = toolchain-setup ]; then
$FBDIR/tools/toolchain_manager setup; exit
elif [ "$1" = toolchain-check ]; then
$FBDIR/tools/toolchain_manager check; exit
elif [ "$1" = connect ]; then
host_connect_target $2 $3; exit
elif [ "$1" = disconnect ]; then
Expand Down Expand Up @@ -1238,6 +1314,10 @@ case "$1" in
generate_initrd_cpio; exit;;
toolchain)
build_distro_rfs_buildroot toolchain $DESTARCH; exit;;
toolchain-setup)
$FBDIR/tools/toolchain_manager setup; exit;;
toolchain-check)
$FBDIR/tools/toolchain_manager check; exit;;
boot)
generate_bootpartition_tarball; exit;;
auto|autobuild)
Expand Down
Loading