Flashing the Neo 1973

From Openmoko

(Difference between revisions)
Jump to: navigation, search
(Actually flashing things into the device)
(Actually flashing things into the device)
Line 98: Line 98:
  
 
  ./dfu-util -a u-boot -R -D u-boot-gta01bv3-r8_70124c2602ae2d4c5d3dba05b482d91548242de8_0_2040.bin}}
 
  ./dfu-util -a u-boot -R -D u-boot-gta01bv3-r8_70124c2602ae2d4c5d3dba05b482d91548242de8_0_2040.bin}}
 +
 +
This is simple - even if I find it somehow scary to flash the bootloader of a device. Don't be too scared, though: Unlike any other device I know the Freerunner contains a second bootloader on a write protected chip - that is still there, even if flashing the original bootloader goes horribly wrong. You can always make the phone use this bootloader instead by pressing the power button whilst pressing the Aux button. In theory it should therefore be impossible to brick your phone completely enough by flashing the bootloader that a debug board is needed to unbrick it.
 +
* Download the newest uBoot binary from http://downloads.openmoko.org/releases/Freerunner/
 +
* start the cellular phone by pressing power whilst pressing the aux button.
 +
* Run the following command: 
 +
dfu-util -a u-boot -R -D uboot-gta02v5-latest.bin
 +
* The device is now flashed:
 +
dfu-util - (C) 2007 by OpenMoko Inc.
 +
This program is Free Software and has ABSOLUTELY NO WARRANTY
 +
 +
Opening USB Device 0x0000:0x0000...
 +
Claiming USB DFU Runtime Interface...
 +
Determining device status: state = appIDLE, status = 0
 +
Device really in Runtime Mode, send DFU detach request...
 +
Resetting USB...
 +
Opening USB Device...
 +
Found Runtime: [0x1d50:0x5119] devnum=9, cfg=0, intf=0, alt=1, name="u-boot"
 +
Claiming USB DFU Interface...
 +
Setting Alternate Setting ...
 +
Determining device status: state = dfuIDLE, status = 0
 +
dfuIDLE, continuing
 +
Transfer Size = 0x1000
 +
bytes_per_hash=4316
 +
