Archive for September, 2008
Backing up OpenMoko FR before bricking it and getting your custom kernel and rootfs onto it …
After successfully configuring Open Embedded http://recluze.wordpress.com/2008/09/07/getting-started-with-openmoko/, the build environment for OpenMoko, we want to try our custom built kernel and rootfs. Although, we will be using Micro SD card to run our custom builds rather than the flash still we will backup the factory default images because you never know when you brick it in stupidity or frustration.
Flash memories are fast but there are two things that need to be kept in mind 1) Flash has a limited age with respect to the number of flashes (maybe a 100,000) 2) And we only flash those images onto the flashes, which are satisfactory for usage and are not experimental. Micro SD has one limitation that it is slower in performance compared to Flash memory. So if you live near an OpenMoko store it’ll be better to use the Flash off and on but if you live in Peshawar than you should prefer to use the Micro SD card.
Backing up the Original Images
(This has been adopted from http://wiki.openmoko.org/wiki/Backup to suit newbies like us)
There are two ways to backup:
- DFU-Util (The official and buggy way of doing it)
- Common Sense
DFU-Util
(Adopted from http://wiki.openmoko.org/wiki/Dfu-util)
DF stands for Device Firmware and U stands for utility. DFU-Util is a host implementation of Universal Serial Bus Device Firmware Upgrade protocol. The device side is implemented in the uBoot of OpenMoko.
- transfer and flash partitions in NAND.
- transfer anything into RAM
- this can be used for fast development cycles of low-level code such as kernels without flashing them (Haven’t tried it yet)
- Read out the current internal NAND
- this is an easy and efficient way of doing full backups of your phone
If you are not sure what NAND and NOR are the read http://www.linuxdevices.com/articles/AT7478621147.html
Installing DFU-Util
Debian/Ubuntu
sudo apt-get install libusb-dev autogen pkg-config autotools-dev autoconf automake
Fedora Core
yum install libusb-devel libusb-static
Or download a binary for Linux from http://downloads.openmoko.org/releases/Om2008.8-update/defu-util
Or if you have built Open Embedded using the mokoMakefile then you should have the binary in <$MOKODIR>/build/tmp/staging/i686-linux/usr/bin
Using DFU-Util
Now that we are ready ensure that you are using the USB Data Cable (stay away from USB HUBs) and you are logged as root on your host PC. Power off the phone. Now hold the AUX (top left of phone) button and then hold the power button until the NOR boot menu appears.
./dfu-util -a kernel -R -U original-kernel.bin
./dfu-util -a rootfs -R -U original-rootfs.jffs2
./dfu-util -a splash -R -U original-splash.bin
./dfu-util -a u-boot -R -U original-u-boot.bin
./dfu-util -a u-boot_env -R -U original-u-boot_env.bin
If you are successful then you are very lucky
We were not as lucky as you were and we had to do it over and over again and still we had a corrupt kernel in our backups.
Using Common Sense
–TODO–
Recluze: I only remember the rootfs part so can you plz complete this….
Flashing kernel and rootfs onto Micro SD Card
(Adopted from http://wiki.openmoko.org/wiki/Booting_from_SD.html)
Preparing the SD card
We got our SD card plugged in to our laptop via USB interface and used the fdisk utility to partition it. On your system it might look like:
[user@system]$ fdisk /dev/sdb0
Command (m for help): d
Selected partition 1
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-983, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-983, default 983): +8M
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (18-983, default 18):
Using default value 18
Last cylinder or +size or +sizeM or +sizeK (18-983, default 983):
Using default value 983
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
When we got over this the /dev/sdb was partitioned into /dev/sdb0p1 and /dev/sdb0p2. Now we needed to firmat it accordingly. The partition which will hold the kernel needs to be in vfat due to some limitations that can be figured out from the wiki by the curious and the partiotion holding the rootfs needs to be in ext2/ext3.
mkfs.vfat /dev/sdb0p1 mkfs.ext3 /dev/sdb0p2
Now to copy the relevant stuff onto these we need to mount them and perform the copying or writes.
mount /dev/sdb0p2 /mnt/moko tar -C /mnt/moko/ -xzvf gta02-custom.rootfs.tar.gz OR copy contents of rootfs to the partition. mount /dev/sdb0p2 /mnt/mokoKernel cp uImage-gta02-custom.bin /mnt/mokoKernel/uImage.bin umount /mnt/moko umount /mnt/mokokernel sync
UBoot Menu Entries
We need to boot a kernel and provide a root filesystem to it at boot time. UBoot functions as a boot-loader similar to GRUB. It loads the kernel into memory and then passes a list of parameters known as kernel command string to the kernel. Path to root filesystem is a common command string. If you have experienced boot entries in GRUB then we have similar (almost) entries in uboot.
Uboot menu entries are defined by environment variables named menu_X, where X is a number. The value of this variable is a string, <label>:<commands>, where label is the text shown on the screen and commands is a sequence of u-boot commands (delimited by ‘;’ characters) to be executed when the menu item is selected.
Note: When entering a string of commands, the ‘;’ and ‘$’ characters must be backslash-escaped (”\;” and “\$”).
Add a uboot entry
By default both NOR and NAND uboots have an entry for kernel on vfat and rootfs on ext2. If you have this combination then you don’t need to read the following mess. Otherwise here is what you need to do.
To get to the boot promt hold the AUX and power button. Select “Set console to USB” to enter into the boot prompt. The other way to get to the boot prompt is through serial console via Debug Board but we are afraid that we have not yet experimented with that due to pushing deadlines :o)
Now that we are inside the uboot and have the prompt the first thing to do is to set the timeout environment variable because no matter what you are doing the uboot will continue booting after default of 60 seconds.
setenv boot_menu_timeout 99999
This should be enough for us, I guess :o)
To see what the boot environment has
printenv
We had vfat for kernel and ext3 for rootfs so this is what our entry looked like
setenv menu_9 Boot from microSD (FAT+ext3): setenv bootargs \${bootargs_base} rootfstype=ext3 root=/dev/mmcblk0p2 rootdelay=5 \${mtdparts} ro\; mmcinit\; fatload mmc 1 0x32000000 \${sd_image_name}\; bootm 0x32000000
Enter “printenv” to verify and then “saveenv” to save your changes.
Forgot the restart or power off command! Then next time you get to your NAND uboot select the entry that you made earlier and thank us for this tutorial because it takes ours for a newbie to get relevant stuff from the wiki.
Getting Java on Openmoko
This post is an experience report on porting java on openmoko. This includes many pastes from other locations, so, this might be ugly to look at. First, I describe how we tried building Kaffe for openmoko. The openmoko devel environment includes kaffe-1.1.5, so make build-package-kaffe-gtk got it started. Some problems were faced which were addressed by looking at these two patches. (Bold text marks changes). I’ve lost the links to the posts but you can find them easily by searching for titles (or author names).
Patch 1 applied:
-----------------------------------------------
[kaffe] [PATCH] JIT on arm
Sascha Hauer s.hauer at pengutronix.de
Wed Oct 4 01:23:18 PDT 2006
Previous message: [kaffe] Kaffe porting on MIPS
Next message: [kaffe] Swing not supporting with kaffe+Nano-X
Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi all,
There is a comment in config/arm/linux/md.c which claims that Kernel 2.6
needs a VM_EXEC flag. Fact is that 2.6 never needed this flag, but since
2.6.9 it no longer ignores it.
I have two patches attached, the first one is the change in between 2.6.8
and 2.6.9 and the second one puts the arm jit back into business for kernels
>2.6.9
Have fun,
Sascha
diff -purN linux-2.6.8/arch/arm/kernel/traps.c linux-2.6.9/arch/arm/kernel/traps.c
— linux-2.6.8/arch/arm/kernel/traps.c 2004-08-14 07:36:56.000000000 +0200
+++ linux-2.6.9/arch/arm/kernel/traps.c 2004-10-18 23:53:51.000000000 +0200
@@ -381,7 +381,7 @@ do_cache_op(unsigned long start, unsigne
{
struct vm_area_struct *vma;
- if (end < start)
+ if (end < start || flags)
return;
vma = find_vma(current->active_mm, start);
Index: kaffe-1.1.7/config/arm/linux/md.c
===================================================================
— kaffe-1.1.7.orig/config/arm/linux/md.c
+++ kaffe-1.1.7/config/arm/linux/md.c
@@ -35,7 +35,7 @@ init_md(void)
void flush_dcache(void *start, void *end) {
__asm __volatile (”mov r0, %0\n”
“mov r1, %1\n”
- “mov r2, #4\n” /* this is VM_EXEC from linux/mm.h, needed for Kernel 2.6 */
+ “mov r2, #0\n”
“swi ” __sys1(__ARM_NR_cacheflush) “\n”
: /* no return value */
: “r” ((long)start), “r” ((long)end)
——————————–
patch 2 appliedd
—————————————–
[kaffe] CVS kaffe (robilad): build fix for arm linux interpreter
Kaffe CVS cvs-commits at kaffe.org
Sat Jan 26 17:52:02 PST 2008
Previous message: [kaffe] OpenSuse 10.3 - Kaffe compile make/ls/grep error
Next message: [kaffe] CVS kaffe (robilad): removed no longer needed cvsignore file
Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
PatchSet 7720
Date: 2008/01/27 01:50:20
Author: robilad
Branch: HEAD
Tag: (none)
Log:
build fix for arm linux interpreter
Members:
ChangeLog:1.5221->1.5222
config/arm/linux/md.c:1.8->1.9
Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.5221 kaffe/ChangeLog:1.5222
— kaffe/ChangeLog:1.5221 Tue Jan 22 23:21:21 2008
+++ kaffe/ChangeLog Sun Jan 27 01:50:20 2008
@@ -1,3 +1,8 @@
+2008-01-25 Dalibor Topic
+
+ * config/arm/linux/md.c (flush_dcache): Only
+ declare for JIT engine.
+
2008-01-22 Dalibor Topic
* kaffe/kaffeh/Makefile.am (kaffeh_LDADD, AM_CPPFLAGS):
Index: kaffe/config/arm/linux/md.c
diff -u kaffe/config/arm/linux/md.c:1.8 kaffe/config/arm/linux/md.c:1.9
— kaffe/config/arm/linux/md.c:1.8 Sun Apr 22 23:39:20 2007
+++ kaffe/config/arm/linux/md.c Sun Jan 27 01:50:22 2008
@@ -26,6 +26,7 @@
#endif
}
+#ifdef TRANSLATOR
/**
* Shamelessly stolen from parrot… ([perl]/parrot/jit/arm/jit_emit.h arm_sync_d_i_cache)
*
@@ -41,3 +42,4 @@
: “r” ((long)start), “r” ((long)end)
: “r0″,”r1″,”r2″);
}
+#endif
—————————————–
After applying these changes, we compiled successfully, moved the images from build/tmp/work/… to the Freerunner, setup the libraries and tried running, only to get a Stackoverflow exception before the class file even loaded.
So, we moved to option #2. JamVM.
JamVM and classpath are two packages which were already in the openmoko environment and were built easily with default values. Ported the ipks for both packages to the device, installed and java works.
The problem is that JamVM will be using GNU Classpath which is known to have issues with some of the apps we’re used to. So, we’ll have to address these issues as they arise. For now, we can be happy that java is operational on our Freerunner.
Search
Recent Comments
- Khushal Khan on Dynamic Behavioral Attestation for Mobile Platforms
- Dynamic Behavioral Attestation for Mobile Platforms - Project « recluze on DBAMP
- shazkhan on Backing up OpenMoko FR before bricking it and getting your custom kernel and rootfs onto it …
- shazkhan on Getting Java on Openmoko
- shazkhan on A Standardized .bib File
Archives
- January 2009 (1)
- December 2008 (1)
- November 2008 (7)
- October 2008 (4)
- September 2008 (2)
- August 2008 (4)
- July 2008 (1)
- June 2008 (5)
- January 2008 (5)
- December 2007 (5)
- November 2007 (5)
- October 2007 (3)
- September 2007 (6)
- August 2007 (14)
- July 2007 (25)
- June 2007 (24)
- May 2007 (33)
- April 2007 (70)
Categories
- Achievements (7)
- Announcements (17)
- Blogroll (1)
- Conferences (11)
- Formal Methods (8)
- Ideas (11)
- Isabelle (6)
- Linux (18)
- News (28)
- Publications (1)
- Resources (31)
- SELinux (10)
- Trusted Computing (11)
- Uncategorized (106)