Repository navigation
Firmware modification guide
Carl Kittelberger edited this page Jul 12, 2026
·
1 revision
This guide explains how to modify the Denon PRIME 4 firmware to include custom software using Yocto/OpenEmbedded builds.
The Denon PRIME 4 uses the AZ01 firmware format which relies on SHA1 hash verification, not cryptographic signatures. This means we can modify the firmware by:
- Building custom software with Yocto
- Extracting the official firmware
- Replacing/modifying files
- Recalculating SHA1 hashes
- Repacking with proper XZ stream
denon-prime4/
├── docs/
│ └── reveng/
│ ├── yocto-build-guide.md
│ └── firmware-modification-guide.md
├── tools/
│ ├── extract-firmware.sh
│ ├── repack-firmware.sh
│ └── calculate-hashes.sh
├── yocto/
│ └── meta-denon/
│ ├── conf/
│ │ └── layer.conf
│ └── recipes-core/
│ └── images/
│ └── denon-prime4-image.bb
└── README.md
Follow the Yocto Build Guide to set up the build environment.
mkdir ~/yocto-prime4
cd ~/yocto-prime4
# Clone layers
git clone -b kirkstone https://git.yoctoproject.org/poky.git
git clone -b kirkstone https://git.openembedded.org/meta-openembedded
cd meta-openembedded
git clone -b kirkstone https://git.openembedded.org/meta-oe
git clone -b kirkstone https://git.openembedded.org/meta-python
git clone -b kirkstone https://git.openembedded.org/meta-networking
git clone https://github.com/JeffyCN/meta-rockchip.git
# Initialize build
cd ~/yocto-prime4/poky
source oe-init-build-env build-prime4
# Add meta-denon layer
echo "BBLAYERS += \"${HOME}/yocto-prime4/meta-denon\"" >> conf/local.confcd /path/to/denon-prime4
# Extract XZ data
binwalk -e PRIME4-5.0.0-Update.img
cd extractions/PRIME4-5.0.0-Update.img/7D0194
# Decompress (binwalk already did this, but verify)
file decompressed.bin
# Should show: Linux rev 1.0 ext2 filesystem data
# Copy to working directory
cp decompressed.bin /tmp/firmware-work/firmware.ext2# Create Yocto recipe
mkdir -p ~/yocto-prime4/meta-denon/recipes-core/my-app
cat > ~/yocto-prime4/meta-denon/recipes-core/my-app/my-app_1.0.bb << 'EOF'
SUMMARY = "My Custom App"
LICENSE = "CLOSED"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
SRC_URI = "file://my-app"
do_install() {
install -d ${D}${bindir}
install -m 0755 my-app ${D}${bindir}/
}
FILES:${PN} = "${bindir}/*"
EOF
# Add source file
mkdir -p ~/yocto-prime4/meta-denon/recipes-core/my-app/files
# Copy your compiled app here
# Build
cd ~/yocto-prime4/poky/build-prime4
bitbake my-app# Mount read-write
sudo mkdir /mnt/firmware
sudo mount -o loop,rw /tmp/firmware-work/firmware.ext2 /mnt/firmware
# Backup original
cp -a /mnt/firmware /tmp/firmware-work/firmware.backup
# Replace files
sudo cp /path/to/your/app /mnt/firmware/usr/Engine/
sudo cp /path/to/your/service /mnt/firmware/lib/systemd/system/
# Unmount
sudo umount /mnt/firmware# Extract partition table
cd /tmp/firmware-work
dd if=PRIME4-5.0.0-Update.img bs=1 skip=$((0xA0)) count=4096 of=partition-table.bin
# Calculate hashes for modified partitions
# (This is complex - see tools/calculate-hashes.sh for details)
# Update partition table with new hashes
# (See tools/repack-firmware.sh)# Compress with proper XZ footer
cd /tmp/firmware-work
xz -9e firmware.ext2
# Extract XZ data
dd if=firmware.ext2.xz bs=1 skip=$((0x7D0194)) of=firmware.xz
# Replace in firmware image
# (See tools/repack-firmware.sh)# Use tools/repack-firmware.sh to create final image
cd /tmp/firmware-work
../denon-prime4/tools/repack-firmware.sh \
--input PRIME4-5.0.0-Update.img \
--output PRIME4-MODIFIED-5.0.0-Update.img \
--rootfs firmware.ext2.xz
# Flash to USB drive
dd if=PRIME4-MODIFIED-5.0.0-Update.img of=/dev/sdX bs=1M#!/bin/bash
set -e
INPUT="${1:-PRIME4-5.0.0-Update.img}"
OUTPUT_DIR="${2:-/tmp/firmware-work}"
mkdir -p "$OUTPUT_DIR"
cd "$OUTPUT_DIR"
echo "Extracting firmware..."
binwalk -e "$INPUT"
cd extractions/$(basename "$INPUT" .img)/7D0194
cp decompressed.bin ../firmware.ext2
echo "Firmware extracted to $OUTPUT_DIR/firmware.ext2"#!/bin/bash
set -e
INPUT="${1:---input}"
OUTPUT="${2:---output}"
ROOTFS="${3:---rootfs}"
# Parse arguments
while [[ $# -gt 0 ]]; do
case $1 in
--input) INPUT="$2"; shift 2;;
--output) OUTPUT="$2"; shift 2;;
--rootfs) ROOTFS="$2"; shift 2;;
*) echo "Unknown option: $1"; exit 1;;
esac
done
echo "Repacking firmware..."
# Compress rootfs with proper XZ footer
xz -9e "$ROOTFS"
XZ_FILE="${ROOTFS}.xz"
# Extract XZ data
dd if="$XZ_FILE" bs=1 skip=$((0x7D0194)) of=firmware.xz
# Replace in original image
dd if=firmware.xz of="$OUTPUT" bs=1 seek=$((0x7D0194)) conv=notrunc
echo "Modified firmware: $OUTPUT"#!/bin/bash
# Calculate SHA1 hashes for partition table
# This is complex and depends on partition layout
echo "Hash calculation requires partition table parsing"
echo "See firmware-image-structure.md for details"- Partition Table Parsing: The partition table format is complex (80 bytes per entry with variable-length names)
- Hash Calculation: Must match exact partition data including padding
- Boot Signatures: Some partitions may have additional signatures (need investigation)
- Test with overlay method first (simpler, no repackaging needed)
- Investigate partition table format in detail
- Create proper hash calculation tool
- Test flashing modified firmware
- Document any issues or workarounds
- Firmware Image Structure - Detailed format analysis
- Yocto Build Guide - Setting up build environment
- SSH Persistence Guide - Alternative overlay method