Skip to main content

pyblhost

Developed by Kristian Sloth Lauszus, 2020-2025

The code is released under the GNU General Public License v3.0.


PyPI pyblhost CI Coverage badge

This is a Python implementation of blhost used to communicate with the NXP MCUBOOT/KBOOT bootloader.

For now it only implements a subset of the blhost commands.

Currently serial and CAN-Bus interfaces are supported.

Installation

pip install pyblhost

Usage

Python

See the examples directory for Python examples.

CLI

I recommend using uvx to run the CLI tool:

uvx pyblhost --help

Or you can install it in your path:

uv tool install pyblhost
pyblhost --help

Usage

usage: pyblhost [-tx TX_ID] [-rx RX_ID] [-e EXTENDED_ID] [-i INTERFACE]
                [-l CHANNEL] [-p PORT] [-h] [--version] [-B BINARY]
                [-s START_ADDRESS] [-c BYTE_COUNT] [-t TIMEOUT]
                [-r CMD_REPEAT] [-b BAUDRATE] [--prop PROP] [--no-reset] [-v]
                [--assume-success]
                {can,serial} {upload,read,ping,reset,get_property}

positional arguments:
  {can,serial}          Communicate with the target via either CAN or serial
  {upload,read,ping,reset,get_property}
                        upload: write BINARY to START_ADDRESS. Before writing it will erase the memory from START_ADDRESS to START_ADDRESS + BYTE_COUNT
                        read: read memory from START_ADDRESS to START_ADDRESS + BYTE_COUNT. the read data will be stored in BINARY
                        ping: send a ping command to the target and check for a response
                        reset: send a reset command to the target and check for a response
                        get_property: get a property from the target

required CAN arguments:
  -tx TX_ID, --tx-id TX_ID
                        The TX ID to use for CAN
  -rx RX_ID, --rx-id RX_ID
                        The RX ID to use for CAN

optional CAN arguments:
  -e EXTENDED_ID, --extended-id EXTENDED_ID
                        CAN ID is an extended ID
  -i INTERFACE, --interface INTERFACE
                        The CAN-Bus interface to use (default "socketcan")
  -l CHANNEL, --channel CHANNEL
                        The CAN-Bus channel to use (default "can0")

required serial arguments:
  -p PORT, --port PORT  The port to use for serial

optional arguments:
  -h, --help            Show this help message and exit
  --version             Show program's version number and exit
  -B BINARY, --binary BINARY
                        The binary to upload or write memory into
  -s START_ADDRESS, --start-address START_ADDRESS
                        The address to upload the binary at or read memory from
  -c BYTE_COUNT, --byte-count BYTE_COUNT
                        The number of bytes to erase/read
  -t TIMEOUT, --timeout TIMEOUT
                        The time to wait in seconds for a response (default 1.0)
  -r CMD_REPEAT, --cmd-repeat CMD_REPEAT
                        The number of times to try to establish a connection (default 3)
  -b BAUDRATE, --baudrate BAUDRATE, --bitrate BAUDRATE
                        The baudrate/bitrate to use for serial/can (default 500000)
  --prop PROP, --property PROP
                        The property tag to get
  --no-reset            Do not reset the target after upload
  -v, --verbose         Increase output verbosity
  --assume-success      Assume success if uploading fails

Upload

uvx pyblhost can upload -tx 0x123 -rx 0x321 -B blink.bin -s 0x4C000 -c 0x34000
uvx pyblhost serial upload -p /dev/ttyUSB0 -b 500000 -B blink.bin -s 0x4C000 -c 0x34000

Read

uvx pyblhost can read -tx 0x123 -rx 0x321 -B memory.bin -s 0xC000 -c 0x34000
uvx pyblhost serial read -p /dev/ttyUSB0 -b 500000 -B memory.bin -s 0xC000 -c 0x34000

Ping

uvx pyblhost can ping -tx 0x123 -rx 0x321
uvx pyblhost serial ping -p /dev/ttyUSB0 -b 500000

Reset

uvx pyblhost can reset -tx 0x123 -rx 0x321
uvx pyblhost serial reset -p /dev/ttyUSB0 -b 500000

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyblhost-1.7.1.tar.gz (40.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyblhost-1.7.1-py3-none-any.whl (30.9 kB view details)

Uploaded Python 3

File details

Details for the file pyblhost-1.7.1.tar.gz.

File metadata

  • Download URL: pyblhost-1.7.1.tar.gz
  • Upload date:
  • Size: 40.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for pyblhost-1.7.1.tar.gz
Algorithm Hash digest
SHA256 ee5f2166b67773c11d22145a9e5b2a83145d6bc05b56a23e361cbcad6c508566
MD5 525f98e1fe205ec8a14f90bec144c612
BLAKE2b-256 d34b29193fd147be7e7fae947bbd1be07369ac8667efbb257d00c9ce62fc5edc

See more details on using hashes here.

File details

Details for the file pyblhost-1.7.1-py3-none-any.whl.

File metadata

  • Download URL: pyblhost-1.7.1-py3-none-any.whl
  • Upload date:
  • Size: 30.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for pyblhost-1.7.1-py3-none-any.whl
Algorithm Hash digest
SHA256 06428b5dee3a127ddbc5f36d5398e27e22b59b01c015665c5ef2b86055403bff
MD5 d07f8268594db3af9339c546741b1e81
BLAKE2b-256 1c6d08decd4cf9f4b156471f0639ec0a6aa3fc2cbae2215f672ef057f96f171a

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.7.1 This release

2 files

1.7.0

2 files

1.6.0

2 files

1.5.0

1 file

1.4.0

1 file

1.3.0

1 file

1.2.0

1 file

1.1.1

1 file

1.1.0

1 file

1.0.0

1 file

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page