-
Notifications
You must be signed in to change notification settings - Fork 25
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
micropy stubs create fails after verifying integrity #495
Comments
Hello @romankulev , did you manage to solve this? I experience the same issue. |
Sorry for the late reply. Have either of you tried using the rshell backend as an alternative to the upysh backend? See |
Hi @BradenM , Thank you for your response. Python version : 3.10.12 micropy stubs create /dev/ttyUSB0 --backend rshell
MicroPy Connecting to Pyboard @ /dev/ttyUSB0
MicroPy ✔ Connected!
2023-09-08 10:30:12.881 | DEBUG | stubber.minify:minify_script:253 - Original length : 26905
2023-09-08 10:30:12.881 | INFO | stubber.minify:minify_script:254 - Minified length : 11631
2023-09-08 10:30:12.881 | INFO | stubber.minify:minify_script:255 - Reduced by : 15274
2023-09-08 10:30:13.040 | DEBUG | stubber.minify:cross_compile:328 - mpy-cross compiled to : mpy_cross_mxm05fa9.mpy
MicroPy Executing stubber on pyboard...
MicroPy Failed to execute script: 'utf-8' codec can't decode byte 0x83 in position 4: invalid start byte
MicroPy UnicodeDecodeError: 'utf-8' codec can't decode byte 0x83 in position 4: invalid start byte
─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /home/gerard/Documents/test_esp32s2/env/lib/python3.10/site-packages/micropy/app/stubs.py:179 in │
│ stubs_create │
│ │
│ 176 │ dev_path = DevicePath("createstubs.mpy") if compile else DevicePath("createstubs.py" │
│ 177 │ log.info("Executing stubber on pyboard...") │
│ 178 │ try: │
│ ❱ 179 │ │ pyb.run_script(create_stubs, DevicePath(dev_path)) │
│ 180 │ except Exception as e: │
│ 181 │ │ # TODO: Handle more usage cases │
│ 182 │ │ log.error(f"Failed to execute script: {str(e)}", exception=e) │
│ │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ _get_desc = <function stubs_create.<locals>._get_desc at 0x7ffbb65c2a70> │ │
│ │ backend = <CreateBackend.rshell: 'rshell'> │ │
│ │ compile = True │ │
│ │ create_stubs = <_io.BytesIO object at 0x7ffbb51186d0> │ │
│ │ ctx = <click.core.Context object at 0x7ffbb65d38e0> │ │
│ │ dev_path = 'createstubs.mpy' │ │
│ │ exclude = [] │ │
│ │ exclude_defaults = True │ │
│ │ log = <micropy.logger.ServiceLog object at 0x7ffbb65d0040> │ │
│ │ message_handler = MessageHandlers( │ │
│ │ │ on_message=<function stubs_create.<locals>.<lambda> at │ │
│ │ 0x7ffbb65c3250>, │ │
│ │ ) │ │
│ │ module = [] │ │
│ │ module_defaults = True │ │
│ │ mp = <micropy.main.MicroPy object at 0x7ffbb6547ee0> │ │
│ │ port = '/dev/ttyUSB0' │ │
│ │ pyb = <micropy.pyd.pydevice.PyDevice object at 0x7ffbb65d3700> │ │
│ │ pyb_log = <micropy.logger.ServiceLog object at 0x7ffbb65d3d30> │ │
│ │ variant = <CreateStubsVariant.BASE: 'base'> │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /home/gerard/Documents/test_esp32s2/env/lib/python3.10/site-packages/micropy/pyd/pydevice.py:94 │
│ in run_script │
│ │
│ 91 │ │ │ ) │
│ 92 │ │ │ else content.read() │
│ 93 │ │ ) │
│ ❱ 94 │ │ return self.pydevice.eval_script(_content, target_path, consumer=self.consumer) │
│ 95 │ │
│ 96 │ def run(self, content: str) -> str | None: │
│ 97 │ │ return self.pydevice.eval(content, consumer=self.consumer) │
│ │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ _content = b'M\x06\x00\x1f\x83\x19u\x1ccreatestubs.py\x00\x0f\x06pyb\x00\n{}/{}\x00\x0el… │ │
│ │ content = <_io.BytesIO object at 0x7ffbb51186d0> │ │
│ │ self = <micropy.pyd.pydevice.PyDevice object at 0x7ffbb65d3700> │ │
│ │ target_path = 'createstubs.mpy' │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /home/gerard/Documents/test_esp32s2/env/lib/python3.10/site-packages/micropy/pyd/backend_rshell. │
│ py:225 in eval_script │
│ │
│ 222 │ ): │
│ 223 │ │ _contents: str | bytes = contents │
│ 224 │ │ if isinstance(_contents, bytes): │
│ ❱ 225 │ │ │ _contents = _contents.decode() │
│ 226 │ │ with self.repl(): │
│ 227 │ │ │ try: │
│ 228 │ │ │ │ out_bytes = self.eval(_contents, consumer=consumer) │
│ │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ _contents = b'M\x06\x00\x1f\x83\x19u\x1ccreatestubs.py\x00\x0f\x06pyb\x00\n{}/{}\x00\x0el… │ │
│ │ consumer = <micropy.pyd.consumers.ConsumerDelegate object at 0x7ffbb65d37c0> │ │
│ │ contents = b'M\x06\x00\x1f\x83\x19u\x1ccreatestubs.py\x00\x0f\x06pyb\x00\n{}/{}\x00\x0el… │ │
│ │ self = <micropy.pyd.backend_rshell.RShellPyDeviceBackend object at 0x7ffbb65d3b20> │ │
│ │ target_path = 'createstubs.mpy' │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x83 in position 4: invalid start byte
|
Same issue on both counts for me... without And with
Environment
|
I have the same issue with a
|
Looks like the format changed in one of the recent stubber updates and somehow was missed in the unit tests. That piece of code specifically (adapting the module format from stubber) is far from ideal and needs some improving. I will try and look into this soon. |
Not ideal of course, but a temporary workaround would be to modify the resulting "modules.json" file on the device by renaming "firmware.family" -> "firmware.name" and "firmware.board" -> "firmware.sysname" (or "firmware.port", either would work) |
Describe the bug
When I try to create stub from my esp32 i get this error (saved all output in error.txt):
KeyError: 'sysname'
error.txt
Steps to Reproduce
1.Plug esp32 to computer, flash micropython binary
2.run
micropy stubs create /dev/ttyUSB0
Logs
attached micropy.log file
micropy.log
Context (Environment)
The text was updated successfully, but these errors were encountered: