-
Notifications
You must be signed in to change notification settings - Fork 164
Sorcerer: Add CLI #890
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+834
−125
Merged
Sorcerer: Add CLI #890
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,127 @@ | ||
| # Sorcerer | ||
|
|
||
| Sorcerer is a suite of tools for visualizing and generating MicroZig register definitions. It | ||
| consists of two components: | ||
|
|
||
| - **Sorcerer (GUI)**: A graphical application for browsing and editing register definitions | ||
| - **sorcerer-cli**: A command-line tool for generating register code | ||
|
|
||
| Both tools work with MicroZig's register definition files (SVD, ATDF, Embassy formats) and use | ||
| [regz](../regz/) to generate type-safe Zig code. | ||
|
|
||
| ## Building | ||
|
|
||
| From the `tools/sorcerer/` directory: | ||
|
|
||
| ```bash | ||
| # Build both tools | ||
| zig build | ||
| ``` | ||
|
|
||
| ## Sorcerer GUI | ||
|
|
||
| The GUI provides an interactive interface for: | ||
| - Browsing all MicroZig register definitions | ||
| - Viewing generated Zig code with syntax highlighting | ||
| - Opening custom SVD/ATDF files | ||
| - Searching chips, boards, and targets | ||
| - Viewing patch files that modify register definitions | ||
| - Statistics overview showing chip counts, formats, and patch coverage | ||
|
|
||
| ### Running | ||
|
|
||
| ```bash | ||
| zig build run | ||
| # or | ||
| ./zig-out/bin/sorcerer | ||
| ``` | ||
|
|
||
| ### Dependencies | ||
|
|
||
| The GUI requires additional dependencies: | ||
| - DVUI (SDL3-based UI framework) | ||
| - tree-sitter-zig (syntax highlighting) | ||
| - serial (serial port communication) | ||
|
|
||
| ## `sorcerer-cli` | ||
|
|
||
| A lightweight CLI alternative that generates register definitions without GUI dependencies. | ||
|
|
||
| ### Usage | ||
|
|
||
| ``` | ||
| sorcerer-cli <command> [options] | ||
|
|
||
| Commands: | ||
| list List all available targets | ||
| generate <chip> Generate register definitions for a chip | ||
|
|
||
| Options for 'list': | ||
| --port <name> Filter by port name (e.g., rp2xxx, ch32v) | ||
| --json Output in JSON format | ||
|
|
||
| Options for 'generate': | ||
| -o, --output <dir> Output directory (default: ./zig-out) | ||
|
|
||
| General options: | ||
| -h, --help Show help | ||
| ``` | ||
|
|
||
| ### Examples | ||
|
|
||
| ```bash | ||
| # List all available chips | ||
| ./zig-out/bin/sorcerer-cli list | ||
|
|
||
| # Output: | ||
| # CHIP PORT BOARD | ||
| # ------------------------ ------------------------ -------------------------------- | ||
| # RP2040 raspberrypi/rp2xxx Raspberry Pi Pico | ||
| # RP2350 raspberrypi/rp2xxx Raspberry Pi Pico 2 | ||
| # STM32F103C8 stmicro/stm32 - | ||
| # CH32V003 wch/ch32v - | ||
| # ... | ||
|
|
||
| # Filter by port (substring matching) | ||
| ./zig-out/bin/sorcerer-cli list --port rp2xxx | ||
|
|
||
| # JSON output (for scripting) | ||
| ./zig-out/bin/sorcerer-cli list --json | jq '.[] | select(.port | contains("rp2xxx"))' | ||
|
|
||
| # Generate register definitions for a chip | ||
| ./zig-out/bin/sorcerer-cli generate RP2040 -o ./my-regs/ | ||
|
|
||
| # This generates: | ||
| # ./my-regs/RP2040.zig | ||
| # ./my-regs/types.zig | ||
| # ./my-regs/types/ | ||
| ``` | ||
|
|
||
| ### Running via build system | ||
|
|
||
| ```bash | ||
| # Run CLI with arguments | ||
| zig build run-cli -- list --port ch32v | ||
| zig build run-cli -- generate CH32V003 -o /tmp/regs | ||
| ``` | ||
|
|
||
| ## Architecture | ||
|
|
||
| Both tools share the same underlying data: | ||
|
|
||
| 1. **Build time**: `build.zig` collects all register definitions from MicroZig ports | ||
| 2. **Schema generation**: Schemas are embedded as Zig compile-time constants in a generated | ||
| `register_schemas.zig` file | ||
| 3. **Both GUI and CLI**: Import the same `schemas` module - no runtime file loading or JSON parsing | ||
| needed | ||
|
|
||
| ## Register Definition Formats | ||
|
|
||
| Sorcerer supports the following formats via regz: | ||
|
|
||
| | Format | Extension | Description | | ||
| |--------|-----------|-------------| | ||
| | SVD | `.svd` | ARM CMSIS System View Description | | ||
| | ATDF | `.atdf` | Microchip ATDF (AVR/SAM devices) | | ||
| | Embassy | - | Embassy HAL register definitions | | ||
| | TargetDB | - | TI TargetDB format | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still want the register schema data to be a runtime file data instead of compile-time, at least for the GUI.