File Encoding / SyntaxError Problem with Arduino Opta and MicroPython
Port, board and/or hardware
OPTA RS485
MicroPython version
Device: Arduino Opta RS485
MicroPython version: v1.26.1 (2025-09-11)
Flashed file: ARDUINO_OPTA-20250911-v1.26.1.dfu
Tools used: Thonny and mpremote
Installation method:Dfu-utils and Arduino’s official MicroPython installer (same result)
Reproduction
-
Reset the Opta’s memory using the example sketch QSPIFormat from the Arduino IDE.
-
Flash the latest .dfu file:
ARDUINO_OPTA-20250911-v1.26.1.dfu
- Disconnect and connect Usb cable
- Connect using Thonny or mpremote.
Every time I connect, I immediately see this error:
Traceback (most recent call last):
File "boot.py", line 3
SyntaxError: invalid syntax
MicroPython v1.26.1 on 2025-09-11; Arduino OPTA with STM32H747
Type "help()" for more information.
Expected behaviour
No response
Observed behaviour
I noticed that boot.py and main.py are always corrupted or encoded incorrectly after flashing.
Example of what boot.py looks like:
boot.py -- run on boot to configure USB and filesystem
Put app code in main®xù
ŠÂ^MŠéÃøïúü¨Ãéëè...
I tried manually reformatting the flash memory:
import os, vfs, pyb
vfs.umount('/flash')
vfs.VfsFat.mkfs(pyb.Flash(start=0))
vfs.mount(pyb.Flash(start=0), '/flash')
os.chdir('/flash')
Then recreated a simple boot.py:
simple boot
print("BOOT OK")
After reset, this works fine:
BOOT OK
MicroPython v1.26.1 on 2025-09-11; Arduino OPTA with STM32H747
But when I upload a new main.py (even a simple one):
import time
print("start program")for i in range(1, 100):
print(f"N Message: {i}")
time.sleep(1)print("End program")
…the file becomes corrupted and unreadable:
import time
print("start pzográm"©ŠŠëïýîüÃú¨½¨...
Then after reset:
BOOT OK
Traceback (most recent call last):
File "main.py", line 2
SyntaxError: invalid syntax
Additional Information
-
The issue seems to be related to filesystem encoding or corruption after writing .py files.
-
It happens both with Thonny and mpremote.
-
I’ve confirmed the .dfu flash completes successfully each time.
Code of Conduct
Yes, I agree
mpremote gives UnicodeError on ARDUINO_OPTA V26, V27, V28
Port, board and/or hardware
ARDUINO_OPTA
MicroPython version
MicroPython v1.26.1 on 2025-09-11; Arduino OPTA with STM32H747
I do not have the WIFI version but the simplest without WIFI and RS485. Might this be the problem?
The same on V27 (latest) and V28 (preview).
py.exe -m mpremote connect COM9 fs tree
tree :
:/flash
mpremote: Error with transport:
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
UnicodeError:
It's not possible to upload any file or use any filesystem function of mpremote.
mpremote repl works!
Using mpremote 1.27.0 on Windows with Python 3.14.2.
Thank you
Best greetings
Thomas
Reproduction
Connect OPTA and run mpremote.
py.exe -m mpremote connect COM9 fs tree
tree :
:/flash
mpremote: Error with transport:
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
UnicodeError:
Expected behaviour
The command should give a similar output to the following;
py.exe -m mpremote connect COM10 fs tree
tree :
:/flash
├── BOOTEX.LOG
├── FOUND.000
│ ├── FILE0000.CHK
│ ├── FILE0001.CHK
│ ├── FILE0002.CHK
│ ├── FILE0003.CHK
│ └── FILE0004.CHK
├── README.txt
├── System Volume Information
│ ├── IndexerVolumeGuid
│ └── WPSettings.dat
├── _mqtt_test_pybd.txt
├── boot.py
Observed behaviour
mpremote ends with the error message "UnicodeError":
py.exe -m mpremote connect COM9 fs tree
tree :
:/flash
mpremote: Error with transport:
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
UnicodeError:
Additional Information
No, I've provided everything above.
Code of Conduct
Yes, I agree