21/07/08 Update:Bought a 400 Mhz laptop and all I got was a 335 MHz MIPS linux playbox..03/08/08 Update:
"learning, playing, creativity and working are all the same thing: Entertaining the brain :-)"Hosed my Trendtac but managed to restore it. On the way I learned about uBoot and the ability to restore flash images.Introduction
"Don't fix what isn't broken. But if you like to fix things then break it ;-)"
Mounting JFFS2 images
Restoring the kernel to flashIntroduction:Recently I acquired a Trendtac EPC 700 (MIPS linux UMPC) at Intertoys (229 Euros). Not knowing what this was I allowed myself to be surprised. This is by no means a real laptop and its horse power is small to say the least.
This however does not mean that the laptop is not interesting. On the contrary, this is a piece of electronics hardware running Linux. That should at least give me the possibility of a great hacking time!
Some info can be found on www.trendtac.nl where they provide useful tips and a recovery procedure (if the laptop gets messed up.) The site also provides a method for getting console access. More info on Linux for this platform can be found on the Ingenic Semiconductor Co, Ltd webpage and on the linux-mips website.
Below a nice picture of the console.
Next step a proper cross compiler environment:The laptop uses a JZ4730 SOC MIPS processor. This processor is unlike the x86 family of processors in current Desktop PCs and laptops. To be able to compile software and build new kernels we need something called a cross compiler. If you are searching for a crosscompiler that is suitable for this processor follow this link. ftp://ftp.ingenic.cn/3sw/01linux/00toolchain/ provides the neccesary toolchain to be able to build for both the 2.4.20 kernel as the 2.6.24 kernel. The sources for the kernel and other goodies can be found on the same ftp site.
After I unpacked the cross compiler I started to test it with the famous 'Hello World' application.
To compile this with the cross compiler on our Desktop PC:
We now have a MIPS executable called hello. We can try this executable by copying it on a SDcard and inserting it in the laptop.
This shows us that our compiled program runs fine on the MIPS laptop.
In the Debian repository for the 'Etch' distribution there is a huge amount of binaries for the mipsel platform. This repository can be searched for packages and so i did a search for gcc and related software. I found the following files :
Debian packages are archives with inside them a control.tar.gz and a data.tar.gz. The control.tar.gz often holds scripts for post installation activities and also for removal. The data.tar.gz holds the files to be copied to the root folder. So if we want to install these on our EPC 700 we just need to collect the data.tar.gz files from each .deb file and extract them on our EPC 700.A simple script or oneliner can do this for us :(WARNING: USE THIS ONLY ON THE EPC 700 and only the above list of .deb files have been tested. Other .deb files can break your EPC 700)
put all de .deb files on the SDcard and use the following commands:
for package in $( ls *.deb ); do ar -x $package data.tar.gz ; tar xzf ./data.tar.gz -C / ; done
ln -s /usr/bin/gcc-4.1 /usr/bin/gcc
This will copy all the necessary files to the correct place on your EPC 700. The ln statement will create a softlink to the new gcc-4.1 executable and allows us to invoke it simply with gcc.
Unfortunately this is not enough to get started. When we want to use the compiler it cannot find the newly installed libraries. The distrib on the EPC 700 does not have a proper ld.so.conf file and thus we need to create one. (this example works but some people might think this is not the proper way to do this.)
echo "# default libc configuration" >> /etc/ld.so.conf
echo "/lib" >> /etc/ld.so.conf
echo "/usr/lib" >> /etc/ld.so.conf
echo "/usr/local/lib" >> /etc/ld.so.conf
The libraries are now detected and we can continue by testing our compiler. Here i have used the earlier file called hello.c that I copied to the SDcard.
/SD/SD_1 $ cat ./hello.c
/* Hello World application */
int main( int argc , char ** argv)
/SD/SD_1 $ gcc -o test ./hello.c
/SD/SD_1 $ ./test
The result is good. We now have a native compiler for our EPC 700. It still lacks the kernel header files and there are no development libraries besides libc installed. There are also issues with floating point and optimizations. If you use FP then don't use -O2 or -O3 since that will break the FP support in libm. Apparently there is now multilib support in the Debian Sid repository for gcc 4.3. No idea if we can get gcc 4.3 running on our EPC 700.
Hacking the root filing system:
From the site www.trendtac.nl we can also get the recovery images. This consists of two files minifs.img and Recovery_EPC700.img. The file minifs.img is a jffs2 image which the recovery procedure will copy straight to a partition of the internal flash rom. The file Recovery_EPC700.img is a tar bzipped file that contains the root filing system.
Before you follow this guide be sure that you do not have a /dev/mtd0 on your system!! if you already have this device it may be possible that you overwrite the firmware of your own system!!
Mounting the jffs2 image on your desktop acn be done using the following method.
This enables the inspection and modification of the jffs2 rescue filingsystem image.
Not sure what to do next but we will see how it goes. For updating the kernel no shortcut exists at the moment. Also I am trying to find a 'simple' method for booting from SDcard.
Restoring the kernel in flash:Playing with the flash images got me stuck with a 'bricked' laptop. Apparently trying to mount mtdblock1 is not a good idea. The JFFS2 will quitly reformat the partition and as a result I saw that the flash image only contained a directory 'lost+found'. Luckily I had a copy of mtdblock1 and after a lot of soldering (rs232 converter) got a uBoot prompt over serial on my PC.Since I had also made a copy of mtdblock0 which contains the uBoot bootloader I was able to browse through the binary and found an interesting reference to uimage. The instructions for loading the uimage were nicely in plain text.So to reload the kernel to flash with uBoot from your SDcard:
> fatload mmc 0 0x80600000 uimage
> nand erase 0x100000 0x180000
> nand write 0x80600000 0x100000 0x180000
This restored the kernel to mtdblock0 and the laptop booted correctly again.
If you want to mail me : JanRinze (at) home (dot) nl or gmail