IBM Support

STM32 Nucleo microcontroller Profile for IBM Rational Rhapsody

White Papers


Abstract

This profile uses IBM Rational Rhapsody to enable model-driven development for embedded solutions with the STM32 family of microcontrollers.

Procedural C code is generated by the STM32 CubeMX application (provided by STMicroElectronics). This contains the configuration code required to use the microcontroller peripherals such as timers, a/d converters, etc...

This code can then be imported into a Rhapsody project and run on the target using a free GNU-based toolchain (Atolic Truestudio).

Author: Chris Sutton

Content

Supported target devices

This profile supports the following STM32 devices, which are all available as development kits:

- STM32F030R8
- STM32F072RB
- STM32F091RC
- STM32F103RB
- STM32F302R8
- STM32F303RE
- STM32F334R8
- STM32F401RE
- STM32F411RE
- STM32F429ZI
- STM32F767ZI
- STM32H743ZI
- STM32L011K4
- STM32L053R8
- STM32L152RE
- STM32L432KC
- STM32L476RG


Supported Rhapsody Frameworks

The default Rhapsody Object Execution Framework (OXF) is not suitable for many small to medium embedded devices.  Rhapsody offers a series of optimised frameworks to accommodate these requirements. The following frameworks are supported by this profile:

1. MicroC Framework (MXF)

The MXF is an optimised static framework for scheduling and memory management. MISRA compliance is also supported.

Further reading:
https://www.ibm.com/support/knowledgecenter/SSB2MU_8.1.2/com.ibm.rhp.microc.doc/topics/t_microcprofile.html

2. Interrupt Driven Framework (IDF)

The IDF is a light-weight, single-threaded framework. It has been optimised to reduce RAM and executable size. Animation/Tracing instrumentation is disabled and Events/Timer queues are static.

Further reading:
ftp://public.dhe.ibm.com/software/rationalsdp/documentation/product_doc/Rhapsody/version_7-4/Using_the_IDF.pdf

3. Framework disabled (NOF)

Some target devices may have extreme limitations on RAM/Flash. In these cases you can disable a large portion of the Rhapsody OXF. 

Further reading:
http://www-01.ibm.com/support/docview.wss?uid=swg27043154


Prerequisites Software

These need to be installed before continuing:

