GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - Evarentha/unpack-sprd-dtb-python3: Python3 tool to extract DTB/DTBO files from Spreadtrum (SPRD) and Android DTBO firmware images.

BranchesTags
Open more actions menu

Latest commit

 

History

6 Commits
6 Commits

Folders and files

NameName
Last commit message
Last commit date
LICENSE
LICENSE
 
 
README.md
README.md
 
 
unsprd.py
unsprd.py
 
 

Repository files navigation

unpack-sprd-dtb-python3

Python utility to extract Device Tree Blobs (DTB/DTBO) from Spreadtrum (SPRD) and Android DTBO images.

Overview

This script extracts individual DTB files from two common firmware image formats used on Spreadtrum/UniSoC platforms:

  1. SPRD Container Format — Used for base DTB images (dtb.img, dtb.bin)
  2. Android DTBO Format — Used for dynamic DTB overlays (dtbo.img)

Both formats are commonly found in Android boot partitions for Spreadtrum/UniSoC SoCs.

Supported Formats

1. SPRD Container Format

Magic: SPRD (0x53 0x50 0x52 0x44)

Structure:

+------------------+
| "SPRD" (4 bytes) |  Magic identifier
+------------------+
| version (u32)    |  Format version (typically 1)
+------------------+
| count (u32)      |  Number of DTB entries
+------------------+
| Entry 0 (20 B)   |  chipset, platform, rev, offset, size
| Entry 1 (20 B)   |  ...
| ...              |
| Entry N-1 (20 B) |
+------------------+
| 0 (u32)          |  End-of-table marker
+------------------+
| padding          |  Align to page size (default 2048)
+------------------+
| DTB 0 data       |  Raw FDT blob (magic 0xD00DFEED)
| DTB 1 data       |
| ...              |
+------------------+

Each entry (little-endian):

  • chipset (u32) — SoC identifier (e.g., 0x9863)
  • platform (u32) — Board/platform variant
  • rev (u32) — Silicon revision
  • offset (u32) — Byte offset from file start to DTB data
  • size (u32) — Size of DTB data in bytes

Output naming: {index:04d}_{chipset}.dtb (e.g., 0000_9863.dtb)

2. Android DTBO Format

Magic: 0xD7B7AB1E (big-endian)

Structure:

+--------------------------+
| dt_table_header (32 B)   |  Magic, total_size, header_size,
|                          |  dt_entry_size, dt_entry_count, etc.
+--------------------------+
| dt_table_entry 0 (32 B)  |  dt_size, dt_offset, dt_id, dt_rev,
| dt_table_entry 1 (32 B)  |  custom[4]
| ...                      |
+--------------------------+
| DTB 0 data               |  Raw FDT blob (magic 0xD00DFEED)
| DTB 1 data               |
| ...                      |
+--------------------------+

All fields are big-endian.

Output naming: {index:04d}_{dt_id}.dtb (e.g., 0000_1234.dtb)

Installation

# No dependencies beyond Python 3 standard library
chmod +x unsprd.py

Usage

# Extract SPRD container
python unsprd.py dtb.img [output_dir]

# Extract Android DTBO
python unsprd.py dtbo.img [output_dir]

# Options
-f, --force    Overwrite existing files
-v, --verbose  Detailed logging
-d, --all      Extract duplicate entries too

Examples

# Extract to current directory
python unsprd.py dtb.img

# Extract to specific directory
python unsprd.py dtbo.img ./extracted

# Verbose with force overwrite
python unsprd.py -fv dtb.img output/

How It Works

The script auto-detects the format by checking the first 4 bytes:

  • SPRD → SPRD container (little-endian)
  • 0xD7B7AB1E → Android DTBO (big-endian)

It then parses the entry table, validates each DTB has the correct FDT magic (0xD00DFEED), and writes individual .dtb files.

License

MIT, Copyright (C) 2026 Evarentha. See LICENSE.

About

Python3 tool to extract DTB/DTBO files from Spreadtrum (SPRD) and Android DTBO firmware images.

Resources

Readme
MIT license
Activity
Custom properties

Stars

4 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.