Microcontroller-UE Help

VSCode

If you encounter problems during setup, please ask for help on discord

Initial project setup

  1. Find your repository on the GitLab page of the course. It should be named like mic-student-123

  2. Click on the blue Code button on the top right and copy the URL displayed below "Clone with SSH"

    Clone with SSH
  3. Open Visual Studio Code and select View -> Command Palette... or press Ctrl + Shift + P

  4. Type Git: Clone (Recursive) and press Enter

    Git clone command
  5. Paste the URL into the Repository URL field and press enter.

  1. Select the directory where you want to store the repository. You will be asked to confirm trusting the host. Select yes.

    Trust host dialog
  2. You will be asked to open the repository. Click on Open. Confirm that you trust the authors of the project.

  3. The repository will be cloned and opened in Visual Studio Code.

  4. If you are asked to install the recommended extensions, click on Install All.

  5. Click on the Cmake tab vscCMake tab on the left of the screen. and click on Select a Kit next to the [No Kit Selected] dropdown.

    CMake kit configuration

    A kit can also be selected by pressing Ctrl + Shift + P and typing CMake: Select kit

  6. Select Pico ARM GCC from the list. CMake will now build the project.

    CMake kit selection
  7. If you are not using Windows, open .vscode/settings.json and change the openocd_binary path to the correct one for your system. The path should point to the openocd executable in the .openocd/[arch] directory. Make sure that the binary is executable (run chmod +x openocd in the binary directory)

  8. On linux, please change line 11 of .vscode/launch.json to "gdbPath": "gdb-multiarch"

Flashing and running

  1. Click on the Run tab vsc Run and Debug tab on the left of the screen or press Ctrl + Shift + D

  2. Select the Pico Run configuration from the dropdown menu.

    Run configuration for the Pico
  3. Press the green play button to build, flash and run your code. If you are asked to select a target, select the assignment you want to flash.

    Selecting the CMake Run target

    If you want to flash a different target, you can change the target in the Cmake tab vsc CMake tab. Select the target for Debug and Launch by clicking on the pencil icon next to the target.

    Configured target on CMake settings
  4. To view the serial output of the board, you can click on the Serial Monitor tab at the bottom of the screen. Select the COM port of the Pico, modify the settings to match those in the image below and press on Start monitoring.

    Serial monitor settings

Debugging

  1. Click on the Run tab vsc Run and Debug tab on the left of the screen or press Ctrl + Shift + D

  2. Select the Pico Debug configuration from the dropdown menu. Debug vsc

  3. Press the green play button to build, flash and run your code. The debugger will start and halt your program. You can see the call stack and variables in the Run tab vsc Run and Debug tab.

  4. You can set breakpoints by clicking on the left side of the line number. The program will stop at the breakpoint and you can inspect the variables in the Variables tab.

  5. To view the registers and their values, open the XPERIPHERALS in the Run tab vsc Run and Debug tab.

  6. Use the debugger controls to step through the code, continue the execution or stop the debugging session. Hover over the buttons to see their function.

    Debugger controls

    Debugging the hardware will be covered in assignment 0

Using the integrated Git

Committing and pushing changes

  1. Click on the Vcs tab vsc Source Control tab on the left of the screen or press Ctrl + Shift + G.

  2. You will see a list of repositories and the changes you made. Ignore all repositories except your gitlab repository.

  3. Enter a commit message which briefly describes the changes you made. Then press Commit to commit the changes.

    Git commit interface

    If you are asked to stage the changes, click on Always

  4. Click on Sync Changes to push the changes to the server.

Creating a tag

  1. Click on the Vcs tab vsc Source Control tab on the left of the screen or press Ctrl + Shift + G.

  2. Click on the three dots next to your GitLab repository and select Create Tag... in the Tags submenu.

    Creating a tag
  3. Enter a name for the tag and press Enter. You can skip setting a message by pressing Enter.

  4. After creating the tag, you need to push it to the server. Press Ctrl + Shift + P and type Git: Push Tag and press Enter. Then select your repository and press Enter.

    Git push tags command

Your VSCode setup is complete! 🎉

You can now start working on the assignments.

Last modified: 16 December 2024