Python Scripts for the BusPirate (intended for Linux)
is a small USB-attached hardware debugging
interface using a USB-serial attachment. While it can
be used interactively with a terminal program, e.g. with
minicom, that gets tedious fast. For this reason I wrote a
set of Python 3.x scripts to automatize things. I have
tried for reasonable in-code documentation so the scripts
can also serve as templates for other tools.
- Uses Python 3.x. May be made to work with Python 2.x
as there is nothing special in use.
- Uses PySerial available
- May be made to work on Windows too, as PySerial
is cross-platform. I have no idea what changes would
be needed, at the very least I expect the USB-serial
devices have other names.
If anybody ports it over, I can link to the
modified version here.
- Tested with my BusPirate v3.5c. Other versions
should work too.
- Uses interactive commands, for easier debugging and because
at least for SPI, I did not get the binary mode to work.
Note: Interactive mode has a line-length limit of
256 bytes and will not give an error message when that is
exceeded. It instead gives a bell, which does not work for
line-buffered mode as used by scripting. It will also
execute shortened commands which can result in wrong
bytes being sent to the SPI bus. As long as you respect
this limit, it works fine.
- You need to run the programs as an user that has access
to the serial interface. For example on Debian, a user
added to group "dialout" is allowed to do that. You can
also run the programs as "root", but that is not
This is a script that finds the interface a BusPirate is attached
to. It first tests interfaces from a list whether they are
active and then sends a BusPirate reset, i.e. "#" + CR and
evaluates the response. Note that this may confuse other
devices attached via USB-serial. Also note that BP response
is inconsiostend across firmware versions, including v6.1
that does not manage to answer "RESET" as first line,
but instead writes "RE", whith an occasional 0xff added.
This version here should work at least for firmware
5.10 and 6.1
SPI: Reading and writing 4Mbit (and maybe other) FLASH memories
Tools for SPI Flash memories. The 4Mbit variants are
popular and widely used, because they are fast and very cheap.
These tools are tested with a Microchip 25x40 and an
AMIC 25L040. They should work with others as well, but may
need adjustment. Do not use pull-up mode, it is unreliable.
read_jedec.py: Read JEDEC ID
read_status.py: Reads the
status register and displays its bits. Note that only
the WEL is standard, other bits may be missing.
read_guid.py: Read 64 bit device GUID.
Works only for the 25x40, the AMIC device does not have a GUID.
read_image.py: Read the whole data
area and write it to file. Warning: Overwrites output
file "flash_data.img" if it exists.
erase_all.py: Issues a device erase
command and waits for completion.
write_image.py: Writes a 512kB image
file to the device, default name is "org.img", change in the
sources as needed.
Last update: November, 2013 Arno