Skip to main content

PyOCD debug probe plugin for Bitbang debug probes

Project description

pyOCD RemoteBitbang DebugProbe plugin

This pyOCD plugin provides a debug probe that allows connection to a remote bitbang interface via a TCP socket. It is design to be used with targets running in simulation. The remote end must provide a TCP server that accepts a socket connection. The debug probe sends an ASCII encoding of the bitbang interface.

Installation

$ pip install pyocd-bitbang

Background

This plugin is designed to be used to connect, via SWD, to a Verilator model of a Cortex-M based MCU. This is the pyOCD equivalent to the OpenOCD JTAG remote_bitbang interface, and in fact, uses the same ASCII encoding.

Implementation Detail

DebugProbe

The class bitbang_probe:RemoteBitbangProbe implements the minimum subset required by the pyOCD pyocd.probe.debug_probe:DebugProbe class. Any SWD commands are translated to a series of read and write calls that drive the remote SWD interface via a TCP socket. The protocol used is the same as defined in the OpenOCD remote_bitbang specification. Each character sent over the socket corresponds to a request to set the bus to a particular state or to read the value currently being driven on SWDI.

Unlike debug probes connected via USB, pyOCD cannot auto-detect the probe. Instead, a unique ID must be specified when launching pyOCD that specifies the probe to use and the IP address and port to use. See below.

TCP Server and SV DPI

In addition to this plugin, the testbench must implement a TCP server to which the probe connects as well as a DPI interface that drives the SWD pins of the DUT. A good example of such an implementation can be found in the OpenTitan repository here.

Modifying the above example to drive a SWD interface is fairly simple. Instead of the 3 bit Write encoding driving {tck, tms, tdi}, they should drive {swclk, swdoen, swdo}.

The following snippet shows the character decoding in the main loop of the DPI C function:

  // parse received command byte
  if (cmd >= '0' && cmd <= '7') {
    char cmd_bit = cmd - '0';
    ctx->swclk  = (cmd_bit >> 2) & 0x1;
    ctx->swdoen = (cmd_bit >> 1) & 0x1;
    ctx->swdo   = (cmd_bit >> 0) & 0x1;
  } else if (cmd == 'R') {
    act_send_resp = true;
  } else if (cmd == 'Q') {
    act_quit = true;
  } else {
    fprintf(stderr,
      "SWD DPI Protocol violation detected: unsupported command '%c'\n", cmd);
    exit(1);
  }

Inside the remote_bitbang:BitBanger class the character encoding for writing a zero or one on the bus as well as a read is defined:

    ZERO  = b'62'
    ONE   = b'73'
    READ  = b'40R'

Usage

Assuming you have pip installed the pluggin, you should be able to connect to the target using:

$ pyocd commander -u remote_bitbang:localhost:5555

which would connect to TCP port 5555 on localhost. No further configuration is necessary.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyocd-bitbang-1.0.2.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyocd_bitbang-1.0.2-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file pyocd-bitbang-1.0.2.tar.gz.

File metadata

  • Download URL: pyocd-bitbang-1.0.2.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.0

File hashes

Hashes for pyocd-bitbang-1.0.2.tar.gz
Algorithm Hash digest
SHA256 0b2736e4d93a237bcf1392cc6bcfb6ae550fcaac445a3cb287088e050168162e
MD5 06c093a745d532326e20907fc34f726a
BLAKE2b-256 cf5f42cc2b804028e48e3a02acfbd49dfae012ee116f548360ed1a9d47fcdda9

See more details on using hashes here.

File details

Details for the file pyocd_bitbang-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: pyocd_bitbang-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 10.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.0

File hashes

Hashes for pyocd_bitbang-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8aaf55bcb49c05f7a0dbb450862ae766998d140694e16405f210a773a9fc2dae
MD5 400b18f22be0a20366cbd10db7c381f7
BLAKE2b-256 8d8aaa3df7a8a0e9006b514f0a92eca731c67260f371e7922192c84070a904f3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page