Skip to main content

Tools for working with GP2040-CE firmware and storage binaries.

Project description

GP2040-CE Binary Tools

Tools for working with GP2040-CE binary dumps.

Dependencies

Interacting with your board (e.g. getting dumps, etc.) requires picotool, and currently the expectation is that you can run it yourself before invoking these tools. That may change one day.

Installation

% git clone [URL to this repository]
% cd gp2040ce-binary-tools
% python -m venv venv
% source ./venv/bin/activate
% pip install -e .

At some point we may publish packages to e.g. pypi.

Development Installation

As above, plus also pip install -Ur requirements/requirements-dev.txt to get linters and whatnot.

Config Editor

asciicast

A terminal UI config editor, capable of viewing and editing existing configurations, can be launched via edit-config. It supports navigation both via the keyboard or the mouse.

Simple usage:

Key(s) Action
Up, Down Move up and down the config tree
Left, Right Scroll the tree left and right (when content is long)
Space Expand a tree node to show its children
Enter Expand a tree node, or edit a leaf node (bools toggle)
Tab (in edit popup) Cycle highlight between input field and buttons
Enter (in edit popup) Choose dropdown option or activate button
S Save the config to the opened file
Q Quit without saving

A quick demonstration of the editor is available on asciinema.org.

Tools

In all cases, online help can be retrieved by providing the -h or --help flags to the below programs.

concatenate

concatenate combines a GP2040-CE firmware .bin file (such as from a fresh build) and a GP2040-CE board's storage section .bin or config (with footer) .bin, and produces a properly-offset .bin file suitable for flashing to a board. This may be useful to ensure the board is flashed with a particular configuration, for instances such as producing a binary to flash many boards with a particular configuration (specific customizations, etc.), or keeping documented backups of what you're testing with during development.

Sample usage:

% concatenate build/GP2040-CE_foo_bar.bin storage-dump.bin new-firmware-with-config.bin

visualize-storage

visualize-storage reads a dump of a GP2040-CE board's flash storage section, where the configuration lives, and prints it out for visual inspection or diffing with other tools. It can also find the storage section from a GP2040-CE whole board dump, if you have that instead. Usage is simple; just pass the tool your binary file to analyze along with the path to the Protobuf files.

Because Protobuf relies on .proto files to convey the serialized structure, you must supply them from the main GP2040-CE project, e.g. pointing this tool at your clone of the core project. Something like this would suffice for a working invocation (note: you do not need to compile the files yourself):

% visualize-storage -P ~/proj/GP2040-CE/proto -P ~/proj/GP2040-CE/lib/nanopb/generator/proto memory.bin

(In the future we will look into publishing complete packages that include the compiled _pb2.py files, so that you don't need to provide them yourself.)

Sample output:

% visualize-storage -P ~/proj/GP2040-CE/proto -P ~/proj/GP2040-CE/lib/nanopb/generator/proto ~/proj/GP2040-CE/demo-memory.bin
boardVersion: "v0.7.2"
gamepadOptions {
  inputMode: INPUT_MODE_HID
  dpadMode: DPAD_MODE_DIGITAL
  socdMode: SOCD_MODE_SECOND_INPUT_PRIORITY
  invertXAxis: false
  invertYAxis: false
  switchTpShareForDs4: true
  lockHotkeys: false
}
hotkeyOptions {
  hotkeyF1Up {
    dpadMask: 1
    action: HOTKEY_SOCD_UP_PRIORITY
  }
  hotkeyF1Down {
    dpadMask: 2
    action: HOTKEY_SOCD_NEUTRAL
  }
  ...[and so on]...
}
pinMappings {
  pinDpadUp: 19
  pinDpadDown: 18
  pinDpadLeft: 16
  pinDpadRight: 17
  pinButtonB1: 8
  pinButtonB2: 7
  pinButtonB3: 12
  pinButtonB4: 11
  pinButtonL1: 9
  pinButtonR1: 10
  pinButtonL2: 5
  pinButtonR2: 6
  pinButtonS1: 15
  pinButtonS2: 13
  pinButtonL3: 21
  pinButtonR3: 22
  pinButtonA1: 14
  pinButtonA2: 20
}
...[and so on]...
addonOptions {
  bootselButtonOptions {
    enabled: false
    buttonMap: 0
  }
  ...[and so on]...
  dualDirectionalOptions {
    enabled: true
    upPin: 23
    downPin: 27
    leftPin: 26
    rightPin: 24
    dpadMode: DPAD_MODE_DIGITAL
    combineMode: 3
  }
  ...[and so on]...
}
forcedSetupOptions {
  mode: FORCED_SETUP_MODE_OFF
}

Dumping the GP2040-CE board

These tools require a dump of your GP2040-CE board, either the storage section or the whole board, depending on the context. The storage section of a GP2040-CE board is a reserved 8 KB starting at 0x101FE000. To dump your board's storage:

% picotool save -r 101FE000 10200000 memory.bin

And to dump your whole board:

% picotool save -a whole-board.bin

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

gp2040ce-binary-tools-0.3.2.tar.gz (1.2 MB view details)

Uploaded Source

Built Distribution

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

gp2040ce_binary_tools-0.3.2-py3-none-any.whl (15.5 kB view details)

Uploaded Python 3

File details

Details for the file gp2040ce-binary-tools-0.3.2.tar.gz.

File metadata

  • Download URL: gp2040ce-binary-tools-0.3.2.tar.gz
  • Upload date:
  • Size: 1.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.11

File hashes

Hashes for gp2040ce-binary-tools-0.3.2.tar.gz
Algorithm Hash digest
SHA256 b9a8d73880b603d1677bd5fd1ee98ff610a58d73dc211c4c96f8a5c09b791b2a
MD5 fc85432ece75226eaf95e88de0353d0c
BLAKE2b-256 9937b8dade4ca7b065854960b0dac46f57ffd0159b3bc05cc9d85f9d0426dd16

See more details on using hashes here.

File details

Details for the file gp2040ce_binary_tools-0.3.2-py3-none-any.whl.

File metadata

File hashes

Hashes for gp2040ce_binary_tools-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0f51c17e6fb96b3324be5805cc8ccee7c242489777da6102d7fcc3898e8fb6e1
MD5 41009ee9b5b66e80d7cd4da250dc87b6
BLAKE2b-256 57d1c671bf527ac7ae545ba259a02f57ec473583e9726179b226acc545235989

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