tweliter
module is currently in beta.Overview
The tweliter
module is a Python module for flashing firmware to TWELITE devices.
It can be installed from PyPI, used as a command-line tool, or controlled from Python scripts.
Installation
Install it from PyPI:
pip install tweliter
With Poetry:
poetry add tweliter
Additional Notes for Linux
Setting udev
rules
You may need to grant permissions via udev
.
- Create
/etc/udev/rules.d/99-ftdi.rules
# TWELITE R / MONOSTICK (FT232R / 0403:6001)
SUBSYSTEM=="usb", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", MODE="0666"
# TWELITE R2 / R3 (FT230X / 0403:6015)
SUBSYSTEM=="usb", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6015", MODE="0666"
- Reload udev rules
sudo udevadm control --reload-rules
sudo udevadm trigger
Also, the TWELITE STAGE app requires unloading the ftdi_sio
module, but when using Python, you need to load it:
modprobe usbserial
modprobe ftdi_sio
Additional Notes for Windows
Applying libusb
driver
If you get errors like No backend available
, applying the libusb-win32
driver might resolve it. Install Zadig, select TWELITE R or MONOSTICK, and apply the libusb-win32
driver (not WinUSB
).
Reference: Installation — PyFtdi documentation (used by the
pyftdi
module)
Examples
As a Command-Line Tool
Specify a .bin
binary file after tweliter
.
tweliter dir/SomeApp_BLUE.bin
Command-Line Options
tweliter -h
usage: tweliter [-h] [-u URL] [-t TYPE] [-g] [-v] [-s] [-m STARTMSG] [-r RETRY] [--clear] [file]
Write TWELITE series firmware
positional arguments:
file Firmware file to write (not required with --clear)
options:
-h, --help show this help message and exit
-u URL, --url URL Optional device URL starting with ftdi://
-t TYPE, --type TYPE Device type(s), comma-separated. e.g., TWELITE_R3,MONOSTICK
-g, --gold Select GOLD series
-v, --verify Verify firmware after writing
-s, --safe Safe mode (GOLD series only, write slowly)
-m STARTMSG, --startmsg STARTMSG
Prefix for startup message to check
-r RETRY, --retry RETRY
Retry count in case of firmware writing failure
--clear Clear application NVM memory (GOLD only)
u
url
: You can specify the URL for identifying FTDI device- If not specified, automatically selected if one device is found; otherwise, a prompt is shown.
t
type
: Specify the type(s) to narrow the target device(s)- Comma-separated. e.g.,
TWELITE_R3,MONOSTICK
.
- Comma-separated. e.g.,
g
gold
: Selects the GOLD series.v
verify
: Verifies after flashing.s
safe
: Applies Safe Mode (slower transfer) for GOLD series only.m
startmsg
: Captures and shows startup messages following the specified text after flashing.- Default is
!INF
- Default is
r
retry
: Number of retries upon flashing failure.- Defaults to 2 retries.
clear
: (GOLD only) Clears non-volatile memory (such as settings).
From a Script
Use an instance of the Tweliter
class.
from pathlib import Path
from tweliter import Tweliter
file = Path("firmware/SomeApp_BLUE.bin")
try:
with Tweliter(
type_filter=Tweliter.Type.TWELITE_R2 | Tweliter.Type.TWELITE_R3
) as liter:
# Get serial interface
ser = liter.get_serial_instance()
# Write firmware
liter.write(ser, file, verify=True)
# Show startup message
print(liter.get_startup_message_after(ser, "!INF"))
except IOError as e:
print(f"Couldn't connect {e}")
except RuntimeError as e:
print(f"Failed to write {e}")