In this blog post, we'll showcase two methods for installing the essential tools to develop software for an STM32 target without depending on an Integrated Development Environment (IDE).
- We'll begin by examining the process of collecting and installing the necessary tools directly onto your host PC.
- Next, we'll explore the creation of a containerized solution using the same toolset, leveraging DEM, our open-source Development Environment Manager.
Disclaimer:
This post is primarily tailored for x86_64 Linux users. However, Windows users can also follow along using Windows Subsystem for Linux (WSL).
Development Environment vs IDE
When starting development on a new target, the typical approach is to download the vendor-specific IDE, which comes with all the necessary tools preinstalled. While this method offers a quick start, it lacks flexibility. The IDE is a fixed environment, making it challenging to modify or update integrated tools later on.
Alternatively, opting for a Development Environment (Dev Env) allows us to assemble the tools we need individually, providing greater control over the development process. Unlike an IDE, a Dev Env consists of standalone tools tailored to our requirements.
One significant advantage of using a Dev Env is the freedom to choose your preferred editor for coding. This flexibility empowers developers to work with the tools and workflows that best suit their needs.
DEM
We'll be utilizing DEM to create our containerized Dev Env. DEM, which stands for Development Environment Manager, facilitates the creation and management of Dev Envs based on a containerized toolset. When working without an IDE, DEM serves as the glue between individual tools, enabling their assignment to the development project seamlessly.
If you're interested in delving deeper into the advantages of containerization, you can explore our article on Maximizing efficiency.
The toolset
To establish a functional Dev Env, we'll choose the following tools:
- Build system: make
- Toolchain: gnu-arm-none-eabi
- Debugger: stlink-org
Dev Env creation - Two ways
I. Installing on the native host
The build system
The make build system is typically available by default on most major Linux distributions, requiring no additional actions.
The toolchain
- Visit the official ARM website to download the GNU ARM toolchain.
- Navigate to the appropriate section for your host's compatibility.
-
Download the archived file and extract it into the /opt/gnu directory using the command:
tar -xf arm-gnu-toolchain-13.2.rel1-x86_64-arm-none-eabi.tar.xz -C /opt/gnu/
- Add the path of the toolchain binaries to your PATH environment variable to enable systemwide usage.
- Verify the installation by running:
arm-none-eabi-gcc --version
The debugger
The stlink-org is the open-source version of the STMicroelectronics STLINK Tools.
- Follow the installation instructions outlined in the project's README file.
-
Verify the installation by running:
st-info –version
II. Simple, containerized installation
To set up a containerized Dev Env, you'll need the following tools:
- The Docker container engine to run containers.
- The DEM to manage the Development Environment.
- Python 3.10 or higher to run DEM.
Refer to the installation section of DEM’s README and follow the instructions.
Confirm the successful installation of DEM by running:
dem –version
Now, proceed with creating a Dev Env named "stm32" (or any preferred name) using the command:
dem create stm32
DEM will prompt you to select the desired tools for inclusion in the Dev Env. Choose from the available tool images:
- axemsolutions/make_gnu-arm:13.2
- axemsolutions/stlink-org:1.8.0
Finally, install the newly created Dev Env with:
dem install stm32
Containerized vs Native Dev Env
Containerized Dev Env | Native Dev Env | |
---|---|---|
Installation | A simple dem install command. The tool container images can be used immediately. | Manually, every time. |
Scalability | The toolset can be modified by simply adding/removing tools with DEM. | Modifying the toolset involves many manual installation/uninstallation steps. |
Interference | The tools live in their own isolated environment. | Tools can affect the behaviour of other tools and the host system. |
Reproducibility | Tools are guaranteed to always work the same way in every host environment. | Differences in the OS and library versions between two dev PCs can result in different outputs of the same tools. |
Simple reproducibility with DEM
A Dev Env can be assigned to a project with the following command:
dem assign {dev_env_name} {project_path}
This command saves the selected Development Environment descriptor to the project's root directory. Consequently, the descriptor can be added to the version control system. Employing this technique guarantees that all project contributors utilize the exact same Development Environment throughout the project's lifecycle .
Further reading
For readers interested in further exploration, we've prepared a step-by-step tutorial on creating a project for an STM32F1 target and establishing a containerized Development Environment (Dev Env). You can access the tutorial through the following link: Tutorial on STM32F1 project creation and containerized Dev Env setup.
This additional resource offers detailed guidance and insights into practical implementation, complementing the information provided in this article.