Posts Tagged: ipaq

2005
09
aug

Running Linux on iPaq 1940


Corrections:

  • Andrew Booth
  • Ilia Bazliancov

I have just received the latest issue of the Hungarian Linux magazine Linuxvilag. There was a note in the introduction, that this issue contained an article about the implementation of Linux on PDAs. I had previously researched this topic without any great success. The most famous – and maybe the only – Linux distribution for PDAs is Familiar Linux. The Familiar Project is quite active and I have just one problem with it: currently Familiar is supported “only” on these handhelds: iPAQ 3100, 3600/3700, 3800, 3900, 5100/5400/5500 series, HP Jornada 565/568 and 720 series and Sharp Zaurus SL-5500/SL-5600, SL-6000, SL-C750/SL-C760/SL-C860, but I have an iPaq 1940.

I quickly read the Linuxvilag’s article and I realized that this article was describing Familiar Linux as well. So, I’ve started Googling the web to see is there anything new about this topic. I found a page on Handhelds.org but it had “Work in progress” next to the project name. However, while browsing the links on this site I found a page with the following title: “iPAQ 1930/1940 adventures“. Cool, that’s what I searching for. The author talks about OpenEmbedded and the page contains some precompiled kernel images for different purposes:

  • SSH: we can connect to the handheld through the SSH protocol.
  • NFS Root: this image mounts a predefined NFS partition, and than starts GPE or OPIE from this NFS share.

The Bootldr – PDA Boot Loader – is currently not supported on the 1940, but HaRET – Handheld Reverse Engineering Tool – can help us to boot Linux on the PDA. HaRET is a small PDA application which loads a Linux kernel based on the predefined configuration file (default.txt). Here is the content of a possible default.txt:

set MTYPE 347
set KERNEL "zImage"
set INITRD "initrd"
set RAMADDR 0x30000000
set CMDLINE "console=ttySAC2,115200n8 root=/dev/ram ramdisk_size=4096 init=/linuxrc panic=30" 

bootlinux

But be careful, because HaRET clears everything from the memory of PDA. The data can remain on File Storage and on SD/MMC card but everything else will be deleted (it’s equivalent to a hardware reset).

To start with, I chose the SSH image and copied the files (config, default.txt, initrd, zImage and of course haret.exe) to my SD card through ActiveSync. I executed haret.exe – which read the configuration from default.txt – then I clicked on “Run” and Linux started to boot.

The screen went black and then the well-known and lovely penguin was displayed in the corner of the screen and some minutes later the “h1940 login:” as well. Unfortunately the linux console doesn’t support the virtual keyboard, so I had to login through ssh because I don’t have external keyboard for my handheld. The downloaded image sets the IP address of the iPAQ to 192.168.6.2. I had to change the IP address on my notebook as well, but first I had to remove and reattach the USB cable between the iPaq and the laptop. The connection was established by executing the command ‘ifconfig usb0 192.168.6.1′ on the laptop. I could ping the handheld, so, I tried ssh as well. It was successful so, in the first step I tested the most important commands of Linux. It seemed that everything worked the same as on a desktop computer, so my next goal was to run GPE on the PDA.

It wasn’t that easy. I downloaded the NFS image and I installed an NFS server on my laptop. I extracted one of the gpe images (from the previously-mentioned site) to the NFS partition. I copied the necessary files to the handheld, and then I executed HaRET. The PDA had mounted the appropriate NFS drive during the boot process and started GPE from that. The USB connection between the devices was very unreliable – maybe because of NFS. I had to ping the PDA from an other console to know when the connection was broken. When it happend I had to remove/reattach the USB cable and re-execute ‘ifconfig usb0 192.168.6.1′ to continue the booting process. Some minutes later the GPE login screen was displayed on the PDA’s screen.

