Last active
February 23, 2021 11:34
-
-
Save CommitThis/7d68d6c7f088718bcbf8c07dc8b4c5b4 to your computer and use it in GitHub Desktop.
Stratum BMv2 Build Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env bash | |
if [[ "$UID" != "0" ]]; then | |
sudo $0 | |
exit | |
fi | |
export BMV2_COMMIT=498202d98d83a6c580aa86a3497b9b496bcd43b2 | |
export JDK_URL=https://mirror.bazel.build/openjdk/azul-zulu11.29.3-ca-jdk11.0.2/zulu11.29.3-ca-jdk11.0.2-linux_x64.tar.gz | |
export LLVM_REPO_NAME="deb http://apt.llvm.org/stretch/ llvm-toolchain-stretch main" | |
export JOBS=2 | |
export PATH=$PATH:/usr/local/lib/jvm/bin | |
export PI_COMMIT=0fbdac256151eb1537cd5ebf19101d5df60767fa | |
export BMV2_INSTALL=/usr/local | |
export BAZELISK_VERSION=1.6.1 | |
apt-get update | |
apt-get install -y --no-install-recommends pkg-config zip zlib1g-dev unzip python wget ca-certificates \ | |
ssh git gdb vim emacs-nox sudo libudev-dev libjudy-dev bison flex \ | |
libfl-dev libgmp-dev libi2c-dev python-yaml libyaml-dev build-essential \ | |
lcov curl autoconf automake libtool libgmp-dev libpcap-dev \ | |
libboost-thread-dev libboost-filesystem-dev libboost-program-options-dev \ | |
gnupg2 software-properties-common python-pip python-dev python3-dev \ | |
apt-transport-https libelf-dev libbz2-dev | |
export JAVA_HOME=/usr/local/lib/jvm | |
wget --quiet -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - | |
add-apt-repository "$LLVM_REPO_NAME" | |
apt-get update && apt-get install -y --no-install-recommends clang-format clang | |
wget $JDK_URL -O $HOME/jdk_11.0.2.tar.gz && \ | |
mkdir -p $JAVA_HOME && \ | |
tar xf $HOME/jdk_11.0.2.tar.gz -C $JAVA_HOME --strip-components=1 && \ | |
rm $HOME/jdk_11.0.2.tar.gz | |
git clone https://github.com/p4lang/PI.git /tmp/PI && \ | |
cd /tmp/PI && git checkout ${PI_COMMIT} && \ | |
git submodule update --init --recursive && \ | |
./autogen.sh | |
./configure --without-bmv2 --without-proto --without-fe-cpp \ | |
--without-cli --without-internal-rpc && \ | |
make -j${JOBS} && make install && ldconfig | |
cd | |
git clone https://github.com/p4lang/behavioral-model.git /tmp/bmv2 && \ | |
cd /tmp/bmv2 && git checkout ${BMV2_COMMIT} && ./autogen.sh | |
./configure --without-targets --with-pi --disable-elogger --without-nanomsg \ | |
--without-thrift --prefix=${BMV2_INSTALL} CXXFLAGS="-I${PWD}/targets/simple_switch \ | |
-DWITH_SIMPLE_SWITCH -isystem$BMV2_INSTALL/include -isystem$PI_INSTALL/include -L$PI_INSTALL/lib" && \ | |
make -j${JOBS} && make install && ldconfig && \ | |
cd targets/simple_switch && \ | |
make -j${JOBS} && make install && ldconfig | |
cd | |
echo 3.5.0 >> .bazelversion | |
wget https://github.com/bazelbuild/bazelisk/releases/download/v${BAZELISK_VERSION}/bazelisk-linux-amd64 && \ | |
mv bazelisk-linux-amd64 /usr/local/bin/bazel | |
chmod +x /usr/local/bin/bazel && bazel version | |
pip install setuptools wheel && pip install 'cpplint==1.*' | |
wget -O /usr/local/bin/buildifier https://github.com/bazelbuild/buildtools/releases/download/4.0.0/buildifier | |
chmod +x /usr/local/bin/buildifier | |
curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add - | |
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | |
curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash | |
apt-get install -y --no-install-recommends git-lfs && git lfs install | |
cd | |
# Necessary for BMv2 build | |
export BMV2_INSTALL=/usr/local | |
git clone https://github.com/stratum/stratum | |
cd stratum | |
bazel build //stratum/hal/bin/bmv2:stratum_bmv2 |
tar xvf bf-sde-9.3.0.tgz
cd bf-sde-9.3.0/p4_studio_build
./p4studio_build.py -up stratum_profile
tar -xvf ./bf-reference-bsp-9.3.0.tgz
unzip bf-reference-bsp-9.3.0-BF2556_1c5723d.zip
cd packages/
tar xvf bf-platforms-9.3.0.tgz
cd bf-platforms-9.3.0/platforms
mv ../../../../apsn .
cd bf-reference-bsp-9.3.0/packages/bf-platforms-9.3.0/
patch -p1 < ../../../bf2556x_1t.diff
export SDE=/home/ubuntu/bf-sde-9.3.0
export SDE_INSTALL=/home/ubuntu/bf-sde-9.3.0/install/
export BSP_INSTALL=$SDE_INSTALL
autoreconf && autoconf
CFLAGS="-Wno-error" ./configure --prefix=${BSP_INSTALL} --with-tof-brgup-plat
sudo apt install libusb-1.0-0-dev
sudo apt install libcurl4-openssl-dev
make
make install
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Having prior done
multipass launch 18.04 -n stratum -m 32G -d 50G
or something. Stick to Debian Buster, although unclear if it would actually work on later versions.For the love of the FSM, make sure you provide large enough memory (>8GB), and disk (>20G, SDE requires 20G free alone)