problems in uploading code to stm32 bluepill

hi
i am not able to program the stm32 bluepill board using arduino ide.

i am trying to upload the blinky sketch using USB ttl converter. but everytime i try to upload i am getting the same error.

i am following this instructions STM32 arduino .

but i am getting the same error every time.

Archiving built core (caching) in: C:\Users\user\AppData\Local\Temp\arduino_cache_99041\core\core_stm32duino_STM32F1_genericSTM32F103C_device_variant_STM32F103C8,upload_method_serialMethod,cpu_speed_speed_72mhz,opt_osstd_2319373ca4baa5514c3629abb9b23228.a
Sketch uses 12652 bytes (19%) of program storage space. Maximum is 65536 bytes.
Global variables use 2456 bytes (11%) of dynamic memory, leaving 18024 bytes for local variables. Maximum is 20480 bytes.
C:\Users\user\AppData\Local\Arduino15\packages\stm32duino\tools\stm32tools\2019.6.29/win/serial_upload.bat COM10 {upload.altID} {upload.usbID} C:\Users\user\AppData\Local\Temp\arduino_build_867610/stm_blinky.ino.bin 
stm32flash 0.4
Failed to init device.

http://stm32flash.googlecode.com/

Using Parser : Raw BINARY
Interface serial_w32: 115200 8E1

till now i have done the following

  1. reinstalled the arduino ide to vs 1.8.5 from 1.8.9

  2. reinstalled the boards from the board anagers.

3 correctly installed the bootloader from the roger clark's github. using stlink v2.

  1. connections are correct. tx -> rx and rx-> tx

  2. restarted the computer . and reinstalled the drivers for usb ttl.

  3. changed the usb ttl .

  4. changed the stm board.

  5. jumpers are at correct position.

  6. reflashed the bootloader.

i also have a st link v2 . it is also not been able to upload the code.

but st utility is showing that everything is fine.

Note 1 .
after googling a lot. i came across a post saying that downgrading for 1.8.5 from 1.8.6 worked for someone. so i tried that. it was able to upload the code. but led didnt blink .

so i tried again and after that ide was not able to upload any code.

pic 1

pic 2

log while using the st link

Build options changed, rebuilding all
Archiving built core (caching) in: C:\Users\user\AppData\Local\Temp\arduino_cache_476880\core\core_stm32duino_STM32F1_genericSTM32F103C_device_variant_STM32F103C8,upload_method_STLinkMethod,cpu_speed_speed_72mhz,opt_osstd_2319373ca4baa5514c3629abb9b23228.a
Sketch uses 14324 bytes (21%) of program storage space. Maximum is 65536 bytes.
Global variables use 3088 bytes (15%) of dynamic memory, leaving 17392 bytes for local variables. Maximum is 20480 bytes.
C:\Users\user\AppData\Local\Arduino15\packages\stm32duino\tools\stm32tools\2019.6.29/win/stlink_upload.bat C:\Users\user\AppData\Local\Temp\arduino_build_724584/stm_blinky.ino.bin 

C:\Program Files (x86)\Arduino>rem @echo off 

C:\Program Files (x86)\Arduino>rem: Note C:\Users\user\AppData\Local\Arduino15\packages\stm32duino\tools\stm32tools\2019.6.29\win\ get path of this batch file 

C:\Program Files (x86)\Arduino>rem: Need to change drive if My Documents is on a drive other than C: 

C:\Program Files (x86)\Arduino>set driverLetter=C:\Users\user\AppData\Local\Arduino15\packages\stm32duino\tools\stm32tools\2019.6.29\win\ 

C:\Program Files (x86)\Arduino>set driverLetter=C: 

C:\Program Files (x86)\Arduino>C:

C:\Program Files (x86)\Arduino>cd C:\Users\user\AppData\Local\Arduino15\packages\stm32duino\tools\stm32tools\2019.6.29\win\ 

C:\Users\user\AppData\Local\Arduino15\packages\stm32duino\tools\stm32tools\2019.6.29\win>rem: the two line below are needed to fix path issues with incorrect slashes before the bin file name 

