Setting up the New STM32CubeIDE
In this post, we will be introducing the official development tools offered by ST Micro. It is called STM32CubeIDE and is based on Eclipse and the GNU/GCC toolchain. Eclipse is a very popular integrated development environment (IDE) among embedded developers.
STM32CubeIDE is pretty stable and supports multiple platforms (Windows, Mac and Linux). We will be walking through the setup of the Windows version (1.8.0).
Hardware Platform
In this post, we will be using an STM32L475 IoT Discovery board (B-L475E-IOT01A) as an example. You may check out more details at its product website B-L475E-IOT01A.
If you need more Flash memory, SRAM and higher CPU speed, you may consider the newer STM32L4S5 IoT Discovery board (B-L4S5I-IOT01A), which comes with a generous 2MB Flash and 640KB SRAM (compared to 1MB Flash and 128KB SRAM of the STM32L475 variation).
Installation
- Download the installer from STM32 website: STM32CubeIDE – Integrated Development Environment for STM32 – STMicroelectronics.
Select version 1.8.0 for Windows.
- Review the license agreement. After accepting it, you will be asked to login to your STM32 account to start the download. Create an account if you have not done so already.
- Download should automatically start. If not, click the Download button again.
- Unzip the downloaded file and run the installation .exe program. Follow the on-screen instruction to complete the installation. It is suggested that you keep the default installation directory (C:\ST\STM32CubeIDE_1.8.0) as we may refer to it later on. Ensure the option for “ST-LINK drivers” is checked.
- The installed application is named STM32CubeIDE 1.8.0. On first run, your Windows firewall may prompt you to allow network access. The application requires a network port to communicate with the debugger (OpenOCD or ST-LINK GDB Server). The following screenshot shows enabling the option to allow private network access.
Workspace
- In Eclipse, a workspace is your working environment containing one or more projects. This allows you to configure global settings shared among multiple projects. You may also quickly change your environment by switching to a different workspace. Every time when Eclipse is launched, you will be asked to select your workspace directory. By default it is set to C:\Users\<username>\STM32CubeIDE\workspace_1.8.0. It is recommended that you leave it as default. After selecting your workspace directory, click the Launch button to launch the main application window.
- When STM32CubeIDE is started for the first time, the main window shows the Information Center. It allows you to quickly create a new project or import an example project based on your hardware platform. In this post, we will start with a common baseline project which is already setup (available from github. See later). Go ahead to close the Information Center.
Import Project
- Download the baseline project from Gallium IO’s github link (https://github.com/galliumio/platform-stm32l475-disco-stm32ide.git). Here we use the STM32L475 IoT Discovery board as an example. You will find more platforms as they are added. We assume your local folder is named by default as platform-stm32l475-disco-stm32ide.
- Open Project Explorer by selecting from the top menu Window > Show View > Project Explorer. Click Import projects…
- Select General > Existing Projects into Workspace and click the Next button. Navigate to and select our example project folder (by default named as platform-stm32l475-disco-stm32ide). Click the Select Folder button.
- Next, you will be presented the Import Projects window. You should see the project named platform-stm32l475-disco checked in the Projects box. Leave all options as default. In particular, DO NOT check the “Copy projects into workspace” option to keep the source in the original folder.
- Finally, the imported project platform-stm32l475-disco appears in the Project Explorer panel. Click the > icon next to the project name to expand the project folders.
Build Project
- Right-click on the project name in the Project Explorer to bring up the context menu. There are a few important items here:
- Build Project – To compile and link the source code to generate executable elf and bin files.
- Clean Project – To clean the project. You may run this before archiving your source folder, or to resolve any dependency issues.
- Properties – To configure project settings such as compiler and linker flags, environment variables, etc.
- Delete – To delete the project from the Project Explorer. Note: Make sure the option “Delete project contents on disk” is UNCHECKED if you want to keep the source folder on disk so that you can re-import the project later. This is useful when you need to switch between different source folders with the same project names.
- Click Build Project and you should see a message similar to the following when it is built successfully:
arm-none-eabi-objcopy -O binary platform-stm32l475-disco.elf "platform-stm32l475-disco.bin" text data bss dec hex filename 493916 648 81192 575756 8c90c platform-stm32l475-disco.elf Finished building: default.size.stdout Finished building: platform-stm32l475-disco.bin Finished building: platform-stm32l475-disco.list 15:25:20 Build Finished. 0 errors, 41 warnings. (took 21s.476ms)
It is OK to have warnings but there should be no errors. Most of the warnings are caused by 3rd party libraries. Now we have successfully built the firmware for our B-L475E-IOT01A discovery board. We are ready to move on to set up the debugger, download the firmware and run the program on the real hardware. Check out our next post at Debugging with STM32CubeIDE.