Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Just flash ELF without debugging #45

Closed
Slion opened this issue Jun 13, 2024 · 4 comments
Closed

Just flash ELF without debugging #45

Slion opened this issue Jun 13, 2024 · 4 comments

Comments

@Slion
Copy link

Slion commented Jun 13, 2024

I'm trying to streamline my workflow by not having to mount the boot drive and copy the uf2.
I have not find a way to do that reliably from Visual Studio Code but it could be I just missed it.

Trying to do it from the command line seems to work but then I would need a one liner cause as it is I'm still faster mounting the drive and copying the file.

See also:
raspberrypi/debugprobe#141
https://forums.raspberrypi.com/viewtopic.php?t=302344

@ndabas
Copy link
Contributor

ndabas commented Jun 13, 2024

If you have a debug probe connected, you can use OpenOCD to just flash the ELF. There is a "flash" task included in the VS Code configuration that we ship.

You could use that (it's a bit clunky in the VS Code UI) or the equivalent one-liner:

openocd -f interface/cmsis-dap.cfg -f target/rp2040.cfg -c "adapter speed 5000; program {path/to/elf} verify reset exit"

@Slion
Copy link
Author

Slion commented Jun 13, 2024

Awesome, the one-liner works great.
I could eventually find the Flash task through the global search box in the top tool bar.
image

I could also add a dependency to the flash task so that it builds first:

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "Flash",
      "type": "shell",
      "command": "openocd",
      "args": [
        "-f",
        "interface/cmsis-dap.cfg",
        "-f",
        "target/rp2040.cfg",
        "-c",
        "adapter speed 5000; program {${command:cmake.launchTargetPath}} verify reset exit"
      ],
      "problemMatcher": [],            
      "dependsOn": ["Build"]
    },
    {
      "label": "Build",
      "type": "cmake",
      "command": "build",
      "problemMatcher": "$gcc",
      "group": {
        "kind": "build",
        "isDefault": true
      }
    }
  ]
}

Now I may swap this around so that Ctrl+Shift+B does build then flashes or I need to find a way to set a shortcut to the flash task.

Thanks a lot!

@Slion Slion closed this as completed Jun 13, 2024
@ndabas
Copy link
Contributor

ndabas commented Jun 13, 2024

Great, glad that helped!

I think you might want to look into launch configurations -- we added that Flash task (and did not add the build task as a dependency) for the C++ debugger task that we have in the configuration (the last one in the file), because that task builds the code but does not flash it by default. You might be able to create a configuration which just does the build and flash, without lauching a debugger.

@Slion
Copy link
Author

Slion commented Jun 13, 2024

To bind the Flash task that depends on the Build task to Ctrl+Shift+B I used that as my .vscode/tasks.json:

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "Flash",
      "type": "shell",
      "command": "openocd",
      "args": [
        "-f",
        "interface/cmsis-dap.cfg",
        "-f",
        "target/rp2040.cfg",
        "-c",
        "adapter speed 5000; program {${command:cmake.launchTargetPath}} verify reset exit"
      ],
      "problemMatcher": [],            
      "dependsOn": ["Build"],
      "group": {
        "kind": "build",
        "isDefault": true
      }
    },
    {
      "label": "Build",
      "type": "cmake",
      "command": "build",
      "problemMatcher": "$gcc",
    }
  ]
}

Just moved the following block from the Build task to the Flash task:

      "group": {
        "kind": "build",
        "isDefault": true
      }

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants