---
# System prepended metadata

title: INSTALL SDE NOTE
tags: [P4]

---

###### tags: `P4`

# INSTALL SDE NOTE
This document describes only how to install SDE.
SDE9.5有兩種方式可以安裝SDE, p4studio_build和p4studio.
兩個安裝方式大同小異，但9.5以上版本開始，不會有p4studio_build.


## 解壓套件包、SDE
### p4studio_build
```shell=
tar xvf bf-sde-x.x.x.tar
tar xvf bf-reference-bsp-x.x.x.tar
```
### p4studio
安裝bsp不用解壓縮，直接給檔案路徑既可
```shell=
tar xvf bf-sde-x.x.x.tar
```
## 安裝 onl kernel package
```shell=
dpkg -i onl-kernel-4.14.151-lts-x86-64-all_1.0.0_amd64.deb
ln -s /usr/share/onl/packages/amd64/onl-kernel-4.14-lts-x86-64-all/mbuilds/ /lib/modules/4.14.151-OpenNetworkLinux/build
```

## 設定環境變數
```bash=
buildNumber=9.5.0
WORKSPACE=`pwd`
export SDE=$WORKSPACE/bf-sde-$buildNumber
export SDE_INSTALL=$SDE/install
export PATH=$SDE_INSTALL/bin:$PATH
```
---
## 透過p4studio_build安裝SDE
### 安裝套件包
```shell=
cd dependencies
./install.sh
```
### 安裝SDE
```shell=
cd ~/bf-sde-9.5.0/p4studio_build/
./p4studio_build.py --use-profile p416_examples_profile --bsp-path /root/bf-reference-bsp-9.5.0
```

## 透過p4studio安裝SDE
### 安裝requirements
```shell=
apt-get update

#for SDE9.5.x
pip install setuptools wheel
pip3 install setuptools wheel

#for later version of SDE
apt-get install -y python3-setuptools python3-wheel

cd $SDE/p4studio
./install-p4studio-dependencies.sh
```
:::info
If ./p4studio dependenscies install still raised setuptools nod found errer, than retry following:
```shell=
pip install setuptools
```
:::
### 安裝套件包
```shell=
./p4studio dependencies install
```

:::info
---
若安裝dependencies有出現error，以下可以參考
1. bridge : certificate time expire error
    ```bash=
    //open file 
    vim $SDE/p4studio/dependencies/source/install_bridge_utils.py  
    // adding flag into command. 
    --no-check-certificate
    ```
    ![](https://i.imgur.com/3VIkakd.png)

2. pi
```bash=
//same with bridge.
vim $SDE/p4studio/dependencies/source/install_pi.py
--with-boost-libdir=/usr/local/lib/
```
:::

:::danger
SDE9.5.x(包含)以下的thired-party路徑跟9.5以上的路徑不一樣
若你使用SDE9.6以下, 若要修改thried_party
```shell=
#SDE9.5以上
$SDE/p4studio/dependencies/source/ 
#SDE9.5以下
$SDE/p4studio_build/third_party
```
:::

---
## 安裝SDE
bsp-path請提供你放bsp壓縮檔的路徑. 

p4studio跟p4stuio_build一樣提供三種build的方式：
1. Interactive Mode
2. Profile Mode
3. Command Mode
這邊用 Command Mode
### tofino1
```shell=
cd $SDE/p4studio
./p4studio configure asic --bsp-path $WORKSPACE/bf-reference-bsp-9.5.x.tgz
./p4studio build --jobs 8 p4-16-programs
```
### tofino2
```shell=
cd $SDE/p4studio
./p4studio configure asic bsp --bsp-path $WORKSPACE/bf-reference-bsp-9.5.x.tgz
./p4studio build --jobs 8 p4-16-programs
```
### tofino2(AS9516)
```shell=
cd $SDE/p4studio
./p4studio configure asic newport --bsp-path $WORKSPACE/bf-reference-bsp-9.5.2.tgz
./p4studio build --jobs 8 p4-16-programs
```
---
## load driver
```
bf_kdrv_mod_load $SDE_INSTALL
```
---
## run switch
```
$SDE/run_switchd.sh -p tna_simple_switch
```
---