Compiling firmware for Bus Pirate 6

The build instructions (readme.md) need to be updated to include the new flag -DBP_PICO_PLATFORM=rp2350
Also, when compiling, if I use -DPICO_SDK_FETCH_FROM_GIT=FALSE I get an error about not finding pio2. If I try setting this to ‘TRUE’ but not specifying the PICO_SDK_PATH it fails to find it and also doesn’t work. The following worked for me:

cmake -S . -B build_rp2350 -DPICO_SDK_FETCH_FROM_GIT=TRUE -DPICO_SDK_PATH=/home/user/github/pico-sdk -DBP_PICO_PLATFORM=rp2350
cmake --build ./build_rp2350 --parallel --target bus_pirate6

(edit: obviously set your SDK directory to wherever you downloaded it from)

3 Likes

Thank you for the info. I will push that to readme.

In terms of the pico path: this has been a real issue lately. RPI has a vscode extension to handle this, but several of us have had horrible experiences with it.

Several of us develop on WSL (Linux on Windows) now to avoid that big mess.

I have to manually add back in a sdk path to the cmakelists in the root directory for it to work.

Is there a better way to handle all of this?

1 Like

I have no idea if there’s a better way. FWIW, I am developing in Linux (Debian).
Side note, I did flash the latest firmware on my BP6 and got (edit) blueTag to identify SWD and JTAG correctly. I’m rather impressed. Been having issues with an old Jtagulator, but I think it’s because I never changed the series resistors from 1k to 10ohm.

2 Likes

Glad it worked out for you! Thank you for checking out the Bus Pirate.

1 Like

I went to update the documentation and it appears to have some info for BP6, though it is not particularly clear about it.

This project uses cmake as the build system, so building the project only takes 2 steps:

  1. project configuration (needs to be ran once, or when you want to change configuration).

    cmake -S . -B build_rp2040 -DPICO_SDK_FETCH_FROM_GIT=TRUE
    cmake -S . -B build_rp2350 -DPICO_SDK_FETCH_FROM_GIT=TRUE -DBP_PICO_PLATFORM=rp2350
    

    you may want to add the flags -DPICO_SDK_PATH=/path/to/pico-sdk -DPICO_SDK_FETCH_FROM_GIT=FALSE if you want to use pico-sdk that is in your local path.

  2. project build

    cmake --build ./build_rp2040 --parallel --target all
    cmake --build ./build_rp2350 --parallel --target all
    # you may add a specific target, such as:
    cmake --build ./build_rp2040 --parallel --target bus_pirate5_rev8
    cmake --build ./build_rp2040 --parallel --target bus_pirate5_rev10
    cmake --build ./build_rp2350 --parallel --target bus_pirate5_xl
    cmake --build ./build_rp2350 --parallel --target bus_pirate6
    

Do you have any suggested updates?

What I do on Ubuntu is to have two directories:

  • build
  • build6
    I have two files in the main directory two files, called CMake5 and CMake6:

The is CMake5

#!/bin/sh
cmake -S .. -B build_rp2040 -DPICO_SDK_FETCH_FROM_GIT=TRUE

and CMake6

#!/bin/sh
PICO_SDK_PATH=
export PICO_SDK_PATH
cmake -S .. $* -B build_rp2350 -DPICO_SDK_FETCH_FROM_GIT=TRUE -DBP_PICO_PLATFORM=rp2350

I then type [edited] either
cd build; ../CMake5;make
or
cd build6; ../CMake6;make

I might add the “clean” argument if I have problems compiling.

Checked into the repository is a hacks/chk.sh which does a full clean build of both RP2040 and RP2350 builds. It also ensures the translation strings are updated. This script intentionally avoids using ./build as a target directory, to avoid stomping on VSCode’s CMake extension (which doesn’t like others messing with that directory).

HOWEVER,  because bash is >15th in my list of programming languages, I haven’t cleaned it up to ensure each step succeeds before doing the next one. Would love some help cleaning that script up.

That said, I just manually review the output. It’s pretty easy to see warnings and errors from CMake and GCC…

1 Like

I like to do everything from VSCode WSL, so here’s my tasks.json and launch.json for BP6 (feel free to adapt it to your needs). Put in BusPirate5-firmware/.vscode

With this setup, you can configure CMake, build, flash and debug everything directly from the IDE.

Steps:

:one: Open the task runner:

  • Press CTRL+SHIFT+P
  • Select “Tasks: Run Task”
  • Run “ownbuild: configure BP6”

:two: Build BP6:

  • Press CTRL+SHIFT+P
  • Select “Tasks: Run Task”
  • Run “ownbuild: build BP6”

:three: Flash BP6:

  • Press CTRL+SHIFT+P
  • Select “Tasks: Run Task”
  • Run “Flash BP6”

Debugging:

Just use the GUI Debugger in VSCode. :rocket:

Windows:

