Booting A Cortex M with NO IDE : like a caveman : Part 1 Toolchain
I like to jump into things and learn as I go so ill do the same for you. Ill explain what is necessary when it becomes relevant. However, I also dont explain simple things like how to extract a file or how to add paths to your system variables, this can be googled.
Add path to windows environment
I am going to proceed under the assumption that you have already installed one of the following: STM32CubeIDE, STM32CubeMX, or STM32CubeCLT. These software packages from STMicroelectronics come bundled with their own versions of OpenOCD and the ARM GNU Toolchain, both of which are specifically tailored to work seamlessly with STM32 microcontrollers.
Now, you might be wondering why these packages are relevant, especially if we’re not using the integrated development environment (IDE) itself. We need OpenOCD and ARM GNU tools to compile and debug our application. When you're working with a newly released STM32 chip, the publicly, or mainstream, available versions of OpenOCD might not yet support it. In such cases, the configuration files and toolchains provided by STMicroelectronics in their software packages are invaluable, as they ensure compatibility with the latest STM32 devices. However, this post is about booting a Cortex M MCU that does not necessarily have to be an STM32
At this point, you have three options:
- Follow the Steps Provided (recommended to follow this post): You can continue with the instructions I will provide, which involve downloading and setting up the required tools independently from mainstream sources, which is fine unless you're using a new STM32 released yesterday or something, you lucky dog!! The good thing about this approach is that you'll have an OpenOcd version tailored for most microcontrollers not just STM32
- Use the Pre-Installed Tools: Alternatively, if you already have STM32CubeIDE, STM32CubeMX installed, you can skip the downloading steps. Instead, you can use the versions of OpenOCD and the ARM GNU Toolchain included in these packages. To do this, you’ll simply need to locate the relevant files within your installation directory.
- Use STM32CubeCLT : Download STM32CubeCLT from the ST website it contains STLinkGDBServer (OpenOcd alternative) and ARM GNU Toolchain.
Toolchain setup
- core_cm0.h: This is the primary header file for the Cortex-M0 core. It contains the core definitions, register structures, and intrinsic functions necessary for programming the Cortex-M0.
- cmsis_compiler.h: This file provides the necessary compiler-specific definitions that are compatible across different toolchains. It's used to ensure that the CMSIS (Cortex Microcontroller Software Interface Standard) code works across various compilers.
- cmsis_gcc.h: Since we are using the GNU ARM toolchain (GCC), this file contains GCC-specific macros and definitions that you'll need.
- cmsis_version.h: This file contains the CMSIS version information and is generally included in CMSIS projects for consistency.
- stm32g071xx.h: device header file with register definitions
- stm32g0xx.h: This is the generic header file for the STM32G0 series of microcontrollers. It provides common definitions and macros that apply to the entire STM32G0 family, ensuring that your code can be easily ported across different STM32G0 devices
- system_stm32g0xx.h: This file contains the system configuration functions and setup routines for the STM32G0 series. It typically includes the system clock configuration and other critical low-level initialization code that needs to be executed before your main application can run.
Comments