Zephyr Development Windows Setup
TL;DR
nice try, learn to read
No, seriously, read all of the instructions this guide points to. Embedded systems toolchains are very particular. Skipping steps is a recipie for wading through staggeringly unhelpful error messages.
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
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 ofzephyrproject
becauseFSW
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 runningwest build -p always
when you change the target. Sometimes even this is not sufficient and you have to remove thebuild
directory entirely.
Flash binary
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. which also allows you to auto-attach a device (assuming it retains its Windows GUID between sessions).
Follow Zephyr’s instructions to add user device rules to allow WSL to communicate with the debug probe.
Run
sudo service udev restart
followed bysudo udevadm control --reload
Notes
Make sure to bind and attach the device to WSL.
For a more user-friendly experience, you may want the GUI.
First-stage troubleshooting: detach and reattach, unbind and rebind
Second-stage troubleshooting: Re-run
sudo service udev restart
followed bysudo udevadm control --reload
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
You should create a symbolic link from Zephyr on WSL to an easily accessible location in Windows to make this easier