Execvp(3) failed.: Permission denied Error when launching debug session

Getting the following error when launching a debug session in OS x Catalina 10.15.7:

Executing task: platformio debug --environment nano_33_iot 

execvp(3) failed.: Permission denied

 *  The terminal process "platformio 'debug', '--environment', 'nano_33_iot'" failed to launch (exit code: 1). 
 *  Terminal will be reused by tasks, press any key to close it. 

If I run the same command on a new terminal (inside VSCode) it works. Eg:

$ platformio debug --environment nano_33_iot 
Warning! `src_filter` configuration option in section [env] is deprecated and will be removed in the next release! Please use `build_src_filter` instead
Warning! `src_filter` configuration option in section [env] is deprecated and will be removed in the next release! Please use `build_src_filter` instead
Processing nano_33_iot (platform: atmelsam; board: nano_33_iot; framework: arduino)
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Library Manager: Could not parse manifest -> Expecting ',' delimiter: line 64 column 5 (char 1477)

I tried adding the following to settings.json as suggested in this VSCode issue, but still not working.

{
    "terminal.integrated.profiles.osx": {
        "zsh": {
            "path": "/usr/local/bin/zsh"
        },
    },
    "terminal.integrated.defaultProfile.osx": "zsh",
    "terminal.integrated.automationProfile.osx": {
        "path": "/usr/local/bin/zsh"
    }
}

Thanks

With what platformio.ini is that occurring?

; 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
; http://docs.platformio.org/page/projectconf.html

[platformio]
src_dir= .

[env]
src_filter = 
lib_ldf_mode = deep+

; ------------------------------------------------------------------------------------------------------------------------------------------------------------ 
; ESP32
; ------------------------------------------------------------------------------------------------------------------------------------------------------------ 

[env:esp32]
platform = espressif32
board = esp32dev
framework = arduino
upload_speed = 921600
monitor_speed = 115200
lib_deps = IoTeX-blockchain-client
upload_port = /dev/cu.SLAB_USBtoUART                                

[env:esp32_debug]
platform = espressif32
board = esp32dev
framework = arduino
upload_speed = 921600
monitor_speed = 115200
build_type = debug
debug_tool = esp-prog
debug_init_break = tbreak setup
upload_protocol = esp-prog
lib_deps = IoTeX-blockchain-client

; ------------------------------------------------------------------------------------------------------------------------------------------------------------ 
; Nano 33 IoT
; ------------------------------------------------------------------------------------------------------------------------------------------------------------ 

[env:nano_33_iot]
platform = atmelsam
board = nano_33_iot
framework = arduino
monitor_speed = 115200
build_flags = -D __SAMD21G18A__
lib_deps = 
   IoTeX-blockchain-client
    WiFiNINA
    FlashStorage

[env:nano_33_iot_debug]
platform = atmelsam
board = nano_33_iot
build_type = debug
framework = arduino
upload_protocol = jlink
debug_tool = jlink
monitor_speed = 115200
debug_init_break = tbreak loop
build_flags = -D __SAMD21G18A__
lib_deps = 
    IoTeX-blockchain-client
    WiFiNINA
    FlashStorage

Any way to launch the debug session from command line rather than pressinf F5?

When you start a new project with just this configuration and the blinky sketch, does it fail as well?

See pio debug — PlatformIO latest documentation

Thanks,

I launched this, it uploads and connects OK but it doesn’t stop at the breakpoint I’ve set in VSCode. See output:

pio debug --environment nano_33_iot_debug --interface=gdb -- -x .pioinit
Warning! `src_filter` configuration option in section [env] is deprecated and will be removed in the next release! Please use `build_src_filter` instead
SEGGER J-Link GDB Server V7.70a Command Line Version

JLinkARM.dll V7.70a (DLL compiled Aug 10 2022 16:28:07)

Command line: -singlerun -if SWD -select USB -device ATSAMD21G18 -port 2331
-----GDB Server start settings-----
GDBInit file:                  none
GDB Server Listening port:     2331
SWO raw output listening port: 2332
Terminal I/O port:             2333
Accept remote connection:      yes
Generate logfile:              off
Verify download:               off
Init regs on start:            off
Silent mode:                   off
Single run mode:               on
Target connection timeout:     0 ms
------J-Link related settings------
J-Link Host interface:         USB
J-Link script:                 none
J-Link settings file:          none
------Target related settings------
Target device:                 ATSAMD21G18
Target device parameters:      none
Target interface:              SWD
Target interface speed:        4000kHz
Target endian:                 little

