Flash firmware to devices running Microchip's 16-bit bootloader.
Project description
mcbootflash
What
Mcbootflash is a tool for flashing firmware to 16-bit Microchip MCUs and DSCs from the PIC24 and dsPIC33 device families, which are running a bootloader generated by the MPLAB Code Configurator tool.
Mcbootflash is intended to be a drop-in replacement for Microchip's official tool, the Unified Bootloader Host Application (UBHA).
Why
Mcbootflash is:
Scriptable
As a command-line application, mcbootflash is easily scriptable.
Extensible
In addition to its command-line interface, mcbootflash can be used as a library by applications wanting to implement firmware flashing as part of a larger suite of features.
Free and Open Source
Mcbootflash is distributed under the MIT license.
Installation
Stand-alone executables for Linux, Mac, and Windows are available from the Github release page.
Mcbootflash can also be installed from PyPI:
pip install mcbootflash
Usage
Mcbootflash can be used as both a command-line application and a library.
Command-line
$ mcbootflash --help
usage: mcbootflash [-h] -p PORT -b BAUDRATE [--timeout TIMEOUT] [--checksum] [--reset] [--debug] [--quiet] [--version] hexfile
mcbootflash is a tool for flashing firmware to 16-bit Microchip MCUs and DSCs from the PIC24 and dsPIC33 device families, which are running a bootloader generated by the MPLAB Code Configurator tool.
positional arguments:
hexfile an Intel HEX file containing application firmware
options:
-h, --help show this help message and exit
-p, --port PORT serial port connected to the device you want to flash
-b, --baudrate BAUDRATE
symbol rate of device's serial bus
--timeout TIMEOUT try to read data from the bus for this many seconds before giving up
--checksum verify flashed data by checksumming after write
--reset reset device after flashing is complete
--debug print debug messages
--quiet suppress output
--version show program's version number and exit
Example
$ mcbootflash --port /dev/ttyUSB0 --baudrate 460800 firmware.hex
Connecting to bootloader...
Erasing program area...
100% 162.0 KiB |######################################| Elapsed Time: 0:00:01
Flashing firmware.hex...
100% 98.8 KiB |#######################################| Elapsed Time: 0:00:06
Self verify OK
Library
When using mcbootflash as a library, typical workflow looks something like this:
import mcbootflash as bf
import serial
# Connect to a device in bootloader mode.
connection = serial.Serial(port=<PORT>, baudrate=<BAUDRATE>, timeout=<TIMEOUT>)
# Query its attributes.
bootattrs = bf.get_boot_attrs(connection)
# Load the firmware image and split it into chunks.
total_bytes, chunks = bf.chunked(hexfile=<HEXFILE_PATH_STRING>, bootattrs)
# Erase the device's program memory area.
bf.erase_flash(connection, bootattrs.memory_range, bootattrs.erase_size)
# Write the firmware chunks to the bootloader in a loop.
for chunk in chunks:
bf.write_flash(connection, chunk)
# Optionally, check that the write is OK by checksumming.
bf.checksum(connection, chunk)
# At this point, you may want to give an indication of the flashing progress,
# like updating a progress bar.
# Verify that the new application is detected.
bf.self_verify(connection)
See also the API Reference.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mcbootflash-10.1.1.tar.gz.
File metadata
- Download URL: mcbootflash-10.1.1.tar.gz
- Upload date:
- Size: 45.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ea1fc75cc8f46c9f272641b8f36d1a910d76c3cbd2412800a3106d772ccbed7d
|
|
| MD5 |
6beedf979556855fd7760d6dce510b83
|
|
| BLAKE2b-256 |
7ee88fa2e00aca02717f321a4601d171d8ba58e88496f5787bcdd4b084a8b8f6
|
Provenance
The following attestation bundles were made for mcbootflash-10.1.1.tar.gz:
Publisher:
release.yml on bessman/mcbootflash
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mcbootflash-10.1.1.tar.gz -
Subject digest:
ea1fc75cc8f46c9f272641b8f36d1a910d76c3cbd2412800a3106d772ccbed7d - Sigstore transparency entry: 163847472
- Sigstore integration time:
-
Permalink:
bessman/mcbootflash@2e4e856e9151015b1410af13d16f3f998a99b937 -
Branch / Tag:
refs/tags/10.1.1 - Owner: https://github.com/bessman
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@2e4e856e9151015b1410af13d16f3f998a99b937 -
Trigger Event:
release
-
Statement type:
File details
Details for the file mcbootflash-10.1.1-py3-none-any.whl.
File metadata
- Download URL: mcbootflash-10.1.1-py3-none-any.whl
- Upload date:
- Size: 17.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
369b9898cca0f86a48dad8e06d9812afe111ece1be85145d7d327b6f36827931
|
|
| MD5 |
5d178aeedad3f75a420daa57a3afbe0a
|
|
| BLAKE2b-256 |
0e3ed8019b907b39af7dfd345573d9ad16ca3f0af2a381f0b62a627bd4b2ed4f
|
Provenance
The following attestation bundles were made for mcbootflash-10.1.1-py3-none-any.whl:
Publisher:
release.yml on bessman/mcbootflash
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mcbootflash-10.1.1-py3-none-any.whl -
Subject digest:
369b9898cca0f86a48dad8e06d9812afe111ece1be85145d7d327b6f36827931 - Sigstore transparency entry: 163847474
- Sigstore integration time:
-
Permalink:
bessman/mcbootflash@2e4e856e9151015b1410af13d16f3f998a99b937 -
Branch / Tag:
refs/tags/10.1.1 - Owner: https://github.com/bessman
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@2e4e856e9151015b1410af13d16f3f998a99b937 -
Trigger Event:
release
-
Statement type: