How to install "Roger's core" from github on linux and use it with a Bluepill.
AKA "libmaple core", "original stm32duino core", "not compatible with HAL core". "not the one ST is working on core"
1.) In the Arduino IDE, from Tools/ menu, select Board manager and install one of the Arduino SAM cortex-m3/ or cortex-m0 cores. We will never select any of these boards, it is installed only to obtain the arm-none-eabi-g++/gcc toolchain (*)
2.) Close all Arduino windows to exit Arduino.
3.) Install latest version of Roger's core from github into
Sketch Directory/hardware/Arduino_STM32.
Note: assumes your Sketch directory is $HOME/Arduino (the default for Arduino IDE)
In a linux terminal window:
Code: Select all
$ mkdir -p ~/Arduino/hardware
$ cd ~/Arduino/hardware
$ git clone https://github.com/rogerclarkmelbourne/Arduino_STM32.git Arduino_STM32
4.) Start Arduino IDE
5.) From the Tools menu, find the section titled "STM32F1 Boards (stm32duinoforum.com/forum)", select the "Generic STM32F103C series" board.
6.) From the Tools menu, now you can select the upload method.
o If you installed a bootloader, you can use the "STM32duino booloader" upload method. (1)
o If you have a usb serial dongle connected to PA9/PA10, you can use the "Serial" upload method. (2)
o If you have an STLink V2 connected to DCLK/DIO, you can use the "STLink" upload method. (3)
o If you have an BlackMagic probe connected to DCLK/DIO, you can use the "BMP (Black Magic Probe)" upload method. (4)
(1) You probably have to fix the pull up R10 resistor as described in the wiki (10k needs to be 1k5). Once this is fixed the bluepill should enumerate as a /dev/ttyACM0 ( assuming you don't have other ACM devices). This ACM device is used by the uploader to program the board. The Serial object in Arduino code will be the native USB device. You lose some flash to the user DFU bootloader with this method. It also introduces a delay when the chip is powered on. None of the other upload methods result in a delay at chip power on.
(2) Selecting this upload method uses the chip's ROM builtin serial uploader, It also has the side effect of turning off the define that enables the native USB. To start the ROM serial bootloader you have to move the BOOT0 pin to 1 and press the reset. You have to set it back to 0 and press reset to run the code. Code compiled using this upload method results in the Serial object in Arduino code using PA9/PA10. All flash memory available. The serial bootloader is burned at the factory to the chip's ROM. Always available and can't be deleted. See
Application note AN3155
(3) Selecting this upload method uses SWD as the upload method. It doesn't matter what serial port you have selected it isn't used for upload. You will still be able to use the USB native it will be Serial (assuming you have fixed the R10 resistor probem). Serial1 is PA9/PA10. Either way, it doesn't matter which port you have selected in the Arduino IDE, it will not be used for upload, only for Serial console. All flash memory available no bootloader used.
(4) Selecting this upload method uses SWD via GDB Remote Serial Protocol to the BMP device. You must select the first BMP /dev/ttyACM device (there are 2, /dev/ttyACM0, /dev/ttyACM1) ttyACM0 is the BMP gdb debug port. This is used for programming using GDB RSP. ttyACM1 is the BMP virtual port (it acts just like an USB serial dongle). If you want to use the Arduino Serial console you must flip the port back and forth between upload and serial console mode. It is much easier to use an external program like putty on /dev/ttyACM1. All flash memory available no bootloader used.
(*) For fear of confusing the whole issue of the arm gcc toolchain, I'll not describe how to do it, however it is possible to use the arm-none-eabi-gcc toolchain from other boards packages.