- Rhapsody 8.3.1 (32bit) or higher ( http://www-01.ibm.com/support/docview.wss?uid=swg24044644 )
- Truestudio 9.x or higher ( https://atollic.com/resources/download/ )
- Cygwin 32bit with make ( https://cygwin.com/setup-x86.exe )
- Java Runtime 1.8.x 32bit (64bit JRE is not currently supported)
- STM32CubeMX v.4.26 or higher ( https://www.st.com/en/development-tools/stm32cubemx.html )
- STLINK USB drivers ( https://www.st.com/en/development-tools/stsw-link009.html )
 


Profile Installation and setup
 

1. Modify the system environment variable OMROOT so that it is pointing to the Rhapsody installation. For example:

C:\ProgramData\IBM\Rational\Rhapsody\8.3.1\Share



2. Add an environment variables called "TRUESTUDIOROOT" and point it to the installation path of the TrueStudio IDE installation. For example:

TRUESTUDIOROOT="C:\TrueSTUDIO for STM32 9.0.0"


Note the quotes and no trailing slash.


3. Add an environment variable called JavaLocation and point it to the installation path of a Java Runtime Environment:

JavaLocation=C:\Program Files (x86)\Java\jre1.8.0_131



4. Download the attachment below and unzip the STM32Profile folder into the Rhapsody share directory. For example:

C:\ProgramData\IBM\Rational\Rhapsody\8.3.1\Share\Profiles\STM32Profile



5. Open a command prompt as administrator and change directory to the Rhapsody install directory - for example, C:\Program Files(x86)\IBM\Rational\Rhapsody\8.3.1\ - and run the two separate commands:

regsvr32 RhapsodyServer.dll

Rhapsody.exe /RegServer



6. Run the ImportCubeMX setup executable.  Press next/finish until the installer has completed. The import program will open. You can close it for now.


QuickStart Guide

For convenience two STM32CubeMX projects are provided for the STM32F103RB and STML476RG development kits. It is recommended you use one of these while familiarising yourself with this profile.

1. Open one of the .ioc STM32CubeMX projects:

STM32Profile/ExampleProjects/CubeMxProjects/F103RB/F103RB_TimerBlink/
STM32Profile/ExampleProjects/CubeMxProjects/L476RG/L476RG_TimerBlink/

Screen Shot 2018-12-21 at 02.54.59



2. In Project menu > Settings, confirm the Firmware Download Location at the bottom of the window. Uncheck the default option if you wish. 


3. Press OK to close the window. You should be prompted to download the firmware at this point.
 



Select YES.

The firmware will now download. This can take a few minutes.

Note you can also download this manually from the ST website - https://www.st.com/en/embedded-software/stm32cube-mcu-packages.html?querycriteria=productId=LN1897  - but you must download the correct package for your microcontroller family.


4. Generate the code using Project menu > Generate code. Close STMCubeMX when completed.


5.  Run the Start Menu > IBM Rational > ImportCubeMX application.


6. Enter information into the fields so that they are validated: OK



- Truestudio IDE: This is the installation of the Truestudio IDE installed in the prerequisites.
- CubeMX project: This is the folder containing the  .ioc STM32CubeMX project file used in step 1.
- BSP Definitions: This is the Drivers\BSP\STM32xxxx_Nucleo directory downloaded in step 3.  For example:
   C:\Users\chris\STM32Cube\Repository\STM32Cube_FW_F1_V1.6.1\Drivers\BSP\STM32F1xx_Nucleo
- Nucleo Development Kit: Select the version to match your development kit
- Rhapsody Project type: This is the framework that the resulting Rhapsody project will use.
- Rhapsody Project Name: This is the name that the resulting Rhapsody project will use.
- Rhapsody Project Path: This is the directory where the resulting Rhapsody project will reside.


7. Press import. When it completes you will be prompted to open the project in Rhapsody. Select this option.


8.  When the project loads ensure that the following message appears in the output window:


If this does not appear, close Rhapsody and close all other Rhapsody processes (check process explorer)


9. Located the STM32ImportPkg > stm32xxxx_it file and add the following code to the TIM1_UP_TIM16_IRQHandler() function:
 

static uint32_t counter = 0;
if (counter >= 50)
{
HAL_GPIO_TogglePin(LED2_GPIO_Port, LED2_Pin);
counter = 0;
}
counter++;



10. This step is different depending on which Rhapsody framework was selected:


For a "No Framework" (NOF) Project:

- Locate the STM32ImportPkg > main file and add the following code to the main function:

HAL_TIM_Base_Start_IT(&htim1);



For an Interrupt-Driven Framework (IDF) Project:

- Locate the STM32ImportPkg > stm32_main file and add the following code to the stm32_setup function:

HAL_TIM_Base_Start_IT(&htim1);



For a MicroC (MXF) Project:

- Locate the STM32ImportPkg > stm32_main file and add the following code to the stm32_setup() function:

HAL_TIM_Base_Start_IT(&htim1);

- Expand the configuration and run the menu command:  [STM32] Regenerate Configuration
 

11. To generate and build the project, use Code menu > Regenerate and then Code menu > Rebuild.


12. Make sure the STM32 Development kit is connected to the USB port on your computer.


13. To download to the target and run, use the Code menu > Target > Run CubeMXImport.elf.


Creating a CubeMX Timer project

This section shows the steps required to create the STM32Cube TimerBlink example. This is for completeness only. First time users should refer to the Quickstart Guide.

1. Open STM32 CubeMX application

2. New project > Select the device from the support list.

3. In Pinout tab:

  • Select Sys > Debug > JTAG (5 pins)

  • Select TIM1 > Clock Source > Internal Clock

  • In diagram, select PA5 as GPIO_OUTPUT

4. In Configuration tab

  • Click GPIO button under System

    • Add user label “LED2”

  • Click NVIC button under System

    • Check TIM1 break interrupt, set Preemption Priority to 1

    • Check TIM1 update interrupt, set Preemption Priority to 1

  • Click TIM1 button under Control

    • Set Prescaler to 64000 (decimal)

    • Set CounterMode to Down

    • Set Counter Period to 1 (decimal)

5. In Project menu > Settings

  • Add project name and location.

  • Set Toolchain/IDE to “Makefile”

  • Use default Firmware location

  • Accept YES if prompted to download the firmware (this should happen if this is the first time you have selected this device.)

6. Project menu > generate code

image

Download

All source code and/or binaries attached to this document are referred to here as "the Program". IBM is not providing program services of any kind for the Program. IBM is providing the Program on an "AS IS" basis without warranty of any kind. IBM WILL NOT BE LIABLE FOR ANY ACTUAL, DIRECT, SPECIAL, INCIDENTAL, OR INDIRECT DAMAGES OR FOR ANY ECONOMIC CONSEQUENTIAL DAMAGES (INCLUDING LOST PROFITS OR SAVINGS), EVEN IF IBM, OR ITS RESELLER, HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

Please contact Rhapsody support to request the download.

https://www.ibm.com/mysupport/s/createrecord/NewCase

[{"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Product":{"code":"SSB2MU","label":"IBM Engineering Systems Design Rhapsody"},"Component":"","Platform":[{"code":"PF033","label":"Windows"}],"Version":"All Versions","Edition":"","Line of Business":{"code":"LOB59","label":"Sustainability Software"}}]

Product Synonym

Rational Rhapsody

Document Information

Modified date:
27 May 2022

UID

ibm10788409