Bluepill Diagnostics

V1.640

Please see this page which covers the latest release: V1.640

OLDER VERSIONS

V1.632

Project: id-swdcom
Version: 1.632
Created: Mon  17 March 2022
Author 2021 by t.j.porter <techman001@protonmail.com>
Purpose: Determine if your BluePill board contains a genuine STM32F103C8 MCU, attempt to determine clone type if doesn't.
Intended Audience: Blue Pill owners
MCU: STM32F103 and clones
Board: BluePill
Core: Mecrisp-Stellaris RA 2.5.5 for STM32F103 by Matthias Koch
Clock: 72 MHz
Core Options enabled: 1,2,3,4,5,6,7
Required: USB cable, serial terminal emulator, works on any OS. The USB virtual serial (any baudrate) will start in the Bluepill diagnostics menu.
Web Sites Consulted: https://www.blaatschaap.be/32f103-comparison-part-3/ My thanks to Andre for his work with the Jdec data.
For the latest project updates see: https://mecrisp-stellaris-folkdoc.sourceforge.io/bluepill-diagnostics-v1.6.html
License: MIT, please see COPYING

DOWNLOAD: https://sourceforge.net/projects/mecrisp-stellaris-folkdoc/files/bluepill-diagnostics-v1.6.zip

HISTORY

My Blue Pill Diagnostics project grew from an interest to create a self contained binary that would boot on a Blue Pill board and access internal MCU information to determine if it contained a genuine or counterfeit Microprocessor chip.

V1.0 was released in November 2019 and it has taken two years to collate and study user clone/fake information because not a lot is known about these counterfeits which are usually (mis)labelled as genuine STMicroelectronics chips.

This interest was kindled by various articles from Blue Pill owners in online forums.

I now consider this project complete, 14 April 2021 at version V1.631 excepting bugfixes.

My thanks to all those that supplied MCU dumps from my earlier versions and to Matthias Koch the Assembly Wizard who created the Free Mecrisp-Stellaris Forth which made not only made this project possible but fun.

Forth is interactive and allows me to examine/change memory in real time and observe the effects instantly as there is no edit, compile, flash, test, edit cycle such as you have with the C programming language. Because Mecrisp-Stellaris Forth is only 20KB in size, it easily fits in the 64KB flash advertised by the Cortex-M3 STM32F103C8 MCU, unlike Circuit Python or eLua, the only other Cortex_M interactive languages, both of which which require 256KB (or more) flash just for their core.

Note

Blue Pill Diagnostics V1.631 is also a self contained Forth Programming development environment with many tools such as peripheral register real time printing and dissasembler, it even has a PC-13 Blinky. Please see the end of this article for more information.

Changelog from V1.5

V1.631 is a major change as I’ve realised that attempting to collect and analyse the Device electronic signature is pointless as the same codes are used by genuine and clone mcu’s alike. Thank you to those that emailed me their XML ID dump.

V1.631 uses four tests below to determine if a MCU is a genuine STM32F103C8.

  1. Exploit a silicon bug in genuine STM32F1xx chips where the BGMCU_IDCODE cannot be read from within the MCU without a SWD or JTAG interface connected.

  2. Verify the Flash Size Register = 64KB

  3. Verify that the MCU has a hidden second 64KB flash block as most STM32F103C8 chips do.

  4. Verify that the MCU Jdec manufacturer id is that of STMicroelectronics.

Note

Even if the MCU is not a genuine STM32F103C8 doesn’t mean your Bluepill board is no good, it may still work perfectly although there does not seem to be any detailed English techical documentation for them. If the clone is fraduently marked as a genuine STM32F103C8 you may have some recourse against the seller, but I’m not a lawyer, and this is not legal advice.