I could run the GUI on the handheld but I could see it isn’t so useful if the external NFS partition is required for running. My great idea was to mount the GPE image through the loopback interface instead of NFS. I had to do the following:



  • Preparing a GPE image:
    dd if=/dev/zero of=gpe bs=1k count=40k
    mke2fs -i 1024 -b 1024 -m 3 -F -v gpe
    mount -o loop gpe /mnt/rootfs
    //copying files from GPE image to /mnt/rootfs
    umount /mnt/rootfs
    

    So, we now have a file which contains the GPE image.

  • Modifying the linuxrc in initrd:
    gunzip -d < initrd > initrd_unzipped
    mount -o loop initrd_unzipped /mnt/rootfs
    vi /mnt/rootfs/linuxrc
    //do the modifications
    umount /mnt/rootfs
    gzip -9 initrd_uncompressed
    mv initrd_uncompressed.gz initrd
    

    My linuxrc looks like this:

    #!/bin/sh export PATH="/bin:/sbin:/usr/sbin"
    echo "Booting Linux" > /dev/tty1
    sleep 3
    echo "Using kernel `uname -r`" > /dev/tty1
    echo "Configuring usb0 to 192.168.6.2..." > /dev/tty1
    ifconfig usb0 192.168.6.2
    echo "Mounting /dev/mmcblk0p1 to /mnt/sdcard..." > /dev/tty1
    mount /dev/mmcblk0p1 /mnt/sdcard
    echo "Setting up loop device..." > /dev/tty1
    losetup /dev/loop0 /mnt/sdcard/gpe
    echo "Mounting rootfs to /mnt/temproot..." > /dev/tty1
    mount -t ext2 -o rw /dev/loop0 /mnt/temproot
    echo "Executing pivot_root..." > /dev/tty1
    cd /mnt/temproot
    if [ ! -d initrd ]; then
        mkdir initrd
    fi
    pivot_root . initrd
    echo "Executing init..." > /dev/tty1
    exec chroot . /sbin/init > /dev/tty1 2>&1
    echo "Unmounting ramdisk..." > /dev/tty1
    umount /initrd
    

My new initrd is able to chroot to an image – in our example to gpe – and run its init script. The work was finished.

However, unfortunately some hardware components and features are currently not supported on this handheld (as far as I could see). It doesn’t handle the sound card, bluetooth but the worst: there is no power management, so I wasn’t able to suspend the system when I finished my work and I had to reboot the system every time when I turned on the iPaq. Hopefully I can solve these issues by compiling my own kernel.

I tried some tests with OPIE as well but they were unsuccessful. I did the same as with the GPE image but the boot process never finished. I could see some error messages when I monitored the boot process via SSH, but I haven’t started to solve these issues.

2005
11
júl

Linux futtatása iPaq 1940-en


Már nagyon vártam az aktuális havi Linuxvilág megjelenését, mert az előzetesek szerint a Linux és a PDA-k kapcsolatát fogja feszegetni az egyik írás. Korábban már olvastam és érdeklődtem a témával kapcsolatban, sajnos kevés sikerrel. PDA-ra a legelterjedtebb – és talán ezidáig egyetlen – disztribúció a Familiar Linux. A Familiar Project egy elég kiforrott és aktív project, számomra csak egy probléma van vele: nemes egyszerűséggel a Familiar jelenleg "csak" az iPAQ 3100, 3600/3700, 3800, 3900, 5100/5400/5500 szériáit, a HP Jornada 565/568 és 720 szériáit valamint a Sharp Zaurus SL-5500/SL-5600, SL-6000, SL-C750/SL-C760/SL-C860 szériáit támogatja, nekem viszont egy iPAQ 1940-es kézikütyüm van.

Megérkezett a legfrissebb Linuxvilág és már kerestem is a cikket, mely a PDA-Linux házasításról szól. Megtaláltam, és el kellett, hogy keseredjek. Bár a cikk nagyon érdekes, nekem sajnos nem segített, ugyanis a szerző az előbb említett disztribúcióval foglalkozik és egy támogatott iPAQ-el. Nos sebaj. Fel a fejjel és irány a Google. Lássuk van-e valami fejlemény iPAQ 1940 és Linux ügyben…

