Build SOF with Docker

This guide will show you how to use a Docker image containing the Sound Open Firmware build environment.

Note

The example uses ~/work/sof/ as the working directory.

Clone the sof repo.

cd ~/work/sof/
git clone https://github.com/thesofproject/sof.git

Set up Docker

Docker is a popular container management framework. To install on Ubuntu, visit Get Docker CE for Ubuntu.

Installation instructions for other Linux distributions: About Docker CE.

Set Proxy

Docker must be configured if used behind a proxy. Visit HTTP/HTTPS proxy for the guide.

Set user group

To use Docker without sudo follow these post-install steps. Post-installation steps for Linux

Get Docker image

To easily build SOF binaries, we need a Docker image containing all of the cross-compiler and build environment dependencies. We can either build a Docker image from a DockerFile or pull an image binary from Docker Hub.

Note

Building the container from DockerFile will take more than 2 hours, so we recommend using the pre-built image.

Pull Docker image

Pull the docker image from Docker Hub.

docker pull thesofproject/sof

Note

Since there is not yet an offical Sound Open Firmware presence on Dockerhub, the image is hosted in a personal Docker Hub repo until the official image can go live.

Retag the image with sof for scripts.

docker tag thesofproject/sof sof

Build Docker image

Run the Docker build from the sof repo.

cd ~/work/sof/sof/scripts/docker_build/sof_qemu
./docker-build.sh
cd ~/work/sof/sof/scripts/docker_build/sof_builder
./docker-build.sh

After building the Docker image you will see:

docker images
#REPOSITORY             TAG                 IMAGE ID            CREATED             SIZE
#sof                    latest              c8b0e8913fcb        2 days ago          1.46 GB

Build with Docker

Build firmware binaries

Build with scripts

Build the SOF binaries:

cd ~/work/sof/sof/
./scripts/docker-run.sh ./scripts/xtensa-build-all.sh -l

Note

./scripts/docker-run.sh will mount the sof and directories into Docker container and build them inside the container. The build result can be accessed outside the container after the build.

Note

The -l argument causes rimage to be installed in the local sof folder and does not change the container environment.

Build one or more platform binaries.

cd ~/work/sof/sof/
# Baytrail
./scripts/docker-run.sh ./scripts/xtensa-build-all.sh -l byt
# Baytrail and Apollo Lake
./scripts/docker-run.sh ./scripts/xtensa-build-all.sh -l byt apl

Build inside container

Enter the container bash.

cd ~/work/sof/sof/
./scripts/docker-run.sh bash

From inside the container, follow the manual configuration and build steps.

Firmware build results

The firmware binary files are located in src/arch/xtensa/. Copy them to your target machine’s /lib/firmware/intel/sof folder.

sof-apl.ri  sof-bdw.ri  sof-byt.ri  sof-cht.ri  sof-cnl.ri  sof-hsw.ri

Build topology and tools

Build with scripts

Build the sof tools and topology files.

cd ~/work/sof/sof/
./scripts/docker-run.sh ./scripts/build-tools.sh

Build inside container

Enter the container bash.

cd ~/work/sof/sof/
./scripts/docker-run.sh bash

From inside the container:

cd tools

and follow the manual configuration and build steps.

Topology and tools build results

The topology files are all in the topology folder (~/work/sof/sof/tools/build_tools/topology). Copy them to the target machine’s /lib/firmware/intel/sof-tplg folder.

The sof-logger tool is in the tools/logger folder. Copy it to the target machine’s /usr/bin directory.