# How to upgrade OAI from Ubuntu 16 -> Ubuntu 18
## EPC (HSS/MME/SPGW)
### HSS
#### Problem 1: Ubuntu 18 unsupported
```bash=
joon@ubuntu:~/openair-cn/scripts$ sudo ./build_hss -i
...
Your distribution ubuntu18.04 is not supported by openair-cn
joon@ubuntu:~/openair-cn/scripts$
```
##### file to edit:
`/home/<name>/openair-cn/build/tools/build_helper`
###### codes to add:
> add "/18.04"
```bash=27
SUPPORTED_DISTRO="Ubuntu 14.04/16.04/18.04, CentOS 7, RHEL 7"
```
> copy paste 16.04's and change to "18.04"
```bash=100
case "$distribution" in
"ubuntu18.04") return 0 ;;
"ubuntu16.04") return 0 ;;
```
> copy paste 16.04's and change to "18.04"
```bash=736
"ubuntu16.04")
PACKAGE_LIST="\
php \
phpmyadmin \
python-pexpect \
libapache2-mod-php*"
;;
"ubuntu18.04")
PACKAGE_LIST="\
php \
phpmyadmin \
python-pexpect \
libapache2-mod-php*"
;;
```
##### build again
```bash=
sudo ./build_hss -i
```
#### Problem 2: missing mysql library
```bash=
joon@ubuntu:~/openair-cn/scripts$ sudo ./build_hss -i
...
Creating config file /etc/phpmyadmin/config-db.php with new version
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2).
unable to connect to mysql server.
error encountered creating user:
...
HSS not compiled, to compile it, re-run build_hss without -i option
joon@ubuntu:~/openair-cn/scripts$
```
##### install mysql-server
```bash=
sudo apt install mysql-server
```
##### set root p/w to "linux"
```bash=
sudo passwd root
> linux
> linux
```
##### add root to mysql account
```bash=
sudo mysql -u root -p
> linux
> DROP USER 'root'@'localhost';
> CREATE USER 'root'@'%' IDENTIFIED BY 'linux';
> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
> FLUSH PRIVILEGES;
> quit
```
##### build again
```bash=
sudo ./build_hss -i
```
#### Problem 3: missing config/gnutls dev libraries
```bash=
joon@ubuntu:~/openair-cn/scripts$ sudo ./build_hss -i
...
E: Package 'libconfig8-dev' has no installation candidate
...
E: Package 'libgnutls-dev' has no installation candidate
...
-- Configuring incomplete, errors occurred!
...
HSS not compiled, to compile it, re-run build_hss without -i option
joon@ubuntu:~/openair-cn/scripts$
```
##### file to edit:
`/home/<name>/openair-cn/build/tools/build_helper`
###### libraries to substitute:
> libconfig8-dev -> libconfig-dev
```bash=680
libconfig-dev \
```
```bash=824
libconfig-dev \
```
```bash=969
libconfig-dev \
```
> add "#" in front of the code
```bash=175
#$SUDO apt-get remove -y libgnutls-dev
```
> libgnutls-dev -> libgnutls28-dev
```bash=474
libgnutls28-dev \
```
```bash=877
$SUDO apt-get install -y libgnutls28-dev
```
##### build again
```bash=
sudo ./build_hss -i
sudo ./build_hss
```
### MME
#### Problem 4: missing gccxml library
```bash=
oai_hss installed
joon@ubuntu:~/openair-cn/scripts$ sudo ./build_mme -i
...
E: Package 'gccxml' has no installation candidate
Failed to install package list autoconf automake bison build-essential cmake cmake-curses-gui doxygen doxygen-gui flex gccxml gdb git pkg-config subversion
joon@ubuntu:~/openair-cn/scripts$
```
##### file to edit:
`/home/<name>/openair-cn/build/tools/build_helper`
###### library to substitute:
> gccxml -> castxml
```bash=795
castxml \
```
```bash=939
castxml \
```
##### build again
```bash=
sudo ./build_mme -i
```
#### Problem 5: missing iproute library
```bash=
joon@ubuntu:~/openair-cn/scripts$ sudo ./build_mme -i
...
E: Package 'iproute' has no installation candidate
Failed to install package list ethtool iproute vlan tshark
joon@ubuntu:~/openair-cn/scripts$
```
##### file to edit:
`/home/<name>/openair-cn/build/tools/build_helper`
###### library to substitute:
> iproute -> iproute2
```bash=889
iproute2 \
```
```bash=1015
iproute2 \
```
##### build again
```bash=
sudo ./build_mme -i
sudo ./build_mme
```
### SPGW
#### Problem 6: interface name error
```bash=
joon@ubuntu:~$ sudo ./openair-cn/scripts/run_spgw
...
Function spgw_config_parse_opt_line (argc, argv, &spgw_config) has failed
returning -1
joon@ubuntu:~$
```
##### install net-tools & find interface name
```bash=
sudo apt install net-tools
```
```bash=
ifconfig
```
> "ens33" is my interface name
```bash=
joon@ubuntu:~$ ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
...
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
...
joon@ubuntu:~$
```
##### edit interface name
```bash=
sudo vim /usr/local/etc/oai/spgw.conf
```
> change it to your interface name
```bash=84
PGW_INTERFACE_NAME_FOR_SGI = "ens33"; # STRING, YOUR NETWORK CONFIG HERE
```
##### run again
```bash=
sudo ./openair-cn/scripts/run_spgw
```
## eNB
#### Problem 7: Ubuntu 18 unsupported
```bash=
joon@ubuntu:~/openairinterface5g/cmake_targets$ sudo ./build_oai -I -c -C
...
Your distribution ubuntu18.04 is not supported by oai !
build have failed
joon@ubuntu:~/openairinterface5g/cmake_targets$
```
##### file to edit:
`/home/<name>/openairinterface5g/cmake_targets/tools/build_helper`
###### codes to add:
> copy paste 16.04's and change to "18.04"
```bash=97
case "$distribution" in
"ubuntu18.04") return 0 ;;
"ubuntu16.04") return 0 ;;
```
> copy paste 16.04's and change to "18.04"
```bash=491
"ubuntu16.04")
specific_packages="libtasn1-6-dev"
;;
"ubuntu18.04")
specific_packages="libtasn1-6-dev"
;;
```
##### build again
```bash=
sudo ./build_oai -I -c -C
```
#### Problem 8: missing several libraries
```bash=
joon@ubuntu:~/openairinterface5g/cmake_targets$ sudo ./build_oai -I -c -C
...
E: Package 'gccxml' has no installation candidate
E: Package 'iproute' has no installation candidate
E: Package 'libatlas-dev' has no installation candidate
E: Package 'libconfig8-dev' has no installation candidate
build have failed
joon@ubuntu:~/openairinterface5g/cmake_targets$
```
##### file to edit:
`/home/<name>/openairinterface5g/cmake_targets/tools/build_helper`
###### libraries to substitute:
> gccxml -> castxml
```bash=511
castxml \
```
> iproute -> iproute2
```bash=518
iproute2 \
```
```bash=596
iproute2 \
```
> delete line "libatlas-dev \\"
```bash=521
libatlas-base-dev \
libblas-dev \
```
> libconfig8-dev -> libconfig-dev
```bash=524
libconfig-dev \
```
##### build again
```bash=
sudo ./build_oai -I -c -C
```
#### Problem 9: library alternative setting error
```bash=
joon@ubuntu:~/openairinterface5g/cmake_targets$ sudo ./build_oai -I -c -C
...
joon@ubuntu:~/openairinterface5g/cmake_targets$ sudo update-alternatives: error: no alternatives for liblapack.so
build have failed
joon@ubuntu:~/openairinterface5g/cmake_targets$
```
##### file to edit:
`/home/<name>/openairinterface5g/cmake_targets/tools/build_helper`
###### library to substitute:
> add "#" in front of the code
```bash=559
#$SUDO update-alternatives --set liblapack.so /usr/lib/atlas-base/atlas/liblapack.so
```
##### build again
```bash=
sudo ./build_oai -I -c -C
```
#### Problem 10: missing gnutls dev library
```bash=
joon@ubuntu:~/openairinterface5g/cmake_targets$ sudo ./build_oai -I -c -C
...
E: Package 'libgnutls-dev' has no installation candidate
build have failed
joon@ubuntu:~/openairinterface5g/cmake_targets$
```
##### file to edit:
`/home/<name>/openairinterface5g/cmake_targets/tools/build_helper`
###### library to substitute:
> libgnutls-dev -> libgnutls28-dev
```bash=563
$SUDO apt-get install -y libgnutls28-dev
```
##### build again
```bash=
sudo ./build_oai -I -c -C
sudo ./build_oai -w USRP --eNB -c -C
```
#### Problem 11: build with USRP option failed
```bash=
10. Bypassing the Tests ...
joon@ubuntu:~/openairinterface5g/cmake_targets$ sudo ./build_oai -w USRP --eNB -c -C
...
-- Configuring incomplete, errors occurred!
See also "/home/joon/openairinterface5g/cmake_targets/lte_build_oai/build/CMakeFiles/CMakeOutput.log".
build have failed
joon@ubuntu:~/openairinterface5g/cmake_targets$
```
##### try with another build command
```bash=
sudo ./build_oai -I --eNB -x --install-system-files -w USRP
```
#### Problem 12: missing uhd/libuhd003 libraries
```bash=
joon@ubuntu:~/openairinterface5g/cmake_targets$ ./build_oai -I --eNB -x --install-system-files -w USRP
...
E: Unable to locate package uhd
...
E: Unable to locate package libuhd003
build have failed
joon@ubuntu:~/openairinterface5g/cmake_targets$
```
##### file to edit:
`/home/<name>/openairinterface5g/cmake_targets/tools/build_helper`
###### libraries to substitute:
> add "#" in front of the codes
```bash=267
#$SUDO apt-get remove -y uhd || true
#$SUDO apt-get remove libuhd-dev libuhd003 uhd-host -y
```
> libuhd003 -> libuhd-dev
```bash=275
$SUDO apt-get -y --allow-unauthenticated install libuhd-dev libuhd-dev uhd-host
```
##### build again
```bash=
sudo ./build_oai -I --eNB -x --install-system-files -w USRP
```
#### Problem 12-1: missing boost library

