Building AGL Development Enviornment on Mac: 2. Configure poky layers & bitbake for AGL
Set up Yocto layers for Automotive Grade Linux (AGL), configure local.conf and bblayers.conf, and run your first AGL bitbake build inside the Docker container.
Overview
In part 1 we set up Docker, created a persistent volume, exposed it via Samba, and started a poky container. Now we’ll use the dnangellight/agl-poky-dev:latest container specifically designed for AGL development to configure the Yocto layers, set up local.conf and bblayers.conf, and run your first bitbake build.
1. Start the AGL development container
Instead of the generic crops/poky container, use the AGL-specific development container with the shared volume:
docker run --rm -it -v myvolume:/workdir dnangellight/agl-poky-dev:latest --workdir=/workdirThis container comes pre-configured with all the tools and dependencies needed for AGL development, including git, curl, python3, and the repo tool.
You should see a prompt like:
agluser@<container-id>:/workdir$2. Verify required tools
The dnangellight/agl-poky-dev:latest container comes with all necessary AGL development tools pre-installed. Verify they are available:
curl --versiongit --versionpython3 --versionrepo --versionAll these commands should return version information without errors.
3. Initialize and sync the AGL workspace
Create a workspace directory and initialize the repo manifest. Replace <AGL_BRANCH> with your desired AGL release (e.g., octopus, needlefish):
cd /workdirmkdir agl-workspacecd agl-workspacerepo init -u https://gerrit.automotivelinux.org/gerrit/AGL/AGL-repo -b octopusFetch all layers defined in the manifest (this may take several minutes):
repo syncWhen complete, you’ll have a directory structure containing meta-agl, poky, and other required layers.
4. Set up the build environment
Source the AGL setup script to initialize the build environment. Replace <MACHINE> with your target (e.g., qemux86-64 for QEMU, raspberrypi4 for Raspberry Pi):
source meta-agl/scripts/aglsetup.sh -m qemux86-64 -b build agl-demo agl-develNotes:
-m qemux86-64: target machine type-b build: build directory nameagl-demo: includes AGL demo platform featuresagl-devel: includes development tools
After running this, you’ll be in the build directory with the environment configured.
5. Configure local.conf
Open conf/local.conf to adjust build settings:
vi conf/local.confIncrease parallelism for faster builds (adjust based on your Mac’s CPU cores):
BB_NUMBER_THREADS ?= "8"PARALLEL_MAKE ?= "-j 8"Set persistent download and shared state directories to speed up rebuilds:
DL_DIR ?= "/workdir/downloads"SSTATE_DIR ?= "/workdir/sstate-cache"Create these directories:
mkdir -p /workdir/downloads /workdir/sstate-cacheConfirm the machine and distro settings (usually auto-configured):
MACHINE ??= "qemux86-64"DISTRO ?= "poky-agl"Save and exit.
6. Run your first AGL build
With the environment configured, start the build:
bitbake agl-demo-platformNotes:
- The first build can take several hours depending on CPU and network speed
- Bitbake downloads source tarballs to
DL_DIRand shows tasks likedo_fetch,do_compile,do_install - Build artifacts will be in
tmp/deploy/images/<MACHINE>/ - If downloads fail, re-run the command; bitbake resumes from the last successful task
7. Locate and test the built image
After a successful build, find the output image:
ls tmp/deploy/images/qemux86-64/You should see files like agl-demo-platform-qemux86-64.wic, bzImage-qemux86-64.bin, and *.rootfs.ext4.
Test the image with QEMU (if available in the container):
runqemu qemux86-64This boots the AGL demo platform. To exit, press Ctrl-A, then X.
8. Incremental builds and cleanup
To rebuild after making changes:
bitbake agl-demo-platformBitbake only rebuilds changed tasks.
To force rebuild of a specific recipe:
bitbake -c cleansstate <recipe-name>bitbake <recipe-name>To clean the entire build and start fresh:
rm -rf tmp