Commit Graph

103 Commits

Author SHA1 Message Date
Brian S. Stephan 99504bfde6
support loading JSON files as configs to edit
Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
2024-04-20 21:31:14 -05:00
Brian S. Stephan 56eb65dd55
tweak the version flag output to show more package/system info
Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
2024-04-19 08:11:20 -05:00
Brian S. Stephan 2adb1540a1
include .json in the TUI Save As... prompt
Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
2024-04-15 23:22:18 -05:00
Brian S. Stephan b4ba27dda0
add customary EOF \n to written JSON
Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
2024-04-15 20:18:12 -05:00
Brian S. Stephan 58f2f38546
preliminary support for writing configs direct to JSON
I'm hoping this will allow for editing the JSON configs directly with
edit-config

Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
2024-04-15 20:14:08 -05:00
Brian S. Stephan 2648aebd4f
add --backup flag to concatenate
makes it so that we retain the old file, e.g. GP2040CE.uf2.old if we're
about to write GP2040CE.uf2

Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
2024-04-15 10:13:28 -05:00
Brian S. Stephan 6a802bb232
support reading segmented UF2 files
now that we create segmented UF2 files properly in concatenate, we need
the ability to read them, which we'd previously saved for later; that
time is now. the reader now supports jumps forward (but not backwards,
and I don't know how likely it is we'll ever see this)

Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
2024-04-15 09:25:26 -05:00
Brian S. Stephan 7d34a441f8
use the proper block count when publishing multipart UF2s
Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
2024-04-15 00:05:54 -05:00
Brian S. Stephan e133abc922
concatenate smaller UF2s by using indexed offsets
previous commit added the ability to pass a list of location+binary
combinations to create UF2s, meaning we no longer need to pad the
concatenated UF2 the same way we pad the raw binary output. this makes
for a more sanely-sized UF2 and faster write

Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
2024-04-14 23:26:50 -05:00
Brian S. Stephan 2bb049c442
take multiple binary arguments to convert_binary_to_uf2
this is in preparation for making smaller .uf2 files buy not needing
padding, instead passing multiple location+binary combos to the
converter

Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
2024-04-14 22:54:05 -05:00
Brian S. Stephan ea4d4be709
fix bad loading of .uf2 files in summarize-gp2040ce
the UF2 file wasn't converted to binary format before searching for the
board/user config sections, so it was reading the middle of the UF2 file
instead of the end of the binary file and returning that there were no
configs

Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
2024-04-14 11:21:55 -05:00
Brian S. Stephan 5022616f1d
summarize-gp2040ce --- print information about firmware
can be read from a file or over USB

Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
2024-04-12 20:13:38 -05:00
Brian S. Stephan 300fdec86a
import the storage module directly
getting tired of updating the import and having to isort it, honestly

Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
2024-04-12 20:01:20 -05:00
Brian S. Stephan a0734c9b48
add method to search for version strings in binaries
Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
2024-04-12 20:01:20 -05:00
Brian S. Stephan eb95c80815
unsatisfyingly fix a mypy bytes vs. bytearray issue
Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
2024-04-12 20:01:20 -05:00
Brian S. Stephan 2a40c70b56
cover a bit more TUI in tests, and remove dead branches
Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
2024-04-12 20:01:20 -05:00
Brian S. Stephan e35d8dbf3d
add some more UF2 tests and sanity checks
Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
2024-04-12 20:01:20 -05:00
Brian S. Stephan 4a7203d969
dump the board config via --board-config
Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
2024-04-12 20:01:20 -05:00
Brian S. Stephan 6bc93f148b
allow for reading UF2 files in visualize-config
Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
2024-04-12 16:21:20 -05:00
Brian S. Stephan 2ce0c4d7df
don't "optimize" the UF2 until the combination is fixed
naively adding UF2 blocks together is at least wrong by spec; it
produces one file with wrong block counts --- say I'm writing 3770
blocks, the naive uf2(firmware) + uf2(config) solution yields a file
that says it's 3642 blocks for a while, then 128 blocks. picotool kind
of does a "wtf" at this but writes it anyway, but I am not confident
this is safe, so I'll just do the dumb thing again for now (meaning we
pretty much always write 8128 or 8192 blocks when concatenating configs)

Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
2024-04-12 15:27:58 -05:00
Brian S. Stephan 8e6a203398
improve concatenate to create smaller UF2s
the prior version, for the board/user configs, took the whole ~2MB
binary file and converted it to a UF2, which made for a lot of chunks
that were just writing 0s, between the end of the firmware and the start
of the config(s). this changes the logic to build each portion as
separate UF2 chunks and then combine them.

Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
2024-04-12 13:09:02 -05:00
Brian S. Stephan e0f5f8fb5a
rename output file argument to concatenate
to reduce confusion, now that this supports UF2 output, it's not
necessarily a new *binary* file

Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
2024-04-12 07:38:22 -05:00
Brian S. Stephan 0789dd8c9d
follow `reuse lint`
Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
2024-04-12 01:46:25 -05:00
Brian S. Stephan 3e8209e2a5
update .proto snapshot for v0.7.8
this also clarifies the docs a bit regarding versions supported.

Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
2024-04-08 09:07:47 -05:00
Brian S. Stephan 3a55cad86f
implement Save As... in the TUI
this allows for loading an existing GP2040-CE dump or board in BOOTSEL
over USB and saving the parsed configuration to a new .bin/.uf2 file.
might be useful for making quick backups or variants of configs

Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
2024-03-26 13:47:30 -05:00
Brian S. Stephan f6d3ad02e0
support writing new configs as .uf2 files via the TUI
`edit-config --filename foo.uf2` can now create standalone config UF2
files. still working on reading UF2s, or maybe what edit-config needs is
a "Save As..." in order to read from a board/config and output it to a
new file, but this is a start

Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
2024-03-25 12:01:52 -05:00
Brian S. Stephan 449812f1df
optionally dump config to a .uf2 file
this allows for creating a UF2 that writes the user config to the whole
user config section of flash, allowing for easy copying/juggling of
configurations by just maintaining a library of .uf2 files you like to
apply

Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
2024-03-25 10:03:54 -05:00
Brian S. Stephan a3f9f12e74
move UF2 converter to storage, allow specifying start address
the former is to avoid an upcoming circular dependency, the latter is to
allow for creating an e.g. user-config-only .uf2 by specifying the
proper offset to start the UF2 addressing at.

Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
2024-03-25 09:19:58 -05:00
Brian S. Stephan 610e1a2801
show a quick bit of copyright/license info
Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
2024-03-12 13:33:37 -05:00
Brian S. Stephan c1ab61c61e
improve the positioning of the edit dialog buttons
Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
2024-03-12 12:45:58 -05:00
Brian S. Stephan 1d887c9fdf
add MessageScreen back and tweak/enhance screen layouts
this will be used for a help screen, which isn't done yet, but this
makes the edit screen incrementally better too

Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
2024-03-11 12:59:58 -05:00
Brian S. Stephan 5fc2339c74
isort gp2040ce_bintools/gui.py
Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
2024-03-10 23:43:12 -05:00
Brian S. Stephan b900e1dd04
relicense as GPLv3
prior MIT-licensed versions can be obtained from the Git history; this
does not revoke those versions

Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
2024-03-08 00:02:43 -06:00
Brian S. Stephan 069aa27927
style the GUI tree widget a bit
Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
2024-02-18 00:05:16 -06:00
Brian S. Stephan 22de9ae6d6
use Textual's notify instead of a custom popup window
Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
2024-02-17 23:38:41 -06:00
Brian S. Stephan df875a5d99
rename GUI Save button as Confirm
more idiomatic this way, since it's really just "set the value", not
actually saving the config

Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
2024-02-17 23:05:51 -06:00
Brian S. Stephan 03a8235445
include the package version number in the edit-config title
Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
2024-02-17 23:05:36 -06:00
Brian S. Stephan b3f6f86950
ship precompiled protobuf files for convenience
current libraries seem to have problems on Windows with thinking files
are duplicated when they are not, making it impossible to compile .proto
files at runtime in this tool on that platform. this adds a fallback of
using shipped, precompiled files in the package. I was already intending
on providing this as an option anyway, so might as well start doing it
now.

Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
2024-01-09 09:40:07 -06:00
Brian S. Stephan 64d892eea0
ignore libusb NotImplementedError when detaching the driver
this is not meaningful (or possible) on Windows, so we can just ignore
it and move on

Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
2024-01-08 14:35:50 -06:00
Brian S. Stephan 7bd303dd06
optionally concatenate files in .uf2 format 2024-01-06 21:02:27 -06:00
Brian S. Stephan d6857d5da1
add a method to convert binary content to UF2
will be used in concatenate in order to write .uf2 files

Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
2024-01-06 20:51:28 -06:00
Brian S. Stephan 314fc909ff
flag and method to visualize the board config
via file dump or via USB. used to test the writing of the board config
to binary

Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
2024-01-06 17:27:33 -06:00
Brian S. Stephan 1a44e8c1e3
fix some mypy errors in bytearray arguments
Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
2024-01-06 13:48:49 -06:00
Brian S. Stephan 0d54d3b805
concatenate flags to combine board and user configs
Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
2024-01-06 13:45:12 -06:00
Brian S. Stephan ef71db6f5e
methods to add/retrieve board config to binary
with this, the combining methods can combine both a board and user
config into one binary, which is a step closer to having a command that
does it, and then we can start removing BoardConfig.h from the firmware
build and replace it with patched binaries.

to test it, another retrieval method was added too, and this will
probably be used for more dump commands or a better info or something
like that

Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
2024-01-06 11:43:54 -06:00
Brian S. Stephan bc64a6531b
add a method to pad a binary to the spot of the board config
the board config will be the same space as the user config, directly in
front of it in the flash

Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
2024-01-05 23:42:45 -06:00
Brian S. Stephan c74edabf6d
break up pad_binary_to_user_config
just some refactoring in order to reuse parts for the board config
support

Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
2024-01-05 21:13:14 -06:00
Brian S. Stephan 841c3a38c3
s/get_storage_section/get_user_storage_section/
more renaming to make room for future methods

Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
2024-01-05 21:13:14 -06:00
Brian S. Stephan 578fd416da
rename get_config_from_usb as get_user_config_from_usb
this is to distinguish from the board config later

Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
2024-01-05 21:13:10 -06:00
Brian S. Stephan 05228b9f62
s/STORAGE_/USER_CONFIG_/
more address define renames to make an upcoming feature clearer

Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
2024-01-03 18:27:16 -06:00