SN512 Real-Time Operating Systems for Embedded Systems

From Nicolas Barbot website
Jump to navigation Jump to search

These lab series allow you to install and discover the Zephyr Real Time Operating System.

Installation

Note that the dependancies and Zephyr SDK are already installed on the computers of the school. The installation is required only if you install Zephyr on your own computer.

  • Install the binary packages of the dependancies required by Zephyr:
sudo apt install --no-install-recommends git cmake ninja-build gperf \
  ccache dfu-util device-tree-compiler wget python3-dev python3-venv python3-tk \
  xz-utils file make gcc gcc-multilib g++-multilib libsdl2-dev libmagic1
  • Install the Zephyr SDK. Follow the steps describe at this page. The installation can be done by 2 ways: downloading and installing a bundle or installing the SDK using west.

Getting Started

  • In a terminal, go into a directory where you want to place your workspace
$ git clone https://github.com/nicolas-barbot/zephyr_workspace.git
  • Enter inside the workspace, you should see 2 directories. manifest-repo contains the central manifest. hello_world is a project. During the lab, we will create multiple project in the workspace.
  • Inside the workspace, create a virtual environment
$ python3 -m venv .venv

Note the .venv directory in the workspace

  • Activate the virtual environment using
$ source .venv/bin/activate

Note that if you want to deactivate your virtual environment, simply type deactivate. If you want to re activate it, simply activate it with the source command.

  • In the (activated) virtual environment, install west
$ pip install west


  • Initialize west with the manifest already present in our workspace:
$ west init -l manifest-repo/

Note that this command will create a .west directory in the workspace.

  • Download all the dependancies of our workspace
$ west update

This command will download the correct version (indicated in the manifest) of each depedancie and store them in the workspace. Note that the Zephyr source code will be downloaded at this step.

  • Install some python dependancies associated with the specific versions indicated in the manifest of the workspace
$ west packages pip --install


  • Build the hello_world project located in the workspace
$ west build -p always -b nucleo_f103rb hello_world/

Note that this command create a build directory in the workspace. The executable file corresponding to the application in located at .build/zephyr/zephyr.elf

  • Flash the executable file on the STM32 board:
$ west flash

During this command, check that LD1 present on the STLinkv2 is blinking red and green.

  • In another terminal, simply type the command:
$ screen /dev/ttyACM0 115200

Be careful to not close this terminal (because you will not be able to open the /dev/ttyACM0 file a second time). The correct procedure the close the screen session is to type Ctrl+A, k and finally y.

  • Finally, if you see in the terminal the following message:
*** Booting Zephyr OS build v4.3.0 ***
Hello World! nucleo_f103rb

Congratulation, you just successfully set up, build and run your first Zephyr application!