How to use Bluepill Diagnostics V1.631

  1. Download https://sourceforge.net/projects/mecrisp-stellaris-folkdoc/files/bluepill-diagnostics-v1.6.zip

  2. Flash the bluepill-diagnostics-v1.6xx inside the above zipfile to your Bluepill/Maple Board with OpenOCD or whatever you normally use. Basically you flash this binary exactly as you would flash any STM32Fxx binary.

  3. 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.

  4. Connect the serial terminal program to the “Mecrisp STM32F10x Forth Serial Port” USB device now created on your PC. Any speed is ok, I use 460800 Baud myself.

  5. Press the “m” key on your keyboard to bring up the bluepill-diagnostics user menu.

Optional SWDCOM Terminal

https://mecrisp-stellaris-folkdoc.sourceforge.io/swdcom.html

There is a bootup option for development use. Normally the Diags boots up into USB virtual comms and a menu, however there is a development option enabled by jumpering PA-0 to 3.3v before bootup.

This switches the terminal to use SWDCOM and disables the Diags menu from starting. The menu is still there and can be started by entering “m” or “menu”.

Enable SWDCOM

PA-0  <--> 3.3V

Bluepill SWD connections

SWD

Bluepill Target Board

SWCLK

PA-14

SWDIO

PA-13

Unknown clones/fakes

If your test MCU FAILS the ‘a - Authenticity test’ menu, please email your details to me at techman001@protonmail.com so I can work out what the MCU is and add a test for it to the next release.

New Menus

h - testing flash

Note: Codes are written to each flash location and are read after writing to ensure every bit is tested.

_images/testing-flash.jpg

f - how much Flash is declared in the Flash Size Register ?

_images/flash-declared.jpg

d - Print DBGMCU_IDCODE

_images/dbgmcu.jpg

a - Authenticity test, don’t use with SWD/JTAG. Requires test h once to complete

Passed - genuine STM32F103C8T6

_images/auth-passed.jpg

Failed - CKS clone

_images/windows-auth-fail.jpg

j - Jdec manufacturer id

Genuine STM32F103C8

_images/jdec-mfr-id.jpg

CKS/APM Clone

_images/windows-clone-jdec-codes.jpg

Extra Menu

_images/extra-menu.jpg

i - unique device Id register

_images/unique-dev-id.jpg

n - unique derived serial Number

_images/unique-serial-number.jpg

DBGMCU_IDCODE

The DBGMCU_IDCODE, CPU-ID and RevID values in this table may help you determine the actual MCU in your Blue Pill. If St-link or OpenOCD don’t work, try using the serial bootloader or even DFU via the Blue Pill USB connector to flash my V 1.6 Diags binary to your MCU.

  • DBGMCU_IDCODE is at 0xE0042000

  • Bits 11:0 DEV_ID: Device identifier

  • Bits 15:12 Reserved

  • Bits 31:16 REV_ID: Revision identifier

|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|
|-----------REV_ID--------------|rsrvd|---------DEV_ID----------|

Table: Device Info

Device

DEV-ID

RevID

Flash (KB)

2nd 64KB Hidden ?

Ram (KB)

Manufacturer

SWD?

Notes

STM32F103C8T6

0x410

0x2003

2x 64

YES

20

STMicroelectronics

Y

STM32F103RBT6

0x410

0x2003

128

NO

20

STMicroelectronics

Y

CKS32F103C8T6

0x410

0x2003

64

NO

20

China Key System

N

A

CKS32F103CBT6

0x410

0x2003

128

NO

20

China Key System

N

APM32F103CBT6

0x410

0x2003

?

?

?

Apex Micro

N

GD32F130C8

0x410

0x1303

64

n/a

8

Gigadevice

?

GD32F150C8

0x410

0x1303

64

n/a

8

Gigadevice

?

STM32F103VET6

0x414

0x1001

512

n/a 512kb

64

STMicroelectronics

Y

GD32F103VE

0x414

0x1309

512

n/a 512kb

64

Gigadevice

?

GD32F103VK

0x430

0x1309

3072

n/a 3MB

96

Gigadevice

?

GD32F103C8T6

0x436 ?

0x1038 ?

?

?

?

Gigadevice

?

CH32F103C8T6

?

?

64

n/a

20

WCH

?

Note

