Can't get arduino to install software.

Post here all questions related to STM32 core if you can't find a relevant section!
Post Reply
nleco
Posts: 4
Joined: Sun Dec 04, 2022 3:47 am

Can't get arduino to install software.

Post by nleco »

I am using a mac running BigSur 11.7.1
I have a STM32F411CEU6.
I installed STM32CubeProgrammer v 2.12 (I also tried 2.11 and 2.10)
In the Arduino IDE, I use STM32 libraries version 2.2.0

I have set the following options in my IDE.

Code: Select all

Board Generic STM32F4 series, Board part number BlackPill F411CE (or BlackPill F401CC).
Upload method STM32CubeProgrammer (DFU).
U(S)ART Support Enabled (no generic 'Serial').
USB Support CDC (generic 'serial' superseded U(S)ART).
Press and hold button BOOT0 while powering on or resetting then release BOOT0.
No matter what I do, e.g. reconnect, hold boot0 and try again, hold reset, then boot0, release reset, release boot0... Nothing seems to work and I always get this:

Code: Select all

Sketch uses 23800 bytes (4%) of program storage space. Maximum is 524288 bytes.
Global variables use 3864 bytes (2%) of dynamic memory, leaving 127208 bytes for local variables. Maximum is 131072 bytes.
      -------------------------------------------------------------------
                        STM32CubeProgrammer v2.12.0                  
      -------------------------------------------------------------------



USB speed   : Full Speed (12MBit/s)
Manuf. ID   : STMicroelectronics
Product ID  : STM32  BOOTLOADER
SN          : 3667355C3036
DFU protocol: 1.1
Board       : --
Device ID   : 0x0431
Device name : STM32F411xC/E
Flash size  : 512 KBytes (default)
Device type : MCU
Revision ID : --  
Device CPU  : Cortex-M4


Memory Programming ...
Opening and parsing file: BlinkSTM32F4.ino.bin
  File          : BlinkSTM32F4.ino.bin
  Size          : 23.68 KB 
  Address       : 0x08000000 


Erasing memory corresponding to segment 0:
Erasing internal memory sectors [0 1]
erasing sector 0000 @: 0x08000000 done
erasing sector 0001 @: 0x08004000 done
Download in Progress:
Error: 
Write failed at address: 0x8000000 



Error: failed to download Segment[0]
Error: failed to download the File
Error: failed to download the File

The example program I am trying to upload is the following:

Code: Select all

void setup() {
  // put your setup code here, to run once:
  pinMode(PC13, OUTPUT);
  Serial.begin(9600);

}

void loop() {
  // put your main code here, to run repeatedly:
  digitalWrite(PC13, HIGH);
  delay(1000);
  digitalWrite(PC13, LOW);
  delay(1000);
  Serial.println("Hello world!");
}
GonzoG
Posts: 325
Joined: Wed Jan 15, 2020 11:30 am
Answers: 24
Location: Prudnik, Poland

Re: Can't get arduino to install software.

Post by GonzoG »

Resetting those boards into DFU bootloader is tricky as they are not designed properly.
Open STM32CubeProgrammer and check if it detects board (select USB on top right as an interface).

Here: viewtopic.php?t=1680
@bm16ton2 posted about a fix for F4x1 black pills and DFU bootloader.
Just use a pull down resistor on PA10.
ag123
Posts: 1421
Joined: Thu Dec 19, 2019 5:30 am
Answers: 19

Re: Can't get arduino to install software.

Post by ag123 »

Perhaps try with a st-link v2?
https://www.adafruit.com/product/2548
https://www.st.com/en/development-tools/st-link-v2.html

maybe that could help

for what is worth, if you managed to get the board / chip to connect in DFU mode,
i.e. press boot0 and reset,
hold boot0 release reset,
release boot0 1 sec later
in device manager, it should probably indicate some sort of USB DFU device connected
in Linux, i run dmesg command to see those messages that it is connected as a DFU device

in this mode, it should be able to update / install / flash the firmware.
ozcar
Posts: 127
Joined: Wed Apr 29, 2020 9:07 pm
Answers: 4

Re: Can't get arduino to install software.

Post by ozcar »

GonzoG wrote: Sun Dec 04, 2022 11:57 am Resetting those boards into DFU bootloader is tricky as they are not designed properly.
Open STM32CubeProgrammer and check if it detects board (select USB on top right as an interface).

Here: viewtopic.php?t=1680
@bm16ton2 posted about a fix for F4x1 black pills and DFU bootloader.
Just use a pull down resistor on PA10.
I have not had this problem myself, but I normally use stlink and would not have put one of those boards into DFU mode very often.

That thread, and the Micropython page mentioned there both seem to say "do this" without explaining why there is an issue in the first place.

I guess it must be due to the bootloader checking USART1 (RX = PA10) first before checking USB, and if PA10 is floating it might incorrectly go down the USART path.
ag123
Posts: 1421
Joined: Thu Dec 19, 2019 5:30 am
Answers: 19

Re: Can't get arduino to install software.

Post by ag123 »

That is a likely problem, it may prioritize uart over USB (DFU) while bootloading.
Normally, if PA9, PA10 is floating, not connected, it would likely drop in and wait for USB DFU to connect
nleco
Posts: 4
Joined: Sun Dec 04, 2022 3:47 am

Re: Can't get arduino to install software.

Post by nleco »

Thank you all for pointing me in the proper direction. I will take a look at those options and threads.

After posting this, I somehow got the board to show up in my STM32CubeProgrammer app. I am using mac os, so I don't have a "device manager".
I don't have an st-link v2, but I may try.
nleco
Posts: 4
Joined: Sun Dec 04, 2022 3:47 am

Re: Can't get arduino to install software.

Post by nleco »

I think that my issue is that it does enter boot mode.. it is able to erase the memory, but it just won't let me write.
imk
Posts: 31
Joined: Fri Sep 24, 2021 9:26 pm

Re: Can't get arduino to install software.

Post by imk »

I use a STLink V3 Mini and wire to the programming four pins at the end of board.
Works just fine with the same board as yours and ARDUINO V2
imk
1201 Alarm
nleco
Posts: 4
Joined: Sun Dec 04, 2022 3:47 am

Re: Can't get arduino to install software.

Post by nleco »

I got it to work. I had to hold the reset button as I then ran the command:

Code: Select all

$st-flash write CODE.bin 0x08000000
I did have to try it a few times, unplug/plug the ST-Link usb, etc.. but the key was that I had to hold the reset button as I ran the upload.
once it began to flash, I released the reset button.
Post Reply

Return to “General discussion”