Coder Social home page Coder Social logo

lauszus / pyblhost Goto Github PK

View Code? Open in Web Editor NEW
7.0 2.0 5.0 65 KB

Python implemented of blhost used to communicate with the NXP MCUBOOT/KBOOT bootloader

License: GNU General Public License v3.0

Python 100.00%
blhost bootloader nxp mcu kboot mcuboot freescale

pyblhost's Introduction

pyblhost

Developed by Kristian Sloth Lauszus, 2020-2022

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


PyPI pyblhost CI

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

$ pyblhost -h
usage: pyblhost [-tx TX_ID] [-rx RX_ID] [-i INTERFACE] [-l CHANNEL] [-p PORT] [-h] [--version] [-B BINARY] [-s START_ADDRESS] [-c BYTE_COUNT] [-t TIMEOUT] [-r CMD_REPEAT] [-b BAUDRATE] {can,serial} {upload,read,ping,reset}

positional arguments:
  {can,serial}          Communicate with the target via either CAN or serial
  {upload,read,ping,reset}
                        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

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

optional CAN arguments:
  -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 (in hex) to upload the binary at or read memory from
  -c BYTE_COUNT, --byte-count BYTE_COUNT
                        The number of bytes (in hex) 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)

Upload

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

Read

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

Ping

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

Reset

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

pyblhost's People

Contributors

lauszus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

pyblhost's Issues

[ERROR] BlhostBase: Unsupported protocol version: P1.3.0

how to update ?

pyblhost serial ping -p /dev/ttyUSB0 -b 115200
[INFO] BlhostBase: Sending ping command
[INFO] BlhostBase: Ping response: version: P1.3.0, options: 0
[ERROR] BlhostBase: Unsupported protocol version: P1.3.0
[INFO] Ping responded in 1 attempt(s)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.