Closed Lars-O-Knudsen closed 1 year ago
Hi @Lars-O-Knudsen,
Apologies for the late reply, but the issue you running into here is due to memory constraints on esp8266 devices.
Under micropy stubs create --help
, you can find a list of --variant
options you can pass to the command that apply codemods for certain situations.
The low memory variants were designed specifically for this type of scenario and I have tested them on esp8266 devices with success.
Please let me know if you continue to have issues even with applying the low memory variants. Thanks.
Hey, thanks for a great tool!
I am now trying to install on laptop, running win11 and I have had some problems. The one below I can not solve.
Please advise :)
Lars
MicroPy Connecting to Pyboard @ COM5 MicroPy ✔ Connected! 2023-07-30 16:56:38.381 | DEBUG | stubber.minify:minify_script:253 - Original length : 26905 2023-07-30 16:56:38.383 | INFO | stubber.minify:minify_script:254 - Minified length : 11631 2023-07-30 16:56:38.384 | INFO | stubber.minify:minify_script:255 - Reduced by : 15274 2023-07-30 16:56:39.035 | DEBUG | stubber.minify:cross_compile:328 - mpy-cross compiled to : mpy_cross_6_9g81iq.mpy MicroPy Executing stubber on pyboard... MicroPy Pyboard Writing /createstubs.mpy: 100%|████████████████████████████████████████████| [10.4k/10.4k @ 1.67kB/s] MicroPy Pyboard Port: esp8266 MicroPy Pyboard Board: ESP_module_with_ESP8266 MicroPy Pyboard Clean/remove files in folder: /stubs/micropython-v1_20_0-esp8266-ESP_module_with_ESP8266 MicroPy Pyboard Stub module: _onewire to file: _onewire.py mem: 5456 MicroPy Pyboard MicroPy Pyboard ets Jan 8 2013,rst cause:4, boot mode:(3,7) MicroPy Pyboard MicroPy Pyboard wdt reset MicroPy Pyboard load 0x40100000, len 30756, room 16 MicroPy Pyboard tail 4 MicroPy Pyboard chksum 0xe7 MicroPy Pyboard load 0x3ffe8000, len 1016, room 4 MicroPy Pyboard tail 4 MicroPy Pyboard chksum 0x6e MicroPy Pyboard load 0x3ffe8400, len 1080, room 4 MicroPy Pyboard tail 4 MicroPy Pyboard chksum 0x67 MicroPy Pyboard csum 0x67 MicroPy Failed to execute script: 'utf-8' codec can't decode byte 0x84 in position 0: invalid start byte MicroPy UnicodeDecodeError: 'utf-8' codec can't decode byte 0x84 in position 0: invalid start byte ╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮ │ c:\users\famil\appdata\local\programs\python\python39\lib\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.._get_desc at 0x000001A34B9C19D0> │ │
│ │ backend = <CreateBackend.upydevice: 'upydevice'> │ │
│ │ compile = True │ │
│ │ create_stubs = <_io.BytesIO object at 0x000001A34BC04E50> │ │
│ │ ctx = <click.core.Context object at 0x000001A34B9E8B80> │ │
│ │ dev_path = 'createstubs.mpy' │ │
│ │ exclude = [] │ │
│ │ exclude_defaults = True │ │
│ │ log = <micropy.logger.ServiceLog object at 0x000001A34B9AEAC0> │ │
│ │ message_handler = MessageHandlers( │ │
│ │ │ on_message=<function stubs_create.. at │ │
│ │ 0x000001A34B9C1940>, │ │
│ │ ) │ │
│ │ module = [] │ │
│ │ module_defaults = True │ │
│ │ mp = <micropy.main.MicroPy object at 0x000001A34B9AE9A0> │ │
│ │ port = 'COM5' │ │
│ │ pyb = <micropy.pyd.pydevice.PyDevice object at 0x000001A34B9D63A0> │ │
│ │ pyb_log = <micropy.logger.ServiceLog object at 0x000001A34B9E8C70> │ │
│ │ variant = <CreateStubsVariant.BASE: 'base'> │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ c:\users\famil\appdata\local\programs\python\python39\lib\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 0x000001A34BC04E50> │ │
│ │ self = <micropy.pyd.pydevice.PyDevice object at 0x000001A34B9D63A0> │ │
│ │ target_path = 'createstubs.mpy' │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ c:\users\famil\appdata\local\programs\python\python39\lib\site-packages\micropy\pyd\backend_upyd │
│ evice.py:330 in eval_script │
│ │
│ 327 │ │ │ self.resolve_path(target_path) if target_path else f"{self._rand_device_path │
│ 328 │ │ ) │
│ 329 │ │ self.write_file(contents, DevicePath(_target_path), consumer=consumer) │
│ ❱ 330 │ │ self.eval(f"import {Path(_target_path).stem}", consumer=consumer) │
│ 331 │ │ self.uos.remove(str(_target_path)) │
│ 332 │ │
│ 333 │ def remove(self, path: DevicePath) -> None: │
│ │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ _target_path = '/createstubs.mpy' │ │
│ │ consumer = <micropy.pyd.consumers.ConsumerDelegate object at 0x000001A34B9D64F0> │ │
│ │ contents = b'M\x06\x00\x1f\x83\x19u\x1ccreatestubs.py\x00\x0f\x06pyb\x00\n{}/{}\x00\x0e… │ │
│ │ self = <micropy.pyd.backend_upydevice.UPyDeviceBackend object at 0x000001A34B9D6400> │ │
│ │ target_path = 'createstubs.mpy' │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ c:\users\famil\appdata\local\programs\python\python39\lib\site-packages\micropy\pyd\backend_upyd │
│ evice.py:315 in eval │
│ │
│ 312 │ │ return value │
│ 313 │ │
│ 314 │ def eval(self, command: str, , consumer: MessageConsumer = NoOpConsumer) -> str | N │
│ ❱ 315 │ │ return self._pydevice.cmd( │
│ 316 │ │ │ command, follow=True, pipe=lambda m, args, **kws: consumer.on_message(m) │
│ 317 │ │ ) │
│ 318 │
│ │
│ ╭───────────────────────────────────────── locals ─────────────────────────────────────────╮ │
│ │ command = 'import createstubs' │ │
│ │ consumer = <micropy.pyd.consumers.ConsumerDelegate object at 0x000001A34B9D64F0> │ │
│ │ self = <micropy.pyd.backend_upydevice.UPyDeviceBackend object at 0x000001A34B9D6400> │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ c:\users\famil\appdata\local\programs\python\python39\lib\site-packages\upydevice\serialdevice.p │
│ y:333 in cmd │
│ │
│ 330 │ │ │ │ rtn = False │
│ 331 │ │ │ │ rtn_resp = False │
│ 332 │ │ │ │ try: │
│ ❱ 333 │ │ │ │ │ self.follow_output(cmd, pipe=pipe, multiline=multiline, │
│ 334 │ │ │ │ │ │ │ │ │ silent=silent_pipe) │
│ 335 │ │ │ │ except KeyboardInterrupt: │
│ 336 │ │ │ │ │ # time.sleep(0.2) │
│ │
│ ╭──────────────────────────────────────── locals ────────────────────────────────────────╮ │
│ │ cmd = 'import createstubs' │ │
│ │ dlog = False │ │
│ │ follow = True │ │
│ │ long_string = False │ │
│ │ multiline = False │ │
│ │ nb_queue = None │ │
│ │ pipe = <function UPyDeviceBackend.eval.. at 0x000001A34BC7C9D0> │ │
│ │ rtn = False │ │
│ │ rtn_resp = False │ │
│ │ self = SerialDevice @ COM5, Type: esp8266, Class: SerialDevice │ │
│ │ Firmware: MicroPython v1.20.0 on 2023-04-26; ESP module with ESP8266 │ │
│ │ USB, Manufacturer: wch.cn │ │
│ │ (MAC: a2:2f:27:00) │ │
│ │ silent = True │ │
│ │ silent_pipe = False │ │
│ ╰────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ c:\users\famil\appdata\local\programs\python\python39\lib\site-packages\upydevice\serialdevice.p │
│ y:430 in follow_output │
│ │
│ 427 │ │ │ │ if pipe: │
│ 428 │ │ │ │ │ cmd_filt = bytes(inp + '\r\n', 'utf-8') │
│ 429 │ │ │ │ │ self.message = self.message.replace(cmd_filt, b'', 1) │
│ ❱ 430 │ │ │ │ msg = self.message.replace(b'\r', b'').decode('utf-8') │
│ 431 │ │ │ │ if 'cat' in inp: │
│ 432 │ │ │ │ │ if msg.endswith('>>> '): │
│ 433 │ │ │ │ │ │ msg = msg.replace('>>> ', '') │
│ │
│ ╭─────────────────────────────────────── locals ───────────────────────────────────────╮ │
│ │ cmd_filt = b'import createstubs\r\n' │ │
│ │ inp = 'import createstubs' │ │
│ │ msg = 'csum 0x67\n' │ │
│ │ multiline = False │ │
│ │ pipe = <function UPyDeviceBackend.eval.. at 0x000001A34BC7C9D0> │ │
│ │ pipe_out = 'csum 0x67\n' │ │
│ │ self = SerialDevice @ COM5, Type: esp8266, Class: SerialDevice │ │
│ │ Firmware: MicroPython v1.20.0 on 2023-04-26; ESP module with ESP8266 │ │
│ │ USB, Manufacturer: wch.cn │ │
│ │ (MAC: a2:2f:27:00) │ │
│ │ silent = False │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────╯ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x84 in position 0: invalid start byte