Zephyr RTOS devenv setup guide on Ubuntu 21.10

Jin·2022년 2월 28일
0

embedded_system

목록 보기
1/1
post-thumbnail

Hi, I'm Jin
After some personal trial and error, I am writing a Zephyr RTOS custom setup guide
I'm using Ubuntu 21.10 Desktop OS and Asus ROG Zephyrus G15
and ST Microelectronics Nucleo WL55JC

1. Basic package installations

Let's run commands below and it takes some time
Smoke outside or grab a coffee

# set your Zephyr directory whatever you want
export MY_ZEPHYR_DIR=$HOME/Applications/zephyrproject
mkdir -p $MY_ZEPHYR_DIR
sudo apt upgrade && sudo apt upgrade -y
sudo apt install --no-install-recommends git ninja-build gperf \
    ccache dfu-util device-tree-compiler wget \
    python3-dev python3-pip python3-setuptools python3-tk python3-wheel \
    xz-utils file libtool-bin build-essential libsdl2-dev
sudo snap install cmake # installs cmake up to 3.20
sudo pip3 install west # the Zephyr RTOS env tool

2. Getting ready for OpenOCD

You may have installed git command
We will build/install OpenOCD(Open On-Chip Debugger) from source code

export OPENOCD_SOURCE_DIR=$HOME/Applications
cd $OPENOCD_SOURCE_DIR
git clone https://github.com/openocd-org/openocd
cd openocd
./bootstrap
./configure --enable-stlink
make -j$(nproc)
sudo make install

3. libpython3.8 installation

APT package manager on Ubuntu 21.10 doesn't have libpython3.8 package
And seems Zephyr SDK's GNU Debugger for ARM needs it
So we're also gonna install the library from the source code

export LIBPYTHON_SOURCE_DIR=~/Downloads
cd $LIBPYTHON_SOURCE_DIR
wget https://www.python.org/ftp/python/3.8.12/Python-3.8.12.tgz
tar zxvf Python-3.8.12.tgz
cd Python-3.8.12
./configure --enable-shared --enable-optimizations
make -j$(nproc)
sudo make install

4. Zephyr base directory setup

Alright, are you following me well?
If not, just go back read the official Getting started guide
Now let's get some... initial things to do like making directories or something

west init $MY_ZEPHYR_DIR
cd $MY_ZEPHYR_DIR
west update
# we will remove the original kernel source code
# and download the latest release source code from github
rm -rf zephyr
wget https://github.com/zephyrproject-rtos/zephyr/archive/refs/tags/zephyr-v3.0.0.tar.gz
tar -zxvf zephyr-v3.0.0.tar.gz
mv zephyr-zephyr-v3.0.0 zephyr
rm zephyr-v3.0.0.tar.gz
west zephyr-export
pip3 install --user -r $MY_ZEPHYR_DIR/zephyr/scripts/requirements.txt
echo -e "\nexport ZEPHYR_BASE=$MY_ZEPHYR_DIR/zephyr" >> ~/.bashrc
source ~/.bashrc

5. Zephyr SDK installation

Do like the below just don't fucking ask anything

cd $MY_ZEPHYR_DIR
wget https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.13.2/zephyr-sdk-0.13.2-linux-x86_64-setup.run
chmod +x ./zephyr-sdk-0.13.2-linux-x86_64-setup.run
./zephyr-sdk-0.13.2-linux-x86_64-setup.run -- -d $MY_ZEPHYR_DIR/zephyr-sdk | echo -e "y\ny\ny\n"
sudo cp $MY_ZEPHYR_DIR/zephyr-sdk/sysroots/x86_64-pokysdk-linux/usr/share/openocd/contrib/60-openocd.rules /etc/udev/rules.d
sudo udevadm control --reload

6. Test with Blinky sample

Build/flash and see how my board LED blinks

cd $ZEPHYR_BASE
west build -p auto -b nucleo_wl55jc samples/basic/blinky
west flash

Thanks for following my guide

profile
C/C++ Middleware developer

0개의 댓글