Skip to content
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

[Enhancement] flashtool.py: Guardrail to prevent flashing wrong MCU type. #86

Open
Laikulo opened this issue Sep 7, 2023 · 1 comment

Comments

@Laikulo
Copy link

Laikulo commented Sep 7, 2023

I'm not entirely sure of the feasibility of this, as it relies on being able to reliably extract the MCU type from a klipper/deployer image to be deployed. Information about that should be readily available in the klipper .elf, but getting it out from .bin may be pain. This would probably best be an opportunistic check, that maybe prints an informative message if it can't determine the MCU type of a firmware blob.

@Laikulo
Copy link
Author

Laikulo commented Sep 16, 2023

It appears that it is not too difficult to extract a dictionary from a bin, since the zlib header is pretty recognizable. Here's an example of doing so with binwalk:

[aaron@warforged]~/vcs/klipper/out% binwalk klipper.bin

DECIMAL       HEXADECIMAL     DESCRIPTION
--------------------------------------------------------------------------------
28856         0x70B8          Zlib compressed data, best compression

[aaron@warforged]~/vcs/klipper/out% binwalk klipper.bin -e

DECIMAL       HEXADECIMAL     DESCRIPTION
--------------------------------------------------------------------------------
28856         0x70B8          Zlib compressed data, best compression 

[aaron@warforged]~/vcs/klipper/out% cd _klipper.bin.extracted
[aaron@warforged]~/vcs/klipper/out/_klipper.bin.extracted% zstdcat <70B8 | jq .config.MCU
"stm32g0b1xx"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant