Zephyr Development Windows Setup

TL;DR

nice try, learn to read

Don’t use Windows

Follow Microsoft’s instructions to install the Windows Subsystem for Linux. I recommend getting the latest Ubuntu LTS (long-term support) distribution.

Notes

  • This will install a shell only, graphical applications may not work (but you should get good at using the terminal anyway)

  • Zephyr only has Ubuntu instructions, you might need to change the package manager or do things a bit more manually for another distribution

Linux setup

Create a shortcut (symbolic link) to a convenient spot on Windows from your Linux home directory.

sudo apt update -y && sudo apt upgrade -y to update all of the packages on your system.

Install Zephyr and FSW

We set up FSW as a zephyr project repository. Follow Zephyr’s instructions to install its dependencies, but where the instructions say west init ~/zephyrproject, instead run west init -m https://github.com/RIT-Launch-Initiative/FSW ~/zephyrproject

Notes

  • I named it launch-fsw instead of zephyrproject because FSW is the “parent” repository and you can’t add arbitrary project repositories easily, but if you do this you will need to change all of the directory names in Zephyr’s guides

Build code

Execute west build <target_directory>.

Notes

  • If you use west build with a target (defaults to . if one is not given), and you change that target, try running west build -p always when you change the target. Sometimes even this is not sufficient and you have to remove the build directory entirely.

Flash binary

Flashing through Windows

Zephyr will generate several build files in the build/zephyr directory. Copy one of them to a location visible to the Windows filesystem, which is accessible from Linux through /mnt/c/.... They are the same as any other type of file you would flash ~ For Nucleos, flash the .hex file through STM32CubeProgrammer or copy the .bin file to the Nucleo’s “storage”.

Notes

  • The shortcut recommended previously helps (also consider writing a make target to do this)

Flashing through Linux

To do this, you need to pass a USB device from Windows to WSL 2 (this does not work with WSL 1, you are stuck with flashing through Windows) and make sure OpenOCD is able to flash to it. Follow Microsoft’s instructions to install and use usbipd-win. For a more user-friendly experience, you may want the GUI, which also allows you to auto-attach a device (assuming it retains its Windows GUID between sessions).

Notes

  • If it doesn’t work, try detaching and re-attaching.

  • Sometimes this will fail due to mumble mumble udev rules mumble mumble. Try running sudo service udev restart followed by sudo udevadm control --reload to