Arduion Blue Pill (STM32F103)

This popular, low cost Arduino board (below $2.00) is based on the STM32F103C8 which is a 72MHz device from the STM32 medium-performance line with Cortex-M3 core and FS-USB device. This STM32F103 device has 64k Flash* and 20k SRAM and is in a 48 pin LQFP package, whereby the STM32F103 is also available in various packages from VFQFPN36 up to BGA100 and as 128kB flash part. There is a 8MHz crystal on the board for clocking the part.

Although the STM32F103C8 is specified as having 64kB Flash it is a well known fact that almost all parts on Blue Pill boards physically have 128k Flash!

Full details and documentation for this board can be obtained from its Wiki: Arduino Blue Pill

To configure the µTasker project for this board simply enable the define ARDUINO_BLUE_PILL in the project's config.h file. The compiler needs to be set to build for Cortex M3 (and not Cortex M0, M4 or M7) and the linker script STM32F103_64_20.ld should be selected [STM32F103_64_20_BM.ld for downloadable version] {the linker script extension may vary for different compilers, whereby *.ld is valid for GCC}

Arduino users can use their projects together with the µTasker serial loader by ensuring that their application is linked to the correct start location (typically 0x08003080) and respects a few details as discussed in the appendix of the µTasker serial user's guide : "µTasker – Serial Loader User’s Guide"


Arduino Blue Pill Binaries

Here are some binary files that can be loaded to the board. These were built using the µTasker applications (serial loader and V1.4 application) and can be simply generated using the supported compilers/IDEs [these were built using GCC], built using different configuration options or modified to suit specific requirements or hardware derived from this board:

  • uTaskerSerialLoader_USB-MSD.bin USB-MSD loader which accepts binary files [11.2k] allowing applications to be loaded at link address 0x08003080 (using USB-MSD when the board appears as upload hard disk with the name "BLUE_PILL"). When operating, the green LED blinks at 5Hz. To force the loader, reset the board with the BOOT 1 switch in its '1' position. To disable the watchdog reset the board with pin 20 [B12] connected to GND. This can be loaded using the chip's inbuild UART loader or via the SWD pins. Note that the loader limits application sizes to 32k - it can be built without limits using the µTasker project.
  • BluePill_CDC_BM_V1.4.bin Arduino Blue Pill application with command-line menu on a USB-CDC device connection with various menu items, including the ability to switch to USB-UART-3 bridge mode with end-to-end flow control. USB-CDC requires no drivers from Windows 10. The processor runs at 72MHz [23.3k].
    Linked to 0x08003080, this binary image can be loaded with drag-and-drop onto the upload disk "BLUE PILL" that appears when the serial loader is operating.
    When the application is running the green LED blinks at 2.5Hz.

Instructions

After loading the serial loader for the first time it will start automatically since there is no application loaded and will appear as an external hard drive to the PC host (Windows, Linux and MAC compatible). If there is a file on the disk named "UNKNOWN-BIN" it means that the rest of the flash is not empty and this can be deleted in order to ensure that the flash content is otherwise erased.

Now drag-and-drop the application binary, which will cause an automatic reset and the application will then start operating, appearing as a USB-CDC connection. Open a terminal emulator (eg. TeraTerm) on its virtual COM port and press the input key to see its command line interface. The menus contain various commands that can be experimented with - such a seeing how long the board has been operating for and the state of the HEAP and STACK utilisation, or displaying and modifying internal registers, SRAM or internal Flash.

Enter the administrator menu (4) to find the commands "reset" and "boot": "reset" can be used to command a reset and start the applciation again. "boot" can be used to command a reset back to the boot loader.

Once in the USB-MSD boot loader again a new file can be programmed by first deleting the existing application (which is shown with its original file name, size and data, and can be copied back to the host using drag-and-drop if desired). If the new file to be loaded has the same name as the one already programmed a drag-and-drop on top of the original one is also accepted. Again the new application will start automatically as long as the BOOT 1 switch is not set to the '1' position.

If ever it is necessary to force back to the boot loader (eg. the application that was loaded doesn't allow commanding the loader mode) the BOOT 1 switch can be used instead.

If the application is to be started from the boot loader mode without loading a new version this can be come my commanding an Eject" of the disk from the PC host.

Note that the µTasker project allows various serial loader modes, including SD card, UART, I2C and Ethernet, as well as strong encryption based methods (eg. AES256 over USB-MSD) for professional requirements. The solutions are compatible across many STM32 parts and other families such as Kinetis.

Click to see the video of the serial loader operation on the Arduino Blue Pill.

USB-CDC and Virtual FAT MSD Composite Device

This Arduine Blue Pill application adds FAT emulation on a composite USB-MSD device that appears as an external hard drive in addition to the the USB-CDC virtual COM port.

The µTasker V1.4 application is configured with USB_INTERFACE, USB_DEVICE_SUPPORT, USE_USB_CDC, USE_USB_MSD and FAT_EMULATION). This enables the FAT emulation and makes the device accessible from a USB host. The technique is discussed in the document µTasker - FAT Emulation and allows viewing data files in binary and formatted formats. For example, for retrieving sampled data from linear internal or external SPI Flash to a .csv file for direct import into a processing program.

The disk that appears "DATADISK 1" has 3 fixed files: "ram.bin" containing a snap-shot of the STM32F103's internal SRAM; "software.bin" containing a snap-shot of the devices interal Flash; "uTasker.html" a file that opens in a browser to give additional information and links.

  • BluePill_CDC_VMSD_BM.bin Arduino Blue Pill application with command-line menu on a USB-CDC device connection, plus composite USB-MSD to a virtual FAT system [28.3k].
    Linked to 0x08003080, this binary image can be loaded with drag-and-drop onto the upload disk "BLUE PILL" that appears when the serial loader is operating.


Return to the STM32 landing page


µTasker Arduino Blue Pill support. Copyright (c) 2004..2019 M.J.Butcher Consulting