Setting up your environment - owntech-foundation/Tutorials GitHub Wiki
Objective
The goal of this tutorial is to setup your environment, learn how to compile a code and load it into the Twist converter.
Required hardware
- Twist or SPIN
- PC 64-bits (windows, mac or linux)
Required software
- Git :warning: Make sure that you have Git installed on your machine. You can follow one of these links to install it. GitInstallation. If you are on Windows, go directly to this one. GitForWindows
- Python3 : Make sure you have python3 installed in your machine.
Setup the work environment
To use OwnTech's system, we will use:
- Visual Studio Code - The platform or Integrated Development Environment 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:
-
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.
-
Installation of Visual Studio Code: Download Visual Studio Code, either from https://code.visualstudio.com/ or from the repository manager of your OS. Visual Studio will suggest the version to install according to your OS.
-
Installation of PlatformIO: Launch Visual Studio Code. On the left side menu, click on the extension icon . In the search engine, type "PlatformIO IDE", and click install. Finally, restart Visual Studio Code when you are prompted to do so.
-
In Visual Studio code, on the left side menu, click on 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. If you are on linux and PlatformIO do not find the python path, you can launch the following command : '''sudo apt install python3-venv'''
-
In Platform.io, select "Clone Git Project ". PlatformIO will automatically open a field in which you can copy and paste the path below :
https://github.com/owntech-foundation/Core
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.
- Make sure you are on the
main
branch of the Git project. You should see the following file tree.
Your first Build
- In the bottom menu, click on the 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:
- :warning: Here is where multiple errors may occur. From experience, the main issues that are really recurrent are:
On Windows:
- Check that you are working on a path that is not liked to OneDrive
- Check that you do not have any spaces in the path of your project
- Check that the length of your project path is smaller than 256 characters. You should preferably have your project folder as close as possible to the root
- Check that you have python 3 installed on your machine
- Check that you have CMake installed on your machine
- Check that you have git installed on your machine
On Linux:
- Check that your Linux is 64bits
Setup the hardware
Now we will connect your TWIST board to the PC.
- Connect the USB-C cable to the SPIN as shown in the picture below to supply it with power. The LED2 of the SPIN should be ON.
- In the bottom menu, click on the Upload icon . This will flash the compiled code on the microcontroller. 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
-
The LED1 of the SPIN should blink. You can change the blinking frequency by modifying the input of the
task.suspendBackgroundMs(1000)
function in the file src/main.cpp. -
In the bottom toolbar, click on the Serial Monitor icon . The SPIN is printing “Hello world!” in the terminal.
That’s it!
Contributors
- 2024.02.24: Ayoub Farah, Luiz Villa
- 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
- 2022.01.16: Mathilde Longuet and Luiz Villa
- 2023.07.10: Luiz Villa
- 2023.09.02: Mathilde Longuet
- 2023.09.25: Mathilde Longuet