PS C:\Users\regue> usbipd attach -b 1-1 --wsl
usbipd: info: Using WSL distribution 'Ubuntu' to attach; the device will be available in all WSL 2 distributions.
usbipd: info: Detected networking mode 'nat'.
usbipd: info: Using IP address 172.29.128.1 to reach the host.
PS C:\Users\regue> usbipd list
Connected:
BUSID  VID:PID    DEVICE                                                        STATE
1-1    2e8a:000c  CMSIS-DAP v2 Interface, USB Serial Device (COM33)             Attached
1-2    046d:c52b  Logitech USB Input Device, USB Input Device                   Not shared
1-3    1209:7331  USB Serial Device (COM55), USB Serial Device (COM54), USB...  Not shared
1-8    174f:241a  EasyCamera                                                    Not shared
1-14   8087:0a2a  Intel(R) Wireless Bluetooth(R)                                Not shared

Persisted:
GUID                                  DEVICE

Linux WSL:

dreg@leno:~/BusPirate5-firmware/.vscode$ lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 2e8a:000c Raspberry Pi Debug Probe (CMSIS-DAP)
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub

pico-wsl2

openocd-rp2350

Note: Some things are hardcoded and crappy, but for me, it’s good enough :joy:.

tasks.json

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "ownbuild: configure BP6",
      "type": "shell",
      "command": "cmake",
      "args": [
        "-S",
        ".",
        "-B",
        "build_rp2350",
        "-DPICO_SDK_FETCH_FROM_GIT=TRUE",
        "-DBP_PICO_PLATFORM=rp2350"
      ],
      "options": {
        "cwd": "${workspaceFolder}"
      },
      "problemMatcher": [],
      "group": {
        "kind": "build",
        "isDefault": true
      }
    },
    {
      "label": "ownbuild: build BP6",
      "type": "shell",
      "command": "cmake",
      "args": [
        "--build",
        "build_rp2350",
        "--target",
        "bus_pirate6"
      ],
      "options": {
        "cwd": "${workspaceFolder}"
      },
      "problemMatcher": [],
      "group": "build"
    },
    {
      "label": "Flash BP6",
      "dependsOn": [
        "ownbuild: build BP6"
      ],
      "type": "shell",
      "command": "openocd",
      "args": [
        "-f",
        "interface/cmsis-dap.cfg",
        "-f",
        "target/rp2350.cfg",
        "-c",
        "adapter speed 5000; program ./build_rp2350/src/bus_pirate6.elf verify; reset; exit"
      ],
      "options": {
        "cwd": "${workspaceFolder}"
      },
      "problemMatcher": []
    }
  ]
}

launch.json

{
    "version": "0.2.0",
    "configurations": [
      {
        "name": "Pico Debug (Cortex-Debug)",
        "cwd": "${workspaceFolder}",
        "executable": "./build_rp2350/src/bus_pirate6.elf",
        "request": "launch",
        "type": "cortex-debug",
        "servertype": "openocd",
        "gdbPath": "gdb-multiarch",
        "device": "RP2350",
        "configFiles": [
          "interface/cmsis-dap.cfg",
          "target/rp2350.cfg"
        ],
        "svdFile": "${env:PICO_SDK_PATH}/src/rp2350/hardware_regs/rp2350.svd",
        "runToEntryPoint": "platform_entry",
        "openOCDLaunchCommands": [
          "adapter speed 5000"
        ]
      }
    ]
  }
1 Like

Setup is a real pain … but thanks to your launch.json, I finally got debugging working under VSCode. :tada:

At the same time, I lost the ability to view RTT output. That’s rough.

Previously, I’d been following the steps in hacks/rtt_debugging.md, which telnets to port 4444 to manually control the cores, flash the firmware, and start the RTT server.

Cortex-Debug appears to have configuration variables to enable RTT on OpenOCD … but I’m unsure if I’m doing that correctly as I cannot see a port opened for RTT.

Do you have any thoughts on how I might enable RTT as a console window for VSCode?

1 Like

I’m glad it’s been useful to someone!

I also prefer a GUI debugger, and I have no idea about RTT, but…
wouldn’t it be easier to just do a pure software UART bitbang (NO PIO) + use a USB-to-UART adapter on a free BIO pin? :joy:

When I get a moment, I’ll look into RTT and let you know
but first, I want to finish all the PS/2 and USB Plank work, which is already a ton of effort.

It would not be easier. RTT works over the existing debug interface … no second adapter, no additional wires, and no reliance on UART hardware (it’s all memory reads / writes).

Bummer that you haven’t already used RTT. I’m still looking for how to get ALL these parts working at the same time. Wishing this were not quite so much work, just to get a full-featured development environment setup…

Continuing to investigate … it seems Cortex-Debug extension should have support …(but the obvious things aren’t happening…).

1 Like

We definitely need to have an easy path, or we’re not going to attract new developers that easily :pensive_face:

1 Like