Getting Started

From OpenEZX
Jump to: navigation, search

Trying an OpenEZX kernel on a Motorola EZX phone, step by step

This little introduction to OpenEZX should help you to boot a custom kernel on theses highly integrated and very specific devices called 'EZX phones', and finally, to test the FSO, Openmoko, Metano Linux Series, Qt-extended, Opie, GPE , or maybe, with some modifications on the kernel ([1]), non GNU, brand new Android, and any other (alternative) systems (or fun stuff :-) ) that can run in these Motorola's phones. Some of theses are specially developed for Motorola EZX Phones... Like Metano Linux ME..that uses Qtopia as GUI and have functions of phone


Please try to follow theses different steps in the good order:

Contents

Warning

This, even if it change nothing on your original phone's software, could easily damage your phone. Following these steps should not break your phone, but there is a possibility it could. The authors, nor the OpenEZX Project accept no responsibility for any problems (with your phone, or otherwise!) that might arise as a result of following these instructions.

As long as you don't write to the Internal Flash, either to store the alternative rootfs, or change or add a bootloader, OpenEZX does not interfere with your phone's original software (though does allow you to, so be careful!) but legally, it might avoid your phone's warranty...


A) Get moto-boot-usb, gen-blob, and boot the kernel

OpenEZX's moto-boot-usb is a tool that can be used to upload a kernel to a Motorola EZX phone, using the USB cable. More infos at Bootloader.

For a recent 2.6 kernel to boot, due to a bugPXA-UDC bug, we need our second stage bootloader, 'gen-blob' (for "generic blob").

Gen-blob is a second stage bootloader, its purpose is to be flashed, but for testing, it will work the same if you send it to ram with moto-boot-usb, even without any SD card in the phone, we will describe precisely that use case below.

Notes:

As you boot the phone via its usb cable, the phone is started in "flash mode". In this "flash mode" is not possible to use the Baseband Processor (the modem), it is shutdown (no phone calls, SMS, bluetooth, GPS on A780, etc...).

Also, on a GEN2 device, you'll not be able to send any command line parameters without gen-blob, this is due to MBM restrictions. Machid, as a small asm hack before the kernel, does works with any bootloader.


Get a kernel

  • Older kernels oldies,(wich will maybe respond to old EZX machid: 867 ) were compiled for a specific device and maybe not work on all phones, so be very careful (can be dangerous to try 'blindly' an old build, and support cannot be easily done)!

=> Now an OpenEZX kernel is build for all the EZX phones and you need to specify the right machine ID for it to properly work on the desired phone. See "Machine ID (machid)", to find the good machid of your phone.

You can pick a kernel image in the ao2 user-space,have the modules and the latest kernels (.config and build logs are also available) to quickly try a recent kernel.

For instructions on how to build a custom OpenEZX kernel, refer to Kernel hacking - linux-2.6. See also /Documentation/arm/README in the kernel source tree.

Get moto-boot-usb and gen-blob

Pick a compiled moto-boot-usb from here. Pick a compiled gen-blob from here.

- Compiling moto-boot-usb from the sources:

Make sure you have a linux kernel's tree to point to ( at least version 2.6.28RCx, kernel version 2.6.27 should work too, but needs to be configured for arm).

You probably need to install these packages:

libusb-devel package installed (recommended version >= 0.1.12).

autoconf

pkg-config

git

git clone git://git.openezx.org/moto-boot-usb.git 
cd moto-boot-usb
./autogen.sh
./configure --with-kernel-dir=/path/to/a/2.6.27/or/higher/kernel
make
cd src
chmod +x moto-boot-usb

For informations on how to build, (and use flashed) gen-blob, please refer to Dual boot.

Machine id's (machid)

Phone MachID
A780 1740
E680 1741
A1200 1742
E6 1743
E2 1744
A910 1745
MotoQ (Q9,Q9c) 1980
No machID (i.e. for genblob) 0

See [2] (our devices are around 1740, as you noticed) for more infos.

Sending the kernel to boot

First you need to put the phone in the "MBM reflash mode".

If you don't know how to do this follow instructions here: "Enter the bootloader"

  • Connect the phone to the USB cable if it wasn't done yet.

Wait some few seconds for the device to be properly enumerated by your box.

  • Then, on the computer, as root or sudo-ing, run:
./moto-boot-usb setflag usb          
./moto-boot-usb gen-blob 0            

