Difference between revisions of "STM32F103"

From Stm32World Wiki
Jump to navigation Jump to search
 
Line 21: Line 21:
 
== PIN Count ==
 
== PIN Count ==
  
[[File:stm32f103 series.png|800px]]
+
<div class="res-img">
 +
[[File:stm32f103 series.png|1000px]]
 +
</div>
  
 
== Extra Flash ==
 
== Extra Flash ==

Latest revision as of 04:57, 27 May 2024

The STM32F103 processor is used on the Blue Pill STM32 Development Board.

Fakes and Clones

There are a number of "clones" of the STM32F103 available. Most of those are likely properly licensed Cortex-M3 cores with peripherals designed to match the original STM32 and most can be used as drop-in replacements with some "quirks".

Unfortunately there are also quite a lot of fake chips available:

Fake STM32F103.jpg Real STM32F103.jpg
Fake STM32F103 (possibly a HK32) from some random Blue Pill Real STM32F103 from my own Green Pill board

These are chips labelled STM32F103xxx but they are not.

PIN Count

Stm32f103 series.png

Extra Flash

The STM32F103C8 is supposed to have 64kB of flash memory while the STM32F103CB have 128kB. Presumably, at some point, ST figured out that rather than producing two physically different chips it was more cost effective just to produce one and label it differently. For this reason, most (??? if not all) STM32F103C8 MCUs actually do have 128kB of flash even if they report 64kB.

Verify extra flash

To verify the extra flash let us experimentally try to write some data to it. The following experiment were run on a Green Pill board with a known original STM32F103 - in fact the one pictured above.

First step is to create a 64kB file with random data:

lth@ncpws04:/tmp$ dd if=/dev/urandom of=random.dat bs=1k count=64
64+0 records in
64+0 records out
65536 bytes (66 kB, 64 KiB) copied, 0.00402363 s, 16.3 MB/s

To be able to verify the data later, calculate the MD5 sum of this file:

lth@ncpws04:/tmp$ md5sum random.bin 
e7bae4c3030ee01be1e96a416cc4a262  random.bin

Now write this file to the "hidden" 64kB of flash.

lth@ncpws04:/tmp$ st-flash write random.bin 0x8010000
st-flash 1.7.0-dirty
2021-07-20T10:41:00 INFO common.c: F1xx Medium-density: 20 KiB SRAM, 64 KiB flash in at least 1 KiB pages.
Unknown memory region

This fails because the MCU reports only 64kB of flash. Fortunately we can tell the st-flash util that we got more than that.

