CMSIS-Compiler Support  
Standard C Library File, I/O and OS Retargeting
 
Loading...
Searching...
No Matches
I/O Retarget example project

This project prints "Hello World" and a counter value via the UART output. It is configured for Arm Virtual Hardware, but other target hardware that provides a CMSIS Driver:USART can be easily added.

Prerequisites

Tools

Packs

  • Required packs are listed in the file retarget.csolution.yml

Project Structure

The project is generated using the CMSIS-Toolbox and is defined in csolution format:

  • retarget.csolution.yml lists the required packs and defines the hardware target and build-types (along with the compiler).
  • retarget.cproject.yml defines the source files and the software components.

Build project in VS Code

Arm Keil Studio Pack Extensions for VS Code include all required tools and interfaces to build the csolution projects.

When the project is opened in VS Code with Arm Keil Studio Extensions installed one must first ensure that the build tools are configured. The Arm Tools Environment Manager should handle this automatically and create vcpkg-configuration.json with all the necessary tools listed. Right-click anywhere in the workspace and select "Configure Arm Tools Environment" to modify tools configuration. See Arm Tools Environment Manager Overview for available functionality.

To build a project using Keil Studio extensions open CMSIS view, open "Manage Solution Settings" view and verify that "Active Target", "Active Projects" and "Build Type" are selected. Since there is only one option in each category they should all be automatically selected.

You can execute the build by selecting "Build" from the CMSIS view.

Build Project from the Command Line

CMSIS-Toolbox provides cbuild command-line tool that builds csolution projects.

The retarget.csolution.yml solution files defines Debug build-type and VHT_CM3 target-type. To build this configuration using Arm Compiler 6 toolchain execute the following command:

cbuild retarget.csolution.yml --toolchain AC6 --packs --context retarget.Debug+VHT_CM3

Note

  • During the build process required packs may be downloaded (--pack flag).

By default the project does not specify the toolchain and one can build the project by specifying the AC6, GCC, CLANG or IAR toolchain.

Execute Project

The project is configured for execution on Arm Virtual Hardware which removes the requirement for a physical hardware board.

To execute application image on Arm Virtual Hardware use below command:

FVP_MPS2_Cortex-M3 -f fvp-config.txt out/retarget/VHT_CM3/Debug/retarget.axf

Note

  • For GCC and CLANG, the application image file has extension .elf and extension .out for IAR.

This command will execute the simulation model and in the default terminal window you should see the following output:

Starting ...
Hello World 1
Hello World 2
Hello World 3
Hello World 4
Hello World 5
Hello World 6
Hello World 7
Hello World 8
Hello World 9
Hello World 10
Finished

The simulation model will automatically terminate after the above output.