STM32F1 USB

A special USB Blue Pill Image that can be used to test if the USB on your board is working. It can also read the MCU internal ‘Device Electronic Signature’. Runs in a 64KB Flash STM32F103.

This uses the Mecrisp-Stellaris USB driver for STM32F103 by Jean-Claude Wippler which is based on the Coreforth USB driver by Eckhart Köppen.

Note

From Viktor Dvořák. USB needs PC side idVendor = 0x0483 idProduct = 0x7540 driver which is STM32 Virtual COM port driver desribed in en.DM00478229.pdf. The driver is en.stsw-stm32102.zip (24755 kB) is available directly from st.com

Use it to check for FAKE STM32F103 MCU’s and let me know if it is useful ?

Note

if you don’t have a Blue Pill, read my rant before thinking about buying one ?

_images/stm32f1-usb-terminal.jpg
Project Name: STM32F103 Created 20191107-0028 by terry porter
1882bdaff62f637a7bdd517d14f4c1a4.README: Specific Notes regarding Mecrisp-Stellaris
Kernel 1882bdaff62f637a7bdd517d14f4c1a4.bin
-----------------------------------------------------------------------------------
Special 64 KB USB image. This image runs from the USB port on any STM32F103.

1. Flash 1882bdaff62f637a7bdd517d14f4c1a4.bin image to board using your usual method
2. Connect blue pill USB port to PC and look for  "<Mecrisp STM32F10x Forth Serial Port>" device in your system
3. Connect a PC serial terminal to the USB device above, you can choose any Baud Rate. NOTE: There is NO HANDSHAKING,
so a End Of Line Delay of 200ms will required for uploads.
4. You should see "MS RA 2.5.1 tpmod for STM32F103 by Matthias Koch" at board power up

What special facilities exist on the board apart from all the standard Mecrisp-Stellaris Words ?

1. "stm32id" for interrogating the electronic chip ID as below. Perhaps it may find FAKES? let me know if it does ?
stm32id 
Die xy coords: 108068691 
Wafer Number: 80 
Lot_num ascii encoded  [23:0]: 0x00555071  | U P q
Lot_num ascii encoded [55:24]: 0x87011723  | . . . #

2. "free"  
FLASH.. TOTAL REPORTED: 65536 USED: 51200 FREE: 14336 
RAM.... TOTAL PRESET: 20000 USED: 868 FREE: 19132

3. "words4"
Four column Word lister

4. "Dump" and "dump16"
gpioa hex. 40010800  ok.
$40010800 dump16 40010800 :  A4 4A 44 44 44 44 85 88   3C B7 00 00 00 B0 00 00  | .JDDDD..  <....... |
 ok.

5. "bin."
1000 bin. 
3322222222221111111111
10987654321098765432109876543210 
00000000000000000000001111101000

6. all the registers for the following peripherals. Not all peripherals could be included due to flash space requirements.
PWR
RCC
GPIOA
GPIOB
GPIOC
AFIO
EXTI
DMA1
SDIO
RTC
TIM1
I2C1
SPI1
USART1
ADC1
NVIC

Example:
rcc_cfgr. 
RCC_CFGR  $001D840A 
3|3|2|2|2|2|2|2|2|2|2|2|1|1|1|1|1|1|1|1|1|1|
1|0|9|8|7|6|5|4|3|2|1|0|9|8|7|6|5|4|3|2|1|0|9|8|7|6|5|4|3|2|1|0 
0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 1 1 0 0 0 0 1 0 0 0 0 0 0 1 0 1 0
 ok.

gpioa. 
GPIOA_CRL  $44444AA4 
3|3|2|2|2|2|2|2|2|2|2|2|1|1|1|1|1|1|1|1|1|1|
1|0|9|8|7|6|5|4|3|2|1|0|9|8|7|6|5|4|3|2|1|0|9|8|7|6|5|4|3|2|1|0 
0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 1 0 1 0 1 0 1 0 0 1 0 0

GPIOA_CRH  $88854444 
3|3|2|2|2|2|2|2|2|2|2|2|1|1|1|1|1|1|1|1|1|1|
1|0|9|8|7|6|5|4|3|2|1|0|9|8|7|6|5|4|3|2|1|0|9|8|7|6|5|4|3|2|1|0 
1 0 0 0 1 0 0 0 1 0 0 0 0 1 0 1 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0

