libuuu Python Wrapper
libuuu is a Python wrapper for the native NXP libuuu library, a universal update utility primarily used for flashing and interacting with NXP i.MX series embedded devices. It provides Python bindings to the C library's functionalities, allowing programmatic control over device flashing and communication. The library generally follows the versioning of the underlying C library, with releases occurring periodically to match new `libuuu` versions.
Common errors
-
FileNotFoundError: Could not find 'libuuu.so' or 'uuu.dll' in standard paths. Set UUU_LIB_PATH to specify its location.
cause The Python wrapper cannot find the native `libuuu` shared library on your system.fixInstall the native `libuuu` library (e.g., `uuu` from NXP mfgtools) and ensure it's in a system-standard library path. Alternatively, set the environment variable `UUU_LIB_PATH` to the full path of the shared library file (e.g., `export UUU_LIB_PATH=/usr/local/lib/libuuu.so`). -
TypeError: 'str' object is not iterable
cause You passed a single string to `Uuu.cmd()` instead of a list of strings.fixWrap your command-line arguments in a list. For example, change `lib_uuu.cmd('-h')` to `lib_uuu.cmd(['-h'])`. -
AttributeError: module 'uuu' has no attribute 'cmd'
cause You tried to import `cmd` directly from the `uuu` module, but it's a method of the `Uuu` class.fixImport the `Uuu` class and call `cmd` as a method on an instance of `Uuu`: `from uuu import Uuu; lib_uuu = Uuu(); lib_uuu.cmd(['-h'])`.
Warnings
- gotcha The `libuuu` Python package is a wrapper. It requires the native `libuuu` shared library (e.g., `libuuu.so` on Linux, `uuu.dll` on Windows) to be installed on your system. This dependency is not handled by `pip` and must be resolved manually.
- gotcha The `Uuu.cmd()` method expects its arguments as a list of strings, mimicking command-line arguments. Passing a single string will result in a `TypeError`.
- gotcha The `libuuu` library is primarily designed for NXP i.MX series processors. While the Python wrapper can be installed anywhere, its practical utility is limited without access to compatible hardware or specific flashing images.
Install
-
pip install libuuu
Imports
- Uuu
from uuu import Uuu
- cmd
from uuu import cmd
from uuu import Uuu; Uuu.cmd(...)
Quickstart
from uuu import Uuu
import os
# Optionally set the path to the native libuuu library if not in standard locations
# os.environ['UUU_LIB_PATH'] = '/path/to/your/libuuu.so'
try:
# Initialize the Uuu wrapper
lib_uuu = Uuu()
# Run a uuu command, e.g., get help
# Arguments must be passed as a list of strings
print("Running uuu -h...")
return_code = lib_uuu.cmd(['-h'])
print(f"Command exited with code: {return_code}")
# Example of a command that might not apply without hardware
# print("Running uuu --version...")
# return_code = lib_uuu.cmd(['--version'])
# print(f"Command exited with code: {return_code}")
except Exception as e:
print(f"An error occurred: {e}")
print("Ensure the native libuuu shared library is installed and accessible.")