Download and unpack the official firmware

From Eminent Opensource

Jump to: navigation, search

Contents

Introduction

This page describes how to download and unpack the official firmware. Unpacking the official firmware means that you extract all directories and files that are inside the firmware. After unpacking the firmware you can start to modify the directories and files. Eventually you can pack the files into your new custom firmware.

Unpacking consists of two steps. You need two tools, 'dd' and cramfs. dd is usually available on every Linux machine, but for cramfs we will explain how to obtain and install it.

Obtain and install cramfs

As of version 2.x of the official firmware, 16k sized blocks are required. The official cramfs tool works with 4k sized blocks. That is why we need to modify the cramfs source code before compilation.

We assume that you are working in your own home-directory under your personal account. We call this user 'user' and the home-directory /home/user. It is strongly discouraged to use the root account from now on. When cross-compiling applications it is very easy to make a mistake and install new binaries compiled for MIPS architecture on your Linux host. This can (as Alex calls it) fck up your Linux host.

Sourceforge.net provides a safe place for downloading the official cramfs-1.1 package. Let's download it. Oh, we will be using /home/user/EM7075 from now on.

cd /home/user
mkdir EM7075
cd EM7075
wget http://downloads.sourceforge.net/project/cramfs/cramfs/1.1/cramfs-1.1.tar.gz

Now extract the tarball:

tar -zxvf cramfs-1.1.tar.gz

Now to use 16k sized blocks, you have to modify two files inside the new directory cramfs-1.1:

cramfsck.c: line 68, replace

#define PAGE_CACHE_SIZE (4096)

with

#define PAGE_CACHE_SIZE (4096 * 4)

and line 88, replace

#define ROMBUFFER_BITS   13

with

#define ROMBUFFER_BITS   14

mkcramfs.c, line 48, replace

#define PAGE_CACHE_SIZE (4096)

with

#define PAGE_CACHE_SIZE (4096 * 4)

Save the files and compile:

cd /home/user/EM7075/cramfs-1.1
make

This will likely give you some errors:

gcc -W -Wall -O2 -g -I.   mkcramfs.c  -lz -o mkcramfs
mkcramfs.c: In function ‘parse_directory’:
mkcramfs.c:245: warning: passing argument 4 of ‘scandir’ from incompatible pointer type
/usr/include/dirent.h:252: note: expected ‘int (*)(const struct dirent **, const struct dirent **)’ but argument is of type ‘int (*)(const void *, const void *)’
mkcramfs.c:287: warning: pointer targets in assignment differ in signedness
mkcramfs.c: In function ‘write_superblock’:
mkcramfs.c:399: warning: pointer targets in passing argument 1 of ‘strncpy’ differ in signedness
/usr/include/bits/string3.h:120: note: expected ‘char * __restrict__’ but argument is of type ‘u8 *’
mkcramfs.c:401: warning: pointer targets in passing argument 1 of ‘strncpy’ differ in signedness
/usr/include/bits/string3.h:120: note: expected ‘char * __restrict__’ but argument is of type ‘u8 *’
mkcramfs.c: In function ‘write_directory_structure’:
mkcramfs.c:480: warning: pointer targets in passing argument 1 of ‘strlen’ differ in signedness
/usr/include/string.h:397: note: expected ‘const char *’ but argument is of type ‘unsigned char *’
mkcramfs.c: In function ‘do_compress’:
mkcramfs.c:598: warning: pointer targets in passing argument 1 of ‘compress2’ differ in signedness
/usr/include/zlib.h:1024: note: expected ‘Bytef *’ but argument is of type ‘char *’
mkcramfs.c:598: warning: pointer targets in passing argument 3 of ‘compress2’ differ in signedness
/usr/include/zlib.h:1024: note: expected ‘const Bytef *’ but argument is of type ‘char *’
mkcramfs.c: In function ‘write_data’:
mkcramfs.c:647: warning: pointer targets in passing argument 3 of ‘do_compress’ differ in signedness
mkcramfs.c:578: note: expected ‘const char *’ but argument is of type ‘unsigned char *’
mkcramfs.c: In function ‘main’:
mkcramfs.c:773: warning: format ‘%Ld’ expects type ‘long long int’, but argument 3 has type ‘loff_t’
mkcramfs.c:810: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘ssize_t’
mkcramfs.c:817: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘ssize_t’
mkcramfs.c:821: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘long unsigned int’
mkcramfs.c:825: warning: pointer targets in passing argument 2 of ‘crc32’ differ in signedness
/usr/include/zlib.h:1285: note: expected ‘const Bytef *’ but argument is of type ‘char *’
gcc -W -Wall -O2 -g -I.   cramfsck.c  -lz -o cramfsck
cramfsck.c: In function ‘test_crc’:
cramfsck.c:224: warning: ignoring return value of ‘read’, declared with attribute warn_unused_result
cramfsck.c: In function ‘romfs_read’:
cramfsck.c:294: warning: ignoring return value of ‘read’, declared with attribute warn_unused_result
cramfsck.c: In function ‘do_symlink’:
cramfsck.c:553: warning: ignoring return value of ‘asprintf’, declared with attribute warn_unused_result