GPIOA_IDR  $0000B73C 
3|3|2|2|2|2|2|2|2|2|2|2|1|1|1|1|1|1|1|1|1|1|
1|0|9|8|7|6|5|4|3|2|1|0|9|8|7|6|5|4|3|2|1|0|9|8|7|6|5|4|3|2|1|0 
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 1 1 1 0 0 1 1 1 1 0 0

GPIOA_ODR  $0000B000 
3|3|2|2|2|2|2|2|2|2|2|2|1|1|1|1|1|1|1|1|1|1|
1|0|9|8|7|6|5|4|3|2|1|0|9|8|7|6|5|4|3|2|1|0|9|8|7|6|5|4|3|2|1|0 
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0

GPIOA_BSRR  $00000000 
3|3|2|2|2|2|2|2|2|2|2|2|1|1|1|1|1|1|1|1|1|1|
1|0|9|8|7|6|5|4|3|2|1|0|9|8|7|6|5|4|3|2|1|0|9|8|7|6|5|4|3|2|1|0 
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

GPIOA_BRR  $00000000 
3|3|2|2|2|2|2|2|2|2|2|2|1|1|1|1|1|1|1|1|1|1|
1|0|9|8|7|6|5|4|3|2|1|0|9|8|7|6|5|4|3|2|1|0|9|8|7|6|5|4|3|2|1|0 
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

GPIOA_LCKR  $00000000 
3|3|2|2|2|2|2|2|2|2|2|2|1|1|1|1|1|1|1|1|1|1|
1|0|9|8|7|6|5|4|3|2|1|0|9|8|7|6|5|4|3|2|1|0|9|8|7|6|5|4|3|2|1|0 
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
 ok.

Download

Image tarball here: https://sourceforge.net/projects/mecrisp-stellaris-folkdoc/files/mecrisp-stellaris-1882bdaff62f637a7bdd517d14f4c1a4.tar.gz/download

Note

all software on this site is released under the GPL V2 or BSD V3 licenses.

STM32ID

This program is based on the STM32F0 technical documentation because the STM32F1xx technical doc doesn’t give the format of the actual “device electronic Unique ID register” and many assume that the format is the same as the STM32F0.

I’m leaning towards the theory that they’re slightly different by way of the “lot numbers” because the none of the ASCII data for the F1 chips looks sensible to me so far. Perhaps they are “lot numbers” but just sequential decimal numbers without character based information ?

The “die” and ‘wafer number” data seems reasonable in all cases.

However in the F051 signature below, the ASCII lot number layout seems reasonable ? I’ll add to this when I get another F051 board set up to read.

NON STM32F103 MCU’s For Comparison

STM32F051

Die xy coords: 2752589
Wafer Number: 14
Lot_num ascii encoded  [23:0]: 0x00413657  | A 6 W
Lot_num ascii encoded [55:24]: 0x20323336  |   2 3 6

STM32L073

Die xy coords: 21444402
Wafer Number: 48
Lot_num ascii encoded  [23:0]: 0x00343837  | 4 8 7
Lot_num ascii encoded [55:24]: 0x00000011  | . . . .

STM32F103 or Clone Results

1882bdaff62f637a7bdd517d14f4c1a4.bin User Results

This is the chip/board I developed my 1882bdaff62f637a7bdd517d14f4c1a4.bin image on. It’s in a $9 Shenzhen LC Technology board with 64KB Flash.

_images/Shenzhen-LC-mini-STM32F103-board.jpg

I bought 12 of these boards around 2014, one was dead out of the box, no option jumpers etc and one died while being flashed.

STM32F103C8T6 #1

Die xy coords: 108068691
Wafer Number: 80
Lot_num ascii encoded  [23:0]: 0x00555071  | U P q
Lot_num ascii encoded [55:24]: 0x87011723  | . . . #

STM32F103C8T6 #2

Die xy coords: 108068688
Wafer Number: 80
Lot_num ascii encoded  [23:0]: 0x00555071  | U P q
Lot_num ascii encoded [55:24]: 0x87083408  | . . 4 .

Note

#1 is very close to this one, same silicon wafer only 3 positions away!

