custom-files/usr/bin | ||
original | ||
.gitignore | ||
README.md |
HiBy R2II Firmware Customizations
This repo contains scripts and files necessary to modify the official HiBy firmware for the R2II. Currently it adds a mechanism to run a shell script off the SD card at bootup. It does this by adding some custom lines to the /usr/bin/hiby_player.sh
script.
Pre-Requisites
The system image being modified is a UBIFS image, so you will need the tooling to work with those. Since my host kernel is missing the ubi
module, I did this in a newly created Arch Linux VM. These are the packages I needed to install with pacman
:
p7zip
(for the7z
command)mtd-utils
(forflash_erase
and other MTD commands)cdrkit
(for thegenisoimage
command)
Building the Custom Firmware
These instructions are based largely on SuperTaiyaki/hiby-firmware-tools:
- Unpack the stock firmware and rename the original
SYSTEM.UBI
image:7z x -ooriginal/unpack original/r2ii_1.1b1.upt mv original/unpack/SYSTEM.UBI original/unpack/SYSTEM-ORIG.UBI
- Mount the renamed
SYSTEM-ORIG.UBI
image. Make sure that no MTD nodes already exist in your system (ls /dev/mtd*
should return no matches).sudo modprobe nandsim first_id_byte=0x2c second_id_byte=0xda third_id_byte=0x90 fourth_id_byte=0x95 sudo flash_erase /dev/mtd0 0 0 sudo ubiformat /dev/mtd0 sudo modprobe ubi sudo ubiattach -m 0 sudo ubimkvol /dev/ubi0 -a 4096 -N hiby -s 128MiB sudo ubiupdatevol /dev/ubi0_0 original/unpack/SYSTEM-ORIG.UBI sudo mount /dev/ubi0_0 /mnt
- Make a copy of the original firmware file system:
sudo cp -R /mnt customized
- Replace files in the original firmware copy with the customized versions:
sudo cp -R custom-files/* customized/
- Repackage the customized firmware into a new
SYSTEM.UBI
image:sudo mkfs.ubifs -x lzo -d customized -e 0x1F000 -c 512 -m 0x800 -o original/unpack/SYSTEM.UBI
- Update the md5 hash in
UPDATE.TXT
to match the newSYSTEM.UBI
image:sed -i '7,$s/md5=.*/md5='"$(md5sum original/unpack/SYSTEM.UBI | cut -d\ -f1)/" original/unpack/UPDATE.TXT
- Generate the new firmware update file:
genisoimage -l -o r2ii.upt original/unpack/{SYSTEM.UBI,UBOOT.BIN,UIMAGE.BIN,UPDATE.TXT,VERSION.TXT,_GITIGNO}
Now you can copy the r2ii.upt
file that was generated to the root of your R2II's SD card, then initiate a firmware update through the System->Firmware update->Via SD-card
menu. If you are unable to get into the System menu, you can also force an update by turning the device off, then holding the Power and FFWD buttons together until the Hiby logo appears.
Using the Custom Firmware
If you place a text file named startup.sh
onto the root of your SD card, that script will be executed every time the device boots up just prior to the HiBy player interface being launched.