Ok, wait one more second then make sure the phone wrote "USB Ready" in the top of the screen. At this step you have genblob in USB mode and properly boot linux (without having to flash anything on the phone but you can't call or use the modem, remember: the phone has been started in flash mode).

Note: At this step you will maybe need to unplug/plug the usb cable for proper usb re-enumeration of the "new device" or sending the kernel will not work.

  • Finally, the last moto-boot-usb command to load the kernel:
./moto-boot-usb zImage-xxxx <machid> "<optionals commandline parameters in quotes>" <optional initrd>

After a short time the screen should go funny, then you should see Linux booting!

Optionals functionalities and command line parameters

Could be any standard kernel command line (so called "CMDLINE") parameters (in the moto-boot-usb command they have to be quoted and separated by spaces).

Defaults parameters (that are compiled in kernel by default) change rarely. Override them or change them yourself and build your kernel for your convenience, it can be interesting to take a look at them for example, here :-) /arch/arm/configs/ezx_defconfig of the kernel tree, at the line "CONFIG_CMDLINE=".

At the time of writing, default command line parameters should be:

console=tty1 root=/dev/mmcblk0p2 rootfstype=ext2 rootdelay=1 \
ip=192.168.0.202:192.168.0.200:192.168.0.200:255.255.255.0 debug

All parameters are described in /Documentation/kernel-parameters.txt in the kernel source tree.

This manual page at kernel.org can be more verbose and helpful too.

Examples:

  • Overide default filesystem type for rootfs partition:
rootfstype=ext3
  • Place the rootfs on the third partition of the SD/MMC :
root=/dev/mmcblk0p3
  • Network configuration can be overridden to suit your configuration as well with:
ip=<client-ip>:<server-ip>:<gw-ip>:<netmask>:<hostname>:<device>:<autoconf>

Note that the last three (<hostname>, <device>, <autoconf>) aren't necessary to have a working setup.

<server-ip, <gw-ip> and <netmask> are also there in case you would need to use any other services from your host computer.

  • Specify the RAM memory size and layout :
mem=32M@0xA0000000 mem=16M@0xAC000000
  • console= parameter is explained and some of its uses are described on Serial console (custom hardware/cable is also needed).

B) Network and NFS solution to try OpenEZX

Rootfs on NFS is a solution to store the root filesystem, and booting your phone with linux stored in a place in your hard-disk, instead of having it on the SD card, and can be easier to experiment, to try some softwares on the phone from an hard-disk folder...

Just follow this SD card related section, replacing the SD card by the emplacement you choosed for the so-called "export" directory, wich will become the path of your "nfsroot". Of course, doing this way, you can skip the steps partitioning, and formatting the SD card of this tutorial as well.

See Rootfs on NFS for network configuration as well (both usb-network sides's setups will differ from the ones used with motorola's firmware). FIXME: add bridging setup.

C) Putting a rootfs image on an (Micro) SD Card to try or use OpenEZX

For now, the kernel can boot, but does it stop to a step it search for a 'rootfs' and hangs up writing some "unable to find rootfs at:..." lines? This is normal, we will try to fix this in the next paragraphs. :-)

The SD/MMC card needs to be partitioned into two partitions: one FAT(or VFAT) partition, and one EXT2 partition used as root file system.

Creating the partitions on the SD card

For this first example, I recommend a first 600MB fat/fat32 partition and a second ext2 one using the rest (my config for an 1Gig SD).

BACKUP YOUR DATAS ON THE SD BEFORE GOING FURTHER, NEXT STEPS WILL ERASE THEM!

Open a shell and launch the GNU fdisk utility (always as root or sudo-ing):

fdisk -l

Identify your SD/MMC card, then, assuming you find this is: /dev/mmcblk0

fdisk /dev/mmcblk0 
      ^–––––––GUN LOADED !!–––––––– 

Remember here the sd card is called /dev/mmcblk0 but this can be different on your computer.

  • Delete all partitions of the SD/MMC
push [d] until there is no more parts 
  • Then create a first partition of 600MB
push [n] , [p] as primary, and reply the 'wizard' ('1' then '+600M')
  • Then create a second partition
