Software and Installation Guide for STM32F407VG Discovery Board

There are many types of softwares available for programming Micro-controllers. These are called toolchains.

A tool-chain is a set of programs, compilers and tools that allows us:

  • to write down our code and to navigate inside source files of our application;
  • to navigate inside the application code, allowing us to inspect variables, function definitions/declarations, and so on;
  • to compile the source code using a cross-platform compiler;
  • to upload and debug our application on the target development board (or a custom board we have made).

To accomplish these activities, we essentially need:

  • an IDE with integrated source editor and navigator;
  • a cross-platform compiler able to compile source code for the ARM Cortex-M platform;
  • a debugger that allows us to execute step by step debugging of firmware on the target board;
  • a tool that allows to interact with the integrated hardware debugger of our STM32F4xx Discovery board (the ST-LINK interface) or the dedicated programmer (e.g. a JTAG adapter).

There are two types of users, Professionals and hobbyists. Companies often prefers to use commercial IDEs (Integrated Development Environment). These companies purchases IDE softwares from other companies like Keil, which also comes with technical support. Also, there are some softwares which are available for free which are called Open Source Software/Tool-chain.

Keil MDK is available to us in many packages, one of them is free and others are having some price based on their features.

Few of the Open Source Softwares are Eclipse, Coocox (CoIDE based on Eclipse and GCC Tool-chain, available on ST Microelectronics website), TrueSTUDIO for STM32 (available from atollic.com website) etc.

One can find out and compare the features of these tool-chains by checking on their websites from following links.

ARM Keil MDK (Microcontroller Development Kit)

TrueSTUDIO for STM32

OpenSTM32

Coocox

Keil MDK

Keil MDK is the complete software development environment for a wide range of Arm Cortex-M based microcontroller devices. MDK includes the µVision IDE and debugger, Arm C/C++ compiler, and essential middleware components. MDK is available only for Windows based computers.

These are the features of Keil µVision Software (IDE/MDK):

  • µVision IDE comes with Integrated Debugger, Flash programmer and the ARM® Compiler tool-chain. MDK is a turn-key product.
  • A full feature Keil RTOS called RTX is included with MDK. RTX comes with a BSD type license. Source code is provided.
  • Serial Wire Viewer and ETM trace capability is included.
  • RTX Kernel Awareness window. It is updated in real-time.
  • Keil Technical Support is included for one year and is easily renewable. This helps you get your project completed faster.
User Guide to Install Keil MDK
  • Make a folder named “Workspace” where all the softwares and projects will be saved in future while learning.
    Make two sub-folders named “Keil” (for installation of software) and “KeilWorkspace” (for saving project files).
  • Download Keil MDK.
    Website: https://www.keil.com/download/product/
    Download MDK-Arm latest version. (Note: C51, C251, C166 are for other devices and not for Arm/Cortex).
    Note: You need to give the required information to download the MDK software.
  • Install the Keil MDK software in “Keil” folder created in first step.
  • Download ST-Link Utility and Install it. This software is required to check microcontroller board connection and update Firmware of Microcontroller Board.

STM32CubeMX

STM32CubeMX is a graphical tool that allows a very easy configuration of STM32 microcontrollers and the generation of the corresponding initialization C code through a step-by-step process. Features of STM32CubeMX software are:

  • Intuitive STM32 microcontroller selection
  • Microcontroller graphical configuration:
    • Pinout with automatic conflict resolution
    • Clock tree with dynamic validation of configuration
    • Peripherals and middleware functional modes and initialization with dynamic validation of parameter constraints
    • Power sequence with estimate of consumption results
  • C code project generation covering STM32 microcontroller initialization compliant with IAR™, Keil™ and GCC compilers.
  • Available as a standalone software running on Windows®, Linux® and macOS® (Apple Inc. trademark registered in the U.S. and other countries) operating systems, or through Eclipse plug-in
User Guide to Install STM32CubeMX
  • Download STM32CubeMX Software.
    Website: https://www.st.com/en/development-tools/stm32cubemx.html#sw-tools-scroll
    Also, Download MCUs Embedded Software for chosen microcontroller.
    For example, for STM32F4 series controller download STM32CubeF4. This will be in .zip form and will be required later on.
  • Install STM32CubeMX software.
  • Once installed, while creating first project, software will ask to download HAL, CMSIS, etc. libraries. Cancel it, and install these libraries from local directory.
    To install locally, Go to “Help” and select “Manage embedded software packages” and then click on “From local”, navigate to directory to install from .zip file.

Eclipse/GCC as tool-chain for STM32

