This only works for Windows, but you can easily modify it for Linux. It would roughly be the same, except you would need to modify the "linux" sections in the json files.
-
Download OpenOCD for Windows: http://gnutoolchains.com/arm-eabi/openocd/ (you'll need 7zip to extract it).
OpenOCD-20181130.7z
is used in this guide. If you use a different version, you'll have to update the json files.
-
Install libusb and stlink drivers
- libusb: https://zadig.akeo.ie/
- stlink server???: https://www.st.com/en/development-tools/st-link-server.html
- the STLinkWinUSB drivers also have to be installed but I have no idea where to find those yet...
-
Extract it to C:\ (or anywhere you want really).
-
Place
launch.json
andtasks.json
in your .vscode directory- The files are below. Just press 'Raw' and download it or copy-paste it into a new file called
launch.json
ortasks.json
- The .vscode directory will be in the same directory as BUILD, bin, docs, mbed-os, etc. of your project
- If the files don't exist, you'll have to create them
- Example file structure:
- CougSat1-IHU/.vscode/launch.json
- CougSat1-IHU/.vscode/tasks.json
- The files are below. Just press 'Raw' and download it or copy-paste it into a new file called
-
Press the gutter/margin to add little red breakpoints. The area is just left of the line number.
-
Press F5 to start debugging.
- It'll say "Building..." in the lower status bar as it builds.
-
Once OpenOCD (the debugger) is connected, LD4 on the board will flash green/red.
-
It always catches an exception when it begins (in main.cpp) and I'm not exactly sure why... Just press Continue (:arrow_forward: button, or F5) and it'll work.
-
Press Stop Debugging (:white_square_button:, or shift F5) to stop the debugger. It'll change the lower status bar from orange to blue once the process is ended.
- This is setup for the L496ZG. Just ctrl-f & replace it if you want to use the L476RG
MIDebuggerPath
might have to be changed depending on where your ARM debugger is located atdebugServerPath
might have to be changed if you didn't place OpenOCD in C:\
- Try deleting the BUILD directory and rebuilding with F5
- The Debug Console tab has information on the OpenOCD process
- Output has information on the build