Installing Software & Libraries¶
So far I have the tool-chain installed with which to compile my programs. To make writing a program easier there are a few things available to assist me. ARM who develop the Coretex-M3 I am using have devised something called CMSIS (Cortex Microcontroller Software Interface Standard). In simple terms it is a vendor independent layer that goes between the microcontroller and the program. It provides an interface to the ARM Core within whichever vendors device you are using. The structure of CMSISv4 can be seen below.
Now the vendor specific bits. A vendor will use a Cortex-M3 core within a series of micro-controllers. They bolt on additional features and peripherals to that core in order to tailor a chip for a specific need (e.g. More/less flash/ram, additional/fewer ADC). The ARM provided CMSIS-CORE only knows about the Cortex-M3, the vendor will therefore provide some additional information about what has been added to it. The following image shows how the files from both the vendor and ARM relate to a program.
At the time of writing (April 2016) there is active development on CMSISv5 taking place on GitHub https://github.com/ARM-software/CMSIS_5. Indications are that it will be released later in 2016. Some of the filenames/paths referenced on these pages may change as a result.
The vendor might provide a download of the files needed. In my case ST Microelectronics have produced a download STM32CubeF1 which contains all of the CMSIS-CORE files needed, both the ARM and ST specific ones. It also packs in a significant amount of other stuff too.
Most of what is in the STM32CubeF1 I don’t plan on using. In the image above I will be aiming to use the bits covered by the light blue box on the right and the grey box at the bottom as they have the bits I need. The other parts are helpful in speeding up development but it can come at the cost of compiled code size. That said I could later change my mind and make use of some of the other bits.
STM32CubeF1 & STM32CubeMX¶
STM32CubeF1 contains the Firmware components for the STM32F1 series of devices. The files inside are needed to building the firmware for the devices. How much you use will depend on which devices you are using and whether you are using the HAL or RTOS libraries.
STM32CubeMX provides a graphical front-end to configure the pin-out and clocks of a device. Configuring the pin-outs this way allows the automated checking to show you if there are any conflicts or limitations in your design before you proceed with any hardware layout or writing a single line of code. Configuring the clocks clocks graphically is also useful in that you can immediately see what effect changes to the downstream peripherals.
STM32CubeMX can auto-generate startupcode but it appears to do this at the HAL driver level pulling in all the required HAL libraries at the same time. This is not the approach I want to follow. My plan is to use STM32CubeMX to check my pin-out & clock configuration and the implement them by hand.
STM32CubeMX contains an updater that will not only update itself but also the Firmware components (e.g. STM32CubeF1).
To get everything I need I will install STM32CubeMX and then use it to obtain STM32CubeF1 (or other device firmware components). I can then link my Makefile to the relevant directory containing STM32CubeF1 to build my programs.
Installing STM32CubeF1 & STM32CubeMX On Linux¶
When using STM32CubeMX to install the Firmware components packages considerations need to be given to the amount of disk space required. Firmware components packages for a range of devices i.e. STM32F1xx is around 300MB, the zip file for this is retained. Update patches are applied to the unzipped Firmware directory structure but again the zip file is retained. The resulting installation size nears 500MB with the possibility that it will grow further. If you plan on using multiple ranges of devices (ie STM32F2xx, STM32L1xx) then a similar amount of space will be used for each range. STM32CubeMX is therefore best installed to a location with plenty of space to grow.
By default the STM32CubeMX will attempt to install itself into the home directory (of the installing user). This is not ideal for me as I backup my user home directory and STM32CubeMX represents a large quantity of data (most of which I don’t need) which can be easily replaced by reinstallation. In my case I will be installing to another directory outside of my home directory (also allows for sharing with other users of the machine).
Download STM32CubeMX from the ST website https://www.st.com
Extract it to a temporary directory ie tempdir/
$ cd tempdir
Follow the graphical installer instructions.
- Change the installation path to a suitable location (ie plenty of room to grow)
Click close to exit the installer.
Go to the installed location and run STM32CubeMX
$ cd /suitable_install_path/STM32CubeMX/
The graphical interface launches.
Select Help > Updater Settings from the menu bar at the top of the screen.
- Change Firmware Repo Folder to a suitable location (subdirectory of STM32CubeMX install location).
Set update check to manual, Click OK.
Select Help>Check for Updates to update STM32CubeMX. This will also check for future updates to the installed Firmware components once they have been added in the next step.
Select Help>Install New Libraries
Install the Libraries for the particular devices you are using. In my case that of STM32F1xx.
Once this has been completed all the tools required should have been installed.