lth@ncpws04:/tmp$ st-flash --flash=128k write random.bin 0x8010000
st-flash 1.7.0-dirty
2021-07-20T10:40:03 INFO common.c: F1xx Medium-density: 20 KiB SRAM, 64 KiB flash in at least 1 KiB pages.
Forcing flash size: --flash=0x00020000
file random.bin md5 checksum: e7bae4c33ee01be1e96a416cc4a262, stlink checksum: 0x007f7350
2021-07-20T10:40:03 INFO common.c: Attempting to write 65536 (0x10000) bytes to stm32 address: 134283264 (0x8010000)
2021-07-20T10:40:03 INFO common.c: Flash page at addr: 0x08010000 erased
2021-07-20T10:40:03 INFO common.c: Flash page at addr: 0x08010400 erased
2021-07-20T10:40:03 INFO common.c: Flash page at addr: 0x08010800 erased
2021-07-20T10:40:03 INFO common.c: Flash page at addr: 0x08010c00 erased
2021-07-20T10:40:03 INFO common.c: Flash page at addr: 0x08011000 erased
2021-07-20T10:40:03 INFO common.c: Flash page at addr: 0x08011400 erased
2021-07-20T10:40:03 INFO common.c: Flash page at addr: 0x08011800 erased
2021-07-20T10:40:03 INFO common.c: Flash page at addr: 0x08011c00 erased
2021-07-20T10:40:03 INFO common.c: Flash page at addr: 0x08012000 erased
2021-07-20T10:40:03 INFO common.c: Flash page at addr: 0x08012400 erased
2021-07-20T10:40:03 INFO common.c: Flash page at addr: 0x08012800 erased
2021-07-20T10:40:03 INFO common.c: Flash page at addr: 0x08012c00 erased
2021-07-20T10:40:03 INFO common.c: Flash page at addr: 0x08013000 erased
2021-07-20T10:40:03 INFO common.c: Flash page at addr: 0x08013400 erased
2021-07-20T10:40:03 INFO common.c: Flash page at addr: 0x08013800 erased
2021-07-20T10:40:03 INFO common.c: Flash page at addr: 0x08013c00 erased
2021-07-20T10:40:03 INFO common.c: Flash page at addr: 0x08014000 erased
2021-07-20T10:40:03 INFO common.c: Flash page at addr: 0x08014400 erased
2021-07-20T10:40:03 INFO common.c: Flash page at addr: 0x08014800 erased
2021-07-20T10:40:03 INFO common.c: Flash page at addr: 0x08014c00 erased
2021-07-20T10:40:03 INFO common.c: Flash page at addr: 0x08015000 erased
2021-07-20T10:40:03 INFO common.c: Flash page at addr: 0x08015400 erased
2021-07-20T10:40:03 INFO common.c: Flash page at addr: 0x08015800 erased
2021-07-20T10:40:04 INFO common.c: Flash page at addr: 0x08015c00 erased
2021-07-20T10:40:04 INFO common.c: Flash page at addr: 0x08016000 erased
2021-07-20T10:40:04 INFO common.c: Flash page at addr: 0x08016400 erased
2021-07-20T10:40:04 INFO common.c: Flash page at addr: 0x08016800 erased
2021-07-20T10:40:04 INFO common.c: Flash page at addr: 0x08016c00 erased
2021-07-20T10:40:04 INFO common.c: Flash page at addr: 0x08017000 erased
2021-07-20T10:40:04 INFO common.c: Flash page at addr: 0x08017400 erased
2021-07-20T10:40:04 INFO common.c: Flash page at addr: 0x08017800 erased
2021-07-20T10:40:04 INFO common.c: Flash page at addr: 0x08017c00 erased
2021-07-20T10:40:04 INFO common.c: Flash page at addr: 0x08018000 erased
2021-07-20T10:40:04 INFO common.c: Flash page at addr: 0x08018400 erased
2021-07-20T10:40:04 INFO common.c: Flash page at addr: 0x08018800 erased
2021-07-20T10:40:04 INFO common.c: Flash page at addr: 0x08018c00 erased
2021-07-20T10:40:04 INFO common.c: Flash page at addr: 0x08019000 erased
2021-07-20T10:40:04 INFO common.c: Flash page at addr: 0x08019400 erased
2021-07-20T10:40:04 INFO common.c: Flash page at addr: 0x08019800 erased
2021-07-20T10:40:04 INFO common.c: Flash page at addr: 0x08019c00 erased
2021-07-20T10:40:04 INFO common.c: Flash page at addr: 0x0801a000 erased
2021-07-20T10:40:04 INFO common.c: Flash page at addr: 0x0801a400 erased
2021-07-20T10:40:04 INFO common.c: Flash page at addr: 0x0801a800 erased
2021-07-20T10:40:04 INFO common.c: Flash page at addr: 0x0801ac00 erased
2021-07-20T10:40:04 INFO common.c: Flash page at addr: 0x0801b000 erased
2021-07-20T10:40:04 INFO common.c: Flash page at addr: 0x0801b400 erased
2021-07-20T10:40:04 INFO common.c: Flash page at addr: 0x0801b800 erased
2021-07-20T10:40:04 INFO common.c: Flash page at addr: 0x0801bc00 erased
2021-07-20T10:40:04 INFO common.c: Flash page at addr: 0x0801c000 erased
2021-07-20T10:40:04 INFO common.c: Flash page at addr: 0x0801c400 erased
2021-07-20T10:40:04 INFO common.c: Flash page at addr: 0x0801c800 erased
2021-07-20T10:40:04 INFO common.c: Flash page at addr: 0x0801cc00 erased
2021-07-20T10:40:04 INFO common.c: Flash page at addr: 0x0801d000 erased
2021-07-20T10:40:04 INFO common.c: Flash page at addr: 0x0801d400 erased
2021-07-20T10:40:04 INFO common.c: Flash page at addr: 0x0801d800 erased
2021-07-20T10:40:04 INFO common.c: Flash page at addr: 0x0801dc00 erased
2021-07-20T10:40:04 INFO common.c: Flash page at addr: 0x0801e000 erased
2021-07-20T10:40:04 INFO common.c: Flash page at addr: 0x0801e400 erased
2021-07-20T10:40:04 INFO common.c: Flash page at addr: 0x0801e800 erased
2021-07-20T10:40:04 INFO common.c: Flash page at addr: 0x0801ec00 erased
2021-07-20T10:40:04 INFO common.c: Flash page at addr: 0x0801f000 erased
2021-07-20T10:40:05 INFO common.c: Flash page at addr: 0x0801f400 erased
2021-07-20T10:40:05 INFO common.c: Flash page at addr: 0x0801f800 erased
2021-07-20T10:40:05 INFO common.c: Flash page at addr: 0x0801fc00 erased
2021-07-20T10:40:05 INFO common.c: Finished erasing 64 pages of 1024 (0x400) bytes
2021-07-20T10:40:05 INFO common.c: Starting Flash write for VL/F0/F3/F1_XL
2021-07-20T10:40:05 INFO flash_loader.c: Successfully loaded flash loader in sram
2021-07-20T10:40:05 INFO flash_loader.c: Clear DFSR
2021-07-20T10:40:05 INFO flash_loader.c: Clear CFSR
 64/ 64 pages written
2021-07-20T10:40:08 INFO common.c: Starting verification of write complete
2021-07-20T10:40:08 INFO common.c: Flash written and verified! jolly good!

No problem at all :) Finally, read the flash and dumb the data into a new file.

lth@ncpws04:/tmp$ st-flash --flash=128k read random2.bin 0x8010000 0x010000st-flash 1.7.0-dirty
2021-07-20T10:42:36 INFO common.c: F1xx Medium-density: 20 KiB SRAM, 64 KiB flash in at least 1 KiB pages.
Forcing flash size: --flash=0x00020000
2021-07-20T10:42:36 INFO common.c: read from address 0x08010000 size 65536

Finally verify the new file is identical to the original.

lth@ncpws04:/tmp$ md5sum random2.bin e7bae4c3030ee01be1e96a416cc4a262  random2.bin

e7bae4c3030ee01be1e96a416cc4a262 = e7bae4c3030ee01be1e96a416cc4a262 so the two files are identical!

Miscellaneous Links