Pack the custom firmware
From Eminent Opensource
Contents |
Introduction
Packing the firmware is just the reverse process of unpacking a firmware. Follow the description on this page.
Input
The changed firmware is not located in /home/user/EM7075/unpacked/2.00.13-custom, which contains:
- bin: directory with the directories and files in which you have made modifications
- em7075.bin: part of the official firmware, after extraction you had the bin directory
- em7075.fff: the kernel
- em7075.ver: a file containing some meta-data
Strip
Use the strip script to decrease size of all binaries.
Pack the custom firmware
First, increase the version number in em7075.ver:
VERSION='2.00.13-custom' LOCATION='em7075.bin' KERNEL='Yes' PKG_LOCATION='em7075.pkg'
Second, set the build-date (format: yyyy.mm.dd-hhmm) in /home/user/EM7075/unpacked/2.00.13-custom/bin/sysconfig:
export SYSCONF_BUILD_DATE=2011.01.26-2004 export SYSCONF_FIRMWARE_BIN=em7075.bin export SYSCONF_FIRMWARE_VER=em7075.ver export SYSCONF_BOOTLOADER_MTD_PARTITION=/dev/sigmblocka export SYSCONF_KERNEL_MTD_PARTITION=/dev/sigmblockd export SYSCONF_FIRMWARE_MTD_PARTITION=/dev/sigmblockh export SYSCONF_FIRMWARE_MTD_SIZE=31195136 export IS_DTS=n export IS_DTCP=n
Make sure that this build date is more recent than the build date of your currently running firmware.
Third, you must update /home/user/EM7075/unpacked/2.00.13-custom/bin/md5sum.txt. This file contains a list of all files within the bin directory and their md5sum. This md5sum is used by the device to verify that all files have been copied correctly to the storage within the device. If the md5sum is incorrect, firmware upgrade will fail.
cd /home/user/EM7075/unpacked/2.00.13-custom/bin/
rm -f md5sum.txt
find -not -name "md5sum.txt" -type f -exec md5sum '{}' ';' > md5sum.txt
Finally, pack everything to new files.
mkdir /home/user/EM7075/packed mkdir /home/user/EM7075/packed/2.00.13-custom cp /home/user/EM7075/unpacked/2.00.13-custom/em7075.ver /home/user/EM7075/packed/2.00.13-custom/em7075.ver cp /home/user/EM7075/unpacked/2.00.13-custom/em7075.fff /home/user/EM7075/packed/2.00.13-custom/em7075.fff /home/user/EM7075/cramfs-1.1/mkcramfs /home/user/EM7075/unpacked/2.00.13-custom/bin /home/user/EM7075/packed/2.00.13-custom/em7075.img md5sum /home/user/EM7075/packed/2.00.13-custom/em7075.img> /home/user/EM7075/packed/2.00.13-custom/em7075.sum dd if=/home/user/EM7075/packed/2.00.13-custom/em7075.sum of=/home/user/EM7075/packed/2.00.13-custom/em7075.bin bs=32 count=1 cat /home/user/EM7075/packed/2.00.13-custom/em7075.img >> /home/user/EM7075/packed/2.00.13-custom/em7075.bin rm /home/user/EM7075/packed/2.00.13-custom/em7075.sum /home/user/EM7075/packed/2.00.13-custom/em7075.img
Output
Now you have a firmware ready for installing on the device located in /home/user/EM7075/packed/2.00.13-custom/. The directory contains:
- em7075.bin: files and directories you have modified in the bin directory
- em7075.fff: the kernel
- em7075.ver: a file containing some fresh meta-data
Automate it again
The pack.sh script helps you in packing a firmware.
touch /home/user/EM7075/pack.sh chmod +x /home/user/EM7075/pack.sh
And put the following lines in pack.sh:
#!/bin/sh
# Strip the new firmware
/home/user/EM7075/strip.sh $1
# First: Adjust em7075.ver
echo "VERSION='$1'" > /home/user/EM7075/unpacked/$1/em7075.ver
echo "LOCATION='em7075.bin'" >> /home/user/EM7075/unpacked/$1/em7075.ver
echo "KERNEL='Yes'" >> /home/user/EM7075/unpacked/$1/em7075.ver
echo "PKG_LOCATION='em7075.pkg'" >> /home/user/EM7075/unpacked/$1/em7075.ver
# Second: Adjust syconfig
echo "export SYSCONF_BUILD_DATE="`date +%Y.%m.%d-%H%M` > /home/user/EM7075/unpacked/$1/bin/sysconfig
echo "export SYSCONF_FIRMWARE_BIN=em7075.bin" >> /home/user/EM7075/unpacked/$1/bin/sysconfig
echo "export SYSCONF_FIRMWARE_VER=em7075.ver" >> /home/user/EM7075/unpacked/$1/bin/sysconfig
echo "export SYSCONF_BOOTLOADER_MTD_PARTITION=/dev/sigmblocka" >> /home/user/EM7075/unpacked/$1/bin/sysconfig
echo "export SYSCONF_KERNEL_MTD_PARTITION=/dev/sigmblockd" >> /home/user/EM7075/unpacked/$1/bin/sysconfig
echo "export SYSCONF_FIRMWARE_MTD_PARTITION=/dev/sigmblockh" >> /home/user/EM7075/unpacked/$1/bin/sysconfig
echo "export SYSCONF_FIRMWARE_MTD_SIZE=31195136" >> /home/user/EM7075/unpacked/$1/bin/sysconfig
echo "export IS_DTS=n" >> /home/user/EM7075/unpacked/$1/bin/sysconfig
echo "export IS_DTCP=n" >> /home/user/EM7075/unpacked/$1/bin/sysconfig
# Third: update md5sum.txt
cd /home/user/EM7075/unpacked/$1/bin
rm -f md5sum.txt
find -not -name "md5sum.txt" -type f -exec md5sum '{}' ';' > md5sum.txt
# Finally: pack
rm -r /home/user/EM7075/packed/$1
mkdir -p /home/user/EM7075/packed/$1
cp /home/user/EM7075/unpacked/$1/em7075.ver /home/user/EM7075/packed/$1/em7075.ver
cp /home/user/EM7075/unpacked/$1/em7075.fff /home/user/EM7075/packed/$1/em7075.fff
/home/user/EM7075/cramfs-1.1/mkcramfs /home/user/EM7075/unpacked/$1/bin /home/user/EM7075/packed/$1/em7075.img
md5sum /home/user/EM7075/packed/$1/em7075.img> /home/user/EM7075/packed/$1/em7075.sum
dd if=/home/user/EM7075/packed/$1/em7075.sum of=/home/user/EM7075/packed/$1/em7075.bin bs=32 count=1
cat /home/user/EM7075/packed/$1/em7075.img >> /home/user/EM7075/packed/$1/em7075.bin
rm /home/user/EM7075/packed/$1/em7075.sum /home/user/EM7075/packed/$1/em7075.img
And run it:
/home/user/EM7075/pack.sh 2.00.13-custom
