This section provides instructions to build your target image. After you build your image, follow the instructions in Exercise 1 - Deploy SONiC/PINS Target Image to Switches.
The following software is needed to build the image: curl, zip, unzip, tar, python, and j2cli. If you need to do a local build of the ONOS driver and SAI
pipeline, you will also need maven and a Java JDK.
- Clone the PINS/sonic-buildimage repository using one of the following:
- HTTPS:
git clone https://github.com/sonic-net/sonic-buildimage.git - SSH:
git clone git@github.com:sonic-net/sonic-buildimage.git - Github CLI:
gh repo clone sonic-net/sonic-buildimage
- HTTPS:
- Change to the new directory:
cd sonic-buildimage - Download submodules and checkout the correct commit number:
make init
Configure your build variables ($BUILD_VARS) on the command line or in the
rules/config file. Here are some examples:
- Debian Buster is the currently supported version; hence use
NOJESSIE=1 NOSTRETCH=1 - The default password for the admin user,
YourPaSsWoRd,should be overridden with a local value. - Setting the cache method,
SONIC_DPKG_CACHE_METHOD=rwcache, speeds up the build process (after the first time) by caching non-SONiC specific build products such as the Linux kernel. - Set
INCLUDE_P4RT=yto build the P4RT app and configure the image to run itINCLUDE_P4RTis the name in rules/configSONIC_INCLUDE_P4RT=yis used on the command line- Confirm by looking at the
INCLUDE_P4RTline in the build config when starting any build
Sample values for $DESIRED_PLATFORM are barefoot, broadcom, marvell, mellanox, cavium, centec, nephos, innovium, vs.
Run the make commands.
- Configure the desired platform.
$BUILD_VARS make configure PLATFORM=$DESIRED_PLATFORM - (Optional) Determine the target list for the configured PLATFORM.
$BUILD_VARS make list- Many individual software targets are listed, as well as the platform
target with the form:
target/sonic-$PLATFORM.binortarget/sonic-$PLATFORM.swi
- Many individual software targets are listed, as well as the platform
target with the form:
- Build the target.
$BUILD_VARS make target/sonic-$PLATFORM.bin
Examples:
NOJESSIE=1 NOSTRETCH=1 make configure PLATFORM=barefoot
NOJESSIE=1 NOSTRETCH=1 PASSWORD=passwd make target/sonic-barefoot.bin
- Individual logs and artifacts
- Deb target logs and artifacts will be in
target/deb/buster - Python Deb target logs and artifacts will be in
target/python-debs - Python Wheel target logs and artifacts will be in
target/python-wheels - Docker backup files and logs, and the actual switch target file and log
file will be in
target
- Deb target logs and artifacts will be in
- The first time you make a target will be very time-consuming. Use the
rwcacheoption to speed up subsequent makes. - Due to race conditions, the build may fail. However, if you rerun the make
command, it may succeed the second time. We have seen this for the
barefoottarget. - If an error occurs during SONiC build, try
make local_build_driverandmake local_build_pipeliner.
We tested with JDK 11 / Maven 3.6.3 installed. If you want to use a newer JDK, you may also need a more recent Maven version (e.g., try JDK 17 / Maven 3.8).-
Check the version of JDK:
java --version mvn --version -
To change version:
sudo update-java-alternatives -s java-1.11.0-openjdk-amd64 -
To install maven and jdk, if they aren’t installed:
sudo apt update sudo apt install maven sudo apt install openjdk-11-jdk-headless -
Build the driver and pipeliner locally:
sudo make local_build_driver local_build_pipeliner
-