Page 1 of 1

Program an STM32F411CEU6 using UART

Posted: Sun Jun 13, 2021 12:19 pm
by mwon
Hello!

My problem: I can't program a STM32F411CEU6 with Arduino IDE and using UART.

So, I have designed a customized board with an STM32F411CEU6. I'm new in the field and so to prevent any big surprises I just used the design of a Black Pill as a reference (it turns out I had a big surprise :D ). Also, I have one Black Pill I use as a control.

I'm able to program the Black Pill with Arduino IDE in three different ways:

1. Via SWD using the official ST-link v2
2. Via SWD using a Chinese made USB pen ST-link like one: https://www.amazon.com/HiLetgo-Emulator ... a?dchild=1.
3. Via UART using an FTDI UART to USB converter

Also, I'm able to program my customized board:

1. Via SWD using the official ST-link v2
2. Via SWD using the ST-link USB pen

But can't program it using UART. :x

I'm using pins PA9 and PA10 that are the UART1 pins in STM32F411CEU6 chip. I have tested a UART communication in these pins on my custom board and everything ok (I uploaded a sketch with a "Hello World" message using SWD).


The error:


When I try to connect STM32CubeProgramer using UART (I'm able to connect it using SWD) I get the error:

Code: Select all

12:58:46 : Serial Port cu.usbserial-A50285BI is successfully opened.
  12:58:46 : Port configuration: parity = even, baudrate = 115200, data-bit = 8,                     stop-bit = 1.0, flow-control = off
  12:58:48 : Timeout error occured while waiting for acknowledgement.
  12:58:48 : Timeout error occured while waiting for acknowledgement.
  12:58:48 : Error: Activating device: KO. Please, verify the boot mode configuration and check the serial port configuration. Reset your device then try again... 

Btw. Not sure if it is related but the first time I tried the chip, I got the following error:

Code: Select all

RUNNING Program ... 
  Address:      : 0x8000000
Warning: The core is locked up
Start operation achieved successfully
the selected serial port Start operation achieved successfully
 does not exist or your board is not connected
that was solved with the following steps:

1. Open STM32CubeProgramer and click connect
2. Click Option Bytes (OB) located in the left bar
3. Select Read Out Protection and choose AA option
4. Then select PCROP and uncheck the box
4. Click apply


So, any ideas one why I can't program it using UART?

Re: Program an STM32F411CEU6 using UART

Posted: Sun Jun 13, 2021 12:38 pm
by ag123
did you set boot0?

Re: Program an STM32F411CEU6 using UART

Posted: Sun Jun 13, 2021 12:51 pm
by mwon
I have two tactile switches, one for boot and another for RST. I do the following steps, which are the same I use when programming the Black Pill.

1. Press and hold boot
2. Press for half a second RST
3. Release boot.

(I wanted to post an image of the schematics but it's complaining that the file is too large! It's 150KB...)

Re: Program an STM32F411CEU6 using UART

Posted: Sun Jun 13, 2021 2:42 pm
by ag123
sequence should be
press both reset and boot0
release reset
release boot0 1 sec later

Re: Program an STM32F411CEU6 using UART

Posted: Sun Jun 13, 2021 4:31 pm
by mwon
Same error. :cry:

The schematics:

https://imgur.com/0HOdgV1

Re: Program an STM32F411CEU6 using UART

Posted: Sun Jun 13, 2021 6:37 pm
by ag123
if you have a usb cable you can try using a usb cable instead
either of dfu-util or stm32cube programmer should work.

the command with dfu-util normally is

Code: Select all

dfu-util -a 0 -s 0x8000000 -RD sketch.bin
stm32cube programmer support the multitudes of options including st-link, uart, dfu, etc

that button dance is necessary for both

Re: Program an STM32F411CEU6 using UART

Posted: Sun Jun 13, 2021 10:23 pm
by .rpv
mwon wrote: Sun Jun 13, 2021 4:31 pm Same error. :cry:

The schematics:

https://imgur.com/0HOdgV1
Hi, I think that NRST needs to be HIGH for normal operation and LOW for RESET, you have this on float, not sure if this it's your problem.

UPDATE, scratch that, sorry, the datasheet says that this mcu has this pin pulled-up:
6.3.17 NRST pin characteristics
The NRST pin input driver uses CMOS technology. It is connected to a permanent pull-up
resistor, R PU (see Table 53).
Unless otherwise specified, the parameters given in Table 56 are derived from tests
performed under the ambient temperature and V DD supply voltage conditions summarized
in Table 14. Refer to Table 53: I/O static characteristics for the values of VIH and VIL for
NRST pin.