Microcontroller-UE Help

CLion

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 CLion and select Get from VCS on the welcome screen or go to File > New project from Version control...

    CLion welcome screen
  4. Paste the URL into the URL field and select the directory where you want to store the repository. Then press Clone.

  1. You will be greeted with a dialog asking you to configure the CMake profile. Click on Manage toolchains....

    CMake configuration
  2. Add a new System toolchain by clicking on the + button and selecting the System tab. Make sure bundled CMake and GDB are selected, ninja.exe should be detected as build tool.

    CLion toolchain

    You will have to set the C Compiler and C++ Compiler manually. On windows, the following paths should be used:

# C Compiler C:\Program Files (x86)\Arm GNU Toolchain arm-none-eabi\13.3 rel1\bin\arm-none-eabi-gcc.exe # C++ Compiler C:\Program Files (x86)\Arm GNU Toolchain arm-none-eabi\13.3 rel1\bin\arm-none-eabi-g++.exe

On linux or macOS, please get the path of arm-none-eabi-gcc and arm-none-eabi-g++ using

# C Compiler which arm-none-eabi-gcc # C++ Compiler which arm-none-eabi-g++

Then click on OK to create the toolchain.

  1. Click on OK in the CMake profile dialog to finish the setup.

  2. The IDE will notify you on the bottom right about missing plugins and to update the Windows Defender settings (if you are on Windows). Click on the notification and install the plugins and update the settings.

    Plugins and Windows Defender configuration
  3. Open the setting by pressing Ctrl + Alt + S or by going to File > Settings.... Search for Embedded Development and select the Embedded Development tab.

  4. Change the OpenOCD Location to executeable located in .openocd/x86_64_win/openocd.exe inside the project directory. If you are on Linux or macOS, you will have to select .openocd/[arch]/openocd. Make sure that the binary is executable (run chmod +x openocd in the binary directory). You can open the file browser by pressing on .... The Stm32CubeMX Location should be left empty, the window should look like this:

    Embedded development settings
  5. Press OK to save the settings.

Flashing and running

  1. On the top right, you can see a dropdown menu with preconfigured run configurations. Select the assignment which you want to flash and run. Then press the green play button to build, flash and run your code.

    Run and debug menu

    Make sure to select the run configuration with the microcontroller icon.

  2. Your code will be compiled and flashed to the board. You can see the build output in the terminal at the bottom of the screen.

  3. To access the serial output of the board, you can click on the Serial tab clion Serial Connections tab at the bottom left of the screen. Select the COM port of the Pico, modify the settings to match those in the image below and press on Connect.

    Serial Connections settings

    Your configuration should match the one shown in the image above.


    Close the active serial connection tab and reconnect after flashing or restarting the board

Debugging

  1. To start a debugging session, click the green bug icon next to the green play button.

    Run and debug menu

    Make sure to select the run configuration with the microcontroller icon.

  2. The code will be compiled and flashed to the board. The debugger will start, and you can see the output in the Debug tab clion Debug tab at the bottom of the screen.

  3. 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 in Threads & Variables.

  4. To view the registers and their values, select the Peripherals tab in the Debug window. When asked to load a svd file, select the file located in .openocd/svd/RP2040.svd.

  5. 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

  6. To stop the debugging session, press the red square button in the top right corner of the screen.

Using the integrated Git

Committing and pushing changes

After making changes to your code, you have to commit and push them to the repository. This can be done directly in CLion.

  1. Click on the Commit tab clion Commit tab on the left of the screen.

    Git commit interface
  2. You will see a list of all changed files. Select the files you want to commit by clicking on the checkbox next to them.

  3. Enter a commit message which briefly describes the changes you made.

  4. Press Commit and Push... to commit the changes to the repository and push them to the server. Confirm the dialog that appears.

Creating a tag

To create a tag for a specific commit, you can use the integrated Git functionality.

  1. Click on the Git tab clion Git tab on the left of the screen.

    Git commit graph
  2. Right-click on the commit you want to tag and select New Tag....

  3. Enter a name for the tag and press OK.

  4. After creating the tag, you need to push it to the server. Right-click on the commit and select Push All up to Here.

  5. Make sure to check the Push tags checkbox and select All, then press Push.

    Git push interface

Your CLion setup is complete! 🎉

You can now start working on the assignments.

Last modified: 16 December 2024