-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Build Broadcom Opennsl and SAI
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.
- Clone SONiC Build Image Repo
- If you are using a branch with pull request #1155, follow Building Guide to finish one full build of SONiC image. But when issue make, make sure provide two options:
KEEP_SLAVE_ON=yes SOURCE_FOLDER=<your source folder, e.g. /home/<username>/src>
Then skip step 3-8, start following from step 9. - Edit buildimage repo root/Makefile, change DOCKER_RUN variable, remove option "--rm=true".
- Then follow Building Guide to finish one full build of SONiC image. This build takes long time, but some built packages are needed for next steps, so be patient.
- While the build is running, issue "docker ps" and note down the name of docker image "
sonic-slave-<user name>:<sha>
". The name is usually a two word combo, like "admiring_pare". - After build is done, the container will disappear from "docker ps", but will still be visible from "docker ps -a".
- check out Makefile to revert the change we made in step 2. We don't need to leave any other docker images behind.
- Restart the docker image and map your local source code repos in the docker image, suppose your source code repos are all under
/home/<user name>/src/
, following one of the following 2 commands to map this folder to /var/src in container:
docker run -t -i -v /home/<user name>/src:/var/src <image name, e.g. admiring_pare> bash
docker run -t -i -v /home/<user name>/src:/var/src sonic-slave-<user name>:<sha> bash
- Inside the socket build slave, issue following command:
sudo apt-get -y install linux-kbuild-3.16 linux-compiler-gcc-4.8-x86
- cd to /sonic/target/debs, install following 2 debian packages into the build slave:
sudo dpkg -i linux-headers-3.16.0-4-amd64_3.16.36-1+deb8u2_amd64.deb linux-headers-3.16.0-4-common_3.16.36-1+deb8u2_amd64.deb
- You can issue "docker rm <image name, e.g. admiring_pare>" to remove this image, when you are done with building SAI.
- Start the SONiC build slave following instruction in step 2 or 8 of previous step depending on your checkout point, if you haven't done so.
- cd into /var/src
- You can choose to clone/unzip opennsl repo from inside the docker, or from your base image.
- 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.
- 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, usesudo fakeroot debian/rules -B binary
to build. Build will take 30-45 minutes. - When build succeeded, the built debian packages are stored at the folder one level above opennsl repo, in our case, /var/src/
- cd to /var/src, issue
sudo dpkg -i libopennsl*
to install the newly built opennsl debian packages to get ready for SAI compile.
-
Start the SONiC build slave following instruction in step 2 or 8 of prepare build environment step depending on your checkout point, if you haven't done so.
-
If you haven't succeeded in "Build opennsl", please do so first.
-
cd /var/src
-
clone/unzip SAI package here. Checkout the branch matches the opennsl if you cloned the SAI repo.
-
cd into SAI repo root, say /var/log/sai/
-
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>
-
Issue
fakeroot debian/rules -B binary
to build SAI. This build should only take a minute or so. -
The built SAI debian pakcages will be at one level above SAI repo root, in this case /var/src/
- Clone SONiC Build Image Repo
- Follow Building Guide, issue
make init
,make config PLATFORM=broadcom
. - copy the newly built opennsl and SAI debian packages to
<build image repo root>/target/debs/
- Edit
<build image repo root>/platform/broadcom/sdk.mk
, change BRCM_OPENNSL_KERNEL to match the name of the new opennsl package. - Edit
<build image repo root>/platform/broadcom/sai.mk
, change BRCM_SAI and BRCM_SAI_DEV respectively to match the new SAI packages names. - Follow normal build procedure to build SONiC image.
-
For Users
-
For Developers
-
Subgroups/Working Groups
-
Presentations
-
Join Us