Skip to content

Build Broadcom Opennsl and SAI

Ying Xie edited this page Dec 28, 2017 · 16 revisions

Intended audience

Almost all users could build SONiC image by following guide on Building Guide, except those who has access to Broadcom Opennsl and SAI source code and are working on bringing up a new SAI version.

Prepare build environment

  1. Clone SONiC Build Image Repo

  2. Make sure you are using a branch with pull request #1155, follow Building Guide to finish one full build of SONiC image. But when issuing make, make sure provide two options: KEEP_SLAVE_ON=yes SOURCE_FOLDER=<your source folder, e.g. /home/<username>/src>. (If you quit the build slave docker, you will have to repeat step 2-4 before each build).

  3. Inside the socket build slave, issue following command:

sudo apt-get -y install linux-kbuild-3.16 linux-compiler-gcc-4.8-x86

  1. cd to /sonic/target/debs, install following 2 debian packages into the build slave:

sudo dpkg -i linux-headers-*.deb

Build opennsl

  1. Start the SONiC build slave following instruction in step 2-4 of prepare build environment step.
  2. cd into /var/src
  3. You can choose to clone/unzip opennsl repo from inside the docker, or from your base image.
  4. If you cloned a git repo, make sure you check out the right branch to build. SAI and opennsl are tightly coupled, their versions needs to match.
  5. cd into the root of your opennsl repo, e.g. /var/src/opennsl/, issue fakeroot debian/rules -B binary to build opennsl debian packages. If the build failed with privilege error, use sudo fakeroot debian/rules -B binary to build. Build will take 30-45 minutes.
  6. When build succeeded, the built debian packages are stored at the folder one level above opennsl repo, in our case, /var/src/
  7. cd to /var/src, issue sudo dpkg -i libopennsl* to install the newly built opennsl debian packages to get ready for SAI compile.

Build SAI

  1. Start the SONiC build slave following instruction in step 2-4 of prepare build environment step.

  2. If you haven't succeeded in "Build opennsl", please do so first.

  3. cd /var/src

  4. clone/unzip SAI package here. Checkout the branch matches the opennsl if you cloned the SAI repo.

  5. cd into SAI repo root, say /var/log/sai/

  6. When building from source code packages directly downloaded from Broadcom, you need to setup environment variable OPENNSL_BASE, if you had to use 'sudo' to build opennsl in step 5, issue sudo bash and do everything afterwards as root.

    6.1 issue export OPENNSL_BASE=<opennsl source tree root, e.g. /var/log/opennsl>

  7. Issue fakeroot debian/rules -B binary to build SAI. This build should only take a minute or so.

  8. The built SAI debian pakcages will be at one level above SAI repo root, in this case /var/src/

Use newly created packages to build a new SONiC image

  1. Clone SONiC Build Image Repo
  2. Follow Building Guide, issue make init, make config PLATFORM=broadcom.
  3. copy the newly built opennsl and SAI debian packages to <build image repo root>/target/debs/
  4. Edit <build image repo root>/platform/broadcom/sdk.mk, change BRCM_OPENNSL_KERNEL to match the name of the new opennsl package.
  5. Edit <build image repo root>/platform/broadcom/sai.mk, change BRCM_SAI and BRCM_SAI_DEV respectively to match the new SAI packages names.
  6. Follow normal build procedure to build SONiC image.
Clone this wiki locally