Starting download: [##################################################] finished!
 +
state(2) = dfuIDLE, status(0) = No error condition is present
 +
Done!
 +
Resetting USB to switch back to runtime mode
 +
* The last message (status(0)) tells us everything just worked fine - at the next boot the device will be started by the newest uboot loader.
 +
 +
  
 
To update the kernel:
 
To update the kernel:

Revision as of 06:03, 18 July 2008

This describes how to update your Neo1973 to the latest software. We'll update the kernel, the root filesystem and optionally u-boot partitions in the internal flash memory.

NOTE:
  • MacOS X users: please refer to MacOS_X.
  • Users without Linux please refer to No_Linux for the moment.


WARNING: If you're updating u-boot and don't have a Debug Board, you might render your unit unusable if the flashing procedure is interrupted


WARNING: If you have U-boot from before 2008 and upload a rootfs image that is smaller than the previous one, or if you have written to the rootfs, just flashing may not work - you may need to run a "nand erase rootfs" before you then upload your rootfs (details here). Running "nand erase rootfs" before flashing a new rootfs, is quick and saves you the time of a second rootfs upload. Attention: If you erase NAND without mentioning the partition to be erased, u-boot will be wiped out and the Neo will be bricked


Contents

Files to download

The rootfs & kernel images you download need to match. The loadable modules for the kernel are in /lib/modules/ on the rootfs partition - if you get the wrong combination, you will get some error messages during bootup that it cannot access /lib/modules/x.y.z-moko123 - in this case swap either the kernel or the rootfs to match the other's version. Unfortunately the rootfs filename does not seem to tell what kernel version it is compatible with, you just have to try a few. NOTE: At least some combinations seem to boot up fine even if the module versions mismatch so be sure to check the console while it's booting after flashing.

The "moko123" in the error message example above indicates the openmoko patchset version.

Necessary files are at:

A list of download locations can be found at Repositories. See Phase 1 Software Testing for a list of tested images.


Changelogs can be found at:


Get:

  • dfu-util (the precompiled binary on http://buildhost.openmoko.org is for Linux/i386)
    • (this is the part that runs on the PC, that pushes the files across the USB to the phone)
  • openmoko-devel-image-fic-gta01-2007********.rootfs.jffs2
  • uImage-2.6.21.*-moko*-r*_0_****_0-fic-gta01.bin
  • for phase 0 (Bv03) phones:
    • Tested by a few people:
      u-boot-gta01bv3-r8_70124c2602ae2d4c5d3dba05b482d91548242de8_0_2040.bin
      MD5SUM: 60c5aeba1bd6642b05b3a5e6f2dafe83
    • Tested by hrw:
      u-boot-gta01bv3-r8_70124c2602ae2d4c5d3dba05b482d91548242de8_0_2062.bin
      MD5SUM: 716f1eba9b0f2be4a0a3be4a56724935
  • for phase 1 phones, uboot update should not be necessary.

Preparing the device for DFU mode

You'll need to boot your openmoko into uboot menu. To do this:

  • Unplug all usb devices from the host.
  • Hold the phone's AUX button and then press the phone's POWER button.
    • You'll need to hold the POWER button for about 4 seconds before the device will turn on. Otherwise the screen will only flash white for a second and the phone won't power up.
  • The u-boot menu should appear:
U-Boot ..

=== BOOT MENU ===

BOOT
Set console to USB
Set console to serial
Power off
Boot from SD
Factory reset

Press [AUX] to select, [POWER] to execute.
  • Plug Neo1973 into host with supplied USB cable. (Plug the phone directly into the host not via a hub.)

Note: If the bootloader remains inactive for about 30 seconds, that is no keypresses or no use of the serial console, the device will automatically power down. You can prevent this by just pressing the AUX button every 30 seconds or so or by telling the bootloader to not exhibit this behaviour. To do so, please connect to the bootloader:

cu -l /dev/ttyACM0
GTA01Bv4 # setenv boot_menu_timeout 65000
GTA01Bv4 # saveenv

For those that are unfamiliar with cu, to exit you need to press "~."

(You may have to install the uucp package to have access to cu, and maybe also "chown uucp:uucp /dev/ttyACM0" as root before it will work)

No further navigation is needed in u-boot - the device will automatically start flashing the images when told to do so by dfu-util below. After flashing all the files, you can choose the "Boot" option to boot the newly flashed stuff.

Actually flashing things into the device

Double check that u-boot matches your hardware version. You'll probably only want to update u-boot if you have the debug board for fixing failed u-boot updates. You can also check the current partitions.

Note: It may be necessary to run the application as root (at least in Ubuntu and Debian).

Note: In case there are more than one available usb devices use -d 0x1457:0x5119 option.

To update u-boot:

First determine what hardware revision you have finding hardware revision, so that you can download and install the correct bootloader.

WARNING: Do not update u-boot unless you have debug board or are really sure about what you are doing. Flashing a wrong u-boot image will brick your device! Note especially that image below is for GTA01B_v03, not GTA01B_v04
./dfu-util -a u-boot -R -D u-boot-gta01bv3-r8_70124c2602ae2d4c5d3dba05b482d91548242de8_0_2040.bin


This is simple - even if I find it somehow scary to flash the bootloader of a device. Don't be too scared, though: Unlike any other device I know the Freerunner contains a second bootloader on a write protected chip - that is still there, even if flashing the original bootloader goes horribly wrong. You can always make the phone use this bootloader instead by pressing the power button whilst pressing the Aux button. In theory it should therefore be impossible to brick your phone completely enough by flashing the bootloader that a debug board is needed to unbrick it.

dfu-util -a u-boot -R -D uboot-gta02v5-latest.bin
  • The device is now flashed:
dfu-util - (C) 2007 by OpenMoko Inc.
This program is Free Software and has ABSOLUTELY NO WARRANTY

Opening USB Device 0x0000:0x0000...
Claiming USB DFU Runtime Interface...
Determining device status: state = appIDLE, status = 0
Device really in Runtime Mode, send DFU detach request...
Resetting USB...
Opening USB Device...
Found Runtime: [0x1d50:0x5119] devnum=9, cfg=0, intf=0, alt=1, name="u-boot"
Claiming USB DFU Interface...
Setting Alternate Setting ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
Transfer Size = 0x1000
bytes_per_hash=4316
Starting download: [##################################################] finished!
state(2) = dfuIDLE, status(0) = No error condition is present 
Done!
Resetting USB to switch back to runtime mode
  • The last message (status(0)) tells us everything just worked fine - at the next boot the device will be started by the newest uboot loader.


To update the kernel:

./dfu-util -a kernel -R -D ./uImage-2.6.21.1-moko10-r0_0_1883_0-fic-gta01.bin

Flashing the kernel will probably take less than 1 minute. If you're having trouble, you may want to compare the output that you see to a "known good" U-Boot/ dmesg/ dfu-util output. The phone display should show "Starting DFU DOWNLOAD to partition 'kernel'.

To update the root filesystem:

./dfu-util -a rootfs -R -D ./Openmoko-devel-image-fic-gta01-20070501054014.rootfs.jffs2

Flashing the root filesystem will probably take around 13 minutes. Note that it can take over an hour if you are using a XEN VM for doing the flash.

Here is some "known good" output from U-Boot, dmesg, and dfu-util. The phone display should show "Starting DFU DOWNLOAD to partition 'rootfs'.

Notice that it's not normally necessary to update the modules anymore. It's just for people with special needs.


...now, you'll end up with system that boots, but does not see audio/SD card. You'll need to download corresponding modules.tgz and copy them over to openmoko. - UPDATE: GTA01 phones appear to not need this step, as long as you have installed a kernel that matches the version of the modules contained in the root image ('uname -r' will show the kernel version, and 'ls /lib/modules/' will show the modules that are present).

VERY IMPORTANT NOTE (I would consider that as a design flaw - either dfu-util should do it automatically): If you upload rootfs image that is smaller that previous one it won't work - you need to attach to the u-boot bootloader, erase NAND first and then upload your rootfs:

cu -l /dev/ttyACM0
GTA01Bv3 # nand erase rootfs

Old versions of u-boot are buggy: You may have to press the AUX button every 25 seconds or so to prevent the phone from going to sleep while being flashed. It also does not erase rootfs before flashing it... to do that, do minicom /dev/ttyACM0, then nand erase rootfs.

Good luck!

Where to go from here

So, now you have one of the more recent kernel and rootfs images, or one of the (semi)official ones, whats next?

You probably want to set up USB_Networking and then configure your Neo1973 some more.

Do not forget to update your Neo1973 using

ipkg update && ipkg upgrade

or (newer versions)

opkg update && opkg upgrade


and have a look at additional ipkg repositories.

Troubleshooting notes

If you're facing errors in seemingly random places during the flashing of images, most likely the USB hub or cable through which your Neo1973 is connected is of too poor quality. It is recommended that you always connect the phone directly to the host when using dfu-util.

If dfu-util reports a message like the following, before it starts flashing:
Resetting USB...
not at least 2 device changes found ?!?
Lost device after RESET?
just retry the command - it should work on a second run.

This message can also occur if you connect the usb cable before you are in the bootloader menu. You must carefully follow the sequence described at the beginning of this article and not connect the USB cable too early.

dfu-util does not seem to be able to download files if run from linux running under VMWare on a Windows OS host.

See other notes on Dfu-util page.

Personal tools

This describes how to update your Neo1973 to the latest software. We'll update the kernel, the root filesystem and optionally u-boot partitions in the internal flash memory.

NOTE:
  • MacOS X users: please refer to MacOS_X.
  • Users without Linux please refer to No_Linux for the moment.


WARNING: If you're updating u-boot and don't have a Debug Board, you might render your unit unusable if the flashing procedure is interrupted


WARNING: If you have U-boot from before 2008 and upload a rootfs image that is smaller than the previous one, or if you have written to the rootfs, just flashing may not work - you may need to run a "nand erase rootfs" before you then upload your rootfs (details here). Running "nand erase rootfs" before flashing a new rootfs, is quick and saves you the time of a second rootfs upload. Attention: If you erase NAND without mentioning the partition to be erased, u-boot will be wiped out and the Neo will be bricked


Files to download

The rootfs & kernel images you download need to match. The loadable modules for the kernel are in /lib/modules/ on the rootfs partition - if you get the wrong combination, you will get some error messages during bootup that it cannot access /lib/modules/x.y.z-moko123 - in this case swap either the kernel or the rootfs to match the other's version. Unfortunately the rootfs filename does not seem to tell what kernel version it is compatible with, you just have to try a few. NOTE: At least some combinations seem to boot up fine even if the module versions mismatch so be sure to check the console while it's booting after flashing.

The "moko123" in the error message example above indicates the openmoko patchset version.

Necessary files are at:

A list of download locations can be found at Repositories. See Phase 1 Software Testing for a list of tested images.


Changelogs can be found at:


Get:

  • dfu-util (the precompiled binary on http://buildhost.openmoko.org is for Linux/i386)
    • (this is the part that runs on the PC, that pushes the files across the USB to the phone)
  • openmoko-devel-image-fic-gta01-2007********.rootfs.jffs2
  • uImage-2.6.21.*-moko*-r*_0_****_0-fic-gta01.bin
  • for phase 0 (Bv03) phones:
    • Tested by a few people:
      u-boot-gta01bv3-r8_70124c2602ae2d4c5d3dba05b482d91548242de8_0_2040.bin
      MD5SUM: 60c5aeba1bd6642b05b3a5e6f2dafe83
    • Tested by hrw:
      u-boot-gta01bv3-r8_70124c2602ae2d4c5d3dba05b482d91548242de8_0_2062.bin
      MD5SUM: 716f1eba9b0f2be4a0a3be4a56724935
  • for phase 1 phones, uboot update should not be necessary.

Preparing the device for DFU mode

You'll need to boot your openmoko into uboot menu. To do this:

  • Unplug all usb devices from the host.
  • Hold the phone's AUX button and then press the phone's POWER button.
    • You'll need to hold the POWER button for about 4 seconds before the device will turn on. Otherwise the screen will only flash white for a second and the phone won't power up.
  • The u-boot menu should appear:
U-Boot ..

=== BOOT MENU ===

BOOT
Set console to USB
Set console to serial
Power off
Boot from SD
Factory reset

Press [AUX] to select, [POWER] to execute.
  • Plug Neo1973 into host with supplied USB cable. (Plug the phone directly into the host not via a hub.)

Note: If the bootloader remains inactive for about 30 seconds, that is no keypresses or no use of the serial console, the device will automatically power down. You can prevent this by just pressing the AUX button every 30 seconds or so or by telling the bootloader to not exhibit this behaviour. To do so, please connect to the bootloader:

cu -l /dev/ttyACM0
GTA01Bv4 # setenv boot_menu_timeout 65000
GTA01Bv4 # saveenv

For those that are unfamiliar with cu, to exit you need to press "~."

(You may have to install the uucp package to have access to cu, and maybe also "chown uucp:uucp /dev/ttyACM0" as root before it will work)

No further navigation is needed in u-boot - the device will automatically start flashing the images when told to do so by dfu-util below. After flashing all the files, you can choose the "Boot" option to boot the newly flashed stuff.

Actually flashing things into the device

Double check that u-boot matches your hardware version. You'll probably only want to update u-boot if you have the debug board for fixing failed u-boot updates. You can also check the current partitions.

Note: It may be necessary to run the application as root (at least in Ubuntu and Debian).

Note: In case there are more than one available usb devices use -d 0x1457:0x5119 option.

To update u-boot:

First determine what hardware revision you have finding hardware revision, so that you can download and install the correct bootloader.

WARNING: Do not update u-boot unless you have debug board or are really sure about what you are doing. Flashing a wrong u-boot image will brick your device! Note especially that image below is for GTA01B_v03, not GTA01B_v04
./dfu-util -a u-boot -R -D u-boot-gta01bv3-r8_70124c2602ae2d4c5d3dba05b482d91548242de8_0_2040.bin


To update the kernel:

./dfu-util -a kernel -R -D ./uImage-2.6.21.1-moko10-r0_0_1883_0-fic-gta01.bin

Flashing the kernel will probably take less than 1 minute. If you're having trouble, you may want to compare the output that you see to a "known good" U-Boot/ dmesg/ dfu-util output. The phone display should show "Starting DFU DOWNLOAD to partition 'kernel'.

To update the root filesystem:

./dfu-util -a rootfs -R -D ./Openmoko-devel-image-fic-gta01-20070501054014.rootfs.jffs2

Flashing the root filesystem will probably take around 13 minutes. Note that it can take over an hour if you are using a XEN VM for doing the flash.

Here is some "known good" output from U-Boot, dmesg, and dfu-util. The phone display should show "Starting DFU DOWNLOAD to partition 'rootfs'.

Notice that it's not normally necessary to update the modules anymore. It's just for people with special needs.


...now, you'll end up with system that boots, but does not see audio/SD card. You'll need to download corresponding modules.tgz and copy them over to openmoko. - UPDATE: GTA01 phones appear to not need this step, as long as you have installed a kernel that matches the version of the modules contained in the root image ('uname -r' will show the kernel version, and 'ls /lib/modules/' will show the modules that are present).

VERY IMPORTANT NOTE (I would consider that as a design flaw - either dfu-util should do it automatically): If you upload rootfs image that is smaller that previous one it won't work - you need to attach to the u-boot bootloader, erase NAND first and then upload your rootfs:

cu -l /dev/ttyACM0
GTA01Bv3 # nand erase rootfs

Old versions of u-boot are buggy: You may have to press the AUX button every 25 seconds or so to prevent the phone from going to sleep while being flashed. It also does not erase rootfs before flashing it... to do that, do minicom /dev/ttyACM0, then nand erase rootfs.

Good luck!

Where to go from here

So, now you have one of the more recent kernel and rootfs images, or one of the (semi)official ones, whats next?

You probably want to set up USB_Networking and then configure your Neo1973 some more.

Do not forget to update your Neo1973 using

ipkg update && ipkg upgrade

or (newer versions)

opkg update && opkg upgrade


and have a look at additional ipkg repositories.

Troubleshooting notes

If you're facing errors in seemingly random places during the flashing of images, most likely the USB hub or cable through which your Neo1973 is connected is of too poor quality. It is recommended that you always connect the phone directly to the host when using dfu-util.

If dfu-util reports a message like the following, before it starts flashing:
Resetting USB...
not at least 2 device changes found ?!?
Lost device after RESET?
just retry the command - it should work on a second run.

This message can also occur if you connect the usb cable before you are in the bootloader menu. You must carefully follow the sequence described at the beginning of this article and not connect the USB cable too early.

dfu-util does not seem to be able to download files if run from linux running under VMWare on a Windows OS host.

See other notes on Dfu-util page.