Differences between revisions 2 and 3
Revision 2 as of 2018-05-04 04:08:23
Size: 4403
Editor: RudolfReuter
Comment: new category CategoryTechDoc
Revision 3 as of 2018-05-04 21:41:29
Size: 13341
Editor: RudolfReuter
Comment: new #2
Deletions are marked like this. Additions are marked like this.
Line 8: Line 8:
 [[https://translate.google.de/translate?sl=en&tl=de&js=y&prev=_t&hl=de&ie=UTF-8&u=http%3A%2F%2Fwww.rudiswiki.de%2Fwiki9%2FESP32DoorSensor&edit-text=&act=url|übersetzte deutsche version by google]]

.

.

.
 [[https://translate.google.de/translate?sl=en&tl=de&js=y&prev=_t&hl=de&ie=UTF-8&u=http%3A%2F%2Fwww.rudiswiki.de%2Fwiki9%2FSTM32F103Board&edit-text=&act=url|übersetzte deutsche version by google]]
Line 27: Line 22:
I like to explain the usage with the '''Arduino IDE''' (version 1.8.5).




||<tablestyle="float:right;">[[attachment:ESP32_doorsensor_DSC07603-.jpg|{{attachment:ESP32_doorsensor_DSC07603-.jpg|attachment:ESP32_doorsensor_DSC07603-.jpg|width="320"}}]] ||
Line 35: Line 23:
  * Low cost (about 24 EUR, if more than one is build)
  * Small size (3D printed housing)
  * Battery powered (!LiPo 18650 cell)
  * Integrated charge circuit
  *
Development under Arduino IDE
  * Low cost (usually below 10 EUR)
  * Small size
  * Can be battery powered
  * Software Development under Arduino IDE (Integrated Development Environment) via USB port
Line 42: Line 29:
  * If you allow a '''push signal''' in a MQTT App on a Smartphone, it empties quickly your battery.
  * If you want to have a small housing, you need a 3D printer
  * You need a lot of background knowledge about software
  * Has no '''EEPROM''' included, if you are using a LCD it may have a SD-card interface

I like to explain the usage with the '''Arduino IDE''' (version 1.8.5). You find a here [[#Links|Links #4]] a '''Arduino for STM32 Forum'''.

/!\ I am using the software under '''Mac OS 10.13.4'''. The usage should be similar to '''Linux'''.
Line 50: Line 39:

=== ESP32 Breakout Board ===


[[#Links]].


 * CPU clock: Standard 80 MHz
 * RAM: 520 KB RAM
 * Flash: external 4 MB
 * I/O: 26 pins
 * Temperature sensor: range of -40°C to 125°C
 * Hall sensor

/!\ The '''pinout''' of the '''ESP32Dev Board''' and the '''Wemos !LoLin32''' are different.


=== ESP32 ADC ===


Let's come to the details:
 * '''Supply voltage, analog:''' 3.3 V
 * '''Reference voltage:''' nominal 1.1 V, span: 1.0 - 1.2 Volt, [[https://dl.espressif.com/doc/esp-idf/latest/api-reference/peripherals/adc.html|see here]]
||<tablestyle="float:right;">[[attachment:ESP32_jumper_DSC07608-.jpg|{{attachment:ESP32_jumper_DSC07608-.jpg|attachment:ESP32_jumper_DSC07608-.jpg|width="320"}}]] ||
 * '''Offset:''' the ADC has an '''offset voltage of 0.1 V'''.
 * '''Voltage Scaling:''' Espressif tell about '''attenuation'''. The highest usable attenuation is '''6 dB''' = divider factor 2. The maximum attenuation is 11 dB (software default), but it is not linear, and needs a lookup table for using it.

See on the right side the '''picture'''. The '''jumper''' can be replaced with an '''mA meter''' for measuring the '''standby current'''.

[[#Links|Links #1]]. Then you need the '''Hardware Extension ESP32''', which can be installed with:
||<tablestyle="float:right;">[[attachment:STM32_BluePill_DSC07650.jpg|{{attachment:STM32_BluePill_DSC07650.jpg|attachment:STM32_BluePill_DSC07650.jpg|width="400"}}]] ||
=== Blue Pill ===
A good description is at [[#Links|Links #4]].

 * Features
  * Model: STM32F103C8T6
  * Kernel: ARM32 bit Cortex™-M3CPU
  * 8 MHz crystal oscillator
  * 32.768 KHz crystal oscillator
  * Size: 22.9 mm x 53.4 mm
  * 40 pins Dual In Line (DIL), '''different''' pin layout to Maple Mini
  * Debug Mode: SWD (Serial Wire Debug), use software [[http://openocd.org/|openOCD]],
  * 4 pin connector for '''STLink V2''' Simulator Programmer Downloader
  * '''Micro''' USB connector, for 5V power supply, serial I/O and programming (Arduino IDE)
  * Boot mode jumper (programming / operation)
  * LED green on port '''PC13'''
  * '''No''' USB '''disconnect''' signal
  * '''Needs''' Bootloader for Arduino USB port programming, [[https://github.com/rogerclarkmelbourne/STM32duino-bootloader/tree/master/binaries|generic_boot20_pc13.bin]]
  * '''No''' separate 3V3 supply for the '''analog part''' of the CPU

 * MCU Introduction
  1. Maximum operating frequency 72MHz
  2. Single-cycle multiply and hardware divide
  3. 64k or 128 Flash program memory
  4. 20k bytes SRAM
  5. 2.0-3.6V power supply and I/O pins
  6. Power On Reset (POR / PDR), programmable voltage detector (PVD)
  7. 4-16 MHz crystal oscillator
  8. PLL (Phase Locked Loop) for CPU clock
  9. Sleep, Stop and Standby modes
  10. VBAT power supply for the RTC (Real Time Clock) and backup registers
  11. 37 I/O ports, the I/O ports can be mapped to 16 external interrupts vectors, some are 5V tolerant

A German description of the '''Blue Pill''' at [[#Links|Links #3]].


||<tablestyle="float:right;">[[attachment:STM32_STLinkV2_DSC07653.jpg|{{attachment:STM32_STLinkV2_DSC07653.jpg|attachment:STM32_STLinkV2_DSC07653.jpg|width="400"}}]] ||
==== Programming the STM32 ====
 1. Programming with the '''STLink V2''' interface, for ordering see at [[https://www.banggood.com/|Banggood]] for the title "3.3V 5V XTW ST-LINK V2 STM8 / STM32 Simulator Programmer" (about 3 EUR). See the '''picture''' on the right, with the 4 wire cable to connect the STM32 board.
 1. With the '''STLink V2''' interface you can use the software [[http://openocd.org/|openOCD]] (On Chip Debugging) for debugging and programming.
 1. If the Boot Loader '''generic_boot20_pc13.bin''' is installed, you can program the STM32 via '''USB port''' with the '''Arduino IDE'''.
Following the different methods are explained in detail.


==== STMLink V2 interface ====
The STMLink V2 interface is connected with 4 wires to the STM32 board '''programming connector'''. It also supplies the 3V3 voltage.
 * USB idendity: VID 0x0483 PID 0x3748
 * Jumper '''BOOT0''' must be set to '''1''' for programming
 * with Arduino USB port Upload method: "STM32duino bootloader" jumper BOOT0 must be 0
 * Install utility '''stlink'''
{{{
# Install on Mac OS with Homebrew (version 1.5.0)
$ brew install stlink
# show manual of flash program
$ man st-flash

# Other checks:
$ st-info --probe
Found 1 stlink programmers
 serial: 543f6b06506650511649173f
openocd: "\x54\x3f\x6b\x06\x50\x66\x50\x51\x16\x49\x17\x3f"
  flash: 131072 (pagesize: 1024)
   sram: 20480
 chipid: 0x0410
  descr: F1 Medium-density device

$ st-info --flash
0x20000 # 131072 bytes
}}}
Another documentation for Linux at [[#Links|Links #2]] from [[https://github.com/rogerclarkmelbourne|Roger Clark]].


==== Boot Loader ====
The board is shipped with a '''Blink''' programm in the Flash-ROM, but it '''no Boot Loader''' programmed, which enumerates the '''USB port''' for '''Arduino programming''' and '''Serial I/O'''.

 * Install Boot Loader with '''STLink V2 interface''':
{{{
# Download Boot Loader file to actual directory, see at "Features" for the Link
# Set Jumper BOOT0 to 1
$ st-flash write generic_boot20_pc13.bin 0x8000000
st-flash 1.4.0
2018-05-02T06:33:00 INFO usb.c: -- exit_dfu_mode
2018-05-02T06:33:00 INFO common.c: Loading device parameters....
2018-05-02T06:33:00 INFO common.c: Device connected is: F1 Medium-density device, id 0x20036410
2018-05-02T06:33:00 INFO common.c: SRAM size: 0x5000 bytes (20 KiB), Flash: 0x20000 bytes (128 KiB) in pages of 1024 bytes
2018-05-02T06:33:00 INFO common.c: Attempting to write 21140 (0x5294) bytes to stm32 address: 134217728 (0x8000000)
Flash page at addr: 0x08005000 erased
2018-05-02T06:33:00 INFO common.c: Finished erasing 21 pages of 1024 (0x400) bytes
2018-05-02T06:33:00 INFO common.c: Starting Flash write for VL/F0/F3/F1_XL core id
2018-05-02T06:33:00 INFO flash_loader.c: Successfully loaded flash loader in sram
 21/21 pages written
2018-05-02T06:33:01 INFO common.c: Starting verification of write complete
2018-05-02T06:33:02 INFO common.c: Flash written and verified! jolly good!

# Remove STLink cable
# Set Jumper BOOT0 to 0

# Connect Micro USB cable to PC
# Check for USB device
$ ls /dev/cu.u*
/dev/cu.usbmodem14321
# Now Arduino IDE programming is possible
}}}


==== openOCD ====
The openOCD software must be used with the STLink V2 interface. The first application is the check for '''128KB Flash-ROM''' in the '''STM32F103x8''' (from data sheet just 64 KB).

See at [[https://www.mikrocontroller.net/articles/STM32F103C8T6_STM32_Billig_Board#128k_Flash|mikrocontroller.net]] for the details.

Program openOCD opens a '''Telnet port 4444''' for remote controlling. Start with '''Terminal #1'''.
{{{
# Install openOCD software with Homebrew
$ brew install openOCD
Installing dependencies for open-ocd: libusb-compat, libftdi, hidapi
 /usr/local/Cellar/open-ocd/0.10.0: 632 files, 4.7MB

# Edit /usr/local/Cellar/open-ocd/0.10.0/share/openocd/scripts/target/stm32f1x.cfg
flash bank $_FLASHNAME stm32f1x 0 0x20000 0 0 $_TARGETNAME
adapter_khz 950

# Press Reset on the board

# Start openOCD Telnet server
$ openocd -f /usr/local/Cellar/open-ocd/0.10.0/share/openocd/scripts/interface/stlink-v2.cfg -f /usr/local/Cellar/open-ocd/0.10.0/share/openocd/scripts/target/stm32f1x.cfg
Open On-Chip Debugger 0.10.0
Licensed under GNU GPL v2
For bug reports, read
 http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "hla_swd". To override use 'transport select <transport>'.
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
adapter speed: 950 kHz
adapter_nsrst_delay: 100
none separate
Info : clock speed 950 kHz
Info : STLINK v2 JTAG v17 API v2 SWIM v4 VID 0x0483 PID 0x3748
Info : using stlink api v2
Info : Target voltage: 3.247246
Info : stm32f1x.cpu: hardware has 6 breakpoints, 4 watchpoints
# waiting for connection via telnet
Info : accepting 'telnet' connection on tcp/4444
# reset halt
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x1ffff020 msp: 0x200001fc
# flash probe 0
Info : device id = 0x20036410
Info : ignoring flash probed value, using configured bank size
Info : flash size = 128kbytes
flash 'stm32f1x' found at 0x08000000
wrote 120832 bytes from file /Volumes/DAT/Users/rudi/STM32_JPG_121K.bin in 6.591493s (17.902 KiB/s)
dumped 131071 bytes in 2.795402s (45.789 KiB/s)

# to finish Telnet server press key CTRL C
}}}

Prepare a JPG picture with a size of about 120KB (< 128 KB), and rename to .bin (e.g. STM32_JPG_121K.bin).

Open '''Terminal #2''' for control.
{{{
# type the commands after the ">" prompt.
# See in Terminal #1 for the answers.

$ brew install telnet # only once
$ telnet localhost 4444
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Open On-Chip Debugger

> reset halt
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x1ffff020 msp: 0x200001fc
> flash probe 0
> flash write_image erase /Volumes/DAT/Users/rudi/STM32_JPG_121K.bin 0x08000000
> dump_image /Volumes/DAT/Users/rudi/STM32_JPG_121K.jpg 0x08000000 0x1ffff
> exit

# check if dumped image is OK, then the Flash-ROM has 128Kb.

# Restore the Boot Loader
}}}


==== Arduino IDE ====
Install the STM32 addition:
 * Arduino menu->Sketch->include library->administrate library - Install '''A_STM32_Examples'''
 * Restart Arduino IDE (V. 1.8.5)
 * Load program Arduino menu->Files->Examples->01.Basics->Blink
 * Replace '''LED_BUILTIN''' by '''PC13'''
 * In Aduino menu->Tools setup:
{{{
Board: "Generic STM32F103C series"
Variant: "STM32F103C8 (20k RAM. 64k Flash)" or 128k
CPU speed (MHz): "72Mhz (Normal)"
Upload method: "STM32duino bootloader"
Optimize: "Smallest (default)"
Port: "/dev/cu.usbmodem14321 (Maple Mini)"
}}}
 * Compile and upload (programm Flah-ROM)
 * Check, if the green LED blinks.


=== Leaf Maple Mini ===
See [[http://wiki.stm32duino.com/index.php?title=Maple_Mini|STM32duino]].

The Maple Mini is the second of the two original STM32F103 boards made by [[https://www.leaflabs.com/maple/|LeafLabs]]. It was released in 2011. The original Maple Mini is no longer available, but several companies make clones, which has virtually identical functionality.

 * Features
  * Model: STM32F103CBT6
  * Kernel: ARM32 bit Cortex™-M3CPU
  * 8 MHz crystal oscillator
  * '''No''' 32.768 KHz crystal oscillator
  * Size: 22.9 mm x 53.4 mm
  * 40 pins Dual In Line (DIL), '''different''' pin layout to Blue Pill
  * Debug Mode: SWD (Serial Wire Debug), use software [[http://openocd.org/|openOCD]],
  * '''No''' 4 pin connector for '''STLink V2''' Simulator Programmer Downloader, connect to DIL pins J2,11 SWDCLK, J2,10 SWDIO
  * '''Mini''' USB connector, for 5V power supply, serial I/O and programming (Arduino IDE)
  * No Boot mode jumper (programming / operation), instead '''Push button''' on BOOT0
  * LED blue on port '''PB1'''
  * Push (3V3) button on port '''PB8''' and '''BOOT0''', J2 pin 18
  * USB '''disconnect''' signal from port '''PB9'''
  * Separate 3V3 supply for the '''analog part''' of the CPU, AV+ at pin J1,1, AV- ar pin J1,2

Line 85: Line 270:
 1. !WeMos® LOLIN32 V1.0.0 !WiFi + Bluetooth Board, https://www.banggood.com Product ID: 1164252, or https://de.aliexpress.com
 1. 100Pcs Mini Micro JST 2.0 PH 2Pin Connector Plug With 120mm Wires Cables, 3 EUR, https://www.banggood.com Product ID: 1147298
Line 92: Line 276:
 1. [[https://hackaday.com/2017/05/03/hands-on-hot-new-wemos-esp-32-breakout/|Hackaday - Wemos LoLin32 ESP32 module review]]  1. [[https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki/Programming-an-STM32F103XXX-with-a-generic-%22ST-Link-V2%22-programmer-from-Linux|Programming an STM32F103XXX with a generic "ST Link V2" programmer from Linux]]
 1. [[https://www.heise.de/developer/artikel/Keine-bittere-Pille-die-Blue-Pill-mit-ARM-Cortex-M3-4009580.html|Keine bittere Pille - die Blue Pill mit ARM Cortex M3]]
 1. [[http://wiki.stm32duino.com/index.php?title=Blue_Pill|Wiki stm32duino Blue Pill documentation]]
 1. [[http://www.stm32duino.com/viewforum.php?f=1|stm32duino Arduino Forum ]]

/!\ Vorläufig / Preliminary, work in progress /!\

STM32F103 Boards

From company STMicroelectronics there is a powerful low cost ARM®-based 32-bit MCU with 64 or 128 KB Flash, USB, CAN, 7 timers, 2 ADCs, 9 com. interfaces, named STM32F103x8 (64 KByte Flash ROM) and STM32F103xB (128 KByte Flash ROM).

It is interesting that some (most?) STM32F103x8 also have a 128 KByte Flash ROM, explained later.

There are 2 popular boards (3 - 5 EUR) on the market (Ebay, banggood.com, etc.):

  • STM32F103C8T6 Small System Board Microcontroller, nick name Blue Pill.

  • STM32F103RCBT6 ARM Cortesx-M3 Leaf Maple Mini Module.

Unfortunately boards delivered from China have usually very little documentation for the usage.

  • Benefits:

    • Low cost (usually below 10 EUR)
    • Small size
    • Can be battery powered
    • Software Development under Arduino IDE (Integrated Development Environment) via USB port
  • Drawbacks:

    • Has no EEPROM included, if you are using a LCD it may have a SD-card interface

I like to explain the usage with the Arduino IDE (version 1.8.5). You find a here Links #4 a Arduino for STM32 Forum.

/!\ I am using the software under Mac OS 10.13.4. The usage should be similar to Linux.

/!\ A mouse click on a picture will expand the picture for better viewing.

/!\ A mouse click on a source program will show the listing in a new window with colour coding.

attachment:STM32_BluePill_DSC07650.jpg

Blue Pill

A good description is at Links #4.

  • Features
    • Model: STM32F103C8T6
    • Kernel: ARM32 bit Cortex™-M3CPU
    • 8 MHz crystal oscillator
    • 32.768 KHz crystal oscillator
    • Size: 22.9 mm x 53.4 mm
    • 40 pins Dual In Line (DIL), different pin layout to Maple Mini

    • Debug Mode: SWD (Serial Wire Debug), use software openOCD,

    • 4 pin connector for STLink V2 Simulator Programmer Downloader

    • Micro USB connector, for 5V power supply, serial I/O and programming (Arduino IDE)

    • Boot mode jumper (programming / operation)
    • LED green on port PC13

    • No USB disconnect signal

    • Needs Bootloader for Arduino USB port programming, generic_boot20_pc13.bin

    • No separate 3V3 supply for the analog part of the CPU

  • MCU Introduction
    1. Maximum operating frequency 72MHz
    2. Single-cycle multiply and hardware divide
    3. 64k or 128 Flash program memory
    4. 20k bytes SRAM
    5. 2.0-3.6V power supply and I/O pins
    6. Power On Reset (POR / PDR), programmable voltage detector (PVD)
    7. 4-16 MHz crystal oscillator
    8. PLL (Phase Locked Loop) for CPU clock
    9. Sleep, Stop and Standby modes
    10. VBAT power supply for the RTC (Real Time Clock) and backup registers
    11. 37 I/O ports, the I/O ports can be mapped to 16 external interrupts vectors, some are 5V tolerant

A German description of the Blue Pill at Links #3.

attachment:STM32_STLinkV2_DSC07653.jpg

Programming the STM32

  1. Programming with the STLink V2 interface, for ordering see at Banggood for the title "3.3V 5V XTW ST-LINK V2 STM8 / STM32 Simulator Programmer" (about 3 EUR). See the picture on the right, with the 4 wire cable to connect the STM32 board.

  2. With the STLink V2 interface you can use the software openOCD (On Chip Debugging) for debugging and programming.

  3. If the Boot Loader generic_boot20_pc13.bin is installed, you can program the STM32 via USB port with the Arduino IDE.

Following the different methods are explained in detail.

The STMLink V2 interface is connected with 4 wires to the STM32 board programming connector. It also supplies the 3V3 voltage.

  • USB idendity: VID 0x0483 PID 0x3748
  • Jumper BOOT0 must be set to 1 for programming

  • with Arduino USB port Upload method: "STM32duino bootloader" jumper BOOT0 must be 0
  • Install utility stlink

# Install on Mac OS with Homebrew (version 1.5.0)
$ brew install stlink
# show manual of flash program
$ man st-flash

# Other checks:
$ st-info --probe
Found 1 stlink programmers
 serial: 543f6b06506650511649173f
openocd: "\x54\x3f\x6b\x06\x50\x66\x50\x51\x16\x49\x17\x3f"
  flash: 131072 (pagesize: 1024)
   sram: 20480
 chipid: 0x0410
  descr: F1 Medium-density device

$ st-info --flash
0x20000           # 131072 bytes

Another documentation for Linux at Links #2 from Roger Clark.

Boot Loader

The board is shipped with a Blink programm in the Flash-ROM, but it no Boot Loader programmed, which enumerates the USB port for Arduino programming and Serial I/O.

  • Install Boot Loader with STLink V2 interface:

# Download Boot Loader file to actual directory, see at "Features" for the Link
# Set Jumper BOOT0 to 1
$ st-flash write generic_boot20_pc13.bin 0x8000000
st-flash 1.4.0
2018-05-02T06:33:00 INFO usb.c: -- exit_dfu_mode
2018-05-02T06:33:00 INFO common.c: Loading device parameters....
2018-05-02T06:33:00 INFO common.c: Device connected is: F1 Medium-density device, id 0x20036410
2018-05-02T06:33:00 INFO common.c: SRAM size: 0x5000 bytes (20 KiB), Flash: 0x20000 bytes (128 KiB) in pages of 1024 bytes
2018-05-02T06:33:00 INFO common.c: Attempting to write 21140 (0x5294) bytes to stm32 address: 134217728 (0x8000000)
Flash page at addr: 0x08005000 erased
2018-05-02T06:33:00 INFO common.c: Finished erasing 21 pages of 1024 (0x400) bytes
2018-05-02T06:33:00 INFO common.c: Starting Flash write for VL/F0/F3/F1_XL core id
2018-05-02T06:33:00 INFO flash_loader.c: Successfully loaded flash loader in sram
 21/21 pages written
2018-05-02T06:33:01 INFO common.c: Starting verification of write complete
2018-05-02T06:33:02 INFO common.c: Flash written and verified! jolly good!

# Remove STLink cable
# Set Jumper BOOT0 to 0

# Connect Micro USB cable to PC
# Check for USB device
$ ls /dev/cu.u*
/dev/cu.usbmodem14321
# Now Arduino IDE programming is possible 

openOCD

The openOCD software must be used with the STLink V2 interface. The first application is the check for 128KB Flash-ROM in the STM32F103x8 (from data sheet just 64 KB).

See at mikrocontroller.net for the details.

Program openOCD opens a Telnet port 4444 for remote controlling. Start with Terminal #1.

# Install openOCD software with Homebrew
$ brew install openOCD
Installing dependencies for open-ocd: libusb-compat, libftdi, hidapi
 /usr/local/Cellar/open-ocd/0.10.0: 632 files, 4.7MB

# Edit /usr/local/Cellar/open-ocd/0.10.0/share/openocd/scripts/target/stm32f1x.cfg
flash bank $_FLASHNAME stm32f1x 0 0x20000 0 0 $_TARGETNAME
adapter_khz 950

# Press Reset on the board

# Start openOCD Telnet server
$ openocd -f /usr/local/Cellar/open-ocd/0.10.0/share/openocd/scripts/interface/stlink-v2.cfg -f /usr/local/Cellar/open-ocd/0.10.0/share/openocd/scripts/target/stm32f1x.cfg
Open On-Chip Debugger 0.10.0
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "hla_swd". To override use 'transport select <transport>'.
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
adapter speed: 950 kHz
adapter_nsrst_delay: 100
none separate
Info : clock speed 950 kHz
Info : STLINK v2 JTAG v17 API v2 SWIM v4 VID 0x0483 PID 0x3748
Info : using stlink api v2
Info : Target voltage: 3.247246
Info : stm32f1x.cpu: hardware has 6 breakpoints, 4 watchpoints
# waiting for connection via telnet
Info : accepting 'telnet' connection on tcp/4444
# reset halt
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x1ffff020 msp: 0x200001fc
# flash probe 0
Info : device id = 0x20036410
Info : ignoring flash probed value, using configured bank size
Info : flash size = 128kbytes
flash 'stm32f1x' found at 0x08000000
wrote 120832 bytes from file /Volumes/DAT/Users/rudi/STM32_JPG_121K.bin in 6.591493s (17.902 KiB/s)
dumped 131071 bytes in 2.795402s (45.789 KiB/s)

# to finish Telnet server press key CTRL C

Prepare a JPG picture with a size of about 120KB (< 128 KB), and rename to .bin (e.g. STM32_JPG_121K.bin).

Open Terminal #2 for control.

# type the commands after the ">" prompt.
# See in Terminal #1 for the answers.

$ brew install telnet # only once
$ telnet localhost 4444
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Open On-Chip Debugger

> reset halt
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x1ffff020 msp: 0x200001fc
> flash probe 0
> flash write_image erase /Volumes/DAT/Users/rudi/STM32_JPG_121K.bin 0x08000000
> dump_image /Volumes/DAT/Users/rudi/STM32_JPG_121K.jpg 0x08000000 0x1ffff
> exit

# check if dumped image is OK, then the Flash-ROM has 128Kb.

# Restore the Boot Loader

Arduino IDE

Install the STM32 addition:

  • Arduino menu->Sketch->include library->administrate library - Install A_STM32_Examples

  • Restart Arduino IDE (V. 1.8.5)
  • Load program Arduino menu->Files->Examples->01.Basics->Blink

  • Replace LED_BUILTIN by PC13

  • In Aduino menu->Tools setup:

Board: "Generic STM32F103C series" 
Variant: "STM32F103C8 (20k RAM. 64k Flash)"  or 128k
CPU speed (MHz): "72Mhz (Normal)"
Upload method: "STM32duino bootloader"
Optimize: "Smallest (default)"
Port: "/dev/cu.usbmodem14321 (Maple Mini)"
  • Compile and upload (programm Flah-ROM)
  • Check, if the green LED blinks.

Leaf Maple Mini

See STM32duino.

The Maple Mini is the second of the two original STM32F103 boards made by LeafLabs. It was released in 2011. The original Maple Mini is no longer available, but several companies make clones, which has virtually identical functionality.

  • Features
    • Model: STM32F103CBT6
    • Kernel: ARM32 bit Cortex™-M3CPU
    • 8 MHz crystal oscillator
    • No 32.768 KHz crystal oscillator

    • Size: 22.9 mm x 53.4 mm
    • 40 pins Dual In Line (DIL), different pin layout to Blue Pill

    • Debug Mode: SWD (Serial Wire Debug), use software openOCD,

    • No 4 pin connector for STLink V2 Simulator Programmer Downloader, connect to DIL pins J2,11 SWDCLK, J2,10 SWDIO

    • Mini USB connector, for 5V power supply, serial I/O and programming (Arduino IDE)

    • No Boot mode jumper (programming / operation), instead Push button on BOOT0

    • LED blue on port PB1

    • Push (3V3) button on port PB8 and BOOT0, J2 pin 18

    • USB disconnect signal from port PB9

    • Separate 3V3 supply for the analog part of the CPU, AV+ at pin J1,1, AV- ar pin J1,2

Parts List

  1. Arduino Software IDE download (Integrated Development Environment), actual version 1.8.5.

  2. Programming an STM32F103XXX with a generic "ST Link V2" programmer from Linux

  3. Keine bittere Pille - die Blue Pill mit ARM Cortex M3

  4. Wiki stm32duino Blue Pill documentation

  5. stm32duino Arduino Forum

{i} Go to Top of the page

Contact Email

Please enter your Email address, if you expect an answer.

/!\ The entered Email address will not be published, or given away.

Comment this page
Name:
Comment:
Are you human?

List of pages in this category:

-- RudolfReuter 2018-05-03 18:02:24


Go back to CategoryTechDoc or FrontPage

STM32F103Board (last edited 2018-05-23 12:53:25 by RudolfReuter)