Version 14 (modified by JM Friedt, on Feb 14, 2015 at 6:44:13 PM) (diff)



The STM32F105, produced by ST Microelectronics, is part of the STM32F1 series of the lower end CPUs with 64 to 256 kB FLASH and are thus best suited for real time control in industrial applications.

The STM32F105 BSP, based on the STM32F4 BSP, is compiled according to We use the RTEMS toolchain builder from source with

  ../source-builder/sb-set-builder --log=build-log.txt --prefix=$HOME/prefix/compiler/4.11 4.11/rtems-arm

Having compiled the toolchain, RTEMS is compiled for the STM32F105 BSP following RTEMS is compiled with

  export PATH=$HOME/prefix/compiler/4.11/bin:$PATH
  export TARGET="arm-rtems4.11"

in the RTEMS directory and then in the build directory:

  ../rtems/configure --target=${TARGET} --enable-rtemsbsp=stm32f105rc --enable-tests=samples --prefix=$HOME/prefix/rtems-4.11
  make install

We run the example from the testsuit c/stm32f105rc/testsuites/samples/hello on Qemu supporting the STM32 architecture as described at:

The trick is that, as indicated at, the console is connected to UART3. Qemu as found on the previous GIT site only implements UART2: the two options are either to add support for UART3 to Qemu, or to move the console to another serial port. The former solution is easiest, the latter most useful for practical applications on real board which might use other UARTs than UART3. For modifying Qemu, edit hw/arm/stm32_p103.c in the Qemu source tree downloaded from the github site and add both UART1 and UART3 by including

    DeviceState *uart1 = DEVICE(object_resolve_path("/machine/stm32/uart[1]", NULL));
    DeviceState *uart3 = DEVICE(object_resolve_path("/machine/stm32/uart[3]", NULL));
    stm32_uart_connect((Stm32Uart *)uart1,serial_hds[0],STM32_USART1_NO_REMAP);
    stm32_uart_connect((Stm32Uart *)uart3,serial_hds[2],STM32_USART3_NO_REMAP);

The latest revision of the two files located in the hw/arm directory of QEmu for STM32 and compatible with running RTEMS are available at and Having compiled Qemu with these updates, and RTEMS for the STM32F105 BSP, the example is loaded using

    qemu-system-arm -M stm32-p103 -serial stdio -serial stdio -serial stdio -kernel hello.bin

(three times -serial stdio to indicate that all three UART outputs are displayed on stdout). The result is

    VNC server running on `::1:5900'
    LED Off
    Hello World

For modifying the default UART used by the console, either edit the RTEMS BSP defined in the rtems/c/src/lib/libbsp/arm/stm32f4/ file and modify RTEMS_BSPOPTS_SET([STM32F4_ENABLE_USART_3],[*],[1]) for disabling UART3 (remove [1] and replace with []) and activating UART1 (replace [] with [1]). Alternatively, before the configuration step, export variables STM32F4_ENABLE_USART_3="" and STM32F4_ENABLE_USART_1="1" for the same effect. Following this modification, the hello.exe example was run successfuly on a STM32F103RCT microcontroller. It is also known not to run on the STM32F100 value line evaluation board.

Notice that at the moment, the STM32 support for QEmu does not include (yet) the A/D converters: requesting a sample with a loop testing the conversion completion will hang since the conversion never occurs.