GSoC23: Getting started with Zephyr for BeaglePlay CC1352

Hello everyone. In this post, I will go over setting up BeaglePlay and my Linux host for BeaglePlay CC1352 firmware development. Check out my GSoC 2023 Introduction post for more information about my project.

Setup Linux host for Zephyr

While it is possible to do Zephyr development on BeaglePlay itself, I will use my Linux PC to program and build the Zephyr application. This is because my Linux PC is much more powerful than BeaglePlay and thus plays well with Neovim + Clangd LSP.

So, I will now go over setting up the Linux host for development.

Setup Zephyr SDK

  1. Install host dependencies.
  2. Download Zephyr SDK Bundle.
cd ~
wget https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.1/zephyr-sdk-0.16.1_linux-x86_64.tar.xz
wget -O - https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.1/sha256.sum | shasum --check --ignore-missing
  1. Extract the Zephyr SDK bundle archive. I extracted the bundle to ~/.local/opt/zephyr-sdk-0.16.1
tar xvf zephyr-sdk-0.16.1_linux-x86_64.tar.xz
  1. Run the Zephyr SDK bundle setup script:
~/.local/opt/zephyr-sdk-0.16.1/setup.sh

Since I will not use my Linux host for flashing, I did not need the udev rules.

Setup Zephyr Builddir

I will be using a Zephyr fork with support for beagleplay-cc1352.

  1. Create a new Python virtual environment.
python -m venv ~/zephyrproject/.venv && cd ~/zephyrproject
  1. Activate virtualenv. Since I am using zsh-autoswitch-virtualenv, this automatically happens when I enter the directory.
  2. Install west:
pip install west
  1. Get the Zephyr source code:
west init -m https://git.beagleboard.org/beagleconnect/zephyr/zephyr ~/zephyrproject
cd ~/zephyrproject
west update
  1. Export a Zephyr CMake package. This allows CMake to automatically load boilerplate code required for building Zephyr applications.
west zephyr-export
  1. Zephyr’s scripts/requirements.txt file declares additional Python dependencies. Install them with pip.
pip install -r ~/zephyrproject/zephyr/scripts/requirements.txt

Build a sample Zephyr application

I will be using the samples/net/dns_resolve.

  1. Build the Zephyr Application.
west build -b beagleplay_cc1352 -p always ~/zephyrproject/samples/net/dns_resolve
  1. Copy the binary to BeaglePlay
scp ~/zephyrproject/build/zephyr/zephyr.bin [email protected]:~/

Run the application on BeaglePlay CC1352

  1. Enable k3-am625-beagleplay-bcfserial-no-firmware.dts overlay. This is needed to ensure the bcfserial driver isn’t blocking the serial port.
echo "    fdtoverlays /overlays/k3-am625-beagleplay-bcfserial-no-firmware.dtbo" | sudo tee -a /boot/firmware/extlinux/extlinux.conf
sudo shutdown -r now
  1. Clone cc1352-flasher
git clone [email protected]:beagleconnect/cc1352-flasher.git && cd cc1352-flasher
  1. We need to checkout the from-20230521 branch.
git checkout from-20230521
  1. Flash the application
python cc1352-flasher --beagleplay ~/zephyr.bin
  1. Try out the application:
tio /dev/ttyACM0

Conclusion

The BeaglePlay CC1352 Firmware I am working on can be found here. You can follow my GSoC23-related blog posts using this feed.

Consider supporting me if you like my work.