C:\Users\user\AppData\Local\Arduino15\packages\stm32duino\tools\stm32tools\2019.6.29\win>set str=C:\Users\user\AppData\Local\Temp\arduino_build_724584/stm_blinky.ino.bin 

C:\Users\user\AppData\Local\Arduino15\packages\stm32duino\tools\stm32tools\2019.6.29\win>set str=C:\Users\user\AppData\Local\Temp\arduino_build_724584\stm_blinky.ino.bin 

C:\Users\user\AppData\Local\Arduino15\packages\stm32duino\tools\stm32tools\2019.6.29\win>rem: ------------- use STLINK CLI 

C:\Users\user\AppData\Local\Arduino15\packages\stm32duino\tools\stm32tools\2019.6.29\win>stlink\ST-LINK_CLI.exe -c SWD -P C:\Users\user\AppData\Local\Temp\arduino_build_724584\stm_blinky.ino.bin 0x8000000 -Rst -Run -NoPrompt 
STM32 ST-LINK CLI v3.3.0.0
STM32 ST-LINK Command Line Interface

ST-LINK SN: 54FF6D064884525019112287
ST-LINK Firmware version: V2J34S7 (Need Update)
Connected via SWD.
SWD Frequency = 4000K.
Target voltage = 3.2 V
Connection mode: Normal
Reset mode: Software reset
Device ID: 0x412 
Device flash Size: 32 Kbytes
Device family: STM32F10xx Low-density

Loading file...
Flash Programming:
  File : C:\Users\user\AppData\Local\Temp\arduino_build_724584\stm_blinky.ino.bin
  Address : 0x08000000
Memory programming...
±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± 0%
 0%ÛÛÛÛÛ 10%ÛÛÛÛÛ 21%ÛÛÛÛÛÛ 32%ÛÛÛÛÛ 42%ÛÛÛÛÛ 53%ÛÛÛÛÛÛ 64%ÛÛÛÛÛ 75%ÛÛÛÛÛ 85%ÛÛÛÛÛÛ 96%ÛÛ 100%
Memory programmed in 1s and 344ms.
Programming Complete.

MCU Reset.

The core is locked up!


C:\Users\user\AppData\Local\Arduino15\packages\stm32duino\tools\stm32tools\2019.6.29\win>rem: Using the open source texane-stlink instead of the proprietary STM stlink exe 

C:\Users\user\AppData\Local\Arduino15\packages\stm32duino\tools\stm32tools\2019.6.29\win>rem:texane-stlink\st-flash.exe write C:\Users\user\AppData\Local\Temp\arduino_build_724584\stm_blinky.ino.bin 0x8000000

The best place to ask this question might be the STM32 Arduino Forum. Search that forum first before you post, maybe others there have solved the same problem.

If you do post there, leave a message on this thread so that other forum members here don't waste time trying to answer your question. If you can't get an answer on the other forum, you can always return to this thread and ask for more help.

i am comming from there only .

manveen_singh:
i am comming from there only .

I don't understand. Did you mean you asked the question on that forum already? If so, you should say that up front. What answer did you get?

faced same issue weeks ago with FTDI board,

tried with ST Link and worked like a charm

PaulRB:
I don't understand. Did you mean you asked the question on that forum already? If so, you should say that up front. What answer did you get?

My account was not allowed to post anything there as of now.

so when i said that i am comming from there. i meant that i have looked a lot of similar forums there . but none of them worked for me .
i have not posted anything there.

KASSIMSAMJI:
tried with ST Link and worked like a charm

I also ttried that . nothing worked. the core is locked up error cam . then i tried all the jumper settings . again nothing worked. again the same error came.

in on jumper setting. it did show that programed sucessfully . but nothing happened. LED didnt blink.

i looked thru the code in the memory . using thier stlink utility before and after programming. there were some changes in the binary . but still nothing happened,

Have you put the jumpers in the right mode as described in the first link you posted?
There is a position for programming and another position for running programs.
You can upload using ST-link too.

zoomx:
You can upload using ST-link too.

yes

zoomx:
You can upload using ST-link too.

