Skip to main content

pyIMX

Build Status Coverage Status PyPI Status Python Version

This repository collects a useful tools and python module targeted for i.MX Applications Processors.

What is implemented:

  • DCD (Device Configuration Data) API

  • Boot Image v2 (i.MX6 and i.MX7) API

  • Boot Image v3 (i.MX8QM-A0 and i.MX8QXP-A0) API

  • SDP (Serial Download Protocol) API - only USB interface

  • HAB-Log parser (only i.MX6 and i.MX7 yet)

  • SRK Table API

Embedded tools:

  • imxim - a tool for manipulation with *.imx boot image

  • imxsd - a tool to download and execute code on i.MX SoCs through the Serial Download Protocol (SDP)

    This project is still in developing phase. Please, test it and report founded issues.

Dependencies

  • Python - Python 3.x interpreter

  • Click - Python package for creating beautiful command line interface.

  • pyYAML - YAML parser and emitter for the Python programming language.

  • bincopy - Python package for parsing S-Record, Intel HEX and TI-TXT files.

  • easy_enum - User friendly implementation of documented Enum type for Python language.

  • cryptography - Provides cryptographic recipes and primitives to Python developers

  • PyUSB - Python package to access USB devices in Linux OS.

  • PyWinUSB - Python package that simplifies USB-HID communications on Windows OS.

Installation

$ pip install imx

To install the latest version from master branch execute in shell following commands:

$ pip install -r https://raw.githubusercontent.com/molejar/pyIMX/master/requirements.txt
$ pip install -U https://github.com/molejar/pyIMX/archive/master.zip

In case of development, install pyIMX from sources:

$ git clone https://github.com/molejar/pyIMX.git
$ cd pyIMX
$ pip install -r requirements.txt
$ pip install -U -e .

You may run into a permissions issues running these commands. Here are a few options how to fix it:

  1. Run with sudo to install pyIMX and dependencies globally

  2. Specify the --user option to install locally into your home directory (export “~/.local/bin” into PATH variable if haven’t).

  3. Run the command in a virtualenv local to a specific project working set.

Usage

In following example is demonstrated the simplicity of usage i.MX boot image API covered by imx.img module:

from imx import img

# --------------------------------------------------------------------------------
# Create new U-Boot i.MX6/7 image
# --------------------------------------------------------------------------------

# Create DCD segment instance
dcd = img.SegDCD()

# Create Write Data command and append values with addresses
cmd = img.CmdWriteData(4, img.EnumWriteOps.WRITE_VALUE)
cmd.append(0x30340004, 0x4F400005)
cmd.append(0x30391000, 0x00000002)
cmd.append(0x307A0000, 0x01040001)

# Append commands into DCD segment
dcd.append(cmd)
dcd.append(img.CmdCheckData(4, img.EnumCheckOps.ANY_CLEAR, 0x307900C4, 0x00000001))

# Open U-Boot raw image
with open('u-boot.img', 'rb') as f:
    app = f.read()

# Create IMX U-Boot image with DCD segment
image = img.BootImg2(0x877FF000, app, dcd)

# Print image info
print(image)

# Save IMX U-Boot image
with open('u-boot.imx', 'wb') as f:
    f.write(image.export())

# --------------------------------------------------------------------------------
# Extract DCD from existing U-Boot i.MX6/7 image
# --------------------------------------------------------------------------------

# Open U-Boot IMX image
with open('u-boot.imx', 'rb') as f:
    data = f.read()

# Parse U-Boot IMX image
image = img.BootImg2.parse(data)

# Extract DCD from U-Boot IMX image
dcd = image.dcd

# Print extracted DCD info
print(dcd)

# Save extracted DCD content as raw image
with open('dcd.img', 'wb') as f:
    f.write(dcd.export())

# Save extracted DCD content as readable text file
with open('dcd.txt', 'w') as f:
    f.write(dcd.store())

Second example demonstrate usage of i.MX serial downloader protocol API covered by imx.sdp module:

    from imx import sdp

    # scan for connected USB devs
    devs = sdp.scan_usb()

    if devs:
        # Print list of connected devices
        for i, dev in enumerate(devs):
            print("{}) {}".format(i, dev.usbd.info()))

        # Connect to first i.MX device
        flasher = devs[0]
        flasher.open()

        # Read data from i.MX Device (i.MX7D OCRAM)
        data = flasher.read(0x910000, 100, 8)

        # Write boot image data into i.MX Device (i.MX7D OCRAM)
        flasher.write_file(0x910000, data)

        # Other commands
        # ...

        # Disconnect IMX Device
        flasher.close()

For running ``imx.sdp`` module without root privileges in Linux OS
copy attached udev rules
`90-imx-sdp.rules <https://github.com/molejar/pyIMX/blob/master/udev/90-imx-sdp.rules>`__
into ``/etc/udev/rules.d`` directory and reload it with command:
``sudo udevadm control --reload-rules``.

TODO

  • Add serial interface support for imx.sdp module

  • Add image security features (sign and encryption)

  • Add eFuses read, write and validation functionality

  • Add HAB-log parser for i.MX-RT and i.MX8 devices

  • Add support for QSPI Flash image

Metadata

Release files for imx 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for imx 0.1.3
File Size Uploaded Provenance Actions
imx-0.1.3.tar.gz 47.5 kB Without provenance Details for imx-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for imx 0.1.3
File Interpreter ABI Platform Actions
imx-0.1.3-py3-none-any.whl Python 3 none any Details for imx-0.1.3-py3-none-any.whl

Total release size: 100.9 kB

Release files / imx-0.1.3.tar.gz

Download URL imx-0.1.3.tar.gz
Size 47.5 kB
Tags Source
SHA-256 checksum
How to use checksums
02053bf98fb150015462a7b5e8bbea00705a7599b8c247c811e52310100651fb
BLAKE2b-256 checksum
How to use checksums
887585e49cfa689262b647a3ab09cdf22f9c32cc0261fcba79bfaa357c5c9eb6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.1

Release files / imx-0.1.3-py3-none-any.whl

Download URL imx-0.1.3-py3-none-any.whl
Size 53.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0c48f9dce46b010be24cd3bf1bd33b8ffbdca19afbfc365064f8fa84a7b199aa
BLAKE2b-256 checksum
How to use checksums
0c9c1436e57efa16e23fc70d8a102195d440505b6dd5fa9a2c4e324ce4374315
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.1

Security for imx 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page