Back to the home page
  

AquaPad


FIC AquaPad - is lovely wireless web pad from First International Computer Inc.

You could also find useful info about AquaPad here.

How to patch AquaPad Compact Flash
There could be few reasons when you want to patch binary image instead of
building your own. In my case I had an image in my AquaPad built from the
newer sources than publicly available Midori-1.0.0-beta3. I wanted to add
JVM and my Java application and also modify Start Menu, but naturally didn't
want to downgrade rest of the image back to Beta3.

Warning! I've tried hard to make sure there's no mistakes in below description,
but I can't guarantee it. So use it at your own risk.

1. Transfer Compact Flash (CF) image to the bigger CF.

There were two options available to me to read/write image from internal CF
after it got extracted from AquaPad - USB CF reader from SanDisk and PCMCIA
adapter from Kingston (I use laptop). Adapter has difficulties figuring out
CF "geometry" correctly so I end up using reader. Here is what I did.

- Pull original 32MB CF made by Feiya out of AquaPad and stick it in SanDisk
  reader, note USB device got registered as sda

- Check partitioning:
  #fdisk /dev/sda

  Disk /dev/sda: 1 heads, 62 sectors, 1015 cylinders
  Units = cylinders of 62 * 512 bytes

     Device Boot    Start       End    Blocks   Id  System
  /dev/sda1   *         2        88      2697   83  Linux
  /dev/sda2            89       175      2697   83  Linux
  /dev/sda3           176       180       155   83  Linux
  /dev/sda4           181      1015     25885   83  Linux

- Save bootloader and MBR:
  #dd if=/dev/sda of=/usr/archive/AquaPad/MBR bs=512 count=1

- Save partitions:
  #cp /dev/sda1 /usr/archive/AquaPad/sda1
  #cp /dev/sda2 /usr/archive/AquaPad/sda2
  #cp /dev/sda3 /usr/archive/AquaPad/sda3
  #cp /dev/sda4 /usr/archive/AquaPad/sda4
  #sync

- Replace original 32MB CF with the new 128MB CF made by Apacer in the CF reader

- Copy bootloader to the new CF. It'll also create partition table like in
  original 32MB CF. Theoretically you would need to copy only first 446 bytes
  occupied by bootloader (the rest 66 bytes of MBR are taken by partition table),
  but I found it more reliable to copy entire MBR and than recreate partition table:
  #dd if=/usr/archive/AquaPad/MBR of=/dev/sda bs=512 count=1

- Repartition CF to use full 128MB capacity:
  #fdisk /dev/sda:

  Disk /dev/sda: 1 heads, 62 sectors, 4034 cylinders
  Units = cylinders of 62 * 512 bytes

   Device Boot    Start       End    Blocks   Id  System
  /dev/sda1   *         2       134      4123   83  Linux
  /dev/sda2           135       267      4123   83  Linux
  /dev/sda3           268       274       217   83  Linux
  /dev/sda4           275      4034    116560   83  Linux

- Copy backup partitions back to CF:
  #cp /usr/archive/AquaPad/sda1 /dev/sda1
  #cp /usr/archive/AquaPad/sda2 /dev/sda2
  #cp /usr/archive/AquaPad/sda3 /dev/sda3
  #cp /usr/archive/AquaPad/sda4 /dev/sda4
  #sync


2. Building Midori-1.0.0-beta3.

I needed to build Midori to use it's packcramfs, mkcramfs, remote upgrade mechanism,
etc.

- Development box is:
  #cat /etc/redhat-release
  Mandrake Linux release 8.2 (Bluebird) for i586

- For convenience:
  #export MIDORI_HOME=/usr/local/src/midori-1.0.0-beta3

- There were numerous errors, while building Midori. During build it complained about
  missing libiberty.a so syslinked it as
  #ln -s $MIDORI_HOME/cache/tools/i686-ml-linux/lib/libiberty.a /usr/lib/libiberty.a

