IP0X Web Firmware Updates

The IP04 IP-PBXes I sell run the BAPS firmware. This is a package based system similar to apt-get. While updating applications is easy updating the Linux uImage requires an awkward RS232 serial cable. This is fine for geeks but very difficult for the average person using an IP04 as their small office phone system. The alternative Astfin and Switchfin IP0X build systems have a web based image update which is much cooler. Web based firmware updates are also common for other embedded devices like OpenWRT and even IP phones.

Briefly, the steps for a BAPs image installation are:

  1. tftp the image, flash the uImage and boot with the RAM based file system
    “root=/dev/mtdblock0”
  2. copy the root file system from RAM to flash (mtdblock2), then reboot with
    “root=/dev/mtdblock2”.

The problem is the “root=/dev/mtdblock0” and “root=/dev/mtdblock2” steps need to be performed in the boot loader using the serial cable. Not for the faint hearted. It also makes switching between IP0X firmware distributions painful.

So I have developed a two stage flashing procedure that works like this. First, flash uImage_r2.mtd0 from the Linux command line:
(cd /persistent if an Astfin box)
root:~> wget http://rowetel.com/ucasterisk/downloads/uImage_r2.mtd0
root:~> dd if=uImage_r2.mtd0 of=/dev/mtdblock1
root:~> reboot

The neat trick is that this image has “root=/dev/mtdblock0” hard coded in the kernel (via a small kernel patch), over-riding the u-boot “root=” settings. This patch doesn’t affect the Ethernet MAC. This image then boots, erases the mtdblock2 flash, then copies the RAM file system to flash. It then wgets uImage_r2.mtd2, which has “root=/dev/mtdblock2” hard coded into the kernel, and flashes this. This second image then installs various packages to bring up an IP0X ready to make phone calls. If an Internet connection is not available it looks for uImage_r2.mtd2 on a local tftp server on 192.168.1.1.

The system works quite well and is fast and reliable in practice. I’ve tested it by flashing about 20 IP0Xs. The IP01s need a special image to install their special brand of zaptel (the only change is one line to pull down the zaptel-ip01 package):
(cd /persistent if an Astfin box)
root:~> wget http://rowetel.com/ucasterisk/downloads/uImage_r2.mtd0.ip01
root:~> dd if=uImage_r2.mtd0.ip01 of=/dev/mtdblock1
root:~> reboot

I have also modified the BAPS uClinux.mk file to automatically make the .mtd0 and .mtd2 targets. You can customise the packages installed by tweaking the rc.normal file and rebuilding uImage_r2.mtd0:
host$ make -f uClinux.mk uImage.mtd0
The rc (executed by uImage_r2.mtd0) and rc.normal (executed by uImage_r2.mtd2) files are captured in this patch.

IP0X Roadmap and Ease of Use

This feature is part of a series of IP0X upgrades, including Asterisk 1.6, Dahdi, security upgrades, bug fixes, uClinux upgrades, and more work on the Mini Asterisk GUI. In particular I am really interested in exploring the ease of use meme. My goal is make the IP0X really easy to install and use in the small office environment for people who know nothing about Asterisk, Linux, and telephony.

I have a theory I would like to explore. One “problem” with the IP0X range is it’s low price (hundreds of $) compared to normal PBXes (thousands of $). There is just no room for regular margins needed by the “PBX guy” to install and maintain an IP0X phone system. So I think the IP0X needs to be really easy to set up and use. More like a Wifi router, ATA or DSL modem. That’s my thinking behind Mini Asterisk.

7 thoughts on “IP0X Web Firmware Updates”

  1. Isn’t there a typo in the following line?

    “root:~> dd if=uImage_r2.mtd0 of=/dev/mtdblock1”

    From the instructions, it looks like it’s actually “/dev/mtdblock0”, ie. the partition in the NAND that’s used to save the RAM-based image, before rebooting into Linux and copying that image to mtdblock2 to make the system persistent.

    Cheers,

    1. Hello Gilles,

      Here is the mtd layout from a running IP04:

      root:~> cat /proc/mtd
      dev: size erasesize name
      mtd0: 00300000 00001000 “ROMfs”
      mtd1: 00800000 00020000 “linux kernel”
      mtd2: 0f800000 00020000 “file system”
      root:~>

      So I think “root:~> dd if=uImage_r2.mtd0 of=/dev/mtdblock1? is correct. Also I have used this procedure many times on IP0X hardware now and it works well.

      Cheers,

      David

  2. Thanks David for the info. I’m still learning about Linux and embedded devices, and I wanted to make sure it wasn’t a typo.

    After going through dmesg, I seem to have understood that /proc/mtd0 is the RAM-based image, while mtd1 and mtd2 are two partitions in the NAND, where mtd1 holds the disk-based image while mtd2 is used to hold persistent data.

    Apparently, the reason for the two-step procedure above is due to a bug in Yaff which explains why we must first boot a RAM-based Linux before copying its live root filesystem to the NAND and reboot the Atcom.

  3. Hi,

    Any option to revert back to atcom atfin image without the serial cable. Their version of Asterisk seems more recent?

    Thanks,
    Stephane

      1. Hi David,

        Thanks for your quick answer.
        Sorry to sounds a bit thick (but I just got my IP02 and scared of brick it, especially as I didn’t get any serial module with it – and not sure where/how to get one). So telnet access is my only option to re-image.
        So if my understanding is right I should be able to take a switchfin image? How do I split it in mtd1 and mtd2? Or do I have to build a special one (how?). If you want to take this offline you can contact me at stephane dot mabille at gmail dot com

        Thanks! (and thanks for the fab project!)
        Stephane

  4. Hi Stephane,

    Sorry I don’t have much experience with the Switchfin images so it’s probably best to contact the switchfin guys for reflash instructions. If you email me your postal adress I can send you a serial daughter card.

    – david

Comments are closed.