Flashing the Neo FreeRunner/zh cn

From Openmoko

(Difference between revisions)
Jump to: navigation, search
(Flashing the boot loader to the NAND)
(烧写更新boogloader)
Line 148: Line 148:
 
</pre>
 
</pre>
  
== 烧写更新boogloader==
+
== 烧写更新boogloader ==
  
 
{{提示|大多数情况下,你并不需要重新烧写你的bootloader,一般在需要更新一些特定功能,或者需要解决一些bug时才有必要重新烧写你的bootloader。}}
 
{{提示|大多数情况下,你并不需要重新烧写你的bootloader,一般在需要更新一些特定功能,或者需要解决一些bug时才有必要重新烧写你的bootloader。}}

Revision as of 10:07, 10 February 2009


OpenMoko会不断发布最新的根文件系统(root file system)、内核(kernel)和[[Bootloader(called U-Boot) 的二进制映像(binary image)文件。这些文件可以被烧写到Neo FreeRunner的Flash memory (NAND) 中,从而达到更新系统套件的目的。你可以通过一根USB线,连接FreeRunner到电脑上,通过OpenMoko提供的烧写工具来更新系统。

Contents

3类软件组件and 2种存储器

FreeRunner的软件系统由3部分组成:

  • bootloader: 这是FreeRunner启动或者重启时执行的第一段小程序,它再启动其他软件系统。
  • kernel: FreeRunner采用的Linux内核。
  • root filesystem: 包括所有的应用程序和命令文件。

FreeRunner的这三类软件组件都打包成二进制映像文件进行发布。

FreeRunner有两种程序存储器:NOR flash与NAND flash。在PC机上,如果你想重装操作系统,你一般会使用一个光盘来启动系统,然后将操作系统从光盘拷贝安装到硬盘上。FreeRunner并没有光驱,但系统文件必须安装进内部的存储器(NAND flash)当中去。当然,一种可能的方式是从microSD卡来启动。

NOR flash是一个很小的程序存储器,里面存放着一段启动代码。当你需要重新安装系统,也就是需要重写NAND flash的时候,你可以从NOR flash启动来进行操作。一般来说,NOR flash是很少需要更新;如果需要,你可以从这里找到更新方法:Flashing NOR.。

NAND flash 就像PC机中的硬盘,它被分为三个分区,分别存放bootloader, kernel, 和rootfs。这三个分区分别可以独立的进行擦写更新。譬如,如果你想更新一个修改过的kernel,你只需要按照更新kernel的步骤进行操作就可以了。

注意:一般很少更新根文件系统rootfs及bootloader,因为有时只需要更新内核(kernel)文件就可以解决一些存在的问题,所以在更新之前请慎重考虑更新的必要性。

另一种方式: 将系统安装运行在 microSD 卡上

你可以将软件系统安装在microSD卡上,这样你可以从microSD卡启动并运行系统 boot from microSD card。这样可以同时保留在NAND flash上的系统,从而达到在FreeRunner上安装双系统的目的。(譬如,假如你的FreeRunner当前已经安装了2007.2的OM系统,你想在不擦除当前系统的前提下测试2008.08的OM系统,这种在microSD卡上的方式就是一个很好的选择了)

Software you need

#1 Tools for flashing: DFU-util and NeoTool

Command-line. DFU-util, the tool to flash the FreeRunner has to be installed on you laptop or desktop machine. It is available for Linux, MacOS X, and Windows (see links below). DFU-util allows you to connect to the FreeRunner through the USB cable and control its bootloader. That connection uses a special protocol which addresses the bootloader's interface, and differs from USB networking. For more details, see the separate dfu-util page.

GUI. Instead of the command-line-based DFU-util, you can use NeoTool, a graphical tool for flashing the FreeRunner: see the NeoTool page.

Linux: http://downloads.openmoko.org/releases/Om2008.9/dfu-util

Make sure it is executable by setting the permissions with this command: chmod a+x dfu-util

Linux 64-bit: You need 64-bit version of dfu-util, which usually can be found in your distribution repository. If your destribution does not provide 64-bit dfu-util, or it consistently fails with a "-62" error, you have two ways to go:

  1. Seek for 32-bit machine and do flashing form it.
  2. Use 32-bit chroot (on amd64 debian). Worked for me --Bubak 16:54, 4 September 2008 (UTC).
  3. Just try the 32-bit dfu-util. Worked fine on my x86_64 Fedora 10 --pcfe 2009-01-16.
    • I can confirm this (Gentoo multilib x86_64) --Unlotto 14:15, 4 February 2009 (UTC)

MacOS X: MacOS_X#Graphical_Flashing_with_Openmoko_Flasher

Windows: http://projects.openmoko.org/frs/?group_id=166&release_id=162

See additional driver installation instructions for Windows at Dfu-util-windows

Virtual machines While there has been some limited success reported using dfu-util from within a Virtual Machine (such as VMware), in general it is not possible to use dfu-util in this fashion. You must use dfu-util on an operating system that has direct access to the physical USB device hardware.

#2 需要烧写映像文件

3类软件组件都有各自的映像文件,你可以选择其中一个或者多个进行更新。大多数情况下,你需要更新kernel(uImage)和根文件系统(rootfs)。bootloader一般不需要更新,除非需要通过更新来解决某个发现的bug。

请参考Distributions 来选择你需要的软件系统,然后到Download 下载。

Boot the FreeRunner from NOR Flash

Booting from NOR Flash
  1. Read the other sections of this page first, because you will have 30 seconds to enter the flashing commands, come back here when ready.
  2. Do not connect the USB cable from the PC to your Neo FreeRunner yet (disconnect it).
  3. Boot your Neo FreeRunner into the NOR uBoot menu for flashing.
    1. Press and hold AUX button
    2. Press the Power button until the boot menu comes up
    3. This menu is labelled *** BOOT MENU (NOR) ***
    4. See also Booting the Neo FreeRunner
  4. Stay in NOR uBoot menu, do not select or enter any item in menu. Now you will be able to flash, make backups of your FreeRunner or query the FreeRunner with dfu-util.
  5. The FreeRunner only stays at the NOR boot prompt for about 30 seconds and then shuts off unless you do something.
  6. Connect your Neo to the GNU/Linux or Windows host via a USB cable.
  7. Now you can enter the dfu-util commands on your PC as described below.
  8. If the Neo FreeRunner turns off before you press start flashing (screen goes black), go back to step 2. If you start flashing in time, the phone will not turn off meanwhile.


Note that the dfu-util connection does not use Ethernet over USB - that is, you should not attempt to set up a usb0 network interface on your GNU/Linux host desktop (on Windows, you need a DFU class driver, or you can use the LibUSB-Win32 driver described on the Dfu-util-windows page). The dfu-util utility sets up its own connection to the FreeRunner. In fact, you will not be able to make an Ethernet-over-USB connection to the FreeRunner when it is at the uBoot menu; this type of connection is only available when the FreeRunner has booted fully.

After connecting the FreeRunner to your host via USB cable, you can test whether dfu-util "sees" the FreeRunner by executing:

dfu-util -l

If you get error messages from the dfu-util command then try again. Often it works on the second try.

dfu-util uses the DeviceFirmwareUpgrade protocol, and may list more than one device. If so, try unplugging the other device (e.g. a USB mouse) or using the -d switch to tell dfu-util which device it should talk to, as described at the relevant bug report [1].

Also, please remember to execute the dfu-util command with sufficient privileges (ie. root) -- you will need complete control over the usb bus.

备份

如果你很喜欢当前已有的系统,又想试试一些新的东东,你最好先做一个备份Backup.

Using dfu-util

dfu-util can be used to read flash memory, write memory, and get information from the device.

This is the general command format to write an image file to a (predefined) "partition name" (referred to as altsetting in dfu-util help/manual) :

dfu-util -a <altsetting> -R -D <file_name>

where:
-a altsetting : Specify the altsetting of the DFU interface by name or by number
-R  : Issue USB Reset signalling once we're finished
-D file_name : Write firmware from file_name into device

On Linux, you run dfu-util from a command shell prompt. If you have not put it somewhere on your command path you probably need to prefix it with a "./" like this ./dfu-util. On some systems you need to be root before this will work and on Ubuntu you must preface the command with "sudo" or you will get the following error: "Cannot claim interface: could not claim interface 2: Operation not permitted"

On Windows, you need to open a command window and run from a command line. Use Start-Run Program and type "cmd" to open a Window.

More detailed manual for dfu-util is available here : Dfu-util

GUI frontend for dfu-util (and more): NeoTool

烧写更新 Kernel

提示: 本操作需要在u-boot的启动菜单界面下进行,在按电源键启动手机时同时按住选择键便可以进入启动菜单。

烧写Kernel的命令如下:

dfu-util -a kernel -R -D /path/to/uImage

如果烧写成功,会显示下面的信息:

status(0) = No error condition is present
Done!

烧写也可能出现代码为-110的错误,这表示要烧写的kernel文件太大,当前分区存放不下。可以通过修改u-boot的参数来调整默认分区的大小。当然这个错误也可能是因为你烧写错了文件,如把rootfs文件当kernel文件烧写了。

烧写根文件系统 rootfs

跟文件系统的映像文件必须是jffs2格式的。如果你下载的是一个压缩文件,请解压缩得到jffs2格式的文件。

烧写根文件系统的命令为:

dfu-util -a rootfs -R -D rootfs_filename.jffs2

rootfs_filename.jffs2 是根文件系统映像文件的文件名。 一个70M的影响文件的烧写时间大约是15分钟,注意保证你的FreeRunner的电池有充足的电量。

如果烧写成功,会显示如下信息:

status(0) = No error condition is present
Done!

烧写更新boogloader

Template:提示

烧写bootloader的命令格式为:

dfu-util -a u-boot -R -D uboot.bin

uboot.bin 是bootloader映像文件的文件名.

提示: 要更新bootloader,你需要从NOR flash启动boot from NOR first. 更新完成后,再从NAND flash启动。

从NAND存储器重启FreeRunner

现在你应该能够启动进入到新的系统了。

注意:如果你同时也更新了bootloader,那么更新后一定要从NAND flash启动, in particular if you upgraded the boot-loader (方法: 1. 按住电源键 ,然后 2. 按选择键)

会出现启动菜单 *** BOOT MENU (NAND) *** (see booting from NAND for more detailed instructions).

A command line script to simplify dfu-util

DFUScript developed to assist users who have multiple devices in using dfu-util via the command line. Information on where to download and use DFUScript can be found on DFUScript

Alternative: using nandwrite

This approach involves writing the rootfs into nand directly on the phone from a system already running on it, not necessarily via usb from a computer.

If you have a system running from a different partition that you intend to flash (for example sd card), you can use nandwrite to do the work, which is much faster (it takes about 30s to write a 59MB jffs2 image).

Make sure you have nandwrite installed (on gentoo, it's in sys-fs/mtd-utils package)

Also make sure that the host system has received correct partition list, for example for my stock Neo Freerunner partition list:

#cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00200000 00010000 "physmap-flash.0"
mtd1: 00040000 00020000 "u-boot"
mtd2: 00040000 00020000 "u-boot_env"
mtd3: 00800000 00020000 "kernel"
mtd4: 000a0000 00020000 "splash"
mtd5: 00040000 00020000 "factory"
mtd6: 0f6a0000 00020000 "rootfs"

In this case, we're looking for 'rootfs' which according to above is mtd6. If you have it somewhere else, substitute mtd6 with whatever you have in the remainder of this section.

You can test your nand for bad blocks by issuing nandtest /dev/mtd6 (this is a destructive test !)

First, put your .jffs2 file somewhere the phone system can read it

Second, write the desired image into the nand this way:

flash_eraseall /dev/mtd6
nandwrite -p /dev/mtd6 /path/to/image.jffs2

You're all done !

问题解决

好的,现在你应该已经更新了系统,启动画面也出现了,但u-boot可能无法加载kernel,然后就返回到了启动菜单界面。这是为什么呢?

  • 你可能把软件的image文件烧写错了位置,譬如你可能把kernel文件当作rootfs来烧写了。内核image文件名一般为uImage.bin,bootloader的image文件名为u-boot.bin。解决办法是重新烧写一次。
  • 另一种可能就是你下载image文件事出错了。重新下载一次,并用MD5检查文件的完整性。

See also

  • Qi 不同于uboot的另一个bootloader
Personal tools


OpenMoko会不断发布最新的根文件系统(root file system)、内核(kernel)和[[Bootloader(called U-Boot) 的二进制映像(binary image)文件。这些文件可以被烧写到Neo FreeRunner的Flash memory (NAND) 中,从而达到更新系统套件的目的。你可以通过一根USB线,连接FreeRunner到电脑上,通过OpenMoko提供的烧写工具来更新系统。

3类软件组件and 2种存储器

FreeRunner的软件系统由3部分组成:

  • bootloader: 这是FreeRunner启动或者重启时执行的第一段小程序,它再启动其他软件系统。
  • kernel: FreeRunner采用的Linux内核。
  • root filesystem: 包括所有的应用程序和命令文件。

FreeRunner的这三类软件组件都打包成二进制映像文件进行发布。

FreeRunner有两种程序存储器:NOR flash与NAND flash。在PC机上,如果你想重装操作系统,你一般会使用一个光盘来启动系统,然后将操作系统从光盘拷贝安装到硬盘上。FreeRunner并没有光驱,但系统文件必须安装进内部的存储器(NAND flash)当中去。当然,一种可能的方式是从microSD卡来启动。

NOR flash是一个很小的程序存储器,里面存放着一段启动代码。当你需要重新安装系统,也就是需要重写NAND flash的时候,你可以从NOR flash启动来进行操作。一般来说,NOR flash是很少需要更新;如果需要,你可以从这里找到更新方法:Flashing NOR.。

NAND flash 就像PC机中的硬盘,它被分为三个分区,分别存放bootloader, kernel, 和rootfs。这三个分区分别可以独立的进行擦写更新。譬如,如果你想更新一个修改过的kernel,你只需要按照更新kernel的步骤进行操作就可以了。

注意:一般很少更新根文件系统rootfs及bootloader,因为有时只需要更新内核(kernel)文件就可以解决一些存在的问题,所以在更新之前请慎重考虑更新的必要性。

另一种方式: 将系统安装运行在 microSD 卡上

你可以将软件系统安装在microSD卡上,这样你可以从microSD卡启动并运行系统 boot from microSD card。这样可以同时保留在NAND flash上的系统,从而达到在FreeRunner上安装双系统的目的。(譬如,假如你的FreeRunner当前已经安装了2007.2的OM系统,你想在不擦除当前系统的前提下测试2008.08的OM系统,这种在microSD卡上的方式就是一个很好的选择了)

Software you need

#1 Tools for flashing: DFU-util and NeoTool

Command-line. DFU-util, the tool to flash the FreeRunner has to be installed on you laptop or desktop machine. It is available for Linux, MacOS X, and Windows (see links below). DFU-util allows you to connect to the FreeRunner through the USB cable and control its bootloader. That connection uses a special protocol which addresses the bootloader's interface, and differs from USB networking. For more details, see the separate dfu-util page.

GUI. Instead of the command-line-based DFU-util, you can use NeoTool, a graphical tool for flashing the FreeRunner: see the NeoTool page.

Linux: http://downloads.openmoko.org/releases/Om2008.9/dfu-util

Make sure it is executable by setting the permissions with this command: chmod a+x dfu-util

Linux 64-bit: You need 64-bit version of dfu-util, which usually can be found in your distribution repository. If your destribution does not provide 64-bit dfu-util, or it consistently fails with a "-62" error, you have two ways to go:

  1. Seek for 32-bit machine and do flashing form it.
  2. Use 32-bit chroot (on amd64 debian). Worked for me --Bubak 16:54, 4 September 2008 (UTC).
  3. Just try the 32-bit dfu-util. Worked fine on my x86_64 Fedora 10 --pcfe 2009-01-16.
    • I can confirm this (Gentoo multilib x86_64) --Unlotto 14:15, 4 February 2009 (UTC)

MacOS X: MacOS_X#Graphical_Flashing_with_Openmoko_Flasher

Windows: http://projects.openmoko.org/frs/?group_id=166&release_id=162

See additional driver installation instructions for Windows at Dfu-util-windows

Virtual machines While there has been some limited success reported using dfu-util from within a Virtual Machine (such as VMware), in general it is not possible to use dfu-util in this fashion. You must use dfu-util on an operating system that has direct access to the physical USB device hardware.

#2 需要烧写映像文件

3类软件组件都有各自的映像文件,你可以选择其中一个或者多个进行更新。大多数情况下,你需要更新kernel(uImage)和根文件系统(rootfs)。bootloader一般不需要更新,除非需要通过更新来解决某个发现的bug。

请参考Distributions 来选择你需要的软件系统,然后到Download 下载。

Boot the FreeRunner from NOR Flash

Booting from NOR Flash
  1. Read the other sections of this page first, because you will have 30 seconds to enter the flashing commands, come back here when ready.
  2. Do not connect the USB cable from the PC to your Neo FreeRunner yet (disconnect it).
  3. Boot your Neo FreeRunner into the NOR uBoot menu for flashing.
    1. Press and hold AUX button
    2. Press the Power button until the boot menu comes up
    3. This menu is labelled *** BOOT MENU (NOR) ***
    4. See also Booting the Neo FreeRunner
  4. Stay in NOR uBoot menu, do not select or enter any item in menu. Now you will be able to flash, make backups of your FreeRunner or query the FreeRunner with dfu-util.
  5. The FreeRunner only stays at the NOR boot prompt for about 30 seconds and then shuts off unless you do something.
  6. Connect your Neo to the GNU/Linux or Windows host via a USB cable.
  7. Now you can enter the dfu-util commands on your PC as described below.
  8. If the Neo FreeRunner turns off before you press start flashing (screen goes black), go back to step 2. If you start flashing in time, the phone will not turn off meanwhile.


Note that the dfu-util connection does not use Ethernet over USB - that is, you should not attempt to set up a usb0 network interface on your GNU/Linux host desktop (on Windows, you need a DFU class driver, or you can use the LibUSB-Win32 driver described on the Dfu-util-windows page). The dfu-util utility sets up its own connection to the FreeRunner. In fact, you will not be able to make an Ethernet-over-USB connection to the FreeRunner when it is at the uBoot menu; this type of connection is only available when the FreeRunner has booted fully.

After connecting the FreeRunner to your host via USB cable, you can test whether dfu-util "sees" the FreeRunner by executing:

dfu-util -l

If you get error messages from the dfu-util command then try again. Often it works on the second try.

dfu-util uses the DeviceFirmwareUpgrade protocol, and may list more than one device. If so, try unplugging the other device (e.g. a USB mouse) or using the -d switch to tell dfu-util which device it should talk to, as described at the relevant bug report [1].

Also, please remember to execute the dfu-util command with sufficient privileges (ie. root) -- you will need complete control over the usb bus.

备份

如果你很喜欢当前已有的系统,又想试试一些新的东东,你最好先做一个备份Backup.

Using dfu-util

dfu-util can be used to read flash memory, write memory, and get information from the device.

This is the general command format to write an image file to a (predefined) "partition name" (referred to as altsetting in dfu-util help/manual) :

dfu-util -a <altsetting> -R -D <file_name>

where:
-a altsetting : Specify the altsetting of the DFU interface by name or by number
-R  : Issue USB Reset signalling once we're finished
-D file_name : Write firmware from file_name into device

On Linux, you run dfu-util from a command shell prompt. If you have not put it somewhere on your command path you probably need to prefix it with a "./" like this ./dfu-util. On some systems you need to be root before this will work and on Ubuntu you must preface the command with "sudo" or you will get the following error: "Cannot claim interface: could not claim interface 2: Operation not permitted"

On Windows, you need to open a command window and run from a command line. Use Start-Run Program and type "cmd" to open a Window.

More detailed manual for dfu-util is available here : Dfu-util

GUI frontend for dfu-util (and more): NeoTool

烧写更新 Kernel

提示: 本操作需要在u-boot的启动菜单界面下进行,在按电源键启动手机时同时按住选择键便可以进入启动菜单。

烧写Kernel的命令如下:

dfu-util -a kernel -R -D /path/to/uImage

如果烧写成功,会显示下面的信息:

status(0) = No error condition is present
Done!

烧写也可能出现代码为-110的错误,这表示要烧写的kernel文件太大,当前分区存放不下。可以通过修改u-boot的参数来调整默认分区的大小。当然这个错误也可能是因为你烧写错了文件,如把rootfs文件当kernel文件烧写了。

烧写根文件系统 rootfs

跟文件系统的映像文件必须是jffs2格式的。如果你下载的是一个压缩文件,请解压缩得到jffs2格式的文件。

烧写根文件系统的命令为:

dfu-util -a rootfs -R -D rootfs_filename.jffs2

rootfs_filename.jffs2 是根文件系统映像文件的文件名。 一个70M的影响文件的烧写时间大约是15分钟,注意保证你的FreeRunner的电池有充足的电量。

如果烧写成功,会显示如下信息:

status(0) = No error condition is present
Done!

烧写更新boogloader

Template:提示

烧写bootloader的命令格式为:

dfu-util -a u-boot -R -D uboot.bin

uboot.bin 是bootloader映像文件的文件名.

提示: 要更新bootloader,你需要从NOR flash启动boot from NOR first. 更新完成后,再从NAND flash启动。

从NAND存储器重启FreeRunner

现在你应该能够启动进入到新的系统了。

注意:如果你同时也更新了bootloader,那么更新后一定要从NAND flash启动, in particular if you upgraded the boot-loader (方法: 1. 按住电源键 ,然后 2. 按选择键)

会出现启动菜单 *** BOOT MENU (NAND) *** (see booting from NAND for more detailed instructions).

A command line script to simplify dfu-util

DFUScript developed to assist users who have multiple devices in using dfu-util via the command line. Information on where to download and use DFUScript can be found on DFUScript

Alternative: using nandwrite

This approach involves writing the rootfs into nand directly on the phone from a system already running on it, not necessarily via usb from a computer.

If you have a system running from a different partition that you intend to flash (for example sd card), you can use nandwrite to do the work, which is much faster (it takes about 30s to write a 59MB jffs2 image).

Make sure you have nandwrite installed (on gentoo, it's in sys-fs/mtd-utils package)

Also make sure that the host system has received correct partition list, for example for my stock Neo Freerunner partition list:

#cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00200000 00010000 "physmap-flash.0"
mtd1: 00040000 00020000 "u-boot"
mtd2: 00040000 00020000 "u-boot_env"
mtd3: 00800000 00020000 "kernel"
mtd4: 000a0000 00020000 "splash"
mtd5: 00040000 00020000 "factory"
mtd6: 0f6a0000 00020000 "rootfs"

In this case, we're looking for 'rootfs' which according to above is mtd6. If you have it somewhere else, substitute mtd6 with whatever you have in the remainder of this section.

You can test your nand for bad blocks by issuing nandtest /dev/mtd6 (this is a destructive test !)

First, put your .jffs2 file somewhere the phone system can read it

Second, write the desired image into the nand this way:

flash_eraseall /dev/mtd6
nandwrite -p /dev/mtd6 /path/to/image.jffs2

You're all done !

问题解决

好的,现在你应该已经更新了系统,启动画面也出现了,但u-boot可能无法加载kernel,然后就返回到了启动菜单界面。这是为什么呢?

  • 你可能把软件的image文件烧写错了位置,譬如你可能把kernel文件当作rootfs来烧写了。内核image文件名一般为uImage.bin,bootloader的image文件名为u-boot.bin。解决办法是重新烧写一次。
  • 另一种可能就是你下载image文件事出错了。重新下载一次,并用MD5检查文件的完整性。

See also

  • Qi 不同于uboot的另一个bootloader