cancel
Showing results for 
Search instead for 
Did you mean: 

Debugger connection fails when using UART2 in DMA mode in Nucleo-401RE

KGrim.2
Associate II

 Hello everybody,

I am trying to build a simple communication between my PC and a Nucleo-F401RE using UART over the USB connection.

I am able to do this successfully using a “polling�? or an “interrupt�? configuration.

However, when I configure the UART2 of my F401RE as using DMA (I use the CubeMX tool in CubeIDE to do the configuration) and then try to run the program in run or debug mode, I get the error messages:

“Debugger connection lost.

Shutting down...�?

Is it not possible to use DMA of UART2??

Many thanks in advance!

12 REPLIES 12
TDK
Guru

It's possible. Not sure what DMA setting could cause the debugger to be lost, but there's gotta be a bug in your program somewhere.

If you feel a post has answered your question, please click "Accept as Solution".
KGrim.2
Associate II

The program is empty. After the configuration in CubeMX I do a build (no error) and then run/debug and the error message comes.

I am attaching .ioc config file and a zip file with the complete CubeIDE project.

KGrim.2
Associate II

Here is the io file

Try to single-step your code (and that includes the Cube portion); if you get close to the spot where the debugger disconnects. My guess is, that it's where the DMA control register gets written in order to enable DMA. In any case, report back, together with the read-back content of relevant DMA registers and any other relevant information from just before the debugger-connection-loss occurs.

JW

KGrim.2
Associate II

Thanks JW by the suggestion.

When I press "Debug" in CubeIDE I don't even get to the part where I can single-step the code, the debugger disconnects before that.

> I don't even get to the part where I can single-step the code

You mean, you can't get it to stop at beginning of main()?

But that then the problem is probably not related directly to the UART DMA, which is supposedly set *after* beginning of main()... To confirm this, try to comment out only the function call where DMA is enabled.

JW

KGrim.2
Associate II

Exactly, I can't get it to stop at beginning of main(). After I click on Run->Debug on CubeIDE I get the following:

"STMicroelectronics ST-LINK GDB server. Version 5.5.0

Copyright (c) 2019, STMicroelectronics. All rights reserved.

Starting server with the following options:

       Persistent Mode           : Disabled

       Logging Level             : 1

       Listen Port Number        : 61234

       Status Refresh Delay      : 15s

       Verbose Mode              : Disabled

       SWD Debug                 : Enabled

       InitWhile                 : Enabled

Waiting for debugger connection...

Debugger connected

Debugger connection lost.

Shutting down..."

KGrim.2
Associate II

If I then delete the DMA configuration of UART2 on CubeMX, then recompile and run I get the following:

"STMicroelectronics ST-LINK GDB server. Version 5.5.0

Copyright (c) 2019, STMicroelectronics. All rights reserved.

Starting server with the following options:

       Persistent Mode           : Disabled

       Logging Level             : 1

       Listen Port Number        : 61234

       Status Refresh Delay      : 15s

       Verbose Mode              : Disabled

       SWD Debug                 : Enabled

       InitWhile                 : Enabled

Waiting for debugger connection...

Debugger connected

     -------------------------------------------------------------------

                      STM32CubeProgrammer v2.4.0                 

     -------------------------------------------------------------------

ST-LINK SN : 066EFF504955857567023636

ST-LINK FW : V2J36M26

Voltage    : 3.25V

SWD freq   : 4000 KHz

Connect mode: Under Reset

Reset mode : Hardware reset

Device ID  : 0x433

Device name : STM32F401xD/E

Flash size : 512 KBytes

Device type : MCU

Device CPU : Cortex-M4

Memory Programming ...

Opening and parsing file: ST-LINK_GDB_server_a08128.srec

 File         : ST-LINK_GDB_server_a08128.srec

 Size         : 8116 Bytes

 Address      : 0x08000000

Erasing memory corresponding to segment 0:

Erasing internal memory sector 0

Download in Progress:

File download complete

Time elapsed during download operation: 00:00:00.686

Verifying ...

Download verified successfully "

And the debugger is stopped at the first line of main()

So the debugger won't even download program when DMA is enabled? That does not make sense at all and indicates problem in CubeIDE itself.

Maybe somehow related to https://community.st.com/s/question/0D50X0000C21PzlSQE/debugger-stuck-on-random-line ?

I don't use Cube/CubeMx/CubeIDE.

JW