SWD?: Does this MCU require an active SWD connection before the DBGMCU_IDCODE can be read INTERNALLY (Using my Diagnostics Binary) ?

Notes Table

Notes

Comment

A

H test fails with errors: 001FCE6 $FF?: $37, 0001FCEA $FF?: $C1, Wrong address or data for writing flash !

Table: JDEC Codes

Note only STMicro and CS32 are verified, the rest pinched from Andre’s site. Please email your labelled MCU confirmations/results for any MCU’s to techman001@protonmail.com.au so I can keep this table updated if clones change id.

Manufacturer

Chip Example

identity (hex)

continuation (hex)

STMicro

STM32F103C8

20

00

GigaDevice Semiconductor

GD32F103C8

C8

07

GigaDevice Semiconductor (Beijing)

GD32F103C8

51

07

HK32

HK32F103CBT6

55

05

CS32

CS32F103C8T6

3B

04

APM32

APM32F103C8T6

3B

04

Forth User Notes

This project is built on Mecrisp-Stellaris Forth and is a complete Forth development environment. The command line may be accessed by quitting the Diagnostics Menu or by attaching a jumper between PA-0 and 3.3V, which at power up will switch the User Terminal into SWDCOM FORTH mode without starting the Bluepill Diagnostics Menu.

Swdcom: https://mecrisp-stellaris-folkdoc.sourceforge.io/swdcom.html

Numerous utilities are available while still keeping the binary size under 64KB so it can be flashed using unmodified st-link or openocd etc.

More information about Mecrisp-Stellaris Forth may be found here: https://mecrisp-stellaris-folkdoc.sourceforge.io/index.html

128KB Flash

If your MCU passed all the tests can the full 128KB flash be used ?

YES! but you need to use OpenOCD with a special config file ‘stm32f103c8-128kb.cfg’ which is included in the openocd subdirectory this release. This tells OpenOCD that the chip has 128KB flash.

Kernel Options

This kernel has the following options enabled: 1,2,3,4,5,7,8

Kernel Options

Description

1

context sensitive color prompt

2

all errors in red and beep terminal bell. Enter “;” at the terminal to test them.

3

“redefine” warning in orange

4

Halts source file uploads on (or about) the first error, all errors in red and sound bell. Swdcom uploads are too fast to see!

5

Simplified stack print. “.s Stack: [0 ] 42 ok.”

6

Swdcom instead of usart user terminal

7

catchflashpointers.s/bl uart_init transposition. Essential for swdcom to work properly.

8

add ‘carriage return’ to ‘newline’ for Windows to prevent ‘stair stepping’

Peripheral Pretty Print Words

RCC. GPIOA. GPIOB. GPIOC. EXTI. TIM2. I2C1. SPI1. ADC1. DBG. NVIC.

Sample

EXTI.
EXTI_IMR.  RW   $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

EXTI_EMR.  RW   $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

EXTI_RTSR.  RW   $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

EXTI_FTSR.  RW   $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

EXTI_SWIER.  RW   $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

EXTI_PR.  RW   $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

Dictionary

These are inbuilt user programs.

i.e. ‘2+’ is a program that adds 2. Forth uses RPN.

2 2+ . 4  ok.

Dissasembler

see 2+

see 2+
0000205A: 3602  adds r6 #2
0000205C: 4770  bx lr
Bytes: 4  ok.

Word Listing

