.. index:: bluepill:128kb ?, stm32f103c8t6:2 x 64kb flash? .. _STM32F103C8T6-128kb?: STM32F103C8T6, 2 x 64kB flash ? =============================== Technically, only the **STM32F103CBT6** contains 128kB of Flash, the STM32F103C8T6 has only 64kB according to the STM device specs. The very popular :ref:`Bluepill Board` contains a MCU marked "STM32F103C8T6", with many units having 128kB of Flash. This has caused a belief that STM put 128kB of Flash in **every** STM32F103C8T6. *But is this true ?* **YES, it sure looks like it is**, read on ... STM32F103C8T6 #1 with 128kB Flash --------------------------------- This Bluepill has a MCU marked "STM32F103C8" and clearly runs a Mecrisp-Stellaris 90kB Forth binary proving it has 128kB of Flash. Data is from EEVblog. ChipID not known. :: ramfree . 19112 ok. flashfree . -24692 ok. free (bytes) FLASH.. TOTAL REPORTED: 65536 USED: 90228 FREE: -24692 RAM.... TOTAL PRESET: 20000 USED: 888 FREE: 19112 Compare a Olimex P103 Board containing a STM32F103CBT6 MCU ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Running a slightly bigger binary of 97kB. The MCU shows 128kB as expected and flashed a 90kB binary using standard OpenOCD configs, as expected. :: stm32id 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 ok. free (bytes) FLASH.. TOTAL REPORTED: 131072 USED: 97028 FREE: 34044 RAM.... TOTAL PRESET: 20000 USED: 892 FREE: 19108 STM32F103C8T6 #2 with 64kB Indicated Flash ------------------------------------------ This board has a MCU marked "STM32F103C8" and clearly fails to flash the 90kB binary, (using the standard OpenOCD configs) indicating it has only 64kB Flash ... but does it ? I own 10 of these :ref:`Chinese lc-mini boards`. They are not Bluepills, but are much the same. Standard OpenOCD Config ^^^^^^^^^^^^^^^^^^^^^^^ The standard OpenOCD flashing utility reads the chip reported Flash size of 64kB and accepts it (as it should). 90kB Binary Failed ~~~~~~~~~~~~~~~~~~ :: % ./flash-eb13e308316527be6a8963098c7291d5.sh Open On-Chip Debugger 0.10.0 Licensed under GNU GPL v2 ** Programming Started ** auto erase enabled Info : device id = 0x20036410 Info : flash size = 64kbytes Warn : no flash bank found for address 8010000 wrote 65536 bytes from file ./eb13e308316527be6a8963098c7291d5.bin in 2.032206s (31.493 KiB/s) ** Programming Finished ** ** Verify Started ** Error: checksum mismatch - attempting binary compare diff 0 address 0x08010000. Was 0xff instead of 0x00 diff 1 address 0x08010001. Was 0xff instead of 0x06 ... diff 127 address 0x0801007f. Was 0xff instead of 0x06 More than 128 errors, the rest are not printed. ** Verify Failed ** shutdown command invoked 62.6 kB Binary PASSED ~~~~~~~~~~~~~~~~~~~~~ :: ./flash-ae9236b921613c07b1967f21ff20ee97.sh Open On-Chip Debugger 0.10.0 ** Programming Started ** auto erase enabled Info : device id = 0x20036410 Info : flash size = 64kbytes wrote 63488 bytes from file ./ae9236b921613c07b1967f21ff20ee97.bin in 3.485837s (17.786 KiB/s) ** Programming Finished ** ** Verify Started ** verified 62672 bytes in 0.919840s (66.537 KiB/s) ** Verified OK ** ** Resetting Target ** Info : JTAG tap: stm32f1x.cpu tap/device found: 0x3ba00477 (mfg: 0x23b (ARM Ltd.), part: 0xba00, ver: 0x3) Info : JTAG tap: stm32f1x.bs tap/device found: 0x16410041 (mfg: 0x020 (STMicroelectronics), part: 0x6410, ver: 0x1) shutdown command invoked ChipID ~~~~~~ :: stm32id 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 free (bytes) FLASH.. TOTAL REPORTED: 65536 USED: 62672 FREE: 2864 RAM.... TOTAL PRESET: 20000 USED: 880 FREE: 19120 Getting 128kB Flash! -------------------- The standard OpenOCD flashing utility reads the reported chip Flash size and uses it, BUT modifying the configuration to direct OpeoOCD to **IGNORE** the reported chip Flash size and use 128kB instead results in the **90kB binary image loading!** stm32f1x.cfg Modification ------------------------- :: # flash size will be probed set _FLASHNAME $_CHIPNAME.flash # flash bank $_FLASHNAME stm32f1x 0x08000000 0 0 0 $_TARGETNAME flash bank $_FLASHNAME stm32f1x 0x08000000 0x20000 0 0 $_TARGETNAME Results ^^^^^^^ :: ** Programming Started ** auto erase enabled Info : device id = 0x20036410 Info : ignoring flash probed value, using configured bank size Info : flash size = 128kbytes wrote 91136 bytes from file ./eb13e308316527be6a8963098c7291d5.bin in 4.948380s (17.986 KiB/s) ** Programming Finished ** ** Verify Started ** verified 90240 bytes in 1.311107s (67.214 KiB/s) ** Verified OK ** ** Resetting Target ** Info : JTAG tap: stm32f1x.cpu tap/device found: 0x3ba00477 (mfg: 0x23b (ARM Ltd.), part: 0xba00, ver: 0x3) Info : JTAG tap: stm32f1x.bs tap/device found: 0x16410041 (mfg: 0x020 (STMicroelectronics), part: 0x6410, ver: 0x1) shutdown command invoked ChipID ~~~~~~ Note this is STM32F103C8T6 #2 the same ID as the one above that initially failed the 90kB binary flash! My Forth "free" program is obviously going to have to be changed to accommodate these findings :) :: stm32id 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 ok. free (bytes) FLASH.. TOTAL REPORTED: 65536 USED: 90228 FREE: -24692 RAM.... TOTAL PRESET: 20000 USED: 888 FREE: 19112 **All 10 of these STM32F103C8T6 powered :ref:`Chinese lc-mini boards` successfully flashed the 90kB image, they *all* have 129kB of Flash.** Thanks "Bingo"! --------------- My thanks to "Bingo600" from EEVblog for convincing me to try this out :)