Hi,
I am encountering some problem in the debugging of my genuine STM32F407VGT6.
There occurs following error message when I open the debugger:
Error: Please specify `debug_port` for environment
The terminal process terminated with exit code: 1
What should I specify for the debug port when I am using STLINK V2?
Here is my platformio.ini:
[env:black_f407vg]
platform = ststm32
board = black_f407vg
framework = arduino
[env:debug]
platform = ststm32
board = black_f407vg
framework = arduino
debug_init_cmds =
target extended-remote $DEBUG_PORT
$INIT_BREAK
monitor reset halt
$LOAD_CMDS
monitor init
monitor reset halt
I don’t think you need these debug_init_cmds
at alls here, you should just remove it. Then, the environment is already exactly the same as the first one, so it can be removed entirely. Should work out of the box.
As this is a GDB command it expects an IP and port to connect to the debug server – usually 127.0.0.1:3333 for openocd. See docs . But as I said, you don’t need that at all.
I have updated the platformio.ini, but still the same problem.
[env:black_f407vg]
platform = ststm32
board = black_f407vg
framework = arduino
[env:debug]
platform = ststm32
board = black_f407vg
framework = arduino
Unfortunately still asking for debug port. So do I need so specify the local IP of the GDB somehow?
It seems that the JLink is the default debugging tool for Black STM32F407VG.
Can you add the following line to your configurations:
debug_tool = stlink
If it still doesn’t work, please add the full log so we can see all details of the used configurations and tools.
2 Likes
Sure your STM32 platform is up-to-date? stlink
is the standard uplink protocol and this debug protocol.
"jlink_device": "STM32F407VG",
"openocd_target": "stm32f4x",
"svd_path": "STM32F40x.svd"
},
"frameworks": [
"arduino",
"cmsis",
"stm32cube",
"libopencm3"
],
"name": "Black STM32F407VG",
"upload": {
"maximum_ram_size": 131072,
"maximum_size": 524288,
"protocol": "stlink",
"protocols": [
"jlink",
"cmsis-dap",
"stlink",
"blackmagic",
"serial"
You can still specifiy
debug_port = 127.0.0.1:5555
(if openocd
starts the GDB server on port 5555).
Does the default upload protocol become the default debug protocol if no other default has been specified? Or what’s the logic?
The documentation of Black STM32F407VG seems to add to the confusion as is declares Black Magic Probe as the default debug protocol.
Oh that’s interesting. Does it alphabetically sort the upload protocols first now o_O?
My understanding is that due to the Python logic for adding default debug tools, it gets it default upload protocol and uses that:
self.packages["toolchain-gccarmnoneeabi"]["version"] = "~1.60301.0"
if "zephyr" in variables.get("pioframework", []):
for p in self.packages:
if p in ("tool-cmake", "tool-dtc", "tool-ninja"):
self.packages[p]["optional"] = False
self.packages["toolchain-gccarmnoneeabi"]["version"] = "~1.80201.0"
if not IS_WINDOWS:
self.packages["tool-gperf"]["optional"] = False
# configure J-LINK tool
jlink_conds = [
"jlink" in variables.get(option, "")
for option in ("upload_protocol", "debug_tool")
]
if board:
jlink_conds.extend([
"jlink" in board_config.get(key, "")
for key in ("debug.default_tools", "upload.protocol")
])
jlink_pkgname = "tool-jlink"
But if the docs show that, maybe the logic is different and indeed debug_tool = stlink
must be added.
1 Like
I’ve just discovered two related issues:
opened 02:12PM - 04 Jan 20 UTC
closed 11:19AM - 24 Jan 20 UTC
help wanted
I am using the blue pill and st link v2.
I have successfully uploaded the led b… linking code and the printf code.
However, I cant seem to debug the bluepill.
I am getting this error when I try to debug the board.
```
> Executing task: platformio debug <
Error: Please specify `debug_port` for environment
The terminal process terminated with exit code: 1
Terminal will be reused by tasks, press any key to close it.
```
This is what is shown in my lsusb
```
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 004: ID 5986:1127 Acer, Inc
Bus 001 Device 003: ID 0cf3:e500 Atheros Communications, Inc.
Bus 001 Device 014: ID 0483:374b STMicroelectronics ST-LINK/V2.1 (Nucleo-F103RB)
Bus 001 Device 002: ID 062a:4101 Creative Labs Wireless Keyboard/Mouse
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
```
I have connected SWDIO AND SWDCLK properly, also TX and RX from STLINK to A2 and A3 I am using the MBED framework.
this is my default config
```
// AUTOMATICALLY GENERATED FILE. PLEASE DO NOT MODIFY IT MANUALLY
// PIO Unified Debugger
//
// Documentation: https://docs.platformio.org/page/plus/debugging.html
// Configuration: https://docs.platformio.org/page/projectconf/section_env_debug.html
{
"version": "0.2.0",
"configurations": [
{
"type": "platformio-debug",
"request": "launch",
"name": "PIO Debug",
"executable": "/mnt/Workspace/drone_parachute/.pio/build/genericSTM32F103C8/firmware.elf",
"toolchainBinDir": "/home/param/.platformio/packages/toolchain-gccarmnoneeabi/bin",
"svdPath": "/home/param/.platformio/platforms/ststm32/misc/svd/STM32F103xx.svd",
"preLaunchTask": {
"type": "PlatformIO",
"task": "Pre-Debug"
},
"internalConsoleOptions": "openOnSessionStart"
},
{
"type": "platformio-debug",
"request": "launch",
"name": "PIO Debug (skip Pre-Debug)",
"executable": "/mnt/Workspace/drone_parachute/.pio/build/genericSTM32F103C8/firmware.elf",
"toolchainBinDir": "/home/param/.platformio/packages/toolchain-gccarmnoneeabi/bin",
"svdPath": "/home/param/.platformio/platforms/ststm32/misc/svd/STM32F103xx.svd",
"internalConsoleOptions": "openOnSessionStart"
}
]
}
```
and my platformio.int file
```
;PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[env:genericSTM32F103C8]
platform = ststm32
board = genericSTM32F103C8
framework = mbed
```
opened 02:55PM - 20 Jan 20 UTC
closed 04:08PM - 20 Jan 20 UTC
I am trying to debug the code using STLINK, but when I click on menu "Debug / St… art Debugging" it shows me an error:
> Error: Please specify debug_port for environment
How can I specify it and where?
P.S. As recommended, I am using Visual Studio Code with Platform IO. I have asked this question on the subreddit and Facebook, but received no reply. So, this bug report is my only hope. Any hint is greatly appreciated. Thanks a lot.
It seems that PlatformIO can indeed raise this confusing error message if no default is specified in board definition. Setting debug_tool
should fix it.
1 Like
Thanks a lot for all these informative posts. It is working now perfect.
I checked again, if no debug tool specified it is blackmagic:
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/black_f407vg.html
PLATFORM: ST STM32 6.0.0 > Black STM32F407VG
HARDWARE: STM32F407VGT6 168MHz, 128KB RAM, 512KB Flash
DEBUG: Current (blackmagic) External (blackmagic, jlink, stlink)