Skip to content

Building and debugging embox on STM32 using Win11 wsl2 openocd

Mariano Eduardo Rodriguez edited this page Oct 28, 2022 · 3 revisions

Preparation steps:

  1. You need Windows 11 and install wsl2 as described here: https://docs.microsoft.com/en-us/windows/wsl/install
  2. You have to install Linux dist to wsl. I choose Ubuntu 18
  3. You have to download and install drivers for your debugger. In my case, this is stlink v2, so drivers can be downloaded from st.com or arduino
  4. Download and install Vs code : https://code.visualstudio.com/ (Optional)
  5. VS code extension in Windows: Remote - WSL
  6. VS code extension in Ubuntu: C/C++; Cortex-Debug

Build openocd in Ubuntu(WSL2):

Get openocd from here: https://sourceforge.net/p/openocd/code/ci/master/tree/

git clone git://git.code.sf.net/p/openocd/code openocd-code

Now build in downloaded folder

sudo apt-get install automake libtool libusb-1.0-0 libusb-1.0-0-dev

./bootstrap

./configure

make

sudo make install

Add user to plugdev:

sudo usermod -aG plugdev $USER

copy rules:

sudo cp path_to_openocd/openocd-code/contrib/60-openocd.rules /etc/udev/rules.d/

access to usb:

sudo chmod -R 777 /dev/bus/usb


Configure Windows for USB : https://docs.microsoft.com/en-us/windows/wsl/connect-usb

Download and install https://github.com/dorssel/usbipd-win/releases

Reboot

Run PowerShell as Administrator:

usbipd wsl list

You have to see something like this:

BUSID VID:PID DEVICE STATE

2-2 0483:3748 STM32 STLink Not attached

Now run Ubuntu with:

sudo apt install linux-tools-5.4.0-77-generic hwdata

sudo update-alternatives --install /usr/local/bin/usbip usbip /usr/lib/linux-tools/5.4.0-77-generic/usbip 20

Go back to PowerShell:

usbipd wsl attach --busid <busid>

For me:

usbipd wsl attach --busid 2-2

Now you have to see after usbipd wsl list:

BUSID VID:PID DEVICE STATE

2-2 0483:3748 STM32 STLink Attached - Ubuntu-18.04

Go to Ubuntu:

lsusb

You have to see:

Bus 001 Device 004: ID 0483:3748 STMicroelectronics ST-LINK/V2

Now you can build and debug embox from wsl2 using https://github.com/embox/embox/wiki/Quick-Start and https://github.com/embox/embox/wiki/How-to-flash-and-run-STM32-boards

Overview

GSoC

Demos

Supported platforms

Examples

Development

Libraries

Subsystems

Misc

Mybuild - build system

Contributing

Clone this wiki locally