2021-05-15 03:48 AM
Hello,
Im just starting with the nucleo board STM32L476RG using mac (10.13.6) and cube IDE 1.6.1. I also updated the firmware on the ST-link to the newest one when prompted.
For the very first program I just wanted to make it blink to see if it works, so I created a project according to the tutorials, added:
HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_5);
HAL_Delay(1000);
to the while (1) loop (user code begin 3) in the main and set LD2 pin as output in the pinout view.
Building is without a problem:
12:11:40 **** Incremental Build of configuration Debug for project first_blinking_LED ****
make -j3 all
arm-none-eabi-size first_blinking_LED.elf
text data bss dec hex filename
12036 20 1700 13756 35bc first_blinking_LED.elf
Finished building: default.size.stdout
12:11:41 Build Finished. 0 errors, 0 warnings. (took 221ms)
But when I hit Run main I get (onboard LD1 blinking red and green):
STMicroelectronics ST-LINK GDB server. Version 5.8.0
Copyright (c) 2020, 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...
I tried adding "monitor flash mass_erase" to the initialization commands, but it didnt help. Also what is really strange, every time I try to Run or Debug, I have aprox. 1,28 GB less free space on my HDD! And I cant find from where this space was taken as neither the repository, neither the workspace_1.6.1 folder, neither the app increased in size.
Anny suggestions on how to get it unstucked? Would be much appreciated. Thanks
Solved! Go to Solution.
2021-05-28 01:00 AM
@mattias norlander
@LaurentL I have "connect under reset" selected by default.
interestingly, I tried selecting the "Shared ST-LINK" in the Debugger configuration (just to see what it does) and suddenly it worked. Now its working even without the shared st-linked checked and without the monitor flash mass_erase. I dont know what exactly does the option do (in the manual I see the communication should go via server?) and whether it solved the problem correctly, but I can upload the program and the LED is blinking as expected.
2021-05-17 03:12 AM
Hi @TKebi.1,
TKebi.1: "But when I hit Run main I get (onboard LD1 blinking red and green):"
So, you are trying to flash the application to the target without debugging?
Looking at the log output the launch configuration (used to launch debugger or only to flash, which is your use case) is setup relying on the default ST-LINK GDB-server.
With ST-LINK GDB-server the flash related operations are carried out by invoking STM32CubeProgrammer_CLI. Here is where things seem to fail.
Your log output looks broken:
"Waiting for debugger connection...
Debugger connected
Debugger connection lost.
Shutting down..."
It should look like this:
---------------------------------------------------------------------------------------------------------------------------------------------------
...
"Waiting for debugger connection...
Debugger connected
-------------------------------------------------------------------
STM32CubeProgrammer v2.7.0-RC1
-------------------------------------------------------------------
ST-LINK SN : 49FF6A064983515137361187
ST-LINK FW : V2J38S0
Board : --
Voltage : 2.92V
SWD freq : 4000 KHz
Connect mode: Under Reset
Reset mode : Hardware reset
Device ID : 0x413
Revision ID : Rev Z
Device name : STM32F405xx/F407xx/F415xx/F417xx
Flash size : 1 MBytes (default)
Device type : MCU
Device CPU : Cortex-M4
Memory Programming ...
Opening and parsing file: ST-LINK_GDB_server_a11132.srec
File : ST-LINK_GDB_server_a11132.srec
Size : 36016 Bytes
Address : 0x08000000
Erasing memory corresponding to segment 0:
Erasing internal memory sectors [0 2]
Download in Progress:
File download complete
Time elapsed during download operation: 00:00:01.178
Verifying ...
Download verified successfully
Debugger connection lost.
Shutting down..."
---------------------------------------------------------------------------------------------------------------------------------------------------
All the output in bold is missing in your log-output. This is the full output from the implicit CubeProg invocation...
Try enabling the log-file in the debug configuration. It will get you some extra log level info.
Look for the lines looking similar to:
[2.057] spawnCubeProgrammer(): ------ Switching to STM32CubeProgrammer -----
[2.057] file_utils_spawn(): Spawning "C:\ST\STM32CubeIDE_1.6.0\STM32CubeIDE\plugins\com.st.stm32cube.ide.mcu.externaltools.cubeprogrammer.win32_1.6.0.202101291314\tools\bin\STM32_Programmer_CLI.exe --connect port=SWD mode=UR reset=hwRst --erase all --log C:\Users\norlandm\AppData\Local\Temp\STM32CubeProgrammer_a22632.log"
[9.436] file_utils_spawn(): Return code 0
[9.439] spawnCubeProgrammer(): 12:10:09:056 -------------------------------------------------------------------
[9.439] spawnCubeProgrammer(): 12:10:09:059 STM32CubeProgrammer v2.7.0-RC1
[9.439] spawnCubeProgrammer(): 12:10:09:059 -------------------------------------------------------------------
Please try his:
Kind regards, Mattias
2021-05-23 02:13 AM
Hi @mattias norlander
thank you for your reply
I was trying both running and debugging, but sure, I want to debug first
I enabled the "Log to file", now the (full) output is:
STMicroelectronics ST-LINK GDB server. Version 5.8.0
Copyright (c) 2020, STMicroelectronics. All rights reserved.
Starting server with the following options:
Persistent Mode : Disabled
LogFile Name : /Users/tobias92k/STM32CubeIDE/workspace_1.6.1/first_LED_blinking/Debug/st-link_gdbserver_log.txt
Logging Level : 31
Listen Port Number : 61234
Status Refresh Delay : 15s
Verbose Mode : Enabled
SWD Debug : Enabled
InitWhile : Enabled
Target connection mode: Under reset
Reading ROM table for AP 0 @0xe00fffd0
Hardware watchpoint supported by the target
COM frequency = 4000 kHz
ST-LINK Firmware version : V2J38M27
Device ID: 0x415
PC: 0x800294c
ST-LINK device status: HALT_MODE
ST-LINK detects target voltage = 3.26 V
ST-LINK device status: HALT_MODE
ST-LINK device initialization OK
Waiting for debugger connection...
Waiting for connection on port 61234...
Accepted connection on port 61234...
Debugger connected
Debugger connection lost.
Shutting down...
and the log file is in the attachment. I was going through it, but I didnt find the lines you were refering to and as Im not familiar with this logs, I dont know if there is something odd, but it doesnt look like on the first sight.
I have found terminal app document "STM32CubeProgrammer" in the plugins folder, with output when I run it:
Last login: Sun May 23 11:04:49 on ttys000
/Applications/STM32CubeIDE.app/Contents/Eclipse/plugins/com.st.stm32cube.ide.mcu.externaltools.cubeprogrammer.macos64_1.6.0.202101291314/tools/bin/STM32CubeProgrammer ; exit;
somebody-2:~ tobias92k$ /Applications/STM32CubeIDE.app/Contents/Eclipse/plugins/com.st.stm32cube.ide.mcu.externaltools.cubeprogrammer.macos64_1.6.0.202101291314/tools/bin/STM32CubeProgrammer ; exit;
/Applications/STM32CubeIDE.app/Contents/Eclipse/plugins/com.st.stm32cube.ide.mcu.externaltools.cubeprogrammer.macos64_1.6.0.202101291314/tools/bin/STM32CubeProgrammer
x@
chdir /Applications/STM32CubeIDE.app/Contents/Eclipse/plugins/com.st.stm32cube.ide.mcu.externaltools.cubeprogrammer.macos64_1.6.0.202101291314/tools/bin
current dir /Applications/STM32CubeIDE.app/Contents/Eclipse/plugins/com.st.stm32cube.ide.mcu.externaltools.cubeprogrammer.macos64_1.6.0.202101291314/tools/bin
Exec error: No such file or directory
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.
[Process completed]
After I tried to run debugging again, but with the same result.
2021-05-26 05:46 AM
Ahh, the STM32CubeProgrammer is not the right file. Instead try to call STM32_Programmer_CLI --version from the terminal.
Does it exist in the same folder and does it print the version number when called?
2021-05-26 05:48 AM
If you are blocked you can probably switch which probe you rely on for debug from
ST-LINK (ST-LINK GDB server) --> ST-LINK (OpenOCD)
OpenOCD does not use CubeProgrammer for flashing. Could be worth trying as a quick work-around.
2021-05-27 12:58 AM
yes, its in the same folder, when I run it, the version number is: STM32CubeProgrammer v2.7.0-RC1 (full output in attachment), but it didnt help. debugging has still the same problem.
OK, I tried ST-LINK (OpenOCD), (with changing 8MHz to 4MHz in Configuration script) but now different errors appear, all in red:
Open On-Chip Debugger 0.11.0-rc2+dev-00037-g4c4dbd9 (2021-02-09-13:43)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : STLINK V2J38M27 (API v2) VID:PID 0483:374B
Info : Target voltage: 3.263559
Info : clock speed 4000 kHz
Info : stlink_dap_op_connect(connect)
Info : SWD DPIDR 0x2ba01477
Info : STM32L476RGTx.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : STM32L476RGTx.cpu: external reset detected
Info : starting gdb server for STM32L476RGTx.cpu on 3333
Info : Listening on port 3333 for gdb connections
Info : accepting 'gdb' connection on tcp/3333
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x0800294c msp: 0x20000520
Info : device idcode = 0x10076415 (STM32L47/L48xx - Rev 4 : 0x1007)
Info : RDP level 0 (0xAA)
Info : flash size = 1024kbytes
Info : flash mode : dual-bank
Info : accepting 'gdb' connection on tcp/3333
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x0800294c msp: 0x20000520
shutdown command invoked
Info : dropped 'gdb' connection
shutdown command invoked
2021-05-27 02:29 AM
I don't see anything weird in the OpenOCD output. The color of the output is always red. The weird part is this:
shutdown command invoked
Info : dropped 'gdb' connection
shutdown command invoked
At this point I can only ask questions, don't have any firm suspicion of what that is wrong.
2021-05-27 02:32 AM
Hi, did you try "Connect under reset" mode with OpenOcd ?
Can you try to debug an empty project.
If not working, can you install STM32CubeProgrammer and mass erase the device's flash.
Then, disconnect STM32CubeProgrammer and try debug again the empty prj.
Rgds,
Laurent
2021-05-28 01:00 AM
@mattias norlander
@LaurentL I have "connect under reset" selected by default.
interestingly, I tried selecting the "Shared ST-LINK" in the Debugger configuration (just to see what it does) and suddenly it worked. Now its working even without the shared st-linked checked and without the monitor flash mass_erase. I dont know what exactly does the option do (in the manual I see the communication should go via server?) and whether it solved the problem correctly, but I can upload the program and the LED is blinking as expected.
2021-05-28 01:17 AM
Hello,
STlink Shared mode is used when you have several ST boards connected or debugging a dual core device.
Do you have another STLink connected on your PC or another ST board ?