Nos, a Handhelds.org-on találtam egy kezdeményezést a 1940-es szériára, de fel van tüntetve, hogy "Work in progress", vagyis "Folyamatban…". Az oldal linkjeit végigjárva azonban beleütköztem egy oldalba, amely a kezdéshez megfelelőnek ígérkezett. Az oldal címe: iPAQ 1930/1940 adventures. Na ez az, amit már régóta kerestem. A site foglalkozik az OpenEmbedded-el és tartalmaz néhány előre lefordított kernel image-et különböző célokra:

  • SSH: ezen image segítségével SSH protokollon keresztül kapcsolódhatunk a PDA-hoz.
  • NFS Root: ez az image felcsatol a PDA-ra egy előre beállított NFS partíciót, majd arról elindítja a GPE vagy OPIE grafikus felületek egyikét.

A Bootldr – PDA Boot Loader – jelenleg még nem támogatott a 1940-es gépeken ezért a HaRET – Handheld Reverse Engineering Tool – segíthet abban, hogy működésre bírjuk a Linuxot a PDA-n. A HaRET egy apró, pár száz kilobájtos PDA alkalmazás, amely egy megadott konfigurációs file alapján (alapértelmezésben default.txt) betölti a lefordított Linux kernelt. Egy lehetséges default.txt tartalma:

set MTYPE 347set KERNEL "zImage"set INITRD "initrd"set RAMADDR 0x30000000set CMDLINE "console=ttySAC2,115200n8 root=/dev/ram ramdisk_size=4096 init=/linuxrc panic=30" 

bootlinux

Azonban óvatosan, ugyanis a Linux indítása után minden adat elvész, amely a PDA memóriájában tárolódott. A File Storage és az SD/MMC kártyákon megmarad az adat, de minden más elveszik (elvileg megfelel egy hardware reset-nek). Az első választásom az SSH-s image-re esett. Felmásoltam az iPAQ-ben lévő SD kártyára a megfelelő file-okat ActiveSync-en keresztül, úgy mint: config, default.txt, initrd, zImage és természetesen magát a haret.exe-t. Ez utóbbi exe-t elindítva, fel is ajánlotta, hogy a default.txt-ből fogja venni a beállításokat, majd "Run" és indult a csoda.

Egy pár másodpercre "bezizisedett" a képernyő, majd fekete lett és megjelent a bal felső sarokban a jól ismert és szeretett pingvin. A bootolási folyamat befelyezése után megjelent a "h1940 login:" felirat. A linux konzol nem tartalmaz virtuális billentyűzetet, külső billentyűzet híjján pedig maradt az ssh login. A letöltött image bedrótózva tartalmazza a 192.168.6.2-es IP címet. Szükséges volt tehát a notebook-om IP címét is utánaállítani. Ez azonban csak akkor vált lehetségessé, ha az USB kábelt le, majd visszacsatoltam a notebook-on. Ekkor az ‘ifconfig usb0 192.168.6.1′ parancs kiadásával életre is kelt a hálózati kapcsolat a két eszköz között. A pingre már válaszolt is a PDA, nem volt más hátra mint "besházni" a kis gépre, ami azon nyomban meg is történt. Leteszteltem a fontosabb Linuxos parancsokat, majd mikor meggyőződtem, hogy minden úgy működik mint egy asztali gépen is, célba vettem a GPE grafikus felületet. Ez már egy kicsit harcosabb feladat volt. Letöltöttem az NFS Root image-et és beélesítettem az NFS szervert a notebook-on. Az NFS partícióra kicsomagoltam a gpe-image-ek egyikét amelyet szintén a korábban említett oldalról töltöttem le. A szükséges file-okat felmásoltam az iPAQ-re, majd indítottam a HaRET-et. A bootolási folyamat során a PDA fel is csatolta a megfelelő NFS meghajtót és elindította az ott található GPE grafikus felületet. Ez azonban nem olyan egyszerűen történt, hogy egy mondatban lerendezzem. Az USB kapcsolat – valószínűleg az NFS-nek köszönhetően – állandóan szakadozott, így tehát a notebook-on egy új konzolon folyamatosan pingelnem kellett a PDA-t, hogy lássam mikor szakad meg az elérés, majd mikor ez megtörtént az USB kábelt ki- és vissza dugva – valamint az interfészt az "ifconfig usb0 192.168.6.1" kiadásával ismét felébresztve – figyeltem a betöltési folyamatot. Jó pár perc múlva – az izgalomnak köszönhetően ez inkább óráknak tűnt – megjelent a GPE bejelentkező képernyője.

