pyUBoot is an Open Source python based library for manipulating with U-Boot images and environment variables. Is distributed with following command-line utilities (tools):
envimg - a tool for editing environment variables inside U-Boot image
mkenv - a tool to generate/extract U-Boot environment variables into/from a binary blob
mkimg - a tool for manipulation with U-Boot executable images (zImage, Scripts, …)
Dependencies
Installation
$ pip install uboot
To install the latest version from master branch execute in shell following commands:
$ pip install -r https://raw.githubusercontent.com/molejar/pyUBoot/master/requirements.txt
$ pip install -U https://github.com/molejar/pyUBoot/archive/master.zip
In case of development, install it from cloned sources:
$ git clone https://github.com/molejar/pyUBoot.git
$ cd pyUBoot
$ pip install -r requirements.txt
$ pip install -U -e .
NOTE: You may run into a permissions issues running these commands. Here are a few options how to fix it:
Run with sudo to install pyUBoot and dependencies globally
Specify the --user option to install locally into your home directory (export “~/.local/bin” into PATH variable if haven’t).
Run the command in a virtualenv local to a specific project working set.
Usage
The first example is showing how to use EnvBlob class from uboot module in your code.
import uboot
# --------------------------------------------------------------------------------
# create env blob
# --------------------------------------------------------------------------------
env = uboot.EnvBlob(name="U-Boot Variables")
env.redundant = True
env.set("bootdelay", "3")
env.set("stdin", "serial")
env.set("stdout", "serial")
# --------------------------------------------------------------------------------
# save env blob as binary file
# --------------------------------------------------------------------------------
with open("env.img", 'wb') as f:
f.write(env.export())
# --------------------------------------------------------------------------------
# save env blob in readable format as text file
# --------------------------------------------------------------------------------
with open("env.txt", 'w') as f:
f.write(env.store())
# --------------------------------------------------------------------------------
# parse env blob from binary file
# --------------------------------------------------------------------------------
with open("env.img", 'rb') as f:
env.parse(f.read())
# print env blob info
print("U-Boot enviroment blob loaded from env.img file:")
print(env)
print()
# --------------------------------------------------------------------------------
# load env blob from text file
# --------------------------------------------------------------------------------
with open("env.txt", 'r') as f:
env.load(f.read())
# print env blob info
print("U-Boot enviroment blob loaded from env.txt file:")
print(env)
The second example is showing how to create Multi-File U-Boot image with uboot module.
import uboot
# --------------------------------------------------------------------------------
# create dummy firmware image (u-boot executable image)
# --------------------------------------------------------------------------------
fwimg = uboot.StdImage(bytes([1]*512),
name="Firmware Test Image",
laddr=0,
eaddr=0,
arch=uboot.EnumArchType.ARM,
os=uboot.EnumOsType.LINUX,
image=uboot.EnumImageType.FIRMWARE,
compress=uboot.EnumCompressionType.NONE)
# --------------------------------------------------------------------------------
# create script image (u-boot executable image)
# --------------------------------------------------------------------------------
scimg = uboot.ScriptImage()
scimg.Name = "Test Script Image"
scimg.OsType = uboot.EnumOsType.LINUX
scimg.ArchType = uboot.EnumArchType.ARM
scimg.Compression = uboot.EnumCompressionType.NONE
scimg.EntryAddress = 0
scimg.LoadAddress = 0
scimg.append("echo", "'===== U-Boot settings ====='")
scimg.append("setenv", "stdin serial")
scimg.append("setenv", "stdout serial")
scimg.append("setenv", "rootdev mmcblk2p2")
# --------------------------------------------------------------------------------
# create multi-file image
# --------------------------------------------------------------------------------
mimg = uboot.MultiImage(name="Multi-File Test Image",
laddr=0,
eaddr=0,
arch=uboot.EnumArchType.ARM,
os=uboot.EnumOsType.LINUX,
compress=uboot.EnumCompressionType.NONE)
mimg.append(fwimg)
mimg.append(scimg)
# print created image info
print(mimg)
# --------------------------------------------------------------------------------
# save created image into file: uboot_mimg.img
# --------------------------------------------------------------------------------
with open("uboot_mimg.img", "wb") as f:
f.write(mimg.export())
# --------------------------------------------------------------------------------
# open and read image file: uboot_mimg.img
# --------------------------------------------------------------------------------
with open("uboot_mimg.img", "rb") as f:
data = f.read()
# --------------------------------------------------------------------------------
# parse binary data into new img object of specific image type
# --------------------------------------------------------------------------------
img = uboot.parse_img(data)
# print parsed image info
print(img)
Metadata
Release files for uboot 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| uboot-0.1.1.tar.gz | 20.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| uboot-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 48.2 kB
Release files / uboot-0.1.1.tar.gz
| Download URL | uboot-0.1.1.tar.gz |
|---|---|
| Size | 20.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1b50f3d1653ebdf8269c715ab718f245eac082ebd41d6ac1e25c386e75a090a7
|
|
BLAKE2b-256 checksum How to use checksums |
b45faaf85e1680f7e075550943fe7a84a1759448aab5338185ff8c2b479ce796
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.18.4 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.19.5 CPython/3.6.8
|
Release files / uboot-0.1.1-py3-none-any.whl
| Download URL | uboot-0.1.1-py3-none-any.whl |
|---|---|
| Size | 28.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
55b703df4dcce1eb4dad42c427dc71d64f3fba25db3cae8ad2647b738e5a8369
|
|
BLAKE2b-256 checksum How to use checksums |
b70e989c8b041ed265efa20c9e49ae20f103c5c41de66556cd2eed2a792758cd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.18.4 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.19.5 CPython/3.6.8
|