I have come to understand that when running openocd as a task under vscode, the "command" : "openocd" is executed from the Workspace Folder. The examples from the Pico C SDK all generate file structures having a Workspace Folder with the same name as the example. Thus, for instance, the i2c_bus_scan example generates a vscode Workspace Folder with the name /i2c_bus_scan/ established in whatever folder you have chosen to use for pico projects.
When the task executes the "command": "openocd" line in the task file, openocd is executed from the /i2c_bus_scan/ directory. However, when vscode compiles the program, the output files are located in the /i2c_bus_scan/build/ directory. In order for openocd to find the appropriate elf file, it must be referred to as /build/i2c_bus_scan.elf.
Vscode maintains a variable, ${workspaceFolderBasename} that contains the name of the Workspace Folder in which the example is instantiated. It this case, ${workspaceFolderBasename} contains 'i2c_bus_scan'. To refer to the elf file, the following command string must be used: "-c", "program build/${workspaceFolderBasename}.elf" in order that openocd can correctly locate the program file to be uploaded.
My upload task, which has successfully uploaded the program, set the program running on the pico, and cleanly terminated openocd, currently reads:
When the task executes the "command": "openocd" line in the task file, openocd is executed from the /i2c_bus_scan/ directory. However, when vscode compiles the program, the output files are located in the /i2c_bus_scan/build/ directory. In order for openocd to find the appropriate elf file, it must be referred to as /build/i2c_bus_scan.elf.
Vscode maintains a variable, ${workspaceFolderBasename} that contains the name of the Workspace Folder in which the example is instantiated. It this case, ${workspaceFolderBasename} contains 'i2c_bus_scan'. To refer to the elf file, the following command string must be used: "-c", "program build/${workspaceFolderBasename}.elf" in order that openocd can correctly locate the program file to be uploaded.
My upload task, which has successfully uploaded the program, set the program running on the pico, and cleanly terminated openocd, currently reads:
Code:
{"label": "Upload","type": "shell","command": "openocd"."args": ["-f", "interface/cmsis-dap.cfg","-f", "target/rp2040.cfg","-c", "adapter speed 5000","-c", "program build/${workspaceFolderBasename}.elf verify reset exit"]"problemMatcher": [],"group": {"kind": "build","isDefault": true}}
Statistics: Posted by picopirate — Sat Dec 21, 2024 7:41 pm