U-Boot/zh cn

From Openmoko

(Difference between revisions)
Jump to: navigation, search
(QT2410)
Line 1: Line 1:
[[Image:Uboot-s3c2410fb.jpg|thumb|300px|Neo1973控制台上的u-boot]] [[Image:Neo1973 uboot splash closeup.jpg|thumb|300px|Neo1973上的u-boot引导菜单]]
+
{{Languages|Bootloader}}
 +
[[Image:GTA01-U-Boot.JPG|thumb|300px|u-boot menu on Neo1973]] [[Image:Neo1973 uboot splash closeup.jpg|thumb|300px|u-boot splash screen on Neo1973]]
  
== 概述 ==
+
[[Neo1973]]上的bootloader  '''U-Boot''',负责硬件装置的功能运作,直到 [[Openmoko]]被启动加载装置为止。这包括用来[[Flashing openmoko/zh tw|更新Openmok]]的 [[USB DFU]]、屏幕显示、启动选单、[[bootloader commands|bootloader 指令列]] 控制台。透过 [[bootloader environment|bootloader 环境]]设定及加载[[kernel]]等。
  
GTA01使用了[http://u-boot.sourceforge.net/ u-boot]引导装载程序。
+
有不同的[[bootloader versions|bootloader版本]]可供使用:
  
关于u-boot的更多信息可以在下列地方找到
+
== Phase0 快速启动==
 +
* 请确认你的电话是目前是装好电池,并且USB接线至少移开30秒以上。
 +
* 利用USB接线,将Neo (并不是侦错板) 连接到Linux主机。
 +
* 在启动电源时,按住AUX按钮以存取选单。
 +
* 将控制台设定为USB。
 +
* 在Linux主机上利用「终端机」连接到/dev/ttyACM0 (你可能会用到chown uucp.uucp /dev/ttyACM0 )。
 +
* 请注意cdc_acm /dev/ttyACM0 存取会连同Neo boots一起消失,它会被cdc_ether usb0网络存取取代。
 +
* 你现在会进入bootloader 提示指令下。
 +
*如果你希望在每次启动时都停留在bootloader,将bootdelay uboot 环境变量设定为-1 。
 +
 
 +
== 一般 ==
 +
GTA01 使用[http://u-boot.sourceforge.net/ u-boot] bootloader.
 +
 
 +
关于u-boot的更多信息,可以参考下列网址:
 
* http://www.denx.de/wiki/DULG
 
* http://www.denx.de/wiki/DULG
 
* http://www.gumstix.org/tikiwiki/tiki-index.php?page=U-Boot
 
* http://www.gumstix.org/tikiwiki/tiki-index.php?page=U-Boot
 
* http://linuxdevices.com/articles/AT5085702347.html
 
* http://linuxdevices.com/articles/AT5085702347.html
  
但是,未经修改的u-boot不支持GTA01所需要的许多特性,比如
+
您也可以参考下面的内容,得到其它u-boot的信息:
* 利用[[S3C2410 Steppingstone/zh_cn|S3C2410 Steppingstone]]从NAND闪存启动
+
* 使用[[S3C2410 Steppingstone]]支持从NAND 中启动
* 从SD/Transflash读取内核/initrd
+
* 支持S3C2410 NAND 内存
* S3C2410 NAND闪存
+
* 支持透过S3C2410 USB 装置控制器下载程序
* 通过S3C2410 USB Device控制器下载程序
+
* 支持在S3C2410 Framebuffer中显示启动logo / 状态
* S3C2410 Framebuffer启动logo/状态显示
+
然而,u-boot并不会支持GTA01所需要的功能,如
 +
*支持从SD/Transflash读取kernel/initrd
  
[[User:HaraldWelte|Harald Welte]]正在为这些解决问题而工作,并且实际上它们中的大多数已经得到了实现。
+
[[User:HaraldWelte|HaraldWelte]]目前正在进行这项工作,事实上,已完成大部份的工作。
  
== 引导装载程序源代码 ==
+
== Bootloader 源码==
 +
目前的bootloader patche 可以在[http://svn.openmoko.org/trunk/src/target/u-boot/patches/| http://svn.openmoko.org/trunk/src/target/u-boot/patches/这个位置]]下位置取得。.
  
从 http://svn.openmoko.org/trunk/src/target/u-boot/patches/ 可以获得当前的引导装载程序的补丁。
+
将源码解压缩缩,套用到patch,执行"make gta01bv3_config" (或gta01bv2_config, 或你拥有的任何硬件版本),执行"make"。你将会得到"u-boot.bin" 映像档,你可以在NAND中直接更新 (也可以使用现有的bootloader 或 [[sjf2410-linux]])。
  
Untar the sources, apply the patch.  run "make gta01bv3_config" (or gta01bv2_config, or whatever hardware revision you have), run "make".  You will get a resulting "u-boot.bin" image, which you can directly flash (either using existing bootloader or [[sjf2410-linux]]) into NAND.
 
  
== 引导装载程序二进制文件 ==
+
== Bootloader 二进制文件==
  
最新的引导装载程序二进制文件可以从 http://buildhost.openmoko.org/tmp/gta01/deploy/images/ 网站找到。它应该写到 NAND flash 0x00000000 (size 0x30000) 地址处。
+
最新的bootloader 二进制文件可以在以下的位置中找到under http://buildhost.openmoko.org/snapshots in the subdirectory 200X.XX/images/。它应该被写入NAND 0x00000000的位置 (大小为0x30000) (第一个 [[partition|分割区]]).
  
== 引导装载程序开发 ==
+
== 开发Bootloader ==
  
 
=== QT2410 ===
 
=== QT2410 ===
If you want to do bootloader development on the QT2410, it's easier to work with a bootloader image that can be downloaded via USB into RAM instead of flashing.
+
如果你想要在QT2410上开发bootloader,使用bootloader 映像档更新会从USB上下载到RAM来的简单的多。
 +
要进行这项工作,你必须编辑u-boot/include/configs/qt2410.h 档案,并且将第32行程序中的"if 0"变更为 "if 1",之后再使用"make"重新编译。
  
为了做到这一点,你需要编辑 u-boot/include/configs/qt2410.h 文件,将32行的 "if 0" 改为 "if 1",然后用 "make" 重新编译。
+
产生的"u-boot.bin" 档案对于NAND内存并不稳定,但却可以直接或在RAM中执行,如透过使用[[s3c2410_boot_usb]] 程序。
 
+
The resulting "u-boot.bin" is _NOT SUITABLE_ for NAND flash, but only for direct execution from within ram, e.g. by using the [[s3c2410_boot_usb]] program.
+
  
 
=== GTA01 ===
 
=== GTA01 ===
  
Doing bootloader development on the GTA01 is a bit more tricky.  first, we don't have any NOR flash.  Second, there is no other way to boot _but_ from NAND.  Therefore, we also don't have a USB downloader like the QT2410.
+
在GTA01上开发bootloader是很辣手的一件事情,首先,我们并不会有任何的NOR内存。第二,并没有其它的方法可以不从NAND中启动。然而,我们也不会有一个像QT2410一样的USB下载器。
 
+
The main problem is:  The [[S3C2410 Steppingstone]] unconditionally copies the first 4k of flash into its internal SRAM.  That SRAM segment stays unconditionally mapped at physical address zero. How do we get around this
+
  
==== 使用JTAG从RAM启动 ====
+
最主要的问题是:[[S3C2410 Steppingstone]]内部的SRAM的前4K并没有被限制。SRAM 分割并非绝对性的对应到实体0的位置。我们要如何因应呢?
  
So how can we boot from RAM? We use JTAG / OpenOCD to
+
==== 使用JTAG 自RAM中启动====
 +
那我们要如何自RAM启动?我们使用JTAG / OpenOCD 进行:
  
* reset and halt the cpu at PC=0
+
* 在PC=0的时候重设及暂停CPU
 
<pre>
 
<pre>
 
> reset halt
 
> reset halt
Line 56: Line 69:
 
</pre>
 
</pre>
  
* download a small piece of code for low-level SDRAM timing initialization (overwrite 4k SRAM of steppingstone)
+
* 针对低阶SDRAM启动下载程序片段 (做为4k的sram踏脚石)
 
<pre>
 
<pre>
> load_binary /space/misc/gta01/u-boot.git/foo.bin 0             
+
> load_binary /space/misc/gta01/u-boot.git/board/gta01/lowlevel_foo.bin 0             
 
downloaded 332 byte in 0s 21899us
 
downloaded 332 byte in 0s 21899us
 
</pre>
 
</pre>
  
* assert a break point at address 0x33f80000 (which indicates that the low-level code has finished)
+
* 在0x33f80000插入断点 (能指出低阶程序已完成)
 
<pre>
 
<pre>
 
> bp 0x33f80000 4 hw
 
> bp 0x33f80000 4 hw
breakpoint added at address 0x33f80000
+
在0x33f80000 中加入断点
 
</pre>
 
</pre>
  
* run the code up to the break point
+
* 执行程序到断点
 
<pre>
 
<pre>
 
> resume
 
> resume
Target 0 resumed
+
Target 0 重新开始
 
> Target 0 halted
 
> Target 0 halted
target halted in ARM state due to breakpoint, current mode: Supervisor
+
因断点的关系,目标暂停,目前的模式为:Supervisor
 
cpsr: 0x600000d3 pc: 0x33f80000
 
cpsr: 0x600000d3 pc: 0x33f80000
 
MMU: disabled, D-Cache: disabled, I-Cache: enabled
 
MMU: disabled, D-Cache: disabled, I-Cache: enabled
 
</pre>
 
</pre>
  
* download the u-boot RAM image to 0x33f80000
+
* 下载u-boot RAM映像档到0x33f80000
 
<pre>
 
<pre>
 
> load_binary /space/misc/gta01/u-boot.git/u-boot.bin 0x33f80000
 
> load_binary /space/misc/gta01/u-boot.git/u-boot.bin 0x33f80000
Line 84: Line 97:
 
</pre>
 
</pre>
  
* resume processing
+
* 继续处理
 
<pre>
 
<pre>
 
> resume
 
> resume
Target 0 resumed
+
Target 0 重新开始
 
</pre>
 
</pre>
  
At this point, the display backlight gets bright and we see the following familiar prompt on the serial console:
+
在进行到这里时,显示的背光会变明亮,我们会看到下面的指令:
 
<pre>
 
<pre>
 
U-Boot 1.1.6 (Jan 13 2007 - 23:44:23)
 
U-Boot 1.1.6 (Jan 13 2007 - 23:44:23)
Line 105: Line 118:
 
</pre>
 
</pre>
  
== 建立可引导的映像文件 ==
+
== 建立可启动的映像档 ==
 
+
u-boot needs bootable images (such as kernels, but also initrd and others) in form of a so-called ''uImage''.  In order to create a ''uImage'' from e.g. a ''vmlinux'' kernel image, you can proceed as follows:
+
  
 +
u-boot 需要可启动的映像档 (如kernels,也包括 initrd 及其它内容) ,形成所谓的''uImage''。为了建立''uImage'',如从''vmlinux'' kernel 映像档,你可以进行下面的处理:
 
<pre>
 
<pre>
 
objcopy -O binary -R .note -R .comment -S vmlinux linux.bin
 
objcopy -O binary -R .note -R .comment -S vmlinux linux.bin
Line 115: Line 127:
 
</pre>
 
</pre>
  
== 引导菜单 ==
+
== 启动选单==
 
[[Image:Neo1973 uboot menu.jpg|thumb|400px|u-boot boot menu on Neo1973]]
 
[[Image:Neo1973 uboot menu.jpg|thumb|400px|u-boot boot menu on Neo1973]]
  
As of the Phase-0 release, our u-boot version now features an on-screen boot menu.
+
从Phase-0 释出后,我们的u-boot版本现在放在以屏幕显示的启动选单中,选单中的项目被定义在[[bootloader environment#menu|环境选单输入]]中。
  
=== 进入引导菜单 ===
+
=== 存取启动选单===
  
You can access the boot meny by pressing and holding the [[Neo1973 AUX Button]] together with the power button while switching the phone on.
+
你可以在启动电话时,藉由按下[[Neo1973 AUX Button]] 及电源按钮来存取选单。
  
=== 使用引导菜单 ===
+
=== 使用启动选单===
  
By pressing the [[Neo1973 AUX Button]] you can cycle through the menu items.  Use the ''POWER'' button to select one item.
+
藉由按下[[Neo1973 AUX Button]] 你可以循环使用选单项目。使用''POWER''按钮选取其中的项目。
  
=== 给引导菜单增加项目 ===
+
== Bootloader 命令提示==
  
You can add items to the boot menu by setting environment variables.  FIXME.
+
===存取bootloader的命令提示===
 +
bootloader 命令提示可以在序列控制台上进行 (透过[[Debug Board]]) 或者是虚拟USB 序列装置(USB CDC_ACM)。
 +
不论是串行端口或usb,都依照'''stdin'''、 '''stdout''' 及 '''stderr''' u-boot 环境变量而定。
  
== 引导装载程序命令提示行 ==
+
不论你是否使用usbtty,前面的讯息会在序列控制台中显示。bootloader 目前被设定为三秒钟的等待时间。如果在 三秒内,'''stdin'''中收到键入的讯息,自动启动就会被取消掉。
  
=== Accessing the bootloader prompt ===
+
==== 自Linux中使用usbtty ====
The bootloader prompt is available either on the serial console (via [[Debug Board]]), or as virtual USB Serial device (USB CDC_ACM).
+
Whether the serial port or usb i used depends on the u-boot environment variables '''stdin''', '''stdout''' and '''stderr'''.
+
  
Whether or not you use usbtty, the first couple of messages will always be displayed on the serial console.
+
藉由在u-boot模式下连接电话到Linux 主机上,它会让它侦测到 [[CDC ACM]] 装置,你会拥有一个名为/dev/ttyACM0的新tty装置。若没有的话,请启用CONFIG_USB_ACM (Device Drivers -> USB support -> USB Modem (CDC ACM) support)。 (MacOS 的使用者请参考[[MacOS_X#USB_Serial|这里取得更多信息]])
  
The bootloader is currently configured to waid for three secondsIf a key press on the '''stdin''' is received within those three seconds, auto-boot is aborted.
+
使用你熟悉的仿真器 (minicom, cu, zc, screen ...) 像使用任何串行端口般存取。如果你并没有熟悉的仿真器,可以试试看: (位于taylor-uucp 中的cu,使用"apt-get 安装 cu" 如果它还未安装话。
 +
  cu -l /dev/ttyACM0
  
==== Using usbtty from Linux ====
+
你会需要用到
 +
chown uucp.uucp /dev/ttyACM0
  
Just by connecting the phone in u-boot mode to your Linux pc should make it detect a [[CDC ACM]] device, and you should get a new tty device called /dev/ttySAC0.  Use your favourite terminal emulator (minicom, cu, zc, ...) to access it like any other serial port.
+
取得必要的权限(甚至是root)
  
First, you should try to check whether the USB device shows up in 'lsusb' while you're running in u-boot mode:
+
可以用来取代cu的另一个方法是 Werner Almesberger的 [[NeoCon|neocon]]。
  
<pre>
+
首先,你必须试着去查看在你执行u-boot模式时,USB装置是否出现了'lsusb' 。
# lsusb -d 1457:5119
+
 
Bus 005 Device 079: ID 1457:5119   
+
# lsusb -d 1457:5119
</pre>
+
Bus 005 Device 079: ID 1457:5119   
 +
 
 +
接着,让我们来查看更多可用的endpoint及设定:
  
 
<pre>
 
<pre>
Line 255: Line 271:
 
</pre>
 
</pre>
  
Next, you can access it using your favourite terminal program.
+
接下来,你可以使用你最喜欢的终端机程序存取它。之后,若环境仍然不正确的话,你必须使用目前的控制台(如序列控制台(serial console)) 来变更[[bootloader environment#console|控制台环境下的输入选项]]:
 
+
Then, if the environment is not set correctly, you will need to use the current console (e.g. serial console) to set
+
 
<pre>
 
<pre>
 
GTA01Bv2 # setenv stderr usbtty
 
GTA01Bv2 # setenv stderr usbtty
Line 264: Line 278:
 
</pre>
 
</pre>
  
==== Typical u-boot prompt ====
+
==== 典型的u-boot提示字符====
  
 
<pre>
 
<pre>
Line 281: Line 295:
 
</pre>
 
</pre>
  
=== Commands on the bootloader prompt ===
+
=== bootloader 提示字符下的指令===
  
==== 自动引导 ====
+
'请参考[[bootloader commands|bootloader 指令集]].''
  
Auto-boot executes the command[s] specified in the ''bootcmd'' environment variable. The default configuration is:
 
<pre>
 
GTA01Bv3 # printenv
 
bootcmd=setenv bootargs ${bootargs_base} ${mtdparts}; nand read.e 0x32000000 kernel; bootm 0x32000000
 
</pre>
 
  
This basically tells us that it will load the content of the NAND partition '''kernel''' to memory address 0x32000000 and then try to boot it. 
+
== 装置轫体更新==
  
==== 环境变量 ====
+
u-boot也可以使用[[USB DFU]]做为更新工具。对于快速测试下的加载档案及kernel而言,是很有效的一个方法。
 +
要找出你的u-boot版本是否支持这个USB DFU,请使用下面的方法:
 +
$ lsusb -v -d 1457:5119
 +
当装置目前使用的是u-boot模式。
  
u-boot is configured to manage a non-volatile environment that is stored in NAND flash.  You can use the commands to read/alter/store the environment in the following example:
+
如果它支持DFU,你可以在输出的讯息后面看到以下的内容:
 
<pre>
 
<pre>
GTA01Bv2 # printenv
+
    Interface Descriptor:
baudrate=115200
+
      bLength                9
bootargs=rootfstype=jffs2 root=/dev/mtdblock4 console=ttySAC0,115200 console=tty0 loglevel=8 dyntick=enable lpj=252416
+
      bDescriptorType        4
usbtty=cdc_acm
+
      bInterfaceNumber        2
bootdelay=10
+
      bAlternateSetting      0
stdout=serial
+
      bNumEndpoints          0
stderr=serial
+
      bInterfaceClass      254 Application Specific Interface
stdin=serial
+
      bInterfaceSubClass      1 Device Firmware Update
mtdparts=mtdparts=neo1973-nand:0x00030000(u-boot),0x0000c000(u-boot_env),0x00200000(kernel),0x00130000(splash),0x03c94000(rootfs)
+
      bInterfaceProtocol      1
mtdids=nand0=neo1973-nand
+
      iInterface              0
bootargs_base=rootfstype=jffs2 root=/dev/mtdblock4 console=ttySAC0,115200 console=tty0 loglevel=8 dyntick=enable lpj=252416
+
bootcmd=setenv bootargs ${bootargs_base} ${mtdparts}; nand read.e 0x32000000 kernel; bootm 0x32000000
+
pcf50606_int1=0x40
+
filesize=160C000
+
partition=nand0,0
+
mtddevnum=0
+
mtddevname=u-boot
+
 
+
Environment size: 670/16380 bytes
+
GTA01Bv3 # setenv bootdelay 10
+
GTA01Bv3 # printenv bootdelay
+
bootdelay=10
+
GTA01Bv3 # saveenv
+
Saving Environment to NAND...
+
Erasing Nand...Writing to Nand... done
+
GTA01Bv3 #
+
 
</pre>
 
</pre>
  
Note: When setting multiple commands, e.g. for bootcmd, you need to escape the ';', for instance
+
要查看韧体如何更新,请参考[[dfu-util]]。
  
<pre>
+
=== 透过DFU置入档案 ===
GTA01Bv3 # setenv bootcmd mmcinit\; ext2load mmc 0 0x32000000 uImage\; bootm 0x32000000
+
</pre>
+
  
==== MMC/SD卡 ====
+
要将档案加载内存位置0x32000000:
 
+
in order to initialize a MMC/SD card, you have to use the ``mmcinit'' command.
+
 
<pre>
 
<pre>
GTA01Bv3 # mmcinit
+
dfu-util -a 0 -D fileToLoad -R
trying to detect SD Card...
+
MMC found. Card desciption is:
+
Manufacturer ID = 58d564
+
HW/FW Revision = 3 8
+
Product Name = 21DN!@X�
+
Serial Number = 445303
+
Month = 5
+
Year = 2000
+
READ_BL_LEN=15, C_SIZE_MULT=7, C_SIZE=3197
+
size = 4208984064
+
GTA01Bv3 #
+
 
</pre>
 
</pre>
  
afterwards, you can read ext2 filesystems like:
+
之后,传送'bootm 0x32000000' 到u-boot或者 'bootelf 0x32000000',如果它是一个elf档案。
<pre>
+
GTA01Bv3 # ext2ls mmc 0
+
<DIR>      1024 .
+
<DIR>      1024 ..
+
<DIR>      12288 lost+found
+
        1544788 uImage
+
</pre>
+
  
==== NAND ====
+
简单的python script可以启动ELF映像档—以防止ACM bug破坏较大的封包。
  
 
<pre>
 
<pre>
GTA01Bv3 # help nand
+
#!/usr/bin/python
nand info                  - show available NAND devices
+
import sys
nand device [dev]    - show or set current device
+
import os
nand read[.jffs2]    - addr off size
+
import time
nand write[.jffs2]    - addr off size - read/write `size' bytes starting
+
    at offset `off' to/from memory address `addr'
+
nand erase [clean] [off size] - erase `size' bytes from
+
    offset `off' (entire device if not specified)
+
nand bad - show bad blocks
+
nand dump[.oob] off - dump page
+
nand scrub - really clean NAND erasing bad blocks (UNSAFE)
+
nand markbad off - mark bad block at offset (UNSAFE)
+
nand biterr off - make a bit error at offset (UNSAFE)
+
</pre>
+
  
===== 从 NAND 加载内核 =====
+
cmd1 = "neo backlight off\n"
 +
cmd2 = "bootelf 0x32000000\n"
  
<pre>
+
def output(tty, str):
GTA01Bv3 # nand read 0x32000000 kernel
+
    for x in str:
 +
        tty.write(x)
 +
        tty.flush()
  
NAND read: device 0 offset 212992, size 2097152 ...  2097152 bytes read: OK
+
if len(sys.argv) == 2:
GTA01Bv3 # bootm 0x32000000
+
    print "Loading %s..." % sys.argv[1]
## Booting image at 32000000 ...
+
  Image Name:  OpenMoko Kernel Image Neo1973
+
  Created:      2007-02-15  23:54:18 UTC
+
  Image Type:  ARM Linux Kernel Image (gzip compressed)
+
  Data Size:    1546258 Bytes = 1.5 MB
+
  Load Address: 30008000
+
  Entry Point:  30008000
+
  Verifying Checksum ... OK
+
  Uncompressing Kernel Image ... OK
+
Starting kernel ...
+
</pre>
+
  
===== 向 NAND 写新的引导装载程序 =====
+
    loadfile = "dfu-util -a 0 -D %s -R" % sys.argv[1]
  
The following set of commands loads the file u-boot.bin from ext2/mmc and flashes it into the
+
    os.system(loadfile)
bootloader flash partition:
+
  
<pre>
+
    time.sleep(3)
GTA01Bv3 # ext2load mmc 0 0x32000000 u-boot.bin
+
GTA01Bv3 # nand erase u-boot
+
GTA01Bv3 # nand write 0x32000000 u-boot ${filesize}
+
</pre>
+
  
===== 向 NAND 写内核 =====
+
    tty = open("/dev/ttyACM0", "a")
  
The following set of commands loads the file uImage from ext2/mmc and flashes it into the
+
    output(tty, cmd1)
kernel flash partition:
+
    output(tty, cmd2)
  
<pre>
+
    tty.close()
GTA01Bv3 # ext2load mmc 0 0x32000000 uImage
+
else:
GTA01Bv3 # nand erase kernel
+
    print "Usage: %s elffile" % sys.argv[0]
GTA01Bv3 # nand write.e 0x32000000 kernel ${filesize}
+
    print ""
 +
    sys.exit(2)
 
</pre>
 
</pre>
  
===== 向 NAND 写根文件系统 =====
+
== 问题排除 ==
  
The following set of commands loads the file rootfs.jffs2 from ext2/mmc and flashes it into the
+
=== USB连接问题 ===
rootfs flash partition:
+
  
<pre>
+
在连接Neo时,位于u-boot下,在Linux主机上,我曾经遇到如下的问题 (在 dmesg or /var/log/messages) o。
GTA01Bv3 # ext2load mmc 0 0x32000000 rootfs.jffs2
+
GTA01Bv3 # nand erase rootfs
+
GTA01Bv3 # nand write.e 0x32000000 rootfs ${filesize}
+
</pre>
+
  
Please note that this will only work with root file system sizes that are smaller than the amount of memory above 0x32000000, which in the case of 64MB SDRAM is something like 32MB.
+
usb 2-1: device descriptor read/64, error -110
 +
usb usb2: Controller not stopped yet!
  
==== Neo1973 相关的命令 ====
+
利用下面的指令,我解决掉上述的问题。请注意,如果你没有USB键盘或者是鼠标,用这些指令可能会造成问题。 我只有PS/2界面的装置,所以,并无法测试这个问题。
  
我们的 u-boot 支持几个 Neo1973 专用命令:
+
rmmod uhci_hcd ; modprobe uhci_hcd
<pre>
+
GTA01Bv2 # help neo1973
+
neo1973 neo1973 info - display phone informantion
+
neo1973 power-off - switch off the phone
+
neo1973 charger status - display charger status
+
neo1973 charger autofast - enable automatic fast (500mA) charging
+
neo1973 charger !autofast - disable automatic fast (500mA) charging
+
neo1973 charger fast - enable fast (500mA) charging
+
neo1973 charger off - disable charging
+
neo1973 backlight (on|off) - switch backlight on or off
+
neo1973 vibrator (on|off) - switch vibrator on or off
+
</pre>
+
  
===== 关机 =====
 
  
使用
 
neo1973 power-off
 
 
you can switch the device off from the bootloader prompt.
 
 
===== 充电器相关 =====
 
 
For a detailed description of the charger basics, see [[Neo1973 Battery Charger]].
 
 
====== 查询充电器状态 ======
 
 
You can get the current charger status by issuing
 
neo1973 charger status
 
 
The following modes are possible:
 
 
* idle - no charging
 
* trickle - FIXME
 
* pre - Slow (100mA) charging, works in hardware.
 
* fast_cccv - Fast (500mA) charging, using Constant-Current followed by Constant Voltage (Li-Ion)
 
 
====== 禁用充电器 ======
 
 
You can disable battery charging (until the next reboot) by issuing
 
neo1973 charger off
 
 
====== 强制快速充电 ======
 
 
使用
 
neo1973 charger fast
 
you can force the PMU to try to do a fast (500mA) charge of the battery. It will abort if the battery is in over temperature or some other error condition occurs.
 
 
====== 使能/禁用自动快速充电 ======
 
 
Autofast is a feature of the PCF50606 PMU.  It means that the fast_cccv mode will be automatically selected if a charger with suitable voltage is plugged in, and the battery not in over temperature condition.
 
 
{{warning|This is potentially dangerous.  Only enable autofast if you ARE SURE that you can draw 500mA from the USB connector.  This is the case with a wall outlet charger, or if you are attached to a self-powered hub or a desktop PC root hub.  Bus powered hubs and some laptops only provide 100mA on their USB ports and can thus not support fast charging}}
 
 
You can enable or disable autofast by
 
neo1973 charger autofast
 
and
 
neo1973 charger !autofast
 
respectively.
 
 
===== 背光灯 =====
 
 
You can switch the backlight on and off by using
 
neo1973 backlight on
 
and
 
neo1973 backlight off
 
respectively.
 
 
===== 振动 =====
 
 
You can switch the vibrator on and off by using
 
neo1973 vibrator on
 
and
 
neo1973 vibrator off
 
respectively.
 
 
==== S3C2410 专用命令 ====
 
 
<pre>
 
GTA01Bv2 # help s3c2410
 
s3c2410 speed get - display current PLL speed config
 
s3c2410 speed list - display supporte PLL speed configs
 
s3c2410 speed set - set PLL speed
 
GTA01Bv2 # s3c2410 speed list
 
50 MHz
 
101 MHz
 
202 MHz
 
266 MHz
 
GTA01Bv2 # s3c2410 speed get
 
FCLK = 202 MHz, HCLK = 101 MHz, PCLK = 50 MHz
 
GTA01Bv2 # s3c2410 speed set 101
 
GTA01Bv2 # s3c2410 speed get
 
FCLK = 101 MHz, HCLK = 50 MHz, PCLK = 50 MHz
 
</pre>
 
 
===== 266MHz时钟 =====
 
 
You can re-configure the [[S3C2410]] PLL to generate a 266 MHz core cpu clock (rather than the 200MHz default) by using
 
GTA01Bv2 # s3c2410 speed set 266
 
and
 
GTA01Bv2 # s3c2410 speed set 202
 
respectively.
 
 
{{warning|The current hardware (as of GTA01Bv3) only runs stable at 266MHz if you do not attach aynthing (esp. the FPC / [[Debug Board]] to the Debug Port}}
 
 
==== QT2410上的TFTP ====
 
 
The QT2410 cs8900a Ethernet can be used to download images via network.
 
 
First, you have to make sure that ''ipaddr'', ''serverip'', ''ethaddr' and ''netmaskk'' are set correctly in the environment:
 
 
<pre>
 
QT2410 # printenv
 
ethaddr=00:01:02:03:04:05
 
netmask=255.255.255.0
 
ipaddr=192.168.100.100
 
serverip=192.168.100.1
 
</pre>
 
 
 
===== TFTP kernel download =====
 
 
<pre>
 
QT2410 # tftpboot 0x32000000
 
*** Warning: no boot file name; using 'C0A86464.img'
 
TFTP from server 192.168.100.1; our IP address is 192.168.100.100
 
Filename 'C0A86464.img'.
 
Load address: 0x32000000
 
Loading: #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        ##########################################
 
done
 
Bytes transferred = 1544788 (179254 hex)
 
</pre>
 
 
you can then commence booting via
 
<pre>
 
QT2410# bootm 0x32000000
 
</pre>
 
 
== 设备固件升级 ==
 
 
Our version of u-boot also implements [[USB DFU]].
 
 
To find out whether your version of u-boot supports this, use the output of
 
$ lsusb -v -d 1457:5119
 
while the phone is in u-boot mode.
 
 
If it supports DFU, you should see the following snippet towards the end of the output:
 
<pre>
 
    Interface Descriptor:
 
      bLength                9
 
      bDescriptorType        4
 
      bInterfaceNumber        2
 
      bAlternateSetting      0
 
      bNumEndpoints          0
 
      bInterfaceClass      254 Application Specific Interface
 
      bInterfaceSubClass      1 Device Firmware Update
 
      bInterfaceProtocol      1
 
      iInterface              0
 
</pre>
 
 
关于如何进行固件升级的信息,请看[[dfu-util/zh_cn|dfu-util]]。
 
 
{{Languages|Bootloader}}
 
  
 
[[Category:Software]]
 
[[Category:Software]]
 +
[[Category:Kernel]]
 +
[[Category:Guides]]

Revision as of 06:34, 29 April 2008

u-boot menu on Neo1973
u-boot splash screen on Neo1973

Neo1973上的bootloader U-Boot,负责硬件装置的功能运作,直到 Openmoko被启动加载装置为止。这包括用来更新OpenmokUSB DFU、屏幕显示、启动选单、bootloader 指令列 控制台。透过 bootloader 环境设定及加载kernel等。

有不同的bootloader版本可供使用:

Contents

Phase0 快速启动

  • 请确认你的电话是目前是装好电池,并且USB接线至少移开30秒以上。
  • 利用USB接线,将Neo (并不是侦错板) 连接到Linux主机。
  • 在启动电源时,按住AUX按钮以存取选单。
  • 将控制台设定为USB。
  • 在Linux主机上利用「终端机」连接到/dev/ttyACM0 (你可能会用到chown uucp.uucp /dev/ttyACM0 )。
  • 请注意cdc_acm /dev/ttyACM0 存取会连同Neo boots一起消失,它会被cdc_ether usb0网络存取取代。
  • 你现在会进入bootloader 提示指令下。
  • 如果你希望在每次启动时都停留在bootloader,将bootdelay uboot 环境变量设定为-1 。

一般

GTA01 使用u-boot bootloader.

关于u-boot的更多信息,可以参考下列网址:

您也可以参考下面的内容,得到其它u-boot的信息:

  • 使用S3C2410 Steppingstone支持从NAND 中启动
  • 支持S3C2410 NAND 内存
  • 支持透过S3C2410 USB 装置控制器下载程序
  • 支持在S3C2410 Framebuffer中显示启动logo / 状态

然而,u-boot并不会支持GTA01所需要的功能,如

  • 支持从SD/Transflash读取kernel/initrd

HaraldWelte目前正在进行这项工作,事实上,已完成大部份的工作。

Bootloader 源码

目前的bootloader patche 可以在http://svn.openmoko.org/trunk/src/target/u-boot/patches/这个位置]下位置取得。.

将源码解压缩缩,套用到patch,执行"make gta01bv3_config" (或gta01bv2_config, 或你拥有的任何硬件版本),执行"make"。你将会得到"u-boot.bin" 映像档,你可以在NAND中直接更新 (也可以使用现有的bootloader 或 sjf2410-linux)。


Bootloader 二进制文件

最新的bootloader 二进制文件可以在以下的位置中找到under http://buildhost.openmoko.org/snapshots in the subdirectory 200X.XX/images/。它应该被写入NAND 0x00000000的位置 (大小为0x30000) (第一个 分割区).

开发Bootloader

QT2410

如果你想要在QT2410上开发bootloader,使用bootloader 映像档更新会从USB上下载到RAM来的简单的多。 要进行这项工作,你必须编辑u-boot/include/configs/qt2410.h 档案,并且将第32行程序中的"if 0"变更为 "if 1",之后再使用"make"重新编译。

产生的"u-boot.bin" 档案对于NAND内存并不稳定,但却可以直接或在RAM中执行,如透过使用s3c2410_boot_usb 程序。

GTA01

在GTA01上开发bootloader是很辣手的一件事情,首先,我们并不会有任何的NOR内存。第二,并没有其它的方法可以不从NAND中启动。然而,我们也不会有一个像QT2410一样的USB下载器。

最主要的问题是:S3C2410 Steppingstone内部的SRAM的前4K并没有被限制。SRAM 分割并非绝对性的对应到实体0的位置。我们要如何因应呢?

使用JTAG 自RAM中启动

那我们要如何自RAM启动?我们使用JTAG / OpenOCD 进行:

  • 在PC=0的时候重设及暂停CPU
> reset halt
target halted in ARM state due to debug request, current mode: Supervisor
cpsr: 0x400000d3 pc: 0x00000000
MMU: disabled, D-Cache: disabled, I-Cache: disabled
  • 针对低阶SDRAM启动下载程序片段 (做为4k的sram踏脚石)
> load_binary /space/misc/gta01/u-boot.git/board/gta01/lowlevel_foo.bin 0            
downloaded 332 byte in 0s 21899us
  • 在0x33f80000插入断点 (能指出低阶程序已完成)
> bp 0x33f80000 4 hw
在0x33f80000 中加入断点
  • 执行程序到断点
> resume
Target 0 重新开始
> Target 0 halted
因断点的关系,目标暂停,目前的模式为:Supervisor
cpsr: 0x600000d3 pc: 0x33f80000
MMU: disabled, D-Cache: disabled, I-Cache: enabled
  • 下载u-boot RAM映像档到0x33f80000
> load_binary /space/misc/gta01/u-boot.git/u-boot.bin 0x33f80000
downloaded 135692 byte in 6s 567264us
  • 继续处理
> resume
Target 0 重新开始

在进行到这里时,显示的背光会变明亮,我们会看到下面的指令:

U-Boot 1.1.6 (Jan 13 2007 - 23:44:23)

DRAM:  128 MB
NAND:  64 MiB
*** Warning - bad CRC or NAND, using default environment

In:    serial
Out:   serial
Err:   serial
Hit any key to stop autoboot:  0 
GTA01Bv2 # 

建立可启动的映像档

u-boot 需要可启动的映像档 (如kernels,也包括 initrd 及其它内容) ,形成所谓的uImage。为了建立uImage,如从vmlinux kernel 映像档,你可以进行下面的处理:

objcopy -O binary -R .note -R .comment -S vmlinux linux.bin
gzip -9 linux.bin
u-boot/tools/mkimage -A arm -O linux -T kernel -C gzip -a 30008000 -e 30008000 -n "Kernel Image QT2410" -d linux.bin.gz uImage

启动选单

u-boot boot menu on Neo1973

从Phase-0 释出后,我们的u-boot版本现在放在以屏幕显示的启动选单中,选单中的项目被定义在环境选单输入中。

存取启动选单

你可以在启动电话时,藉由按下Neo1973 AUX Button 及电源按钮来存取选单。

使用启动选单

藉由按下Neo1973 AUX Button 你可以循环使用选单项目。使用POWER按钮选取其中的项目。

Bootloader 命令提示

存取bootloader的命令提示

bootloader 命令提示可以在序列控制台上进行 (透过Debug Board) 或者是虚拟USB 序列装置(USB CDC_ACM)。 不论是串行端口或usb,都依照stdinstdoutstderr u-boot 环境变量而定。

不论你是否使用usbtty,前面的讯息会在序列控制台中显示。bootloader 目前被设定为三秒钟的等待时间。如果在 三秒内,stdin中收到键入的讯息,自动启动就会被取消掉。

自Linux中使用usbtty

藉由在u-boot模式下连接电话到Linux 主机上,它会让它侦测到 CDC ACM 装置,你会拥有一个名为/dev/ttyACM0的新tty装置。若没有的话,请启用CONFIG_USB_ACM (Device Drivers -> USB support -> USB Modem (CDC ACM) support)。 (MacOS 的使用者请参考这里取得更多信息)

使用你熟悉的仿真器 (minicom, cu, zc, screen ...) 像使用任何串行端口般存取。如果你并没有熟悉的仿真器,可以试试看: (位于taylor-uucp 中的cu,使用"apt-get 安装 cu" 如果它还未安装话。

cu -l /dev/ttyACM0

你会需要用到

chown uucp.uucp /dev/ttyACM0

取得必要的权限(甚至是root)

可以用来取代cu的另一个方法是 Werner Almesberger的 neocon

首先,你必须试着去查看在你执行u-boot模式时,USB装置是否出现了'lsusb' 。

# lsusb -d 1457:5119
Bus 005 Device 079: ID 1457:5119  

接着,让我们来查看更多可用的endpoint及设定:

# lsusb -v -d 1457:5119
Bus 005 Device 079: ID 1457:5119  
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass            2 Communications
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        16
  idVendor           0x1457 
  idProduct          0x5119 
  bcdDevice            0.00
  iManufacturer           1 OpenMoko, Inc
  iProduct                2 Neo1973 Bootloader U-Boot 1.2.0-g6c7cac8c-dirty-moko3
  iSerial                 3 0000000
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           85
    bNumInterfaces          3
    bConfigurationValue     1
    iConfiguration          4 TTY via USB
    bmAttributes         0xc0
      Self Powered
    MaxPower                0mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         2 Communications
      bInterfaceSubClass      2 Abstract (modem)
      bInterfaceProtocol      1 AT-commands (v.25ter)
      iInterface              6 Control Interface
      CDC Header:
        bcdCDC               0.6e
      CDC Call Management:
        bmCapabilities       0x00
        bDataInterface          1
      CDC ACM:
        bmCapabilities       0x00
      CDC Union:
        bMasterInterface        0
        bSlaveInterface         1 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0010  1x 16 bytes
        bInterval             255
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass        10 CDC Data
      bInterfaceSubClass      0 Unused
      bInterfaceProtocol      0 
      iInterface              5 Bulk Data Interface
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0010  1x 16 bytes
        bInterval             255
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x83  EP 3 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0010  1x 16 bytes
        bInterval             255
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        2
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass       254 Application Specific Interface
      bInterfaceSubClass      1 Device Firmware Update
      bInterfaceProtocol      1 
      iInterface              7 USB Device Firmware Upgrade
Device Status:     0x0001
  Self Powered

接下来,你可以使用你最喜欢的终端机程序存取它。之后,若环境仍然不正确的话,你必须使用目前的控制台(如序列控制台(serial console)) 来变更控制台环境下的输入选项

GTA01Bv2 # setenv stderr usbtty
GTA01Bv2 # setenv stdout usbtty
GTA01Bv2 # setenv stdin usbtty

典型的u-boot提示字符

U-Boot 1.2.0-moko1 (Feb 16 2007 - 00:36:13)

DRAM:  128 MB
NAND:  64 MiB
Found Environment offset in OOB..
Video: 640x480x8 31kHz 59Hz
USB:   S3C2410 USB Deviced
In:    serial
Out:   serial
Err:   serial
Hit any key to stop autoboot:  0 
GTA01Bv3 #

bootloader 提示字符下的指令

'请参考bootloader 指令集.


装置轫体更新

u-boot也可以使用USB DFU做为更新工具。对于快速测试下的加载档案及kernel而言,是很有效的一个方法。 要找出你的u-boot版本是否支持这个USB DFU,请使用下面的方法:

$ lsusb -v -d 1457:5119

当装置目前使用的是u-boot模式。

如果它支持DFU,你可以在输出的讯息后面看到以下的内容:

    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        2
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass       254 Application Specific Interface
      bInterfaceSubClass      1 Device Firmware Update
      bInterfaceProtocol      1 
      iInterface              0 

要查看韧体如何更新,请参考dfu-util

透过DFU置入档案

要将档案加载内存位置0x32000000:

dfu-util -a 0 -D fileToLoad -R

之后,传送'bootm 0x32000000' 到u-boot或者 'bootelf 0x32000000',如果它是一个elf档案。

简单的python script可以启动ELF映像档—以防止ACM bug破坏较大的封包。

#!/usr/bin/python
import sys
import os
import time

cmd1 = "neo backlight off\n"
cmd2 = "bootelf 0x32000000\n"

def output(tty, str):
    for x in str:
        tty.write(x)
        tty.flush()

if len(sys.argv) == 2:
    print "Loading %s..." % sys.argv[1]

    loadfile = "dfu-util -a 0 -D %s -R" % sys.argv[1]

    os.system(loadfile)

    time.sleep(3)

    tty = open("/dev/ttyACM0", "a")

    output(tty, cmd1)
    output(tty, cmd2)

    tty.close()
else:
    print "Usage: %s elffile" % sys.argv[0]
    print ""
    sys.exit(2)

问题排除

USB连接问题

在连接Neo时,位于u-boot下,在Linux主机上,我曾经遇到如下的问题 (在 dmesg or /var/log/messages) o。

usb 2-1: device descriptor read/64, error -110 usb usb2: Controller not stopped yet!

利用下面的指令,我解决掉上述的问题。请注意,如果你没有USB键盘或者是鼠标,用这些指令可能会造成问题。 我只有PS/2界面的装置,所以,并无法测试这个问题。

rmmod uhci_hcd ; modprobe uhci_hcd

Personal tools
u-boot menu on Neo1973
u-boot splash screen on Neo1973

Neo1973上的bootloader U-Boot,负责硬件装置的功能运作,直到 Openmoko被启动加载装置为止。这包括用来更新OpenmokUSB DFU、屏幕显示、启动选单、bootloader 指令列 控制台。透过 bootloader 环境设定及加载kernel等。

有不同的bootloader版本可供使用:

Phase0 快速启动

  • 请确认你的电话是目前是装好电池,并且USB接线至少移开30秒以上。
  • 利用USB接线,将Neo (并不是侦错板) 连接到Linux主机。
  • 在启动电源时,按住AUX按钮以存取选单。
  • 将控制台设定为USB。
  • 在Linux主机上利用「终端机」连接到/dev/ttyACM0 (你可能会用到chown uucp.uucp /dev/ttyACM0 )。
  • 请注意cdc_acm /dev/ttyACM0 存取会连同Neo boots一起消失,它会被cdc_ether usb0网络存取取代。
  • 你现在会进入bootloader 提示指令下。
  • 如果你希望在每次启动时都停留在bootloader,将bootdelay uboot 环境变量设定为-1 。

一般

GTA01 使用u-boot bootloader.

关于u-boot的更多信息,可以参考下列网址:

您也可以参考下面的内容,得到其它u-boot的信息:

  • 使用S3C2410 Steppingstone支持从NAND 中启动
  • 支持S3C2410 NAND 内存
  • 支持透过S3C2410 USB 装置控制器下载程序
  • 支持在S3C2410 Framebuffer中显示启动logo / 状态

然而,u-boot并不会支持GTA01所需要的功能,如

  • 支持从SD/Transflash读取kernel/initrd

HaraldWelte目前正在进行这项工作,事实上,已完成大部份的工作。

Bootloader 源码

目前的bootloader patche 可以在http://svn.openmoko.org/trunk/src/target/u-boot/patches/这个位置]下位置取得。.

将源码解压缩缩,套用到patch,执行"make gta01bv3_config" (或gta01bv2_config, 或你拥有的任何硬件版本),执行"make"。你将会得到"u-boot.bin" 映像档,你可以在NAND中直接更新 (也可以使用现有的bootloader 或 sjf2410-linux)。


Bootloader 二进制文件

最新的bootloader 二进制文件可以在以下的位置中找到under http://buildhost.openmoko.org/snapshots in the subdirectory 200X.XX/images/。它应该被写入NAND 0x00000000的位置 (大小为0x30000) (第一个 分割区).

开发Bootloader

QT2410

如果你想要在QT2410上开发bootloader,使用bootloader 映像档更新会从USB上下载到RAM来的简单的多。 要进行这项工作,你必须编辑u-boot/include/configs/qt2410.h 档案,并且将第32行程序中的"if 0"变更为 "if 1",之后再使用"make"重新编译。

产生的"u-boot.bin" 档案对于NAND内存并不稳定,但却可以直接或在RAM中执行,如透过使用s3c2410_boot_usb 程序。

GTA01

在GTA01上开发bootloader是很辣手的一件事情,首先,我们并不会有任何的NOR内存。第二,并没有其它的方法可以不从NAND中启动。然而,我们也不会有一个像QT2410一样的USB下载器。

最主要的问题是:S3C2410 Steppingstone内部的SRAM的前4K并没有被限制。SRAM 分割并非绝对性的对应到实体0的位置。我们要如何因应呢?

使用JTAG 自RAM中启动

那我们要如何自RAM启动?我们使用JTAG / OpenOCD 进行:

  • 在PC=0的时候重设及暂停CPU
> reset halt
target halted in ARM state due to debug request, current mode: Supervisor
cpsr: 0x400000d3 pc: 0x00000000
MMU: disabled, D-Cache: disabled, I-Cache: disabled
  • 针对低阶SDRAM启动下载程序片段 (做为4k的sram踏脚石)
> load_binary /space/misc/gta01/u-boot.git/board/gta01/lowlevel_foo.bin 0            
downloaded 332 byte in 0s 21899us
  • 在0x33f80000插入断点 (能指出低阶程序已完成)
> bp 0x33f80000 4 hw
在0x33f80000 中加入断点
  • 执行程序到断点
> resume
Target 0 重新开始
> Target 0 halted
因断点的关系,目标暂停,目前的模式为:Supervisor
cpsr: 0x600000d3 pc: 0x33f80000
MMU: disabled, D-Cache: disabled, I-Cache: enabled
  • 下载u-boot RAM映像档到0x33f80000
> load_binary /space/misc/gta01/u-boot.git/u-boot.bin 0x33f80000
downloaded 135692 byte in 6s 567264us
  • 继续处理
> resume
Target 0 重新开始

在进行到这里时,显示的背光会变明亮,我们会看到下面的指令:

U-Boot 1.1.6 (Jan 13 2007 - 23:44:23)

DRAM:  128 MB
NAND:  64 MiB
*** Warning - bad CRC or NAND, using default environment

In:    serial
Out:   serial
Err:   serial
Hit any key to stop autoboot:  0 
GTA01Bv2 # 

建立可启动的映像档

u-boot 需要可启动的映像档 (如kernels,也包括 initrd 及其它内容) ,形成所谓的uImage。为了建立uImage,如从vmlinux kernel 映像档,你可以进行下面的处理:

objcopy -O binary -R .note -R .comment -S vmlinux linux.bin
gzip -9 linux.bin
u-boot/tools/mkimage -A arm -O linux -T kernel -C gzip -a 30008000 -e 30008000 -n "Kernel Image QT2410" -d linux.bin.gz uImage

启动选单

u-boot boot menu on Neo1973

从Phase-0 释出后,我们的u-boot版本现在放在以屏幕显示的启动选单中,选单中的项目被定义在环境选单输入中。

存取启动选单

你可以在启动电话时,藉由按下Neo1973 AUX Button 及电源按钮来存取选单。

使用启动选单

藉由按下Neo1973 AUX Button 你可以循环使用选单项目。使用POWER按钮选取其中的项目。

Bootloader 命令提示

存取bootloader的命令提示

bootloader 命令提示可以在序列控制台上进行 (透过Debug Board) 或者是虚拟USB 序列装置(USB CDC_ACM)。 不论是串行端口或usb,都依照stdinstdoutstderr u-boot 环境变量而定。

不论你是否使用usbtty,前面的讯息会在序列控制台中显示。bootloader 目前被设定为三秒钟的等待时间。如果在 三秒内,stdin中收到键入的讯息,自动启动就会被取消掉。

自Linux中使用usbtty

藉由在u-boot模式下连接电话到Linux 主机上,它会让它侦测到 CDC ACM 装置,你会拥有一个名为/dev/ttyACM0的新tty装置。若没有的话,请启用CONFIG_USB_ACM (Device Drivers -> USB support -> USB Modem (CDC ACM) support)。 (MacOS 的使用者请参考这里取得更多信息)

使用你熟悉的仿真器 (minicom, cu, zc, screen ...) 像使用任何串行端口般存取。如果你并没有熟悉的仿真器,可以试试看: (位于taylor-uucp 中的cu,使用"apt-get 安装 cu" 如果它还未安装话。

cu -l /dev/ttyACM0

你会需要用到

chown uucp.uucp /dev/ttyACM0

取得必要的权限(甚至是root)

可以用来取代cu的另一个方法是 Werner Almesberger的 neocon

首先,你必须试着去查看在你执行u-boot模式时,USB装置是否出现了'lsusb' 。

# lsusb -d 1457:5119
Bus 005 Device 079: ID 1457:5119  

接着,让我们来查看更多可用的endpoint及设定:

# lsusb -v -d 1457:5119
Bus 005 Device 079: ID 1457:5119  
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass            2 Communications
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        16
  idVendor           0x1457 
  idProduct          0x5119 
  bcdDevice            0.00
  iManufacturer           1 OpenMoko, Inc
  iProduct                2 Neo1973 Bootloader U-Boot 1.2.0-g6c7cac8c-dirty-moko3
  iSerial                 3 0000000
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           85
    bNumInterfaces          3
    bConfigurationValue     1
    iConfiguration          4 TTY via USB
    bmAttributes         0xc0
      Self Powered
    MaxPower                0mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         2 Communications
      bInterfaceSubClass      2 Abstract (modem)
      bInterfaceProtocol      1 AT-commands (v.25ter)
      iInterface              6 Control Interface
      CDC Header:
        bcdCDC               0.6e
      CDC Call Management:
        bmCapabilities       0x00
        bDataInterface          1
      CDC ACM:
        bmCapabilities       0x00
      CDC Union:
        bMasterInterface        0
        bSlaveInterface         1 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0010  1x 16 bytes
        bInterval             255
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass        10 CDC Data
      bInterfaceSubClass      0 Unused
      bInterfaceProtocol      0 
      iInterface              5 Bulk Data Interface
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0010  1x 16 bytes
        bInterval             255
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x83  EP 3 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0010  1x 16 bytes
        bInterval             255
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        2
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass       254 Application Specific Interface
      bInterfaceSubClass      1 Device Firmware Update
      bInterfaceProtocol      1 
      iInterface              7 USB Device Firmware Upgrade
Device Status:     0x0001
  Self Powered

接下来,你可以使用你最喜欢的终端机程序存取它。之后,若环境仍然不正确的话,你必须使用目前的控制台(如序列控制台(serial console)) 来变更控制台环境下的输入选项

GTA01Bv2 # setenv stderr usbtty
GTA01Bv2 # setenv stdout usbtty
GTA01Bv2 # setenv stdin usbtty

典型的u-boot提示字符

U-Boot 1.2.0-moko1 (Feb 16 2007 - 00:36:13)

DRAM:  128 MB
NAND:  64 MiB
Found Environment offset in OOB..
Video: 640x480x8 31kHz 59Hz
USB:   S3C2410 USB Deviced
In:    serial
Out:   serial
Err:   serial
Hit any key to stop autoboot:  0 
GTA01Bv3 #

bootloader 提示字符下的指令

'请参考bootloader 指令集.


装置轫体更新

u-boot也可以使用USB DFU做为更新工具。对于快速测试下的加载档案及kernel而言,是很有效的一个方法。 要找出你的u-boot版本是否支持这个USB DFU,请使用下面的方法:

$ lsusb -v -d 1457:5119

当装置目前使用的是u-boot模式。

如果它支持DFU,你可以在输出的讯息后面看到以下的内容:

    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        2
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass       254 Application Specific Interface
      bInterfaceSubClass      1 Device Firmware Update
      bInterfaceProtocol      1 
      iInterface              0 

要查看韧体如何更新,请参考dfu-util

透过DFU置入档案

要将档案加载内存位置0x32000000:

dfu-util -a 0 -D fileToLoad -R

之后,传送'bootm 0x32000000' 到u-boot或者 'bootelf 0x32000000',如果它是一个elf档案。

简单的python script可以启动ELF映像档—以防止ACM bug破坏较大的封包。

#!/usr/bin/python
import sys
import os
import time

cmd1 = "neo backlight off\n"
cmd2 = "bootelf 0x32000000\n"

def output(tty, str):
    for x in str:
        tty.write(x)
        tty.flush()

if len(sys.argv) == 2:
    print "Loading %s..." % sys.argv[1]

    loadfile = "dfu-util -a 0 -D %s -R" % sys.argv[1]

    os.system(loadfile)

    time.sleep(3)

    tty = open("/dev/ttyACM0", "a")

    output(tty, cmd1)
    output(tty, cmd2)

    tty.close()
else:
    print "Usage: %s elffile" % sys.argv[0]
    print ""
    sys.exit(2)

问题排除

USB连接问题

在连接Neo时,位于u-boot下,在Linux主机上,我曾经遇到如下的问题 (在 dmesg or /var/log/messages) o。

usb 2-1: device descriptor read/64, error -110 usb usb2: Controller not stopped yet!

利用下面的指令,我解决掉上述的问题。请注意,如果你没有USB键盘或者是鼠标,用这些指令可能会造成问题。 我只有PS/2界面的装置,所以,并无法测试这个问题。

rmmod uhci_hcd ; modprobe uhci_hcd