esptool.py fails with error UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf0 (micropython build)

julcol
Posts: 10
Joined: Tue Oct 29, 2024 1:23 am

esptool.py fails with error UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf0 (micropython build)

Postby julcol » Tue Oct 29, 2024 1:52 am

I am working in ubuntu platform and esp32s3

I am trying to build a custom micropython firmware.

I have configured the system to use flash encryption, baked my host generated key into the efuses.

I have encrypted bootloader/partition/app.bin--> micropython

I run

Code: Select all

julian@portatilU:~/tmp/proyectos_python/firmware_micropython/micropython/ports/esp32$ esptool.py -p /dev/ttyUSB0 -b 460800 --force --before default_reset --after no_reset --chip esp32s3 write_flash --flash_mode dio --flash_size 8MB --flash_freq 80m 0x0 tmp/bootloader-enc.bin 0x8000 tmp/partition-table-enc.bin 0x10000 tmp/micropython-enc.bin
Traceback (most recent call last):
  File "/home/julian/.espressif/python_env/idf5.1_py3.10_env/bin/esptool.py", line 37, in <module>
    esptool._main()
  File "/home/julian/.espressif/python_env/idf5.1_py3.10_env/lib/python3.10/site-packages/esptool/__init__.py", line 1139, in _main
    main()
  File "/home/julian/.espressif/python_env/idf5.1_py3.10_env/lib/python3.10/site-packages/esptool/__init__.py", line 669, in main
    args = parser.parse_args(argv)
  File "/usr/lib/python3.10/argparse.py", line 1845, in parse_args
    args, argv = self.parse_known_args(args, namespace)
  File "/usr/lib/python3.10/argparse.py", line 1878, in parse_known_args
    namespace, args = self._parse_known_args(args, namespace)
  File "/usr/lib/python3.10/argparse.py", line 2073, in _parse_known_args
    positionals_end_index = consume_positionals(start_index)
  File "/usr/lib/python3.10/argparse.py", line 2050, in consume_positionals
    take_action(action, args)
  File "/usr/lib/python3.10/argparse.py", line 1955, in take_action
    action(self, namespace, argument_values, option_string)
  File "/usr/lib/python3.10/argparse.py", line 1233, in __call__
    subnamespace, arg_strings = parser.parse_known_args(arg_strings, None)
  File "/usr/lib/python3.10/argparse.py", line 1878, in parse_known_args
    namespace, args = self._parse_known_args(args, namespace)
  File "/usr/lib/python3.10/argparse.py", line 2094, in _parse_known_args
    stop_index = consume_positionals(start_index)
  File "/usr/lib/python3.10/argparse.py", line 2050, in consume_positionals
    take_action(action, args)
  File "/usr/lib/python3.10/argparse.py", line 1955, in take_action
    action(self, namespace, argument_values, option_string)
  File "/home/julian/.espressif/python_env/idf5.1_py3.10_env/lib/python3.10/site-packages/esptool/__init__.py", line 1113, in __call__
    argfile = intel_hex_to_bin(argfile, address)
  File "/home/julian/.espressif/python_env/idf5.1_py3.10_env/lib/python3.10/site-packages/esptool/bin_image.py", line 51, in intel_hex_to_bin
    ih.loadhex(file.name)
  File "/home/julian/.espressif/python_env/idf5.1_py3.10_env/lib/python3.10/site-packages/intelhex/__init__.py", line 210, in loadhex
    for s in fobj:
  File "/usr/lib/python3.10/codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf0 in position 2: invalid continuation byte
julian@portatilU:~/tmp/proyectos_python/firmware_micropython/micropython/ports/esp32$
[0]
Flashing of the partition and boot loader is OK, they are recognized when esp32s3 boots up.

However, I cannot upload the micropython encrypted firmware because of the above error.

Same firmware/bootloader/partition runs perectly without encryption ( on a separate chip)

Any ideas ? is this a bug ? I am using

commit 482a8fb2d78e3b58eb21b26da8a5bedf90623213 (HEAD, tag: v5.1.2)
Author: Aditya Patwardhan <aditya.patwardhan@espressif.com>
Date: Fri Nov 10 08:08:53 2023 +0550

change(version): Update version to 5.1.2

Thanks

JC

julcol
Posts: 10
Joined: Tue Oct 29, 2024 1:23 am

Re: esptool.py fails with error UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf0 (micropython build)

Postby julcol » Tue Oct 29, 2024 7:08 am

I forgot to mention that before moving to release mode, in developer mode, things were fine.

chip posted as encrypted, with local key and I could upload/download files in clear text.

Its only after lock down and external encryption that just the flash of the app will produce the mentioned error

Thanks for you advise.

JC

User avatar
ESP_Roland
Posts: 265
Joined: Tue Oct 09, 2018 10:28 am

Re: esptool.py fails with error UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf0 (micropython build)

Postby ESP_Roland » Tue Oct 29, 2024 10:48 am

Duplicate report here: https://github.com/espressif/esptool/issues/1028. It will be handled there.

Who is online

Users browsing this forum: No registered users and 318 guests