Flashing the Neo FreeRunner/zh cn

From Openmoko

(Difference between revisions)
Jump to: navigation, search
(Do a backup)
(#1 烧写工具: DFU-util 或 NeoTool)
 
(13 intermediate revisions by one user not shown)
Line 23: Line 23:
 
你可以将软件系统安装在microSD卡上,这样你可以从microSD卡启动并运行系统[[Booting from SD | boot from microSD card]]。这样可以同时保留在NAND flash上的系统,从而达到在FreeRunner上安装双系统的目的。(譬如,假如你的FreeRunner当前已经安装了2007.2的OM系统,你想在不擦除当前系统的前提下测试2008.08的OM系统,这种在microSD卡上的方式就是一个很好的选择了)
 
你可以将软件系统安装在microSD卡上,这样你可以从microSD卡启动并运行系统[[Booting from SD | 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 ===
+
=== #1 烧写工具: DFU-util 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.
+
''命令行工具:'' DFU-util, 需要安装在你的PC机上,当前有Linux, MacOS X, and Windows (参见下面的链接)多个版本. DFU-util可以帮助你通过USB连接到FreeRunner并控制bootloader。这种连接方式使用了一种特殊的bootloader接口协议,不同于USB网络,详细信息可以参考[[dfu-util]]页面。
  
''GUI''. Instead of the command-line-based DFU-util, you can use NeoTool, a graphical tool for flashing the FreeRunner: see the [[NeoTool]] page.
+
''图形界面工具:'' 你可以使用一个叫做NeoTool的图形界面工具来代替Dfu-util烧写FreeRunner:请参考 [[NeoTool]] 页面.
  
'''Linux:''' http://downloads.openmoko.org/releases/Om2008.9/dfu-util
+
DFU-util的不同版本如下:
  
Make sure it is executable by setting the permissions with this command: chmod a+x dfu-util
+
'''Linux:''' http://downloads.openmoko.org/distro/releases/Om2008.9/dfu-util
 +
 
 +
请执行命令 chmod a+x dfu-util 以保证下载文件的可执行性(Executable)。
  
 
'''Linux 64-bit:''' You need 64-bit version of dfu-util, which usually can be found in your distribution repository.
 
'''Linux 64-bit:''' You need 64-bit version of dfu-util, which usually can be found in your distribution repository.
Line 46: Line 48:
 
'''Windows:''' http://projects.openmoko.org/frs/?group_id=166&release_id=162
 
'''Windows:''' http://projects.openmoko.org/frs/?group_id=166&release_id=162
  
See additional driver installation instructions for Windows at [[Dfu-util-windows]]
+
Windows版本需要安装驱动,具体请参见 [[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 Image files to flash into FreeRunner memory ===
+
=== #2 需要烧写映像文件 ===
  
There are separate image files for all 3 software components and depending on what you want to install, you pick the respective image file. In most cases you will need to install a Kernel (uImage) and a Root Filesystem (rootfs). In rare cases, when there is a bug you need fixed, you will also install a new bootloader.
+
3类软件组件都有各自的映像文件,你可以选择其中一个或者多个进行更新。大多数情况下,你需要更新kernel(uImage)和根文件系统(rootfs)。bootloader一般不需要更新,除非需要通过更新来解决某个发现的bug。
  
Please read [[Distributions]] for choosing the distribution which fits your needs, and then see [[Download]] for downloading.
+
请参考[[Distributions]] 来选择你需要的软件系统,然后到[[Download]] 下载。
  
== Boot the FreeRunner from NOR Flash ==
+
== 从NOR Flash启动FreeRunner ==
  
 
[[Image:menu15.jpg|thumb|Booting from NOR Flash]]
 
[[Image:menu15.jpg|thumb|Booting from NOR Flash]]
  
# Read the other sections of this page first, because you will have 30 seconds to enter the flashing commands, come back here when ready.
+
# 请先阅读本文档的其他部分,因为你只有30秒的时间来输入flash烧写命令。阅读完本文档其他部分后再来阅读这一部分。
# Do not connect the USB cable from the PC to your Neo FreeRunner yet (disconnect it).
+
# 请先"""不要"""用USB线把PC机与FreeRunner连在一起。
# Boot your Neo FreeRunner into the NOR uBoot menu for flashing.
+
# 从NOR Flash启动你的FreeRunner
## Press and hold AUX button
+
## on按住选择键(AUX)
## Press the Power button until the boot menu comes up
+
## 按住电源键(Power)直到出现启动菜单
## This menu is labelled '''*** BOOT MENU (NOR) ***'''
+
## 启动菜单显示: '''*** BOOT MENU (NOR) ***'''
 
## See also [[Booting the Neo FreeRunner]]
 
## See also [[Booting the Neo FreeRunner]]
# 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.
+
# 停留在启动菜单上,不需要选择和进入任何一项,现在你就可以通过DFU-util进行烧写FALSH, 备份以及查询你的FreeRunner设备。
# The FreeRunner only stays at the NOR boot prompt for about 30 seconds and then shuts off unless you do something.
+
# 如果你什么都不做,启动菜单会在30秒后关闭。
# Connect your Neo to the GNU/Linux or Windows host via a USB cable.
+
# 通过USB线将FreeRunner连接到你的PC机。
# Now you can enter the dfu-util commands on your PC as described below.
+
# 现在你就可以在PC机上输入dfu-util的命令了。
# 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.
+
# 如果在你烧写之前启动菜单就关闭了('''屏幕变黑了'''), 回到步骤2. 如果你在30秒内进行了烧写操作,FreeRunner就会一直不关闭.
  
 
<!-- The following, upto dfu-util -l is taken from the thread "Re: FreeRunner (GTK2007.2) has suddenly become unbootable" on the Support list. -->
 
<!-- The following, upto dfu-util -l is taken from the thread "Re: FreeRunner (GTK2007.2) has suddenly become unbootable" on the Support list. -->
  
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.
+
注意dfu-util连接不是基于USB的以太网连接,所以不要在你的Linux机器上试图建立一个USB0的网络接口(在windows上,你需要一个DFU驱动,或者你可以使用LibUSB-Win32驱动[[Dfu-util-windows]] )。dfu-util工具自己会建立一个到FreeRunner的连接。事实上,在FreeRunner的启动菜单界面,你无法通过USB建立一个以太网连接,只有在FreeRunner正常启动后才能建立这种连接。
  
After connecting the FreeRunner to your host via USB cable, you can test whether dfu-util "sees" the FreeRunner by executing:
+
在连接建立好以后,你可以执行以下命令了测试dfu-util是否找到FreeRunner:
  
 
<pre>dfu-util -l</pre>
 
<pre>dfu-util -l</pre>
  
If you get error messages from the dfu-util command then try again. Often it works on the second try.
+
如果你得到出错信息,就再试一次,一般第二次就可以查找到FreeRunner了。
  
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 [http://docs.openmoko.org/trac/ticket/2039].
+
dfu-util使用的是DeviceFirmwareUpgrade协议,所以有可能会列出多个设备。如果出现这种情况,请拔掉其他设备,如usb鼠标;或者使用 -d 选项指定要对话的设备。
 +
[http://docs.openmoko.org/trac/ticket/2039].
  
Also, please remember to execute the dfu-util command with sufficient privileges (ie. root) -- you will need complete control over the usb bus.
+
另外,在执行dfu-util命令的时候,请保证有root用户权限。
  
 
== 备份 ==
 
== 备份 ==
Line 91: Line 94:
 
如果你很喜欢当前已有的系统,又想试试一些新的东东,你最好先做一个备份[[Backup]].
 
如果你很喜欢当前已有的系统,又想试试一些新的东东,你最好先做一个备份[[Backup]].
  
== Using dfu-util ==
+
== 使用dfu-util ==
  
dfu-util can be used to read flash memory, write memory, and get information from the device.
+
dfu-util可以用来读写flash存储器,以及获取设备信息。
  
 +
下面是向flash存储器的一个(预定义的)分区中中写入一个image文件的通用命令格式:
 
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) :
 
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) :
  
Line 100: Line 104:
  
 
where:<br>
 
where:<br>
-a ''altsetting'' : Specify the altsetting of the DFU interface by name or by number<br>
+
-a ''altsetting'' : 使用名字或者数字指定DFU接口的altsetting<br>
-R  : Issue USB Reset signalling once we're finished<br>
+
-R  : 操作完成后发送重置USB信号。<br>
-D  ''file_name'' : Write firmware from ''file_name'' into device
+
-D  ''file_name'' : 向设备的flash存储器写入文件名为''file_name'' 的文件。
  
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'''.
+
在Linux平台上,你可以在shell中运行dfu-util,在有些系统中你可能需要root用户权限,如在ubuntu中你可能需要使用sudo。
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.
+
在Windows系统中,你可以打开一个命令行窗口来执行。
  
More detailed manual for dfu-util is available here : [[Dfu-util]]
+
关于dfu-util的更详细的信息请参考: [[Dfu-util]]
  
GUI frontend for dfu-util (and more): [[NeoTool]]
+
dfu-util的GUI 前端 (更多): [[NeoTool]]
  
== Flashing the Kernel ==
+
== 烧写更新 Kernel ==
  
  Note: The phone needs to be in the U-boot bootup menu for this to work.
+
  提示: 本操作需要在u-boot的启动菜单界面下进行,在按电源键启动手机时同时按住选择键便可以进入启动菜单。
      Get there by holding down the aux button while powering up the device.
+
  
The command format is
+
烧写Kernel的命令如下:
  
 
  dfu-util -a kernel -R -D ''/path/to/uImage''
 
  dfu-util -a kernel -R -D ''/path/to/uImage''
  
When flashing succeeds the following will be shown:
+
如果烧写成功,会显示下面的信息:
  
 
  status(0) = No error condition is present
 
  status(0) = No error condition is present
 
  Done!
 
  Done!
  
Flashing may fail with an error -110. This indicates that the kernel is too big for the default kernel partition. uboot can be used to change the size of the default partitions on the device. It may also mean that you are trying to put the wrong thing in the kernel space.
+
烧写也可能出现代码为-110的错误,这表示要烧写的kernel文件太大,当前分区存放不下。可以通过修改u-boot的参数来调整默认分区的大小。当然这个错误也可能是因为你烧写错了文件,如把rootfs文件当kernel文件烧写了。
  
== Flashing the Root Filesystem ==
+
== 烧写根文件系统 rootfs ==
  
The root filesystem has to be an image in jffs2 format. If the file you downloaded is zipped or compressed (has a .gz, bz2, .zip, tar, tar.gz or .tgz extension) you have to uncompress it first.
+
跟文件系统的映像文件必须是jffs2格式的。如果你下载的是一个压缩文件,请解压缩得到jffs2格式的文件。
  
The command format is
+
烧写根文件系统的命令为:
  
 
<pre>
 
<pre>
 
dfu-util -a rootfs -R -D rootfs_filename.jffs2
 
dfu-util -a rootfs -R -D rootfs_filename.jffs2
 
</pre>
 
</pre>
| U-Boot
 
where ''rootfs_filename.jffs2'' is the name of the file containing the root file system.
 
  
The flashing process can take up to 15 minutes for a ~70MB image. It is also wise to make sure that your Neo has enough battery charge prior to flashing.
+
''rootfs_filename.jffs2'' 是根文件系统映像文件的文件名。
 +
一个70M的影响文件的烧写时间大约是15分钟,注意保证你的FreeRunner的电池有充足的电量。
  
When flashing succeeds the following will be shown:
+
如果烧写成功,会显示如下信息:
  
 
<pre>
 
<pre>
Line 150: Line 151:
 
</pre>
 
</pre>
  
== Flashing the boot loader to the NAND==
+
== 烧写更新boogloader ==
  
{{Note|In most cases you don't need to flash your bootloader. Flash it only if you want to update for a specific feature or due to a specific problem.}}
+
{{Note|大多数情况下,你并不需要重新烧写你的bootloader,一般在需要更新一些特定功能,或者需要解决一些bug时才有必要重新烧写你的bootloader。}}
  
The boot loader (U-boot) file should have a .bin extension. As with the root filesystem, if the file you downloaded is zipped or compressed (has a .gz or .zip extension) you have to uncompress it first.
+
烧写bootloader的命令格式为:
 
+
The command format is
+
  
 
  dfu-util -a u-boot -R -D ''uboot.bin''
 
  dfu-util -a u-boot -R -D ''uboot.bin''
  
where ''uboot.bin'' is the name of the boot loader binary image file.
+
''uboot.bin'' 是bootloader映像文件的文件名.
 
+
''Reminder'': You should have [[Flashing_the_Neo_FreeRunner#Boot_the_FreeRunner_from_NOR_Flash|boot from NOR first]], in order to flash the boot-loader in NAND. After flashing succesfully, make sure you reboot from NAND's newly flashed boot loader, to benefit from the updates.
+
 
+
=== Optional: Verifying boot-loader version ===
+
 
+
<!-- The following should probably be moved to [[Bootloader_versions]], IMHO -->
+
 
+
<!-- Taken from posts by Mikael Berthe <mikael.berthe@lilotux.net> and Torfinn Ingolfsen <tingox@gmail.com> to Support list, subject: Re: Upgrading u-boot needed ? -->
+
(Optional) After an upgrade, you may wish to check that the u-boot version matches the one you have just flashed. You can use 'grep  Bootloader /dev/mtdblock1' from a shell on the FreeRunner (and possibly the 1973 as well) to get the '''NAND''' u-boot version, like this:
+
  root@om-gta02:~# grep Bootloader /dev/mtdblock1
+
  Neo1973 Bootloader U-Boot 1.3.2+gitr18+64eb10cab8055084ae25ea4e73b66dd03cc1a0cb
+
 
+
You can grep for the same string in /dev/mtdblock0 to retrieve the '''NOR''' u-boot version:
+
  root@om-gta02:~# grep  Bootloader /dev/mtdblock0
+
  Neo1973 Bootloader U-Boot 1.3.2-moko12
+
  
<!-- ENDS ... subject: Re: Upgrading u-boot needed ? -->
+
''提示'': 要更新bootloader,你需要从NOR flash启动[[Flashing_the_Neo_FreeRunner#Boot_the_FreeRunner_from_NOR_Flash|boot from NOR first]]. 更新完成后,再从NAND flash启动。
  
 
== 从NAND存储器重启FreeRunner ==
 
== 从NAND存储器重启FreeRunner ==
Line 187: Line 171:
 
会出现启动菜单 '''*** BOOT MENU (NAND) ***''' (see [[Booting#Log_into_U-Boot_in_the_NAND_Flash|booting from NAND]] for more detailed instructions).
 
会出现启动菜单 '''*** BOOT MENU (NAND) ***''' (see [[Booting#Log_into_U-Boot_in_the_NAND_Flash|booting from NAND]] for more detailed instructions).
  
== A command line script to simplify dfu-util ==
+
== 一个简化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]]
+
DFUScript 帮助那些通过命令行使用dfu-util来操作多个设备的用户。关于DFUScript的下载和使用信息从这里可以找到:[[DFUScript]]
  
 
== Alternative: using nandwrite ==
 
== Alternative: using nandwrite ==

Latest revision as of 08:08, 12 February 2009


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

Contents

[edit] 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)文件就可以解决一些存在的问题,所以在更新之前请慎重考虑更新的必要性。

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

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

[edit] 更新系统所需要的软件

[edit] #1 烧写工具: DFU-util 或 NeoTool

命令行工具: DFU-util, 需要安装在你的PC机上,当前有Linux, MacOS X, and Windows (参见下面的链接)多个版本. DFU-util可以帮助你通过USB连接到FreeRunner并控制bootloader。这种连接方式使用了一种特殊的bootloader接口协议,不同于USB网络,详细信息可以参考dfu-util页面。

图形界面工具: 你可以使用一个叫做NeoTool的图形界面工具来代替Dfu-util烧写FreeRunner:请参考 NeoTool 页面.

DFU-util的不同版本如下:

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

请执行命令 chmod a+x dfu-util 以保证下载文件的可执行性(Executable)。

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

Windows版本需要安装驱动,具体请参见 Dfu-util-windows

虚拟机 当前不支持:(

[edit] #2 需要烧写映像文件

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

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

[edit] 从NOR Flash启动FreeRunner

Booting from NOR Flash
  1. 请先阅读本文档的其他部分,因为你只有30秒的时间来输入flash烧写命令。阅读完本文档其他部分后再来阅读这一部分。
  2. 请先"""不要"""用USB线把PC机与FreeRunner连在一起。
  3. 从NOR Flash启动你的FreeRunner
    1. on按住选择键(AUX)
    2. 按住电源键(Power)直到出现启动菜单
    3. 启动菜单显示: *** BOOT MENU (NOR) ***
    4. See also Booting the Neo FreeRunner
  4. 停留在启动菜单上,不需要选择和进入任何一项,现在你就可以通过DFU-util进行烧写FALSH, 备份以及查询你的FreeRunner设备。
  5. 如果你什么都不做,启动菜单会在30秒后关闭。
  6. 通过USB线将FreeRunner连接到你的PC机。
  7. 现在你就可以在PC机上输入dfu-util的命令了。
  8. 如果在你烧写之前启动菜单就关闭了(屏幕变黑了), 回到步骤2. 如果你在30秒内进行了烧写操作,FreeRunner就会一直不关闭.


注意dfu-util连接不是基于USB的以太网连接,所以不要在你的Linux机器上试图建立一个USB0的网络接口(在windows上,你需要一个DFU驱动,或者你可以使用LibUSB-Win32驱动Dfu-util-windows )。dfu-util工具自己会建立一个到FreeRunner的连接。事实上,在FreeRunner的启动菜单界面,你无法通过USB建立一个以太网连接,只有在FreeRunner正常启动后才能建立这种连接。

在连接建立好以后,你可以执行以下命令了测试dfu-util是否找到FreeRunner:

dfu-util -l

如果你得到出错信息,就再试一次,一般第二次就可以查找到FreeRunner了。

dfu-util使用的是DeviceFirmwareUpgrade协议,所以有可能会列出多个设备。如果出现这种情况,请拔掉其他设备,如usb鼠标;或者使用 -d 选项指定要对话的设备。 [1].

另外,在执行dfu-util命令的时候,请保证有root用户权限。

[edit] 备份

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

[edit] 使用dfu-util

dfu-util可以用来读写flash存储器,以及获取设备信息。

下面是向flash存储器的一个(预定义的)分区中中写入一个image文件的通用命令格式: 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 : 使用名字或者数字指定DFU接口的altsetting
-R  : 操作完成后发送重置USB信号。
-D file_name : 向设备的flash存储器写入文件名为file_name 的文件。

在Linux平台上,你可以在shell中运行dfu-util,在有些系统中你可能需要root用户权限,如在ubuntu中你可能需要使用sudo。

在Windows系统中,你可以打开一个命令行窗口来执行。

关于dfu-util的更详细的信息请参考: Dfu-util

dfu-util的GUI 前端 (更多): NeoTool

[edit] 烧写更新 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文件烧写了。

[edit] 烧写根文件系统 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!

[edit] 烧写更新boogloader

NOTE: 大多数情况下,你并不需要重新烧写你的bootloader,一般在需要更新一些特定功能,或者需要解决一些bug时才有必要重新烧写你的bootloader。


烧写bootloader的命令格式为:

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

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

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

[edit] 从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).

[edit] 一个简化dfu-util操作的命令行脚本

DFUScript 帮助那些通过命令行使用dfu-util来操作多个设备的用户。关于DFUScript的下载和使用信息从这里可以找到:DFUScript

[edit] 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 !

[edit] 问题解决

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

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

[edit] 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 Image files to flash into FreeRunner memory

There are separate image files for all 3 software components and depending on what you want to install, you pick the respective image file. In most cases you will need to install a Kernel (uImage) and a Root Filesystem (rootfs). In rare cases, when there is a bug you need fixed, you will also install a new bootloader.

Please read Distributions for choosing the distribution which fits your needs, and then see Download for downloading.

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

Flashing the Kernel

Note: The phone needs to be in the U-boot bootup menu for this to work.
      Get there by holding down the aux button while powering up the device.

The command format is

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

When flashing succeeds the following will be shown:

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

Flashing may fail with an error -110. This indicates that the kernel is too big for the default kernel partition. uboot can be used to change the size of the default partitions on the device. It may also mean that you are trying to put the wrong thing in the kernel space.

Flashing the Root Filesystem

The root filesystem has to be an image in jffs2 format. If the file you downloaded is zipped or compressed (has a .gz, bz2, .zip, tar, tar.gz or .tgz extension) you have to uncompress it first.

The command format is

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

| U-Boot where rootfs_filename.jffs2 is the name of the file containing the root file system.

The flashing process can take up to 15 minutes for a ~70MB image. It is also wise to make sure that your Neo has enough battery charge prior to flashing.

When flashing succeeds the following will be shown:

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

Flashing the boot loader to the NAND

NOTE: In most cases you don't need to flash your bootloader. Flash it only if you want to update for a specific feature or due to a specific problem.


The boot loader (U-boot) file should have a .bin extension. As with the root filesystem, if the file you downloaded is zipped or compressed (has a .gz or .zip extension) you have to uncompress it first.

The command format is

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

where uboot.bin is the name of the boot loader binary image file.

Reminder: You should have boot from NOR first, in order to flash the boot-loader in NAND. After flashing succesfully, make sure you reboot from NAND's newly flashed boot loader, to benefit from the updates.

Optional: Verifying boot-loader version

(Optional) After an upgrade, you may wish to check that the u-boot version matches the one you have just flashed. You can use 'grep Bootloader /dev/mtdblock1' from a shell on the FreeRunner (and possibly the 1973 as well) to get the NAND u-boot version, like this:

  root@om-gta02:~# grep Bootloader /dev/mtdblock1
  Neo1973 Bootloader U-Boot 1.3.2+gitr18+64eb10cab8055084ae25ea4e73b66dd03cc1a0cb

You can grep for the same string in /dev/mtdblock0 to retrieve the NOR u-boot version:

  root@om-gta02:~# grep  Bootloader /dev/mtdblock0
  Neo1973 Bootloader U-Boot 1.3.2-moko12


从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