push [n] again, [p] primary, then ('2' then [ENTER], 
fdisk's default value always use all resting space
  • Change the first partition to "DOS" type
push [t], and [6] ("6" means FAT16 type)
  • Change the second partition to "linux" type
push [t], and type 83 (for a linux filesystem)
just to ensure, as GNU fdisk's newly created partitions are always type "83"
  • Write this partition table
push [w], this confirm and exit datas will be lost (push [q] to exit and cancel changes)

Creating file systems (format), we need a first VFAT and second EXT2

Partitions are made, but need to be formatted to be used:

First partition on the Sd need to be a FAT or FAT16 partition, it is used for media files with the original firmware and gen-blob may also use it for its "/boot" folder. I would recommended to format this partition with inserting in the target phone, the just partitioned SD (read above), and let the original motorola system format it for you. But you should also be able to format it with dos, windows or dosfstools (mkfs.vfat) on a linux box:

mkfs.vfat /dev/sda1 (for VFAT)

Second (and others) partition should be linux and formatted in EXT2 (or any other filesystem if supported by your kernel) to be used as '/' with OpenEZX (it is the default 'rootfs' place):

mkfs.ext2 /dev/sda2

Remember here the SD card is called /dev/sda (and first and second parts of it respectively /dev/sda1 and /dev/sda2) but this can be different on your computer.

Download a recent image for our phones

Most of the alternatives systems (we will called them the "rootfs") have their own web pages, and wikis (see the top of this page), can be build with their OpenEmbedded's scripts collection and some images may also be download-able at Angstrom Distribution. See More infos on Angstrom here and for Openembedded, you can see this or this

There are pre-compiled images for the A780 (that might works also with others phones) in sub folders at

http://www.angstrom-distribution.org/unstable/images/a780/

For what we are planning to do any of the images should be acceptable. Choose the one you want and download it.

Note that Developer's web spaces are also generally full of testing images that you just have to unpack in your sd to try :) . In the Rootfs on SD page, there is yet another rootfs "collection".

Unpacking an image into the card

Now that we have prepared two new partitions (as long as you don't use gen-blob dual boot functions, you -strictly speaking- will only need the ext2 partition and you can let the phone stock operating system format the VFAT one for you).

Assuming your card is at /dev/sda, in command line, type:

#as root, or using sudo:
mount -t ext2 /dev/sda2 /SD/MMC/MOUNTING/FOLDER

#You have mounted the SD or MMC card.
#Then for extracting the rootfs image, type:
#Also as root, or using sudo: 
cd /SD/MMC/MOUNTING/FOLDER/
tar xvjf /PATH/OF/THE/DOWNLOADED/IMAGE/<NAME OF YOUR IMAGE>
#Works for a .tar.bz2 compressed image, use 'tar -xvzf' for a .tar.gz compressed image.
sync
#This ensure copying is finish before doing anything else.
cd ~/
#Exit its folder before unmounting the SD/MMC.
umount /dev/sda2
#Remember our SD card is named /dev/sda here, and this may differ on your own computer.

Some common problems are described here, and here in the general "issues" page.

Add softwares to the distro's rootfs

To find out how the distro's specific package management system works, please refer to the disto's website directly (see links in the first paragraph on top of this page). Some use ipgk, pkg systems and software package, all of them offers a lot of attractive softwares in several repositories. Trying eabi arm binaries packages can work, (extraction of debian armel packages? ) might also work, for simple tools.

Footnotes:

pxa-udc bug There is a bug in the mainline pxa-udc's driver (not used in OpenEZX's 2.6.25 or older kernels that used a different pxa-udc driver and don't necessitate the 'moto-boot-usb gen-blob 0' command) that cause a "kernel panic", so the only way to use usb without any changes on this driver is to boot using a second stage bootloader, gen-blob, that "prepare" the phone in a way the driver can work with it, and not cause a panic.

Oldies History: until 2.6.25, kernel were specifics to a device, each phone had it's kernel. Then developers decided to use the so called "platform device" logic on the code and machid were registered for all EZX devices, this gave an unique kernel for all phones. On 2.6.25, and 2.6.26 there is the first try to the 'machine independent kernel', and this was working with different machine id's than now. (this due to a double registration in kernel's database...now fixed). Note also that old kernels sometimes don't support any commandline parameters.


Other tutorials (outdated) goxboxlive's tutorials here, describing a flash method using an OpenEZX kernel and mtd-utils.

http://www.linuxtogo.org/~goxboxlive/A780/bootloader/HOWTO_FLASH_A780.TXT

and here http://www.linuxtogo.org/~goxboxlive/A780/images/README

Personal tools