cancel
Showing results for 
Search instead for 
Did you mean: 

Problem programming Bluepill from Cube

alphanov
Associate II

Hello. Please forgive a 'newbie' question. Whilst I am new to STM32 chips I have been programming MCUs for many years which makes this problem even more frustrating.

I wrote a program which I then uploaded onto a Bluepill (genuine processor) using CubeIDE v1.16.0 (and later Cube Prog v2.17 as a standalone) and the STLink V2 interface with the most up to date firmware.  The program didn't run so I assumed that it was something that I was doing wrong (it probably still is).  I went back to basics and viewed several 'tutorials' on YouTube.  I then set up a minimal program to flash the onboard LED at PC13.  I left all the settings of the IDE as they came when the IDE was installed.  I set PC13 as a GPIO output and left all the rest of the GPIO settings as they were. I used HAL_GPIO_WritePin to write directly to the pin with HAL_Delay as the delay mechanism.  So four lines of code in total all placed after the /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { construct. The programmed compiled without error and appeared to upload without problem.

Resetting the board did absolutely nothing.. no LED flash or anything. I repeated the exercise by toggling a different GPIO pin and an external LED. Again nothing.

I tried setting the BOOT_0 jumper prior to powering the board and then uploading. Moving the BOOT_0 jumper back and repowering the board.

Again - nothing. I started to think that the board was faulty. I tried a totally different Bluepill board with no success.

I then had a thought. I had read that you could use ArduinoIDE to program these boards. I set up ArduinoIDE and wrote a simple LED flash program and uploaded it to the board using STLink.

To my surprise the program ran with the onboard LED flashing.

To my logic this proves that both the board and STLink are working as they should and the problem is with Cube.

I repeated the process on two other PCs - one running Windows 11 (like the original PC) and the other Ubuntu 24.04. I had exactly the same results in that the programs uploaded via Cube didn't appear to run.

Sorry for the rambling post. Have any of you any suggestions about what I'm doing wrong? Do you need to put the board into BOOT_0 when using STLink since there appears to be conflicting information on the net?

Thanks in anticipation.

Regards Nev

 

13 REPLIES 13

@alphanov wrote:

I have just checked the levels on the BOOT0 pins. There is 3V3 on one outer pin and 0V on the other outer pin. With the header link in the program setting the appropriate voltage (3V3 is present on the centre pin. 

 


Sorry I didn't understand this statement. Did you test the voltage level directly on the MCU BOOT0 pin?

I recommend you to check if BOOT0 pin of the MCU is connected to the GND using a multimeter continuity with the board powered off.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

Hello Sorry for the delay.  I have, finally, managed to read the resistance value between the BOOT0 pi (44 on MCU) and the BOOT0 jumper centre pin.  This is 10k Ohm and, when the jumper is at 0 position, the same value is with reference to ground.

I've downloaded a Bluepill schematic and this value agrees with what is shown on there.  I measured it both at the board via at the side of the chip and actually on MCU pin 44.

I've ordered a Nucleo-F446RE board from Mouser so will see how I fare with that.

The puzzling thing with this is that it programs and runs OK with the ArduinoIDE and the STLink plus it programs OK with at TTL-USB converter.  I'll do some further experimentation and see how things go.  Most of the 'tutorials' appear not to put the Bluepill into BOOT0 high before programming so baffled even more now!

Thanks for your continued assistance on this.

 

Regards

 

Nev

 


@alphanov wrote:

Hello Sorry for the delay.  I have, finally, managed to read the resistance value between the BOOT0 pi (44 on MCU) and the BOOT0 jumper centre pin.  This is 10k Ohm and, when the jumper is at 0 position, the same value is with reference to ground.

 

 You need to put the jumper of BOOT0 on P1 to connect the pins 3-5:

SofLit_0-1725479765675.png

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

***Update***

I have received both the Blackpill boards and the Nucleo446. I had the same issue with both initially. After some further trying I managed to get the Nucleo446 onboard LED to blink using code uploaded using CubeIDE. I'm now going to follow the exact same process with both the Bluepill and the Blackpill.

Thanks to everyone who has taken the time to reply to me with suggestions.

I'll post an update with my findings on here and detail the steps that I took in case anyone else has a similar issue.

Regards

 

Nev