This setup guide assumes WSL is already set up. If not, follow this guide to install WSL.
sudo apt install \
build-essential \
cmake \
python3-dev \
python3-pip \
gcc-arm-none-eabi \
libnewlib-arm-none-eabi \
libstdc++-arm-none-eabi-newlib \
openocd \
ninja-build
pip install \
mbed-tools \
prettytable \
future \
jinja2 \
intelhex
In ~/.bashrc
(or ~/.bash_profile
), append the following to enable mbed-tools
via command line:
export PATH="${PATH}:/home/${USER}/.local/bin"
Author: Michael Owens
Flashing is where WSL begins to diverge from normal Linux. We have to pass through the USB device to WSL and then make sure we have the right installer.
-
Follow this guide to install
usbipd-win
-
Start windows powershell / windows terminal (not cmd, don't be cringe) and try running
usbipd list
. The output should look something like this:PS C:\Users\legor> usbipd list Connected: BUSID VID:PID DEVICE STATE 2-3 0b05:19b6 USB Input Device Not shared 3-2 0483:374b ST-Link Debug, USB Mass Storage Device, USB Serial Device... Attached 3-3 13d3:56eb USB2.0 HD UVC WebCam, USB2.0 IR UVC WebCam, Camera DFU De... Not shared 4-1 0489:e0e2 MediaTek Bluetooth Adapter Not shared
-
We can see here that the bus id of the st link programmer for the board is
3-2
, so we should runusbipd wsl attach --busid 3-2
(replace the busid with yours) -
Finally, open your WSL shell. Run
lsusb
, the output should look like this, and now we know WSL has the device connected.ubuntu@my-pc:~/TR-mbed6$ lsusb Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 001 Device 003: ID 0483:374b STMicroelectronics ST-LINK/V2.1 Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
-
Flash the board with OpenOCD:
sudo openocd -f board/st_nucleo_f4.cfg -c "program cmake-build-debug/robots/TestBench/TR-TestBench.elf verify reset exit"