STM32F103C8T6 #3

Die xy coords: 108003144
Wafer Number: 73
Lot_num ascii encoded  [23:0]: 0x00515389  | Q S .
Lot_num ascii encoded [55:24]: 0x87084441  | . . D A

STM32F103C8T6 #4

Die xy coords: 107675464
Wafer Number: 80
Lot_num ascii encoded  [23:0]: 0x00485366  | H S f
Lot_num ascii encoded [55:24]: 0x87244413  | . $ D .

STM32F103C8T6 #5

Die xy coords: 107872073
Wafer Number: 80
Lot_num ascii encoded  [23:0]: 0x00565467  | V T g
Lot_num ascii encoded [55:24]: 0x87014725  | . . G %

STM32F103C8T6 #6

Die xy coords: 108003159
Wafer Number: 80
Lot_num ascii encoded  [23:0]: 0x00565666  | V V f
Lot_num ascii encoded [55:24]: 0x87014633  | . . F 3

STM32F103C8T6 #7

Die xy coords: 107872086
Wafer Number: 80
Lot_num ascii encoded  [23:0]: 0x00575566  | W U f
Lot_num ascii encoded [55:24]: 0x87092524  | . . % $

STM32F103C8T6 #8

Die xy coords: 107741015
Wafer Number: 80
Lot_num ascii encoded  [23:0]: 0x00545171  | T Q q
Lot_num ascii encoded [55:24]: 0x87231927  | . # . '

STM32F103C8T6 #9

Die xy coords: 108396369
Wafer Number: 80
Lot_num ascii encoded  [23:0]: 0x00574867  | W H g
Lot_num ascii encoded [55:24]: 0x87142756  | . . ' V

STM32F103C8T6 #10

Die xy coords: 108003154
Wafer Number: 80
Lot_num ascii encoded  [23:0]: 0x00545267  | T R g
Lot_num ascii encoded [55:24]: 0x87195634  | . . V 4

STm32F103RBT6

Olimex P103 #1

_images/STM32-P103-01.jpg
Die xy coords: 108068919
Wafer Number: 48
Lot_num ascii encoded  [23:0]: 0x00353650  | 5 6 P
Lot_num ascii encoded [55:24]: 0x43105156  | C . Q V

FLASH.. TOTAL REPORTED: 131072 USED: 101376 FREE: 29696

Olimex P103 #2

Die xy coords: 107741012
Wafer Number: 72
Lot_num ascii encoded  [23:0]: 0x00555285  | U R .
Lot_num ascii encoded [55:24]: 0x87237267  | . # r g

FLASH.. TOTAL REPORTED: 131072 USED: 103628 FREE: 27444

STM32F103ZET

144pinner with 512kB flash and 64kB ram

stm32id
Die xy coords: 97779505
Wafer Number: 78
Lot_num ascii encoded  [23:0]: 0x00383341  | 8 3 A
Lot_num ascii encoded [55:24]: 0x51137004  | Q . p .

free
FLASH.. TOTAL REPORTED: 524288 USED: 51200 FREE: 473088

BPill N1

(it has got 128kB).

stm32id
Die xy coords: 107806536
Wafer Number: 113
Lot_num ascii encoded  [23:0]: 0x00564989  | V I .
Lot_num ascii encoded [55:24]: 0x67255444  | g % T D

free
FLASH.. TOTAL REPORTED: 65536 USED: 51200 FREE: 14336

BPill N2

(it has got 128kB).

stm32id
Die xy coords: 107741009
Wafer Number: 117
Lot_num ascii encoded  [23:0]: 0x00535783  | S W .
Lot_num ascii encoded [55:24]: 0x81174113  | . . A .

free
FLASH.. TOTAL REPORTED: 65536 USED: 51200 FREE: 14336

Bluepill

marked as STM32F103C8T6

Die xy coords: 108068690
Wafer Number: 114
Lot_num ascii encoded  [23:0]: 0x00525366  | R S f
Lot_num ascii encoded [55:24]: 0x67145016  | g . P .

FLASH.. TOTAL REPORTED: 65536 USED: 51200 FREE: 14336

GD32F103C8T6

