UART Echo on a simulated STM32

Simulated STM32 – why?

Jumper is excited to announce support for the STM32F4. To provide you a demo of a simulated STM32, we decided to start with one of the essential parts of any embedded system – serial communication over UART.

The following sample will demonstrate a UART echo communication between a simulated STM32 and the host computer. The firmware we’ll work with can run on the Nucleo-F411RE development kit, and therefore also works on the Jumper Virtual Lab.

For those who are not yet familiar with it, the Jumper Virtual Lab is a virtual production clone for your embedded system, powered by behavioral simulation. Jumper makes it fast and easy to develop, test and deploy embedded software. With Jumper simulated hardware environment you can benefit from test automation and continuous integration for embedded software without the hassle, flakiness, and friction you get when working with target hardware.

Getting to UART echo

One of the first tasks an embedded developer takes on when starting a new project is to bring-up UART communication (after Blinky…).

We’ll start by using real hardware, the Nucleo-F411RE (STM32F411 development kit) and then move to the Virtual Lab’s simulated STM32 model.

Creating a UART Echo Firmware

We’ll use the SystemWorkbench for STM32 to create an Ac6 STM32 MCU C Project with HAL for our board.

  1. Open SytemWorkbench
  2. Open new C project: File -> New -> C Project
  3. Choose Project type: Executable -> Ac6 STM32 MCU Project. Enter a project name. New STM32 project
  4. Check Debug and Release and click Next:                                                                 STM32 project configuration
  5. Choose the STM43F4 and the NUCLEO-F411RE and click Next: STM32 board configuration
  6. Choose HAL on the Firmware Configuration and click Finish: Hardware abstraction layer configuration
  7. Download, unzip this main file and copy to the new project’s source directory (src).
  8. Build a binary: Project->Build All
  9. From Debug folder, load your .bin file into the board.
  10. During loading, the LD1 will blink red and green and will turn green on success Nucleo-F411RE firmware load
  11. Open a terminal and connect to the UART char device with 115200 baud rate, on my Mac I’m using screen: screen /dev/tty.usbmodem1423 115200
  12. Type any characters you like and press enter to get an echo: STM32 UART prints

Running the same binary a simulated STM32

To run the simulated STM32 model, I’ll run the Jumper Virtual Lab using Docker on my Mac. Follow these instructions if are not familiar with Jumper Virtual Lab.

  1. Open free account.
  2. Install Jumper.
  3. Run using Docker on any OS.

From Docker terminal:

  1. Go into the directory where your UART echo binary is (note that it need to be mapped when running Docker).
  2. Run: jumper run -u -p stm32f4 –fw Debug/uart_echo_stm32.bin –uart-device
    1. To learn about the jumper run cli flag run: jumper run –help
  3. From another terminal connect to the same Docker container using: docker exec -it bash (note: get the container ID from the docker bash you just used to run jumper. In this example: root@dea457b6ca14 the ID would be dea457b6ca14).
  4. From the same directory you ran Jumper Virtual Lab, type: “ls” and locate USART2 char device file.
  5. Connect to this char device file, using screen: screen USART2
  6. Type any characters you like and press enter to get an echo: running echo UART on a simulated STM32

Isn’t that pretty? We got the same results with the same binary on a real hardware and on a virtual device.

On top of this Jumper Virtual Lab allows you to debug with any GDB client and run test using Jumper’s Python SDK (learn more). With this SDK you can write test automation scenarios and combine that in a continuous integration flow.

As the STM32F4 is still in beta, If you’d like to check Jumper Virtual Lab with your firmware on a Virtual STM32F4, contact us at so we’ll be able to provide you the proper support.