--- Mecrisp-Stellaris RA 2.5.5 ---
2dup                2drop               2swap               2nip
2over               2tuck               2rot                2-rot
2>r                 2r>                 2r@                 2rdrop
d2/                 d2*                 dshr                dshl
dabs                dnegate             d-                  d+
s>d                 um*                 m*                  ud*
udm*                */                  */mod               u*/
u*/mod              um/mod              m/mod               ud/mod
d/mod               d/                  f*                  f/
2!                  2@                  du<                 du>
d<                  d>                  d0<                 d0=
d<>                 d=                  sp@                 sp!
rp@                 rp!                 dup                 drop
?dup                swap                nip                 over
tuck                rot                 -rot                pick
depth               rdepth              >r                  r>
r@                  rdrop               rpick               roll
-roll               and                 bic                 or
xor                 *                   clz                 ror
rol                 arshift             rshift              lshift
0=                  0<>                 0<                  true
false               >=                  <=                  <
>                   u>=                 u<=                 u<
u>                  <>                  =                   min
max                 umax                umin                move
fill                @                   !                   +!
h@                  h!                  h+!                 c@
c!                  c+!                 bis!                bic!
xor!                bit@                hbis!               hbic!
hxor!               hbit@               cbis!               cbic!
cxor!               cbit@               hflash!             flashpageerase
eraseflash          eraseflashfrom      +                   -
1-                  1+                  2-                  2+
cell+               negate              not                 shr
shl                 2*                  cells               2/
abs                 u/mod               /mod                mod
/                   even                base                binary
decimal             hex                 swd                 swd-init
swd-key?            swd-emit?           swd-key             swd-emit
hook-emit           hook-key            hook-emit?          hook-key?
hook-pause          emit                key                 emit?
key?                pause               cexpect             accept
tib                 >in                 current-source      setsource
source              query               compare             cr
bl                  space               spaces              [char]
char                (                   \                   ."
c"                  s"                  count               ctype
type                hex.                h.s                 u.s
.s                  words               unused              12bitencoding
registerliteral,    movwmovt,           call,               literal,
create              does>               <builds             [']
'                   postpone            inline,             ret,
exit                recurse             state               ]
[                   :                   ;                   execute
immediate           inline              compileonly         0-foldable
1-foldable          2-foldable          3-foldable          4-foldable
5-foldable          6-foldable          7-foldable          constant
2constant           smudge              setflags            aligned
align               h,                  ,                   ><,
string,             allot               forgetram           compiletoram?
compiletoram        compiletoflash      (create)            variable
2variable           nvariable           buffer:             dictionarystart
dictionarynext      skipstring          find                hook-find
(find)              cjump,              jump,               here
flashvar-here       then                else                if
ahead               repeat              while               until
again               begin               k                   j
i                   leave               unloop              +loop
loop                do                  ?do                 case
?of                 of                  endof               endcase
token               parse               digit               number
.digit              hold                hold<               sign
#>                  f#S                 f#                  #S
#                   <#                  f.                  f.n
ud.                 d.                  u.                  .
evaluate            interpret           hook-quit           quit
eint?               eint                dint                ipsr
nop                 unhandled           reset               irq-systick
irq-fault           irq-collection      irq-rtc             irq-exti0
irq-exti1           irq-exti2           irq-exti3           irq-exti4
irq-adc             irq-exti5           irq-tim1brk         irq-tim1up
irq-tim1trg         irq-tim1cc          irq-tim2            irq-tim3
irq-tim4            irq-i2c1ev          irq-i2c1er          irq-i2c2ev
irq-i2c2er          irq-spi1            irq-spi2            irq-usart1
irq-usart2          irq-usart3          irq-exti10          irq-rtcalarm
irq-usbwkup         irq-tim5            irq-spi3            irq-uart4
irq-uart5           irq-tim6            irq-tim7            irq-usbfs
--- Flash Dictionary ---
72mhz               u.1                 u.2                 u.3
u.4                 u.8                 h.1                 h.2
h.3                 h.4                 h.8                 hex.1
hex.2               hex.3               hex.4               u.ns
const.              addr.               .decimal            bit
b8loop.             b16loop.            b16loop-a.          b32loop.
b32sloop.           bin.                bin1.               bin2.
bin4.               bin4l.              bin4h.              bin16.
WRITEONLY           RCC                 RCC_CR              RCC_CFGR
RCC_CIR             RCC_APB2RSTR        RCC_APB1RSTR        RCC_AHBENR
RCC_APB2ENR         RCC_APB1ENR         RCC_BDCR            RCC_CSR
RCC_CR.             RCC_CFGR.           RCC_CIR.            RCC_APB2RSTR.
RCC_APB1RSTR.       RCC_AHBENR.         RCC_APB2ENR.        RCC_APB1ENR.
RCC_BDCR.           RCC_CSR.            RCC.                GPIOA
GPIOA_CRL           GPIOA_CRH           GPIOA_IDR           GPIOA_ODR
GPIOA_BSRR          GPIOA_BRR           GPIOA_LCKR          GPIOA_CRL.
GPIOA_CRH.          GPIOA_IDR.          GPIOA_ODR.          GPIOA_BSRR.
GPIOA_BRR.          GPIOA_LCKR.         GPIOA.              GPIOB
GPIOB_CRL           GPIOB_CRH           GPIOB_IDR           GPIOB_ODR
GPIOB_BSRR          GPIOB_BRR           GPIOB_LCKR          GPIOB_CRL.
GPIOB_CRH.          GPIOB_IDR.          GPIOB_ODR.          GPIOB_BSRR.
GPIOB_BRR.          GPIOB_LCKR.         GPIOB.              GPIOC
GPIOC_CRL           GPIOC_CRH           GPIOC_IDR           GPIOC_ODR
GPIOC_BSRR          GPIOC_BRR           GPIOC_LCKR          GPIOC_CRL.
GPIOC_CRH.          GPIOC_IDR.          GPIOC_ODR.          GPIOC_BSRR.
GPIOC_BRR.          GPIOC_LCKR.         GPIOC.              EXTI
EXTI_IMR            EXTI_EMR            EXTI_RTSR           EXTI_FTSR
EXTI_SWIER          EXTI_PR             EXTI_IMR.           EXTI_EMR.
EXTI_RTSR.          EXTI_FTSR.          EXTI_SWIER.         EXTI_PR.
EXTI.               TIM2                TIM2_CR1            TIM2_CR2
TIM2_SMCR           TIM2_DIER           TIM2_SR             TIM2_EGR
TIM2_CCMR1_Output   TIM2_CCMR1_Input    TIM2_CCMR2_Output   TIM2_CCMR2_Input
TIM2_CCER           TIM2_CNT            TIM2_PSC            TIM2_ARR
TIM2_CCR1           TIM2_CCR2           TIM2_CCR3           TIM2_CCR4
TIM2_DCR            TIM2_DMAR           TIM2_CR1.           TIM2_CR2.
TIM2_SMCR.          TIM2_DIER.          TIM2_SR.            TIM2_EGR.
TIM2_CCMR1_Output.  TIM2_CCMR1_Input.   TIM2_CCMR2_Output.  TIM2_CCMR2_Input.
TIM2_CCER.          TIM2_CNT.           TIM2_PSC.           TIM2_ARR.
TIM2_CCR1.          TIM2_CCR2.          TIM2_CCR3.          TIM2_CCR4.
TIM2_DCR.           TIM2_DMAR.          TIM2.               I2C1
I2C1_CR1            I2C1_CR2            I2C1_OAR1           I2C1_OAR2
I2C1_DR             I2C1_SR1            I2C1_SR2            I2C1_CCR
I2C1_TRISE          I2C1_CR1.           I2C1_CR2.           I2C1_OAR1.
I2C1_OAR2.          I2C1_DR.            I2C1_SR1.           I2C1_SR2.
I2C1_CCR.           I2C1_TRISE.         I2C1.               SPI1
SPI1_CR1            SPI1_CR2            SPI1_SR             SPI1_DR
SPI1_CRCPR          SPI1_RXCRCR         SPI1_TXCRCR         SPI1_I2SCFGR
SPI1_I2SPR          SPI1_CR1.           SPI1_CR2.           SPI1_SR.
SPI1_DR.            SPI1_CRCPR.         SPI1_RXCRCR.        SPI1_TXCRCR.
SPI1_I2SCFGR.       SPI1_I2SPR.         SPI1.               ADC1
ADC1_SR             ADC1_CR1            ADC1_CR2            ADC1_SMPR1
ADC1_SMPR2          ADC1_JOFR1          ADC1_JOFR2          ADC1_JOFR3
ADC1_JOFR4          ADC1_HTR            ADC1_LTR            ADC1_SQR1
ADC1_SQR2           ADC1_SQR3           ADC1_JSQR           ADC1_JDR1
ADC1_JDR2           ADC1_JDR3           ADC1_JDR4           ADC1_DR
ADC1_SR.            ADC1_CR1.           ADC1_CR2.           ADC1_SMPR1.
ADC1_SMPR2.         ADC1_JOFR1.         ADC1_JOFR2.         ADC1_JOFR3.
ADC1_JOFR4.         ADC1_HTR.           ADC1_LTR.           ADC1_SQR1.
ADC1_SQR2.          ADC1_SQR3.          ADC1_JSQR.          ADC1_JDR1.
ADC1_JDR2.          ADC1_JDR3.          ADC1_JDR4.          ADC1_DR.
ADC1.               DBG                 DBG_IDCODE          DBG_CR
DBG_IDCODE.         DBG_CR.             DBG.                NVIC
NVIC_ICTR           NVIC_STIR           NVIC_ISER0          NVIC_ISER1
NVIC_ICER0          NVIC_ICER1          NVIC_ISPR0          NVIC_ISPR1
NVIC_ICPR0          NVIC_ICPR1          NVIC_IABR0          NVIC_IABR1
NVIC_IPR0           NVIC_IPR1           NVIC_IPR2           NVIC_IPR3
NVIC_IPR4           NVIC_IPR5           NVIC_IPR6           NVIC_IPR7
NVIC_IPR8           NVIC_IPR9           NVIC_IPR10          NVIC_IPR11
NVIC_IPR12          NVIC_IPR13          NVIC_IPR14          NVIC_ICTR.
NVIC_STIR.          NVIC_ISER0.         NVIC_ISER1.         NVIC_ICER0.
NVIC_ICER1.         NVIC_ISPR0.         NVIC_ISPR1.         NVIC_ICPR0.
NVIC_ICPR1.         NVIC_IABR0.         NVIC_IABR1.         NVIC_IPR0.
NVIC_IPR1.          NVIC_IPR2.          NVIC_IPR3.          NVIC_IPR4.
NVIC_IPR5.          NVIC_IPR6.          NVIC_IPR7.          NVIC_IPR8.
NVIC_IPR9.          NVIC_IPR10.         NVIC_IPR11.         NVIC_IPR12.
NVIC_IPR13.         NVIC_IPR14.         NVIC.               input.analog
output.pp           input.floating      output.od           input.pullx
output.af.pp        output.af.od        gpio?               SCB_CPUID
SCB_ICSR            SCB_VTOR            SCB_AIRCR           SCB_SCR
SCB_CCR             SCB_SHPR1           SCB_SHPR2           SCB_SHPR3
SCB_SHCSR           SCB_CFSR            SCB_HFSR            SCB_MMFAR
SCB_BFAR            STK_CSR             STK_RVR             STK_CVR
STK_CALIB           STK_CTRL            STK_LOAD            STK_VAL
dump16              dump                words4              chipid
hwid                c,collection        c,                  calign
flash-kb            flash-pagesize      init-ring           c++@
ring-step           ring#               ring?               >ring
ring>               usb:dev             usb:conf            usb:langid
usb:vendor          usb:product         usb:line            usb:init
USB                 USB_EP0R            USB_CNTR            USB_ISTR
USB-FNR             USB_DADDR           USB_BTABLE          USBMEM
usb-pma             usb-pma@            usb-pma!            ep-addr
ep-reg              rxstat!             txstat!             ep-reset-rx#
rxclear             txclear             usb-pend            usb-serial
set-serial          send-data           send-next           send-desc
usb-reset           zero                usb-in-ring         usb-out-ring
ep-setup            tx.pend             usb.ticks           usb-pma-c!
usb-fill            ep-out              ep-in               usb-ctr
usb-flush           usb-poll            usb-key?            usb-key
usb-emit?           usb-emit            usb-io              init.usb
deinit.usb          +usb                -usb                flashfree
ramfree             flashfree.          ramfree.            memstats
word.start          word.end            disasm-$            disasm-fetch
disasm-string       name.               register.           opcode?
reg.                reg16.              reg16split.         registerlist.
imm3.               imm5.               imm8.               imm3<<1.
imm5<<1.            imm8<<1.            imm3<<2.            imm5<<2.
imm7<<2.            imm8<<2.            condition.          rotateleft
rotateright         imm12.              destination-r0      disasm-thumb-2
disasm              memstamp            disasm-step         seec
see                 free                ticktime            tickint
systick-handler     init.systick        ticktime.           zero-ticktime
ms.delay            cornerstone         --utils--           calltrace-handler
init.calltrace      RCC_APB2ENR_IOPAEN  RCC_APB2ENR_IOPBEN  RCC_APB2ENR_IOPCEN
JUMPER-ON?          GPIOA_CRL_MODE0<<   GPIOC_CRH_MODE13<<  GPIOC_BSRR_BS13
GPIOC_BSRR_BR13     GPIOB_CRH_MODE9     GPIOB_CRH_CNF9      GPIOB_BSRR_BS9
GPIOB_BSRR_BR9      PB9-LOW             PB9-HIGH            GPIOA_CRH_MODE12
GPIOA_CRH_CNF12     GPIOA_BSRR_BS12     GPIOA_BSRR_BR12     PA12-HIGH
PA12-LOW            blink               pa12-init           pa12-disable
pa12-pulse          pb9-init            pb9-disable         pb9-pulse
usddp-init          usbdp-pulse         usbdp-disable       2nd64kb-verified-flag
test-flag           pass-flag           flash=65536-declared-flag
qty-flash-declared? 2nd64kb-verified-flag-test
FF?                 AA?                 55?                 fillAA
fill55              erase               2nd64kb?            hidden64kB?
cause-exception     wait                flash-declared?     print-flash-declared
DBGMCU_IDCODE-UNREADABLE-FLAG
3addr               duid                serial              is-ascii?
ascii.              id                  scb_cpuid-bits31-0  scb_cpuid-bits31:24
scb_cpuid-bits23:20 scb_cpuid-bits19:16 scb_cpuid-bits15:4  scb_cpuid-bits3:0
scb-cpuid           uuid                print-dbgmcu_idcode dbgmcu_idcode?
test-status?        F103C8T6-Auth?      0dump               1dump
fflag-fail!         fflag-pass!         ex3                 flash-$55@$1FFF0
read-@$1FFF0        credits             license             faq
usb-faq             fallthru            extra-menu-print    menu-a
menu-print          extra-menu          menu                m
version-major       version-minor       version?            option-jumper?
init

Forth User Notes

  • A PC-13 blinky, ‘blink’ has been included.

: GPIOC_CRH_MODE13<< ( %bbbb -- x ) 20 lshift ;   \ GPIOC-13 mode
: GPIOC_BSRR_BS13 ( -- ) 13 bit GPIOC_BSRR ! ;    \ Set bit 13
: GPIOC_BSRR_BR13 ( -- ) 29 bit GPIOC_BSRR ! ;    \ Reset bit 13

: blink ( -- pc13 )
  $F GPIOC_CRH_MODE13<< GPIOC_CRH bic!            \ clear all bits
  output.od GPIOC_CRH_MODE13<< GPIOC_CRH bis!     \ set PC13 to open drain
  begin
       GPIOC_BSRR_BR13 \ PC13 led on
       1000 ms.delay   \ accurate  1 millisecond blocking delay
       GPIOC_BSRR_BS13 \ PC13 led off
       1000 ms.delay
  key? until           \ keep blinking until a keyboard key is pressed
;
  • ‘free’ shows the flash and ram status. Flash status assumes a 128kb flash chip (including the STM32F103C8 hidden 64KB)

  • To remove all of the BluePill Diags V1.6 code to free up flash space enter the following:

--utils--

This will not affect the USB terminal or developer utils etc.You can replace it by reflashing bluepill-diagnostics-v1.6.bin