Getting Started SPIN 1 Blinky - owntech-foundation/Tutorials GitHub Wiki

Objective

The goal of this tutorial is to learn how to compile a code and load it into the O2.

Required hardware

  • SPIN v_0_9
  • STLinkV3
  • PC 64-bits (windows or linux)

Required software

  • Git :warning: Make sure that you have Git installed on your machine.

Setup the work environment

To use OwnTech's system, we will use:

  • Visual Studio Code - The platform we will use to write code.
  • PlatformIO - A Visual Studio Code plugin that is a toolbox for microcontrollers :warning: Make sure that you have more than 2GB on your hard drive so that PlatformIO can download all the required files without issues.

Here is how to setup the work environment:

  1. Create an empty folder in which you will work throughout the tutorials. :warning: Make sure that you have administrator privileges on the folder where you clone your repository.
  2. Installation of Visual Studio Code: Download Visual Studio Code, either from https://code.visualstudio.com/ or from the repository manager of your OS. Install it.

Blinky step1 - Download VSCode

  1. Installation of PlatformIO: Launch Visual Studio Code. On the left side menu, click on the extension icon extension_icon. In the search engine, type "PlatformIO IDE", and click install. Finally, restart Visual Studio Code when you are prompted to do so.

Blinky step 2 - PlatformIO installation

Now we will download the “Blinky” code from Git to Visual Studio, and compile it.

  1. In Visual Studio code, on the left side menu, click on PlatformIO icon platformio_icon! Pro tip: if the alien icon does not show up spontaneously, wait for a few more seconds, then press F1 key and type platformio home.
  2. In Platform.io, select "Clone Git Project ". PlatformIO will automatically open a field in which you can type https://gitlab.laas.fr/owntech/tutorials.git and press enter. PlatformIO will ask you in which folder to clone the project. Choose the folder you have created previously. A pop up will appear asking if you trust the authors. You can trust us. :smile:
    :warning: Make sure that the name of the cloned project has no space in its path as it would create issues.

Blinky step4 - clone the git repository

  1. Make sure you are on the main branch of the Git project. You should see the following file tree.

Blinky step 5 - File tree and main branch

Setup the hardware

Now we will connect OwnTech’s SPIN Board to the PC.

  1. Connect the USB power supply cable as shown in the picture below. The LED2 of the SPIN should be ON.
  2. Connect the micro-JTAG connector of the SPIN to the PC thanks to the STLinkV3. The leds PWR and COM of the STLinkV3 should be ON.

Connection of the SPIN

Build and Upload

  1. In the bottom menu, click on the Build icon build_icon. This will launch the compilation of the code. If this is the first time that you compile, Visual Studio Code will download several extensions that are required to write the code onto OwnTech’s microprocessor. When the compilation is completed, you should see [SUCCESS] in the terminal.
  2. In the bottom menu, click on the Upload icon flash_icon. This will flash the compiled code on the microcontroller of the SPIN. When the process is completed, you should see [SUCCESS] in the terminal.

:warning: For Linux users, you may have the LIBUSB_ERROR_ACCESS error when uploading to the board, check your udev permissions: https://community.platformio.org/t/stm32-vs-code-mbed-upload-issue-error-libusb-open-failed-with-libusb-error-access-error-open-failed/10650

  1. The LED1 of the SPIN should blink. You can change the blinking frequency by modifying the input of the k_msleep() function in the file src/main.cpp.
  2. In the bottom toolbar, click on the Serial Monitor icon serial_icon. The O2 is printing “Hello world!” in the terminal.

That’s it!

To go a little further

  • :hot_pepper: How would you change the pattern of the blink?

Contributors

  • Owntech team in 2021
  • 2021.11.04: Loïc Quéval, Romain Delpoux, Adrien Prévost
  • 2021.11.07: Luiz Villa, Antoine Boche
  • 2022.01.24: Luiz Villa, Adrien Prevost, Loïc Quéval
  • 2022.03.13: Luiz Villa
  • 2022.05.06: Luiz Villa
  • 2022.06.23: Loïc Quéval