wiki:TBR/BSP/STM32F105

STM32F105

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 http://alanstechnotes.blogspot.fr/2013/03/setting-up-rtems-development.html. 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 http://s937484.blogspot.fr/2013/10/rtems-stm32f407-discovery-board-posted.html: RTEMS is compiled with

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

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
  make install

We run the example from the testsuit c/stm32f105rc/testsuites/samples/hello on Qemu supporting the STM32 architecture as described at: https://github.com/beckus/qemu_stm32

The trick is that, as indicated at ftp://ftp.rtems.eu/pub/rrr/RRR_Quick_Start_Guide_en.pdf, 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));
    assert(uart1);
    assert(uart3);
    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 http://jmfriedt.free.fr/stm32_p103.c and http://jmfriedt.free.fr/stm32.c. 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
    *** BEGIN OF TEST HELLO WORLD ***
    Hello World
    *** END OF TEST 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/configure.ac 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.

Last modified on 02/14/15 at 18:44:13 Last modified on 02/14/15 18:44:13