program_esp works from command line, but not Visual Studio

skanky
Posts: 20
Joined: Mon Nov 21, 2022 12:58 pm

program_esp works from command line, but not Visual Studio

Postby skanky » Mon Nov 21, 2022 1:36 pm

I'm having a strange issue trying to use openocd from visual studio code, where "program_esp" is giving me an "Unexpected command line argument" error
I have this in tasks.json:

Code: Select all

// Flash only OTA ...
{
	"label": "OpenOCD Flash OTA_0",
	"type": "shell",
	"isBackground": false,
	"options": 
	{
		"cwd": "C:\\Users\\Dev\\.espressif\\tools\\openocd-esp32\\v0.11.0-esp32-20220706\\openocd-esp32\\bin"
	},
	"command": "openocd -d2 -f C:\\Users\\Dev\\.espressif\\tools\\openocd-esp32\\v0.11.0-esp32-20220706\\openocd-esp32\\share\\openocd\\scripts\\interface\\ftdi\\esp32_devkitj_v1.cfg -f C:\\Users\\Dev\\.espressif\\tools\\openocd-esp32\\v0.11.0-esp32-20220706\\openocd-esp32\\share\\openocd\\scripts\\board\\esp32-wrover-kit-3.3v.cfg -c \"program_esp C:/_PROJECTS/KegTracker/firm/rpdintl-100-216_kegtracker/build/100_216_kegtracker.bin 0x10000 reset exit\" ",
	"problemMatcher": []
},

Running it I get:

Code: Select all

Open On-Chip Debugger  v0.11.0-esp32-20220706 (2022-07-06-15:48)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
debug_level: 2

Unexpected command line argument: C:/_PROJECTS/KegTracker/firm/rpdintl-100-216_kegtracker/build/100_216_kegtracker.bin

But there's nothing wrong with the path given or the command. I've tried all sorts of things, moved it to different simpler paths, but always the same. If I run openocd from the commandline (windows) using this same command:

Code: Select all

openocd -d2 -f C:\Users\Dev\.espressif\tools\openocd-esp32\v0.11.0-esp32-20220706\openocd-esp32\share\openocd\scripts\interface\ftdi\esp32_devkitj_v1.cfg -f C:\Users\Dev\.espressif\tools\openocd-esp32\v0.11.0-esp32-20220706\openocd-esp32\share\openocd\scripts\board\esp32-wrover-kit-3.3v.cfg -c "program_esp C:/_PROJECTS/KegTracker/firm/rpdintl-100-216_kegtracker/build/100_216_kegtracker.bin 0x10000 reset exit"
I get:

Code: Select all

Open On-Chip Debugger  v0.11.0-esp32-20220706 (2022-07-06-15:48)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
debug_level: 2

adapter speed: 20000 kHz

Warn : Interface already configured, ignoring
Error: libusb_open() failed with LIBUSB_ERROR_NOT_SUPPORTED
Info : ftdi: if you experience problems at higher adapter clocks, try the command "ftdi tdo_sample_edge falling"
Info : clock speed 20000 kHz
Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : [esp32.cpu0] Target halted, PC=0x4019FF4E, debug_reason=00000001
Info : [esp32.cpu1] Target halted, PC=0x4019FF4E, debug_reason=00000000
Info : starting gdb server for esp32.cpu0 on 3333
....etc (clipped)
Can anyone think of any reason why the same command fails from VSC? I'm completely baffled

skanky
Posts: 20
Joined: Mon Nov 21, 2022 12:58 pm

Re: program_esp works from command line, but not Visual Studio

Postby skanky » Tue Nov 22, 2022 10:01 am

I've solved this one. I could find nothing online to answer it, but it turns out using a single quote ' instead of \" was needed in the json. I've no idea why, if I use a single quote with it directly on the command line or via the VS Code Terminal window it fails, it has to be double quotes. But changing \" to ' in the json caused it to magically work.

Who is online

Users browsing this forum: No registered users and 36 guests