But this is considered normal. You should have two executable files now:

/home/user/EM7075/cramfs-1.1/mkcramfs
/home/user/EM7075/cramfs-1.1/cramfsck

Download the official firmware

Latest official firmware can be found here. Just click the support tab.

We download it:

cd /home/user/EM7075
wget http://downloads.eminent-online.com/EM7075-2.00.13.zip

Unpack the official firmware

We will be storing unpacked firmwares into a directory called unpacked/<firmware_name>. To unpack the official firmware:

cd /home/user/EM7075
mkdir unpacked
cd unpacked
mkdir 2.00.13
cd 2.00.13
unzip ../../EM7075-2.00.13.zip

Now you have three files, a .ver, a .fff and a .bin. The .ver tells the device which version is available, the .fff contains the (Linux-based) kernel and the .bin contains the directories and files you want to modify. We extract the .bin into a directory called bin:

cd /home/user/EM7075/unpacked/2.00.13
dd if=em7075.bin of=em7075.romfs bs=32 skip=1
/home/user/EM7075/cramfs-1.1/cramfsck -v -x /home/user/EM7075/unpacked/2.00.13/bin em7075.romfs
rm -f em7075.romfs

Note that the cramfsck command fails when the 'bin' directory already exists.

BUG: this procedure does not work with firmware 2.00.13. The cramfsck command outputs:

/home/user/EM7075/cramfs-1.1/cramfsck: open failed: /home/user/EM7075/unpacked/2.00.13/bin/osd/font/R01_EGBJK.vcp: Permission denied

it seems like the 'font' directory is not having execute permissions. That is why the user 'user' can not open the folder. As a consequence, cramfsck cannot write files into it. User 'root' can always open directories, even if the directory has no execute permissions. As a workaround use:

cd /home/user/EM7075/unpacked/2.00.13
dd if=em7075.bin of=em7075.romfs bs=32 skip=1
sudo /home/user/EM7075/cramfs-1.1/cramfsck -v -x /home/user/EM7075/unpacked/2.00.13/bin em7075.romfs
sudo chmod -R user bin
rm -f em7075.romfs

When a password is asked, use the password for the user 'user', do not use the root password. For non-Ubuntu distributions, use:

cd /home/user/EM7075/unpacked/2.00.13
dd if=em7075.bin of=em7075.romfs bs=32 skip=1
su -c "/home/user/EM7075/cramfs-1.1/cramfsck -v -x /home/user/EM7075/unpacked/2.00.13/bin em7075.romfs"
su -c "chmod -R user bin"
rm -f em7075.romfs

and use your root password.

Automate the steps

These kind of bundled commands are advised to put in a script. Create a file /home/user/EM7075/unpack.sh containing:

#!/bin/sh

if [ ! -n "$1" ]
then
        echo "Usage: `basename $0` <firmware-name>"
        echo "You must specify a firmware-name."
        exit
fi

cd /home/user/EM7075/unpacked/$1
rm -rf bin
dd if=em7075.bin of=em7075.romfs bs=32 skip=1
/home/user/EM7075/cramfs-1.1/cramfsck -v -x /home/user/EM7075/unpacked/$1/bin em7075.romfs
chown -R user bin
rm -f em7075.romfs

Make it executable:

chmod +x /home/user/EM7075/unpack.sh

Script usage:

/home/user/EM7075/unpack.sh 2.00.13

The workaround continues. For 2.00.13 use:

#!/bin/sh

if [ ! -n "$1" ]
then
        echo "Usage: `basename $0` <firmware-name>"
        echo "You must specify a firmware-name."
        exit
fi

cd /home/user/EM7075/unpacked/$1
sudo rm -rf bin
dd if=em7075.bin of=em7075.romfs bs=32 skip=1
sudo /home/user/EM7075/cramfs-1.1/cramfsck -v -x /home/user/EM7075/unpacked/$1/bin em7075.romfs
sudo chown -R user bin
rm -f em7075.romfs

For non-ubuntu users:

#!/bin/sh

if [ ! -n "$1" ]
then
        echo "Usage: `basename $0` <firmware-name>"
        echo "You must specify a firmware-name."
        exit
fi

cd /home/user/EM7075/unpacked/$1
su -c "rm -rf bin"
dd if=em7075.bin of=em7075.romfs bs=32 skip=1
su -c "/home/user/EM7075/cramfs-1.1/cramfsck -v -x /home/user/EM7075/unpacked/$1/bin em7075.romfs"
su -c "chown -R user bin"
rm -f em7075.romfs

Note: please realize that the bug continues. We will fix the bug at a later stage when modifying our own custom firmware.

Final note: Eminent has indicated on the opensource forum that it will fix the bug with the directories within the 'osd' directory in a (near) future release.

Personal tools