Skip to content

Getting started with Zephyr RTOS on BluePill STM32F103C8 board

License

Notifications You must be signed in to change notification settings

m3y54m/zephyr-os-bluepill-playground

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Getting started with Zephyr RTOS on BluePill board

Project Initialization

Create a new project using PlatformIO with the following settings:

  • Board: BluePill F103C8 (Generic)
  • Framework: Zephyr RTOS

Upload

Using ST-LINK

There are several ways to upload the firmware to this board but the default way is to use the ST-Link debugger.

In linux, you can use the following commands to install the ST-Link drivers:

sudo apt -y install stlink-tools
sudo systemctl restart udev

Modify platformio.ini file to set stlink as default upload method:

upload_protocol = stlink

Now you can Upload the firmware to the board using PlaformIO.

You can also use st-flash tool for programming using ST-Link in linux:

st-flash write firmware.bin 0x8000000

Using UART and Embedded Bootloader

All the STM32 microcontrollers come with built-in bootloaders that burned in during production.

memory-mapping

A couple of special MCU pins has to be set-up to proper logical values to enter the bootloader. The pins are named BOOT0 and BOOT1 on the STM32 microcontroller. Boot pins can select several modes of bootloader operation:

BOOT1 BOOT0 Boot Mode Aliasing
X 0 Main Flash Memory Main flash memory is selected as boot space
0 1 System Memory System memory is selected as boot space
1 1 Embedded SRAM Embedded SRAM is selected as boot space

boot-mode

As you can see, there are three cases:

  • The first case is when the BOOT0 pin is tied to the ground, and BOOT1 is open or at a logical state of 0 after the reset program is executed from Main Flash Memory. Grounded BOOT pins are a standard configuration when executing programs in the field.
  • The second case (BOOT1=0; BOOT0=1) means that after reset execution starts at System memory were built into bootloader resides. This is the case when we need to upload binaries via USART1.
  • The third case means that program execution is performed in SRAM.

Read this article to understand how you can use UART1 for programming this board:

Supported Features in Zephyr

The stm32_min_dev board configuration supports the following hardware features:

Interface Controller Driver/Component
NVIC on-chip nested vectored interrupt controller
SYSTICK on-chip system clock
UART on-chip serial port
GPIO on-chip gpio
I2C on-chip i2c
PWM on-chip pwm
SPI on-chip spi
USB on-chip USB device
ADC on-chip adc

Other hardware features are not supported by the Zephyr kernel.

Connections and IOs

Default Zephyr Peripheral Mapping:

  • UART_1 TX/RX: PA9/PA10
  • UART_2 TX/RX: PA2/PA3
  • UART_3 TX/RX: PB10/PB11
  • I2C_1 SCL/SDA : PB6/PB7
  • I2C_2 SCL/SDA : PB10/PB11
  • PWM_1_CH1: PA8
  • SPI_1 NSS_OE/SCK/MISO/MOSI: PA4/PA5/PA6/PA7
  • SPI_2 NSS_OE/SCK/MISO/MOSI: PB12/PB13/PB14/PB15
  • USB_DC DM/DP: PA11/PA12
  • ADC_1: PA0

System Clock

The on-board 8Mhz crystal is used to produce a 72Mhz system clock with PLL.

Serial Port

STM32 Minimum Development Board has 3 U(S)ARTs. The Zephyr console output is assigned to UART_1. Default settings are 115200 8N1.

On-Board LEDs

The board has one on-board LED that is connected to PC13.

Pinout

bluepill-pinout

Schematics

bluepill-schematic

USB to Serial Cable

pl2303hxd-cable

USB to Serial (UART) cable is used to connect the board to a PC.

Blue Pill USB to Serial
A9 (TX1) RXD
A10 (RX1) TXD
G GND

Access to Serial Port in Linux

In order to upload the compiled program to your board you should have access to serial ports. This is done by adding your user to dialout and tty groups:

sudo usermod -a -G dialout $USER
sudo usermod -a -G tty $USER

You can verify if your user is added to dialout and tty groups using this command:

groups $USER

Note: You should log out and log in or reboot your computer to apply the changes.

Resources

Releases

No releases published

Packages

No packages published