Sikerült hát életre kelteni egy grafikus felületet is a handheld-en, de be kell látni elveszti a funkcionalitását a PDA, ha egy NFS meghajtó megléte is szükséges a használatához. Jött tehát a nagy ötlet, csatoljuk fel a GPE image-et NFS helyett loopback interface-en keresztül. Ehhez a követketőket kellett tennem: 

  • El kellett készíteni egy GPE image-et a következő módon:
dd if=/dev/zero of=gpe bs=1k count=40kmke2fs -i 1024 -b 1024 -m 3 -F -v gpemount -o loop gpe /mnt/rootfs//file-ok bemasolasa a GPE image-bol a /mnt/rootfs-be umount /mnt/rootfs

Elkészült a gpe file-unk, amely tartalmazza a GPE-t.

  • Módosítani kellett az initrd-ben lévő linuxrc-t:
gunzip -d < initrd > initrd_unzippedmount -o loop initrd_unzipped /mnt/rootfsvi /mnt/rootfs/linuxrc//modositasok elvegzese...umount /mnt/rootfsgzip -9 initrd_uncompressedmv initrd_uncompressed.gz initrd

Az én linuxrc-m így néz ki:

#!/bin/shexport PATH="/bin:/sbin:/usr/sbin"echo "Booting Linux" > /dev/tty1sleep 3echo "Using kernel `uname -r`" > /dev/tty1echo "Configuring usb0 to 192.168.6.2..." > /dev/tty1ifconfig usb0 192.168.6.2echo "Mounting /dev/mmcblk0p1 to /mnt/sdcard..." > /dev/tty1mount /dev/mmcblk0p1 /mnt/sdcardecho "Setting up loop device..." > /dev/tty1losetup /dev/loop0 /mnt/sdcard/gpeecho "Mounting rootfs to /mnt/temproot..." > /dev/tty1mount -t ext2 -o rw /dev/loop0 /mnt/temprootecho "Executing pivot_root..." > /dev/tty1cd /mnt/temprootif [ ! -d initrd ]; then	mkdir initrdfipivot_root . initrdecho "Executing init..." > /dev/tty1exec chroot . /sbin/init dev/tty1 2>&1echo "Unmounting ramdisk..." > /dev/tty1umount /initrd 

Ezzel el is készült a "saját" initrd-m amely már alkalmas arra, hogy egy image-re – jelen esetben a gpe image-re – chrootoljon, majd elindítja annak az init-jét. Nem volt hát más dolgom, csak hátradőlni és élvezni a munkám gyümölcsét…

Azaz mégsem! Ezzel sajnos nem ért még véget a dolog és nem véletlenül volt a Handhelds.org-on a "Work in progress" feltüntetve. A Linuxom ugyanis még nem kezeli a hangkártyát, a bluetooth-t, de ami a legrosszabb: nincs power management és ez amiatt is nagyon problémás mert így nem lehet a rendszert suspend-elni és minden egyes bekapcsoláskor újra kell indítani a Linuxot. Talán egy saját kernel majd megoldja ezeket a problémákat, de egyelőre még nem szántam rá magam, hogy hozzáfogjak.

Voltak kísérleteim az OPIE-vel is, de ezidáig nem jártam sikerrel. Hasonlóan próbákoztam mint a GPE-nél, de egy végeláthatatlan bootolási folyamat veszi kezdetét és a rendszer soha nem indul el. Ssh-n keresztül tesztelve sikerült kicsalnom néhány hibaüzenetet, de még nem fogtam hozzá a megoldás megkereséséhez. Amennyiben sikerül megoldanom, természetesen be fogok róla számolni.