Programming an STM32F103C8T6 Blue Pill with Arduino
Set up the STM32 Arduino core, upload a first sketch to a Blue Pill, and diagnose boards that fail to identify or run.
Select the board and upload method
Add the STMicroelectronics package index linked below to Arduino IDE's Additional Boards Manager URLs. Install the STM32 MCU based boards package. Choose Generic STM32F1 and the Blue Pill F103C8 variant. Confirm the part marking before using that profile. A clone that looks identical may carry a different device.
For an ST-LINK upload, choose the SWD upload method and install STM32CubeProgrammer if required by the core. Connect SWDIO to PA13, SWCLK to PA14, and GND to GND. Supply the target according to the board and probe documentation. Connect NRST if the probe supports reset control. BOOT0 stays low for normal execution.
For a UART upload, use a 3.3 V USB-to-UART adapter. Connect its TX to PA10, its RX to PA9, and join grounds. Raise BOOT0, keep BOOT1 low, and reset to enter the factory bootloader. Lower BOOT0 and reset after uploading. Using the board's Micro USB port for uploads requires a compatible bootloader already in flash.
Verify with the PC13 LED
The LED on the documented Blue Pill PCB is active low. Each LOW should light the LED for half a second. If the upload verifies but the LED does not flash, check BOOT0, reset the board and confirm the LED connection for your revision.
This Blink and Count example sends one line per LED cycle. In Arduino's Tools menu, make sure the generic Serial instance goes to the interface you are monitoring. If you select native USB CDC, a running sketch must first enumerate on the host.
uint32_t cycles = 0;
void setup() {
pinMode(PC13, OUTPUT);
Serial.begin(115200);
}
void loop() {
digitalWrite(PC13, LOW);
Serial.println(++cycles);
delay(500);
digitalWrite(PC13, HIGH);
delay(500);
}When the programmer cannot read the device
Measure the 3.3 V rail at the target and verify the ground and SWD connections. Lower the SWD frequency. If application firmware disables debug pins or enters deep sleep, try Connect Under Reset with NRST connected. If a USB-powered board has no 3.3 V, diagnose the USB supply and regulator first.
If the tool identifies the chip and reports flash readout protection, consult the option-byte rules for the detected device. On the STM32F103, removing readout protection erases the protected application flash. Preserve any existing firmware you need before changing protection settings.
Upload from macOS
Install the STM32 Arduino core and the STM32CubeProgrammer build for your macOS architecture if the upload method calls it. In verbose upload output, check which programmer executable Arduino starts. Test the same target directly with CubeProgrammer if the IDE cannot start the upload.
For a USB-to-UART adapter, find its new /dev/cu.* device after reconnecting it. A Blue Pill held in ROM USART boot mode has no separate native USB CDC port. If using SWD, select the ST-LINK upload method and confirm the programmer sees the probe and then the target.