```bash=
sudo apt update
sudo apt install libboost-all-dev
sudo ./build_oai -I -c -C
sudo ./build_oai -w USRP --eNB -c -C
```
#### Problem 13: missing USRP device
```bash=
joon@ubuntu:~$ sudo -E ./openairinterface5g/cmake_targets/lte_build_oai/build/lte-softmodem -O ./openairinterface5g/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210.conf
...
[INFO] [UHD] linux; GNU C++ version 7.5.0; Boost_106501; UHD_4.7.0.0-0ubuntu1~bionic1
No USRP Device Found.
/home/joon/openairinterface5g/targets/ARCH/COMMON/common_lib.c 110:oai device intialization failed (null)
Exiting, cannot initialize rf device
joon@ubuntu:~$
```
##### solution
go to the lab and rebuild with USRP connected to your computer.
#
> [name=Joon]
>
> experiment environment:
> > software:
> Ubuntu 18.04.6 LTS (amd64)
> VMware Workstation 17 Player (Non-commercial)
> Windows 11
>
> > hardware:
> intel CPU
> NVIDIA GPU
>
> reference:
> [copy paste in VMware](https://andjjip.tistory.com/273)
> [show line numbers in vim](https://zenoahn.tistory.com/19)
> [mysql command instruction](https://blog.uncletom.co.kr/24)
> [delete certain files in Ubuntu](https://blog.naver.com/hjy5405/222878053110)
> [chatGPT](https://chatgpt.com/)
>
> based on:
> [OAI EPC - OAI eNB](https://hackmd.io/@jhong/oai)