STM32F103C8 Diagnostics¶
This is the older obsolete version of STM32F103XX-DIAGNOSTICS which has many improvements as regards MCU type detection. This is the recommended binary to use with the Blue Pill etc.
STM32F103C8 datasheets specify the on board Flash memory as being 64kB, and this is corroborated by the on chip “Flash Size Register” having a value of 65536 Bytes, however it seems these chips actually have a “hidden” second 64kB Block, making a total of 128kB of Flash onboard!
Many theories abound, did STM simply use the same die for both the more expensive 128kB Flash STM32F103CB and the cheaper STM32F103C8 to save costs, but configure the STM32F103C8 to show only 64kB ?
Perhaps STM ran out of STM32F103C8’s and simply used modified STM32F103CB units instead ?
Or maybe STM32F103CB units with a faulty memory location in the second Flash block were sold as STM32F103C8’s and the”Flash Size Register” set to 65536 Bytes ?
The STM32F103C8 MCU is found in many cheap Chinese boards including the very popular Bluepill Board which means that many owners may not be aware they actually have DOUBLE the Flash they thought they had.
This Project¶
This is a bootable diagnostic program test kit. The size is under 64kB so that it can be flashed by OpenOCD.
The purpose of this kit is to physically test the “hidden” 64kB second Flash block present on many of these chips and determine if it exists and if it is reliable. It does this by flashing all the bits from one to zero and back again.
Download the OBSOLETE STM32F103C8-DIAGNOSTICS.bin here: https://sourceforge.net/projects/mecrisp-stellaris-folkdoc/files/STM32F103C8-DIAGNOSTICS.bin/download
Note
STM32F103C8-DIAGNOSTICS.bin has been replaced by STM32F103XX-DIAGNOSTICS which has many improvements as regards MCU type detection. This is the recommended binary to use with the Blue Pill etc.
Usage¶
Flash the STM32F103C8-DIAGNOSTICS.bin image to your board with OpenOCD or whatever you normally use. See Flashing Methods, but basically you flash this binary exactly as you would flash any STM32Fxx binary. .i.e a. “st-flash erase” b. “st-flash write STM32F103C8-DIAGNOSTICS.bin 0x08000000”
Plug in a USB cable to the “Blue Pill” board and run a serial terminal program on your PC. This will also power the board.
Connect the terminal to the ‘“Mecrisp STM32F10x Forth Serial Port’ USB device now created on your PC. Any speed is ok, I use 460800 Baud myself.
Enter “?” at the prompt to obtain the menu.
The “t” key runs the all important Flash test, but there are other menu functions available as listed below.
Note
The first few versions had a garbled USB device ID string, this was corrected in V1.2 and should look something like this.
umodem1: <Mecrisp STM32F10x Forth Serial Port, class 2/0, rev 2.00/2.00, addr 15> on usbus0
STM32F103 Spec Sheet¶
How does this all work?¶
The fact that my 10 tested STM32F103C8’s had a second hidden 64kB block doesn’t alter the STM spec above because any flashing software must check the MCU internal “Flash Size Register” first, will read that the STM32F103C8 has only 64kB and ignore that second block, it doesn’t have any other choice.
Reading the MCU “Flash Size Register” first is essential for a few reasons one of which is the MCU will throw an exception if a program attempts to do anything to Flash that’s not actually there.
My St-Link would program any size image up to 64kB on the STM32F103C8. If the Image was 100kB, it stopped at 64kB and threw an error as expected.
St-Link reads the MCU “Flash Size Register” and acts accordingly as it must. It can be reconfigured so it thinks the STM32F103C8 has 128kB of Flash, which is what I had to do to flash binaries over 64kB but under 128kB on a STM32F103C8 which actually had the ‘hidden second 64kB Flash Block”.
My Olimex-P103 has a STM32F103CB with 128kB as shown in the Factory Datasheet above, so St-Link would program a 100kB image without complaint because the STM32F103CB MCU “Flash Size Register” indicates the chip has 128kB of Flash.
This is how it all works This “STM32F103C8 Diagnostics” bootable binary is designed to run on any STM32F103Cx as it is under 64kB and reveal all the above.
Chip ID Data¶
Can we tell from the chip ID data if a chip is a fake ?
I think so as genuine STM chip Lot Numbers are in DECIMAL, CS32F103C8T6 chip Lot Numbers are in Hexadecimal.
Chip |
Lot Numbers |
Example |
Description |
---|---|---|---|
Genuine STM |
decimal |
0x00565283 |
Only contains digits 0 - 9 |
CS32F103C8T6 |
hexadecimal |
0x004D3512 |
Contains digits 0 - 9 AND characters A,B,C,D,E,F |
GD32F103C8T6 |
? |
I have no data yet |
Good Chip Reports¶
107741012/72¶
stm32id
Die xy coords: 107741012
Wafer Number: 72
Lot_num ascii encoded [23:0]: 0x00565283 | V R .
Lot_num ascii encoded [55:24]: 0x87242040 | . $ @
Flash Size Register = 65536 Bytes
~~~~~ ALL TESTS PASSED ~~~~~
107872085/72¶
stm32id
Die xy coords: 107872085
Wafer Number: 72
Lot_num ascii encoded [23:0]: 0x00555787 | U W .
Lot_num ascii encoded [55:24]: 0x87061320 | . . .
Flash Size Register = 65536 Bytes
~~~~~ ALL TESTS PASSED ~~~~~
Bad Chip Reports¶
CKS CS32F103C8T6¶
Rhodges from EEVblog reports a CKS CS32F103C8T6 that an ebay seller sold as a ST part (oops!) failed the test with 0x10000 - 0x1FFFF appearing to be a read-only mirror of 0x00000 - 0x10000
stm32id
Die xy coords: 16917299
Wafer Number: 50
Lot_num ascii encoded [23:0]: 0x004D3712 | M 7 .
Lot_num ascii encoded [55:24]: 0x004E4B43 | . N K C
Flash Size Register = 65536 Bytes
Testing 64kB Flash block: 0x10000 - 0x1FFFF
Erasing
FAILTEST: $10000 Data = $8C
FAILTEST: $10001 Data = $03
... all the way to
FAILTEST: $1CDE5 Data = $BD
FAILTEST: $1CDE6 Data = $00
FAILTEST: $1CDE7 Data = $00
blank check FAILTEST