Tutorial: PlatformIO in VSCode
Tutorial: PlatformIO in VSCode
Step 1: Install Python
You can install Python in Window by following the instruction here:
How to check if you already have Python
Open Window Command Prompt > Type
python --version
If you see the version, then you already have python installed.
Step 2: Install VS Code
Refer to Installation-guide: VS CDOE
Step 3: Install PlatformIO Core
You may not need this step if you are going to use VS Code. But, install anyway.
Download python file of PlatformIO Core: 다른이름으로 링크저장: get-platformio.py
Download and save it as in py file
WIN OS: In command prompt
MAC OS
Step 4: Install PlatformIO IDE extension in VS Code
Open VS Code
Open VSCode Package Manager
Search for the official PlatformIO IDE in extension.
Install PlatformIO IDE
Step 5: Setting Up the Project in PlatformIO
Go to PlatformIO Home by clicking on the
PlatformIO Icon
Create New Project
Name the project as
EC
orEC2024
Select Setting as follows
Board: ST Nucleo F411RE
Framework: CMSIS
Location: Your EC workspace
Step 6: Manage Environment, Build and Upload
Open VSCode and select the EC workspace folder
eg.:
\repos\EC\
Go to PlatformIO Home by clicking on the PlatformIO Icon
Creating a new file
You can start your Tutorial or LAB by following the instructions given in the report.
For example, for LAB_GPIO_DIO_LED, we created the project folder and the main program file, under the workspace of ...\repos\EC\
as
Folder:
\LAB\LAB_GPIO_DIO_LED\
Main src:
LAB_GPIO_DIO_LED.c
For this tutorial, create the project folder and program file as
Folder:
\tutorial\TU_CreateProject_VSC\
Main src 1:
TU_CreateProject_Example1_main.c
Main src 2:
TU_CreateProject_Example2_main.c
TU_CreateProject_Example1_main.c
TU_CreateProject_Example2_main.c
Adding Library
You can add your EC library header files under the directory of \include
You can add it under the directory of
\lib.
But you need to modify the include_dir folder inplatformio.ini
Creating Environment
For every new TU or LAB, you can create a new environment that shares the MCU configuration. You do not need to re-configure the MCU setup everytime you create a new project. Simply, add a new environment that links your new program main file.
For this tutorial, we will learn how to add new environments for each TU_CreateProject_Example1_main.c
, and TU_CreateProject_Example2_main.c
.
Modify platformio.ini
in the workspace folder as
Selecting Environment, Build and Run
Click on
Switch the environment
on VSCodeSelect the Environment you want to build.
For this tutorial, first select [env:TU_CreateProject_Example1]
BUILD. If you have MCU connected, you can also UPLOAD
Now, Select the other Environment that uses your EC library [env:TU_CreateProject_Example2]
Appendix
PlatformIO Toolbar
PlatformIO IDE Toolbar is located in VSCode Status Bar (left corner) and contains quick access buttons for the popular commands. Each button contains hint (delay mouse on it).
PlatformIO: Build
PlatformIO: Upload
PlatformIO: Clean
Project environment switcher (if more than one environment is available). See [Section env] of “platformio.ini” (Project Configuration File) .
Last updated