- Than it complained about true/false declarations. Used Felix's article
  (http://sourceforge.net/mailarchive/forum.php?thread_id=593923&forum_id=2274) to
  fix it - cut out his patch from the article, added missing stdbool.h, put into
  $MIDORI_HOME/cache/build/gdb-5.0/bfd.patch and applied it as `patch -p0`.

- Also used Thomas's article to fix issue with @ref{}
  (http://sourceforge.net/mailarchive/forum.php?thread_id=673163&forum_id=2274)
  After that images seem to be compiled.

- To start upgrade http server and IIRC to generate original *.tar.gz in the
  $MIDORI_HOME/cache/image/upgrades:
  #cd $MIDORI_HOME
  #make upgrade

- To stop upgrade server (we'll run it again when necessary files will
  be generated):
  #Ctrl-C

- You might also find these links useful to build Midori:
  patches - http://sourceforge.net/tracker/?group_id=22351&atid=375388
  support - http://sourceforge.net/tracker/?group_id=22351&atid=375387
  bugs - http://sourceforge.net/tracker/?group_id=22351&atid=375386
  tracker - http://sourceforge.net/tracker/?group_id=22351
  midori-devel archive - http://sourceforge.net/mailarchive/forum.php?forum_id=2278


3. Patching CF.

- A big help in doing so was response of Thomas Dodd to my request
  (http://sourceforge.net/mailarchive/forum.php?thread_id=774564&forum_id=2278).

- Let's see what's in the original AquaPad partitions:
  #export PATH=$PATH:$MIDORI_HOME/cache/tools/bin (where packcramfs and friends are)
  #cd $MIDORI_HOME
  #packcramfs -p /usr/archive/AquaPad/sda4
  ....
  overall size:               26506240
  ....
  used partitions:            4
  ....
  [00]: * /                   (edition 1008579018, start=0x00001800, size=4096 bytes)
  [01]: * usr                 (edition 1008579018, start=0x00002800, size=20025344 bytes)
  [02]: * usr/X11R6           (edition 1008579018, start=0x0131b800, size=3223552 bytes)
  [03]: * usr/X11R6/lib/X11/fonts (edition 1008579018, start=0x0162e800, size=1183744 bytes)

- Prepare image for expand. I wanted to add some entry points to the menu, which I know
  is at /usr/local/lib/X11/icewm/menu so to extract usr image out of cramfs:
  #mkdir binaries
  #packcramfs -x /usr/archive/AquaPad/sda4 01 binaries/fs_sda4_01

- Expand image to $MIDORI_HOME/binaries/usr:
  #mkdir /mnt/cf
  #mkdir -p binaries/usr
  #mount -t cramfs -o loop binaries/fs_sda4_01 /mnt/cf
  #cd /mnt/cf
  #find . -print|cpio -pmd $MIDORI_HOME/binaries/usr

- Image usr is convenient location to add new programs (JVM, apps, etc.) to.
  For development I decided temporarely put my additions to external CF and only
  pieces required by new menu entries to usr. This way I could easily try different
  JVMs, new builds of my application without upgrading internal CF. For example to
  run /tmp/extra/scripts/runpos.sh (external CF gets mounted to /tmp/extra) I added
  menu entry to /usr/local/lib/X11/icewm/menu:
  menu "POS" folder {
    prog Pos pos runpos.sh
  }

- These were also added:
  - binaries/usr/local/lib/X11/icewm/icons/pos_32x32.xpm
  - binaries/usr/local/lib/X11/icewm/icons/pos_16x16.xpm
  - binaries/usr/bin/runpos.sh->/tmp/extra/scripts/runpos.sh

To upgrade usr file system in the packed cramfs 4th CF partition all.tar.gz
and usr.tar.gz have to be generated and placed into update host's
$MIDORI_HOME/cache/image/upgrades before running upgrade procedure on AquaPad.
usr.tar.gz contains usr.img.cram image, install and upgrade_packed scripts and
packcramfs binary executable. AquaPad first downloads all.tar.gz to find out
which images to download next.

- To generate new all.tar.gz:
  #cd $MIDORI_HOME/cache/image/upgrades
  #mkdir orig
  #mv * orig
  #cd orig
  #tar zxf all.tar.gz
  #mkdir all
  #mv install all
  #vi all/install (to replace "packed root" in the last line for "usr" as the next
    image to download)
  #cd all
  #tar zcvf ../../all.tar.gz ./*

- To extract contents of the original usr.tar.gz:
  #cd $MIDORI_HOME/cache/image
  #tar zxvf upgrades/usr.tar.gz

- Add whatever you want to add to $MIDORI_HOME/binaries/usr here

- To generate new usr.img.cram:
  #mkcramfs -e 1008579100 -n usr $MIDORI_HOME/binaries/usr usr.img.cram

- To generate new usr.tar.gz:
  #mkdir tmp
  #mv install packcramfs upgrade_packed usr.img.cram tmp
  #cd tmp
  #tar zcvf ../upgrades/usr.tar.gz ./*
  #cd ../upgrades;cp index.html index.html.orig
  #vi index.html (to delete all, but usr. Perhaps unnecessary)
  #vi options.txt (to leave only usr, perhaps also unnecessary)


4. Remote upgrade

- To start upgrade server on the upgrade host:
  #cd $MIDORI_HOME
  #make upgrade

- To disable APM on AquaPad:
  attach USB keyboard
  press PgUp during POST to get into CMOS setup
  change POWER MANAGEMENT/APM to DISABLED
  save changes and exit CMOS setup
  click "system update" button once AquaPad has been booted
  click "remote", enter upgrade host's IP and port 9999
  after that system will switch to shell and you'll see:
  "Waiting
  Remote update running
  Preparing system
  Working on "all"
  Working on "usr"
  Downloading usr .....
  Checking
  Packcramfs: not enough space, trying force
  Upgrade worked! Restarting system"

  Be aware that unlike Midori docs say about "upgrade" utility
  AquaPad's ficupdate (launched by "system update" button) doesn't ask
  if you want to update all, some partition, or individual file system
  images, it just loads whatever mentioned in all.tar.gz.

5. External CF

I have formatted CF with vfat and put on it whatever I wanted to experiment
with (IBM JRE 118, my POS Java application, etc.). For example to add JRE
I just copied entire JRE directory from my desktop (note, latest build from
AquaPad has Kaffe JVM). Script to start some app might look like:
#mount -t vfat /dev/sda1 /mnt/cf
#cat /mnt/cf/scripts/runpos.sh
#!/bin/sh
mem_sh_limit
low_mem=$?
if [ $low_mem -eq 128 ]
then
  mem_sh_msg
else
  mount -n -t vfat /dev/hdc1 /tmp/extra
  /bin/process "POS" "POS is booting, please wait..." 15 &
  /tmp/extra/ibmjre118/bin/jre LinuxPos
fi

Once you have your application debugged you can rebuild usr.tar.gz
and move it to internal CF.

Good Luck!
1