Connecting to J-Link...
J-Link is connected.
Firmware: J-Link EDU Mini V1 compiled Jul 22 2022 10:22:23
Hardware: V1.00
S/N: 801031308
Feature(s): FlashBP, GDB
Checking target voltage...
Target voltage: 3.28 V
Listening on TCP/IP port 2331
Connecting to target...
Connected to target
Waiting for GDB connection...Reading symbols from /Users/Santos/Documents/2-Code/Iotex/arduino/smart-lock/SmartLockDevice/.pio/build/nano_33_iot_debug/firmware.elf...done.
PlatformIO Unified Debugger -> https://bit.ly/pio-debug
PlatformIO: debug_tool = jlink
PlatformIO: Initializing remote target...
Connected to 127.0.0.1
Reading all registers
Read 4 bytes @ address 0x000005F4 (Data = 0xE7FEBE0D)
Read 2 bytes @ address 0x000005F4 (Data = 0xBE0D)
0x000005f4 in ?? ()
Received monitor command: clrbp
Received monitor command: speed auto
Select auto target interface speed (2000 kHz)
Select auto target interface speed (2000 kHz)
Received monitor command: reset
Resetting target
Resetting target
Received monitor command: halt
Halting target CPU...
...Target halted (PC = 0x00000600)
Downloading 15968 bytes @ address 0x00002000
Downloading 15936 bytes @ address 0x00005E60
Downloading 15856 bytes @ address 0x00009CA0
Downloading 15984 bytes @ address 0x0000DA90
Downloading 16112 bytes @ address 0x00011900
Downloading 16080 bytes @ address 0x000157F0
Downloading 16064 bytes @ address 0x000196C0
Downloading 15904 bytes @ address 0x0001D580
Downloading 16000 bytes @ address 0x000213A0
Downloading 15920 bytes @ address 0x00025220
Downloading 16064 bytes @ address 0x00029050
Downloading 15936 bytes @ address 0x0002CF10
Downloading 15920 bytes @ address 0x00030D50
Downloading 16144 bytes @ address 0x00034B80
Downloading 15192 bytes @ address 0x00038A90
Downloading 92 bytes @ address 0x0003C5E8
Downloading 8 bytes @ address 0x0003C644
Downloading 868 bytes @ address 0x0003C64C
Writing register (PC = 0x   104bc)
Loading section .text, size 0x3a5e8 lma 0x2000
Loading section .ramfunc, size 0x5c lma 0x3c5e8
Loading section .ARM.exidx, size 0x8 lma 0x3c644
Loading section .data, size 0x364 lma 0x3c64c
Start address 0x104bc, load size 240048
Transfer rate: 26046 KB/sec, 13336 bytes/write.
Read 4 bytes @ address 0x000104BC (Data = 0x4A12B510)
Read 2 bytes @ address 0x00002664 (Data = 0xB5F0)
Temporary breakpoint 1 at 0x2664: file SmartLockDevice.cpp, line 184.
PlatformIO: Initialization completed
(gdb) PlatformIO: Resume the execution to `debug_init_break = tbreak loop`
PlatformIO: More configuration options -> https://bit.ly/pio-debug
Continuing.
Setting breakpoint @ address 0x00002664, Size = 2, BPHandle = 0x0001
Starting target CPU...
Reading all registers
Removing breakpoint @ address 0x00002664, Size = 2
Read 4 bytes @ address 0x000005F4 (Data = 0xE7FEBE0D)
Read 2 bytes @ address 0x000005F4 (Data = 0xBE0D)

Program received signal SIGTRAP, Trace/breakpoint trap.
0x000005f4 in ?? ()

Is launching the debugger this way supposed to be “wired” to VSCode?

I don’t understand what the x parameter is. It’s not documented?
I might be passing wrong arguments. Could you check?

I tried the blinky example with only that in platformi.ini . It is not working

I am pretty sure this is not sketch related. Looks like it’s a problem caused by the Trusted workspace settings and the way pio launches the debugger (possibly VSCode is blocking the script from running as sudo).
My workspace is trusted so this shouldn’t be happening.
Could you elaborate on how pio launches the debug session? How can I get a log of pio/VSCode?

The VSCode part of it is partly non open-sourced, so I don’t know where to look for logs there.

If it however obviously starts up when doing

then the VSCode side has a problem.

As expected, since when you run it on the command line, it’s completely disconnected from VSCode, so no breakpoints set there matter. It’s a new GDB session disconnected from the GUI.

This occurs when there’s a bootloader on the device. The only 2 known fixes for that is restarting debugging in VSCode (which you can’t yet do because the GUI part is not working for you) or removing the bootloader. See Problems starting debug session with jlink on feather M0 - #10 by RoSchmi.

As the CLI has no problem but VSCode has, please continue by opening an issue in Issues · platformio/platformio-vscode-ide · GitHub.

I can now launch a debug session using the Cortex Debug extension using the launch config below. This is definitely a platformio issue.

{
            "cwd": "${workspaceFolder}",
            "executable": ".../.pio/build/nano_33_iot_debug/firmware.elf",
            "name": "Cortex debug",
            "request": "launch",
            "type": "cortex-debug",
            "runToEntryPoint": "setup",
            "showDevDebugOutput": "none",
            "servertype": "jlink",
            "serverpath": "/usr/local/bin/JLinkGDBServer",
            "armToolchainPath": "/usr/local/bin",
            "device": "ATSAMD21G18",
            "interface": "SWD",
            "svdFile": ".../.platformio/platforms/atmelsam/misc/svd/ATSAMD21G18A.svd"
        },

I opened an issue in Issues · platformio/platformio-vscode-ide · GitHub.

@maxgerhardt I still haven’t got any response on the Github issue. Could you let me know if there are any updates on this?

Thanks