i am techinicaly able to upload the code. but nothing is happening . please see reply #6

Try an example that print on serial like this one that print on all serials and has a blink too, joust to test that maybe the problem is on the LED.

/*
  STM32_serial_test

  Use PC13 instead of PIN13 for generic STM32 boards.
  Print on every serial to identify them.

  Led pin
  BluePill  PC13
  MapleMini PB1
  
*/
#define LED PC13 //PC 13 on BluePill, PB1 on Maple Mini

void blink() {
  digitalWrite(LED, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(200);              // wait for a second
  digitalWrite(LED, LOW);    // turn the LED off by making the voltage LOW
  delay(100);              // wait for a second
}

void setup() {
  // initialize pins PC13, as an output.
  pinMode(LED, OUTPUT);
  Serial.begin(115200);
  Serial1.begin(115200);
  Serial2.begin(115200);
  //Serial3.begin(115200);
  Serial.println("Hello world this is Serial");
  Serial1.println("Hello world this is Serial1");
  Serial2.println("Hello world this is Serial2");
  //Serial3.println("Hello world this is Serial3");

  blink();
}

void loop() {
  blink();              //
  Serial.println("It Works on serial");
  Serial1.println("It Works on serial1");
  Serial2.println("It Works on serial2");
}

tried it. nothing happened.

i seiral didnt not work also.
i attached a usb ttl to uart 1 (hopin that at least something would come up on serial monitor.) nothing happened. serial1 did not print in uart1

:o
I assume that your board is like the one showed in photos.


Check that the MCU is an ST MCU since there are some blue pills that has a sort of "clone" mcu. But You wrote that st-link utility was able to recognize the MCU and this not happens with clones.

Stlink us used for debugging too but I never used it in this way.

Maybe you can use the last version. Remove the core from the IDE using the Board Manager, download the new version from here

just use the download button to get a zip.

In the sketch folder create a new folder named hardware and inside unzio the... zip so you will have
Hardware\Arduino_STM32-master and inside all the files.
Rename Arduino_STM32-master in Arduino_STM32
Launch the IDE.

I used the old version without any problem but you can try.

I don't have a system in front of me, but from your ST-Link log "Device flash Size: 32 Kbytes" doesn't seem right. The Bluepill STM32f103c8t6 is supposed to be a 64 kByte flash device.

What are the markings on the MCU chip?

Karma+ MrMark!
You're right! Flash is almost 64k.
So it is still an STM32 but a LowDensity MCU so the finals letters matter!

yes i will try that and tell you the results

i tried 2 other stms. same problem came up in every one.

then i bought another stm from another shop and used a fresh pc to upload the code.
this worked for now . i am able to upload the code from other pc to a newer stm board.

maybe the problem was in board itself.

maybe the problem was in my older pc.

this issue for now is still not resolved for me. but now lets close this move on .

manveen_singh:
this issue for now is still not resolved for me. but now lets close this move on .

I'm glad that you've got something working. However, the power of this sort of forum is that we can learn from the experience of others to the benefit of all. To that end, I'd suggest the following before "moving on".

  1. What are the chip markings on the board that fail to program with the ST-Link? The program output suggests that you have a STM32F103x6 device rather than the expected STM32F103C8 with 32k flash rather than 64. If this is the case and the vendor advertised it as a C8, they should be notified and allowed to make it right. If they don't it would be nice to know the vendor so others in the community can avoid them.

  2. Assuming the chip is marked as a C8 it would be informative to try programming the "bad" devices with the new PC setup and the "good" device with the old PC setup to isolate the issue to one or the other. It would surprise me if the PC were the issue given the symptoms you've described and I expect the problem will follow the boards. There have been reports of devices with C8 markings having 128k flash (i.e. twice the spec), but I'm not aware of any reported with less than spec.

ya i will try that

zoomx:
I used the old version without any problem but you can try.

I'm getting the same error and I think this ^^^^^ can be the solution. Anybody still keeping this version?

stm32flash Arduino_STM32_0.9

Unfortunately I updated it over the time and didn't keep the old versions.