Following are the most important advantages in using a Eclipse/GCC tool-chain for embedded development with STM32 MCU:

  • GCC based: GCC is probably the best compiler on the earth, and it gives excellent results even with ARM based processors. ARM is nowadays the most widespread architecture, and GCC is used by many hardware and software manufacturers as foundation tool for their platform.
  • Cross-platform: Keil is available for only Windows based PC, one can not use the same project file on other Operating System (iOS, Ubuntu, Linux, etc.). While Eclipse, being open source tool-chain, is available on all the platforms. Hence, the same project files can be used on different Operating Systems.
  • Eclipse diffusion: A lot of commercial IDE for STM32 (like TrueSTUDIO, Coocox and others) are also based upon Eclipse. There are a lot of useful plug-ins for Eclipse available for download
  • Open Source: For such giant pieces of software it’s really hard to try to understand their internal programs and modify the code, especially for hardware engineer. But with open source software, it is easy to identify and understand the program faults.
  • Large and growing community: These tool-chains have their own community, where each all the programmers develop new features and fixes bugs, as well as help others whenever they need. In addition to these programmers gives example to use these tool-chains and give economical contribution to the community.
  • free: A commercial IDE can cost a large amount for a small company or a hobbyist, which might not be economical.
User Guide step-wise to Install Eclipse with OpenOCD
  1. Make a folder named “Workspace” where all the softwares and projects will be saved in the future while learning.
    Make two sub-folders named “EclipseWorkspace” and “Software&Toolchain”.
  2. Download Eclipse for C/C++ Developers.
    Website: http://www.eclipse.org
    Download Filename: eclipse-cpp-oxygen-3a-win32-x86_64
    Put it in Folder “Software&Toolchain” and Unzip it.
  3. Download Cross-Toolchain for ARM Cortex Processor
    Website: https://launchpad.net/gcc-arm-embedded
    Download Filename: gcc-arm-none-eabi-7-2017-q4-major-win32.zip
    Put it in Folder “Software&Toolchain” and Unzip it.
  4. Open Eclipse
    When asked create a new project in the above created “EclipseWorkspace” folder.
    Steps to install GNU ARM Eclipse Plugins are as follows:
    Go to “Help” menu and select “Install new Software”.
    Note: Internet Connection is required.
    Select add and then write the following:
    Name: GNU MCU Eclipse Plugin
    Location: http://gnu-mcu-eclipse.netlify.com/v4-neon-updates/
    When added, it will show “GNU ARM & RISC-V C/C++ Cross Development Tools”
    From the dropdown list check only
    GNU MCU C/C++ ARM Cross Compiler 2.6.2.201804191501
    GNU MCU C/C++ Generic Cortex-M Project Template   1.4.3.201804191501
    GNU MCU C/C++ J-Link Debugging       4.3.2.201804191501
    GNU MCU C/C++ OpenOCD Debugging 4.3.2.201804191501
    GNU MCU C/C++ Packs (Experimental)  2.2.2.201804191501
    GNU MCU C/C++ QEMU Debugging      3.3.2.201804191501
    GNU MCU C/C++ STM32Fx Project Templates  2.6.4.201804191501
  5. Windows build tools installation ( Only for windows OS)
    make, rm, mkdir, etc.
    Website: https://github.com/gnu-mcu-eclipse
    Download from: windows-build-tools
    Download Filename: gnu-mcu-eclipse-build-tools-2.10-20180103-1919-win64.zip
    Put it in Folder “Software&Toolchain” and Unzip it.
    Now, Search for “Edit the system environmental variables” in Windows Menu.
    Add new User variables under Environmental Variables giving the path to “Workspace\Software&Toolchain\GNU MCU Eclipse\Build Tools\ 2.10-20180103-1919\bin” where make, echo, mkdir, etc. files are located.
  6. Download and install OpenOCD
    Website: https://github.com/gnu-mcu-eclipse
    Download from: openocd
    Download Filename:gnu-mcu-eclipse-openocd-0.10.0-7-20180123-1217-win64.zip
    Put it in Folder “Software&Toolchain” and Unzip it.
  7. Eclipse project creation AND compilation for ARM Cortex M processor based MCU. (blinky application)
    Open Eclipse software.
    Create a new C/C++ project giving appropriate name.
    Select “ARM Cortex M C/C++ Project” under project type and “ARM Cross GCC” under Tool-chain.
    Select Processor Core “Cortex M4”
    Note: No need to change Clock Frequency.
    Flash Size (kB): 1024
    RAM Size (kB): 192
    Use System Calls: No system calls
    Trace Output: Semihosting DEBUG Channel
    Check following boxes: Check some warnings, Use Og on debug, Use newlib nano
    Click next to go to “Folders” page and change Vendor CMSIS name to “STM32F4xx”.
    On the next page and browse to the path to “bin” folder in the tool-chain folder (For example, Workspace\Software&Toolchain\gcc-arm-none-eabi-7-2017-q4-major-win32\bin) and write “GNU ARM Embedded Tool-chain” in Tool-chain Name.
    Click finish and on the main start-up page of Eclipse software click on “Workbench” on top right side corner.
  8. Understand the project directory structure. (like Project Explorer, Outline, Task List, Build Targets, Console, etc.)
  9. Download CMSIS-CORE.
  10. Download and populate (in Eclipse project) MCU Peripheral Drivers from the silicon vendor.
    Eclipse project settings for your microcontroller.
    example: if your MCU is based on STM32F406xx family then define
    “STM32F446xx” as the preprocessor directive.
    compile the eclipse project and it must be successful .
    Download the code in to target hardware and debug.
    openocd integration
    making a debug configuration for our project.
Advertisements
%d bloggers like this: