Upgrading AVR32’s Linux using buildroot v2.3.0 without a JTAG

In this article I will discuss how to update Linux on the NGW100 without updating uBoot, since that is a big headache unless you have the Atmel JTAG (AVR JTAGICE mkII) device.

So I will admit originally I did not want to totally re-flash the device but ran into some problems when I was trying to develop applications for the included version of Linux. This all started when I wanted to compile PHP to run on the device, after cross compiling on my desktop I was getting errors such as the following when trying to run PHP:

can't resolve symbol 'atextit'

Which I later realized that there were some differences between the library on the device and the library in my Buildroot environment. So I decided that I must upgrade the installed version of Linux to the same version I compiled PHP with. Well this was a confusing task, the documentation was sparse and hard to understand. So I am documenting my process here.

Things you need:

  • Linux (Ubuntu is used here)
  • JTAGICE programmer (optional)
  • Tftp Server (preferred)
  • Compiled AVR32 Buildroot Environment
  • Serial Port and Cable
  • Serial Port Terminal Program (HyperTerminal or GtkTerm)

First, you must compile Buildroot, you can find instructions on how to do that on Atmel’s Buildroot site: http://www.atmel.no/buildroot/. If this is your first time using Buildroot or you are not too familiar with it, be sure to read that documentation throughly, as it tells you where to find the image files (buildroot-avr32-v2.*/binaries/atngw100/). We are interested in the rootfs.avr32.jffs2-root and rootfs.avr32.jffs2-usr files. If you have a JTAGICE programmer then you would also be interested in the u-boot.bin file, which you would use to upgrade your uBoot.

Secondly, setup your tftp server and host the rootfs.avr32.jffs2-root file on it. Here is a good tutorial on setting up atftp on Ubuntu Linux.

You can now update your NGW100 using TFTP, here are the commands you will need to use.

Disable write protection and erase the flash memory:
Uboot> protect off 0x20000 0x7EFFFF
Uboot> erase 0x20000 0x7EFFFF

Download the firmware from the TFTP server:
Uboot> set ipaddr 10.0.0.100
Uboot> set tftpip 10.0.0.1
Uboot> tftp 0x90000000 rootfs.avr32.jffs2-root

Copy to flash (this will take about 30-60 seconds):
Uboot> cp.b 0x90000000 0x20000 $(filesize)
Copy to Flash... done

Turn write protection back on:
Uboot> protect on all
Uboot>

Lastly reboot and cross your fingers, chances are it will fail with the following error:

find_inode failed for name=uImage
load: Failed to find inode
### JFFS2 LOAD ERROR<0> for uImage!
## Booting image at 10200000 ...
Bad Magic Number
Uboot>

This happens because in the most recent version of uBoot, the uImage moved from /boot/uImage to the root of the file system, you could recompile with it in the correct location, but there is an easier way. Enter the following at the uBoot command prompt:

setenv bootcmd 'fsload 0x90400000 /boot/uImage;bootm'

Everything should be working well now, except you will see some more strange errors during boot, this is because the /usr directory has not been updated and was compiled for the old OS version. So we must update the /usr directory with the new directory image. Use the following commands:

We must stop all running services that are running from within the /usr directory so we can unmount the directory. There is no quick and easy way of doing this other then just using ps to get a list of running daemons from within the /usr directory:

ps | grep /usr

Then we must kill those running daemons, you can do this the following way, replacing pid with the id you retrieved from the above command:

kill pid

Then try to unmount the directory:
umount /usr

If you are still unable to unmount the /usr directory then use the which command on the process name you retrieved from using the ps command. This will locate any other processes that are running out of the /usr directory. Then just kill them and try running umount again.

Once you have successfully unmounted the /usr directory, we can proceed with erasing the flash:

flash_eraseall /dev/mtd3

Now you will need to copy the rootfs.avr32.jffs2-usr file to a memory card or use wget to download it from a Http server. You can just put it into the /tmp directory:

Replace 10.0.0.100 with the IP of your server:
cd /tmp
busybox wget http://10.0.0.100/rootfs.avr32.jffs2-usr

And finally write the image to the flash memory:
dd if=/mnt/rootfs.avr32.jffs2-usr of=/dev/mtd3 bs=1056

Reboot and everything should load fine. I did notice that the SYS led now flashes instead of remaining on, not sure why. The blinking sys LED turns out to be the heartbeat of the system, when the board is idle it flashes slowly and when running a CPU intensive task it flashes rapidly proportional to the CPU load.

About the Author