In private board, not a Blue Pill. (

Device descriptor request failed

GD32F103-supplied-data
Flash Bytes: 65536
[31:00] $3439CB2E | 4 9 . . | <--Hex char detected
[63:32] $0F383438 | . 8 4 8 | <--Hex char detected
[95:64] $38393733 | 8 9 7 3 |

GD32F103 Data
$1FFFF7E0  = $00140040
$1FFFF7E8  = $3439CB2E
$1FFFF7EC  = $0F383438
$1FFFF7F0  = $38393733

Good Bluepill #1

Same marking as #2 below “991KA 93 MYS 903” but 1/2 the flash reported.

Die xy coords: 107806545
Wafer Number: 80
Lot_num ascii encoded  [23:0]: 0x00525680  | R V .
Lot_num ascii encoded [55:24]: 0x87192455  | . . $ U

FLASH.. TOTAL REPORTED: 65536 USED: 65536 FREE: 0

Good bluepill #2

“991KA 93 MYS 903”

Die xy coords: 108068680
Wafer Number: 113
Lot_num ascii encoded  [23:0]: 0x00565366  | V S f
Lot_num ascii encoded [55:24]: 0x67133045  | g . 0 E

FLASH.. TOTAL REPORTED: 131072 USED: 51200 FREE: 79872

POS Bluepill

Requires reconfiguring GDB, does not work with Windows STM debug at all.

Die xy coords: 74414100
Wafer Number: 47
Lot_num ascii encoded  [23:0]: 0x000E0014  | . . .
Lot_num ascii encoded [55:24]: 0x170707E2  | . . . .

FLASH FREE: 0

Note

the total lack of Ascii data is telling and the FLASH FREE = 0 is calculated so something is seriously different.

CKS32F103C8T6

Chinese clone

Die xy coords: 16985099
Wafer Number: 42
Lot_num ascii encoded  [23:0]: 0x004D3512  | M 5 .
Lot_num ascii encoded [55:24]: 0x004E4B31  | . N K 1

Free
FLASH.. TOTAL REPORTED: 131072 USED: 51200 FREE: 79872

Note

The Chinese CKS32F103C8T6 isn’t using ASCII for the lot numbers, but hexadecimal and they’re identical to 276745 below.

CKS32F103C8T6

Chinese clone

Die xy coords: 276745
Wafer Number: 42
Lot_num ascii encoded  [23:0]: 0x004D3512  | M 5 .
Lot_num ascii encoded [55:24]: 0x004E4B31  | . N K 1

FLASH.. TOTAL REPORTED: 131072 USED: 51200 FREE: 79872

STM32F103C8T6

Die xy coords: 107741012
Wafer Number: 72
Lot_num ascii encoded  [23:0]: 0x00565283  | V R .
Lot_num ascii encoded [55:24]: 0x87242040  | . $   @

FLASH.. TOTAL REPORTED: 65536 USED: 51200 FREE: 14336

Bluepill

Die xy coords: 107741008
Wafer Number: 73
Lot_num ascii encoded  [23:0]: 0x00485572  | H U r
Lot_num ascii encoded [55:24]: 0x87243926  | . $ 9 &

Bluepill

Die xy coords: 108265297
Wafer Number: 72
Lot_num ascii encoded  [23:0]: 0x00515782  | Q W .
Lot_num ascii encoded [55:24]: 0x87061344  | . . . D

Bluepill

Die xy coords: 108068681
Wafer Number: 73
Lot_num ascii encoded  [23:0]: 0x00545682  | T V .
Lot_num ascii encoded [55:24]: 0x87055015  | . . P .

Bluepill

This one didn’t want to program with st-flash as in the supplied script. Programs fine with openocd

Die xy coords: 108134227
Wafer Number: 113
Lot_num ascii encoded  [23:0]: 0x00544872  | T H r
Lot_num ascii encoded [55:24]: 0x67041446  | g . . F

Bluepill

Die xy coords: 108003154
Wafer Number: 72
Lot_num ascii encoded  [23:0]: 0x00565388  | V S .
Lot_num ascii encoded [55:24]: 0x87093153

STM32F103CBT6

Die xy coords: 108199730
Wafer Number: 52
Lot_num ascii encoded  [23:0]: 0x00353254  | 5 2 T
Lot_num ascii encoded [55:24]: 0x57012556  | W . % V