U-Boot

From Openmoko

(Difference between revisions)
Jump to: navigation, search
m (we don't do FAT)
m (U-Boot source code)
 
(161 intermediate revisions by 60 users not shown)
Line 1: Line 1:
== General ==
+
{{Languages|U-Boot}}
 +
{{Bootloader}}
  
The GTA01 uses the [http://u-boot.sourceforge.net/ u-boot] bootloader.
+
Just want to note that I (gena2x) decided to provide and support U-Boot as far as I can. To find info on my latest U-Boot version with bug-fixes, description how to setup u-boot, list of known bugs please visit '''[[U-boot-gena2x]]'''
  
More information on u-boot can be found at [http://www.denx.de/wiki/DULG], [http://www.gumstix.org/tikiwiki/tiki-index.php?page=U-Boot] and [http://linuxdevices.com/articles/AT5085702347.html].
+
{{outdated}}
  
However, the vanilla u-boot doesn't support many of the features that GTA01 needs, such as
+
[[Image:GTA01-U-Boot.JPG|thumb|300px|U-Boot menu on Neo 1973]] [[Image:Neo1973 uboot splash closeup.jpg|thumb|300px|[[Configuring_the_boot_splash_screens#U-Boot_Splash|U-Boot splash screen]] on Neo 1973]]
* Support for boot from NAND flahs using [[S3C2410 Steppingstone]]
+
 
* Support for reading kernel/initrd from SD/Transflash
+
'''U-Boot''' is a [[bootloader]] which can be used on the [[Neo 1973]] and [[Neo FreeRunner]]. It takes care of device functionality until the operating system is booted. This includes [[USB DFU]] for [[Flashing the Neo FreeRunner]], a [[Configuring_the_boot_splash_screens#U-Boot_Splash|splash screen]], a boot menu, a console for [[U-Boot commands]], configuration via [[U-Boot environment]], and loading a [[kernel]].
 +
 
 +
== Booting into U-Boot ==
 +
 
 +
* Make sure that your phone has had the battery and USB cable removed for at least 30 seconds.
 +
* Hold in the AUX button on power-up to access the boot menu.
 +
* Connect the Neo (ie not Debug Board) to a Linux host with the USB cable.
 +
* Set the console to USB.
 +
* Connect to /dev/ttyACM0 with a terminal program on the Linux host (you might need to chown uucp.uucp /dev/ttyACM0; see also below)
 +
* Note that the cdc_acm /dev/ttyACM0 access disappears as soon as the Neo boots, and is replaced by the cdc_ether usb0 network access.
 +
* You're now at the U-Boot prompt.
 +
* Set the bootdelay U-Boot environment variable to -1 if you want it to always halt at the U-Boot on power-up.
 +
 
 +
== General ==
 +
 
 +
More information on U-Boot can be found at
 +
* http://www.denx.de/wiki/DULG
 +
* http://www.gumstix.org/tikiwiki/tiki-index.php?page=U-Boot
 +
* http://linuxdevices.com/articles/AT5085702347.html
 +
 
 +
Additions to the vanilla U-Boot already implemented include:
 +
* Support for boot from NAND flash using [[S3C2410 Steppingstone]]
 
* Support for S3C2410 NAND flash
 
* Support for S3C2410 NAND flash
 
* Support for downloading programs via S3C2410 USB Device Controller
 
* Support for downloading programs via S3C2410 USB Device Controller
 
* Support to display bootup logo / status on S3C2410 Framebuffer
 
* Support to display bootup logo / status on S3C2410 Framebuffer
  
[[User:HaraldWelte]] is working on those issues, and in fact most of them have already been implemented.
+
However, U-Boot still doesn't support many of the features that GTA01 needs, such as
 +
* Support for reading kernel/initrd from SD/Transflash
 +
 
 +
[[User:HaraldWelte|HaraldWelte]] is working on those issues, and in fact most of them have already been implemented.
 +
 
 +
== U-Boot source code ==
 +
 
 +
The current U-Boot source can be found at http://git.openmoko.org/?p=u-boot.git;a=shortlog;h=stable .
 +
 
 +
To get U-Boot by git:
 +
 
 +
  git clone git://git.openmoko.org/git/u-boot.git openmoko/u-boot
 +
 
 +
To build U-Boot:
 +
* Clone the git tree and check out the stable branch (commands from above)
 +
  git checkout origin/stable
 +
* Set the CROSS_COMPILE environment variable to specify the prefix to your toolchain binaries
 +
* Run "make gta02v5_config" (or gta01bv4_config, or whatever hardware revision you have)
 +
* Run "make u-boot.udfu". This will give you an image which you can install with dfu-util, or which you can upload into memory via JTAG (with a debug board)
 +
 
 +
All together:
  
== Bootloader source code ==
+
  git clone git://git.openmoko.org/git/u-boot.git openmoko/u-boot
 +
  cd openmoko/u-boot
 +
  git checkout origin/stable
 +
  export CROSS_COMPILE=arm-angstrom-linux-gnueabi-
 +
  make gta02v5_config
 +
  make u-boot.udfu
  
The current bootloader patches can be found at https://svn.openmoko.org/trunk/src/target/u-boot/patches/.
+
== U-Boot binary ==
  
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.
+
The latest U-Boot binary builds can be found under:
 +
* Before 20100131? Are there any newer that supports ubifs? Can it be replaced by [[Qi]]?:
 +
** http://downloads.openmoko.org/distro/unstable/daily/
  
== Bootloader binary ==
+
All versions of the GTA02 (Neo FreeRunner) that have been sold to the public are version 5 hardware, so look for a file with "gta02" and "v5" in the name, for example:
 +
uboot-gta02v5-latest.bin
  
The latest bootloader binary (for NAND) can be found at
+
The file should be written to the NAND flash address 0x00000000 (size 0x30000) (the first [[Partitions|partition]]).
[http://people.openmoko.org/laforge/src/u-boot/current/u-boot.bin].  It should be written to the NAND flash address 0x00000000 (size 0x30000)
+
  
== Bootloader development ==
+
== U-Boot development ==
  
 
=== 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.
+
If you want to do U-Boot development on the QT2410, it's easier to work with a U-Boot image that can be downloaded via USB into RAM instead of flashing.
  
 
To do so, you need to edit the u-boot/include/configs/qt2410.h file, and change the "if 0" in Line 32 into a "if 1", then recompile with "make".
 
To do so, you need to edit the u-boot/include/configs/qt2410.h file, and change the "if 0" in Line 32 into a "if 1", then recompile with "make".
Line 34: Line 83:
 
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.
 
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 ===
+
=== Neo 1973 ===
  
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.
+
Doing U-Boot development on the [[Neo 1973]] 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.
  
 
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
 
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
 +
 +
=== Neo FreeRunner ===
 +
{{main|Neo_FreeRunner_Memory_Mapping}}
  
 
==== Using JTAG to boot from RAM ====
 
==== Using JTAG to boot from RAM ====
  
So how can we boot from RAM? We use JTAG / OpenOCD to
+
So how can we boot from RAM? We use JTAG / OpenOCD to:
  
* reset and halt the cpu at PC=0
+
* Reset and halt the cpu at PC=0
 
<pre>
 
<pre>
 
> reset halt
 
> reset halt
Line 52: Line 104:
 
</pre>
 
</pre>
  
* download a small piece of code for low-level SDRAM timing initialization (overwrite 4k SRAM of steppingstone)
+
* Download a small piece of code for low-level SDRAM timing initialization (overwrite 4k SRAM of steppingstone)
 
<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)
+
* Assert a break point at address 0x33f80000 (which indicates that the low-level code has finished)
 
<pre>
 
<pre>
 
> bp 0x33f80000 4 hw
 
> bp 0x33f80000 4 hw
Line 64: Line 116:
 
</pre>
 
</pre>
  
* run the code up to the break point
+
* Run the code up to the break point
 
<pre>
 
<pre>
 
> resume
 
> resume
Line 74: Line 126:
 
</pre>
 
</pre>
  
* download the u-boot RAM image to 0x33f80000
+
* Download the U-Boot RAM image to 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 80: Line 132:
 
</pre>
 
</pre>
  
* resume processing
+
* Resume processing
 
<pre>
 
<pre>
 
> resume
 
> resume
Line 97: Line 149:
 
Out:  serial
 
Out:  serial
 
Err:  serial
 
Err:  serial
Hit any key to stop autoboot:  0  
+
Hit any key to stop autoboot:  0
GTA01Bv2 #  
+
GTA01Bv2 #
 
</pre>
 
</pre>
  
 
== Creating bootable images ==
 
== Creating bootable images ==
  
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 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:
  
 
<pre>
 
<pre>
Line 111: Line 163:
 
</pre>
 
</pre>
  
== Bootloader prompt ==
+
== Boot menu ==
 +
[[Image:Neo1973 uboot menu.jpg|thumb|400px|U-Boot boot menu on Neo1973]]
  
The bootloader prompt is available either on the serial console (via [[Debug Board]]), or as virtual USB Serial device (USB CDC_ACM).
+
As of the Phase-0 release, our U-Boot version now features an on-screen boot menu. The items are defined by [[U-Boot environment#menu|menu entries in the environment]].
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.
+
=== Accessing the boot menu ===
  
The bootloader is currently configured to waid for three seconds.  If a key press on the serial port is received within those three seconds, auto-boot is aborted.
+
You can access the boot menu by pressing and holding the [[Neo1973 AUX Button]] together with the power button while switching the phone on.
  
<pre>
+
=== Using the boot menu ===
U-Boot 1.1.4-ga2c95a72-dirty (Aug  6 2006 - 22:05:48)
+
  
DRAM: 64 MB
+
By pressing the [[Neo1973 AUX Button]] you can cycle through the menu items. Use the ''POWER'' button to select one item.
Flash: 512 kB
+
NAND:  64 MiB
+
In:    serial
+
Out:  serial
+
Err:  serial
+
  
cs8900a chipid 0x630e
+
== U-Boot prompt ==
Hit any key to stop autoboot:  0
+
QT2410 #
+
</pre>
+
  
=== Auto-boot ===
+
=== Accessing the U-Boot prompt ===
 +
The U-Boot 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 is used depends on the U-Boot environment variables '''stdin''', '''stdout''' and '''stderr'''.
  
Auto-boot executes the command[s] specified in the ''bootcmd'' environment variable. The default configuration is:
+
Whether or not you use usbtty, the first couple of messages will always be displayed on the serial console.
<pre>
+
GTA01Bv2 # printenv
+
bootcmd=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.
+
The U-Boot is currently configured to wait for three seconds.  If a key press on the '''stdin''' is received within those three seconds, auto-boot is aborted.
  
=== Environment ===
+
==== Using usbtty from Linux ====
  
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:
+
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/ttyACM0. If not, check that module cdc_acm is loaded or CONFIG_USB_ACM=y (Device Drivers -> USB support -> USB Modem (CDC ACM) support). (Instructions for MacOS users are [[MacOS_X#USB_Serial|here]])
<pre>
+
QT2410 # printenv
+
bootcmd=mmcinit; ext2load mmc 0 0x32000000 uImage; bootm 0x32000000
+
bootdelay=3
+
baudrate=115200
+
ipaddr=10.0.0.110
+
serverip=10.0.0.1
+
netmask=255.255.255.0
+
bootargs=root=/dev/mmcblk0p1 console=ttySAC0,115200 loglevel=8 rootdelay=10
+
stdin=serial
+
stdout=serial
+
stderr=serial
+
  
Environment size: 271/16380 bytes
+
Use your favourite terminal emulator (minicom, cu, zc, screen ...) to access it like any other serial port. Clear any modem intialisation strings (minicom).
QT2410 # setenv bootdelay 10
+
QT2410 # printenv bootdelay
+
bootdelay=10
+
QT2410 # saveenv
+
Saving Environment to NAND...
+
Erasing Nand...Writing to Nand... done
+
QT2410 #
+
</pre>
+
  
Note: When setting multiple commands, e.g. for bootcmd, you need to escape the ';', for instance
+
You can adapt the instructions for USB-serial from the [[MacOS_X#USB_Serial|Mac OS]] page.
 +
If you don't have a favorite, try just "cu -l dev/ttyACM0". It is in the taylor-uucp package, use "apt-get install cu" if it is not yet installed
  
 +
Enter Bootprompt with:
 
<pre>
 
<pre>
QT2410 # setenv bootcmd mmcinit\; ext2load mmc 0 0x32000000 uImage\; bootm 0x32000000
+
cu -l /dev/ttyACM0
 
</pre>
 
</pre>
 +
You might need to
 +
chown uucp.uucp /dev/ttyACM0
 +
to get the necessary rights (even as root, must be done each time). For example, if cu prints "cu: /dev/ttyACM0: Line in use", then try chowning /dev/ttyACM0 to uucp.uucp; apparently cu can be pretty picky about permissions.
  
As of 2007-02-01, laforge says the correct bootargs are:
+
A nice alternative for cu is Werner Almesberger's [[NeoCon|neocon]].
<pre>
+
rootfstype=jffs2 root=/dev/mtdblock4 console=ttySAC0,115200 console=tty0 loglevel=8
+
</pre>
+
Note that this requires flashing the jffs2 root image into NAND.
+
  
=== MMC/SD ===
+
First, you should try to check whether the USB device shows up in 'lsusb' while you're running in U-Boot mode:
  
in order to initialize a MMC/SD card, you have to use the ``mmcinit'' command.
 
 
<pre>
 
<pre>
QT2410 # mmcinit
+
# lsusb -d 1457:5119
trying to detect SD Card...
+
Bus 005 Device 079: ID 1457:5119
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
+
 
</pre>
 
</pre>
 +
'''Note''': The Neo Freerunner (GTA02) has the ID 1d50:5119
 +
 +
Second, let's see some more details about the available endpoints and configurations:
  
afterwards, you can read ext2 filesystems like:
 
 
<pre>
 
<pre>
QT2410 # ext2ls mmc 0
+
# lsusb -v -d 1457:5119
<DIR>      1024 .
+
Bus 005 Device 079: ID 1457:5119
<DIR>      1024 ..
+
Device Descriptor:
<DIR>     12288 lost+found
+
bLength                18
         1544788 uImage
+
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
 
</pre>
 
</pre>
  
=== NAND ===
+
Next, you can access it using your favourite terminal program.
  
 +
Then, if the environment is not set correctly, you will need to use the current console (e.g. serial console) to change the [[U-Boot environment#console|console entries in the environment]]:
 
<pre>
 
<pre>
QT2410 # help nand
+
GTA01Bv2 # setenv stderr usbtty
nand info                  - show available NAND devices
+
GTA01Bv2 # setenv stdout usbtty
nand device [dev]    - show or set current device
+
GTA01Bv2 # setenv stdin usbtty
nand read[.jffs2]    - addr off size
+
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>
 
</pre>
  
==== Loading Kernel from NAND ====
+
==== Typical U-Boot prompt ====
  
 
<pre>
 
<pre>
QT2410 # nand read 0x32000000 0x34000 0x200000
+
U-Boot 1.2.0-moko1 (Feb 16 2007 - 00:36:13)
  
NAND read: device 0 offset 212992, size 2097152 ... 2097152 bytes read: OK
+
DRAM:  128 MB
QT2410 # bootm 0x32000000
+
NAND:  64 MiB
## Booting image at 32000000 ...
+
Found Environment offset in OOB..
  Image NameKernel Image QT2410
+
Video: 640x480x8 31kHz 59Hz
   Created:      2006-08-06  20:23:01 UTC
+
USBS3C2410 USB Deviced
  Image TypeARM Linux Kernel Image (gzip compressed)
+
In:   serial
  Data Size:   1546258 Bytes =  1.5 MB
+
Outserial
  Load Address: 30008000
+
Err:   serial
  Entry Point30008000
+
Hit any key to stop autoboot0
  Verifying Checksum ... OK
+
GTA01Bv3 #
  Uncompressing Kernel Image ... OK
+
Starting kernel ...
+
 
</pre>
 
</pre>
  
==== Writing new bootloader to NAND ====
+
=== Commands on the U-Boot prompt ===
 +
 
 +
:''See [[U-Boot commands]].''
 +
 
 +
=== What if I borked my U-Boot environment and don't get a prompt anymore? ===
 +
{{Note|This solution applies to a changed U-Boot environment which prevents NAND U-Boot to successfully boot.  The Debian U-Boot configuration script may be a cause of this issue.}}
 +
Found a solution here:
 +
[[http://markmail.org/message/gqypwiohdet6x4am?q=almesberger+partition&page=1&refer=xbamkzwwsaobv7wa]]
 +
 
 +
It works the following way:
 +
* Get the [[devirginator]]:
 +
svn co http://svn.openmoko.org/trunk/src/host/devirginator
 +
cd devirginator
 +
* Read the U-Boot environment from the device:
 +
dfu-util -a u-boot_env -R -U env.in
 +
* Create a file that contains everything you want to change in your U-Boot environment or get it by issuing the following command:
 +
wget http://svn.openmoko.org/trunk/src/host/devirginator/environment.in
 +
* Now let devirginator generate a new u-boot_env partition for us, - that contains the partition table from our u-boot_env, - and all changes we wanted to make; Note that the -D GTA02 is needed for the neo FreeRunner only, and has to come before the other options.
 +
./envedit.pl -D GTA02 -i env.in -f environment.in -o env.out
 +
* On my box the partition layout didn't seem to match the idea of envedit.pl, so it issued 2 warnings:
 +
warning: environment is 262144 bytes, expected 16384
 +
CRC error: expected 0xc33e35fc, got 0x93097bfb
 +
* In this case jut add an additional argument to the command line - that has to be the 1st argument, though, and that contains the size information we got from the warning:
 +
./envedit.pl -s 262144 -D GTA02 -i env.in -f environment.in  -o env.out
 +
* Now the perl script should produce no more output anything but write a new u-boot_env partition that we can upload to the device by:
 +
dfu-util -a u-boot_env -R -D env.out
 +
 
 +
== Device Firmware Upgrade ==
 +
 
 +
Our version of U-Boot also implements [[USB DFU]]. This can be useful to
 +
load files and kernel for quick testing.
  
The following set of commands loads the file u-boot.bin from ext2/mmc and flashes it into the
+
To find out whether your version of U-Boot supports this, use the output of
bootloader flash partition:
+
$ 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>
 
<pre>
QT2410 # ext2load mmc 0 0x32000000 u-boot.bin
+
Interface Descriptor:
QT2410 # nand erase 0x00000000 0x30000
+
bLength                9
QT2410 # nand write 0x32000000 0x00000000 0x30000
+
bDescriptorType        4
 +
bInterfaceNumber        2
 +
bAlternateSetting      0
 +
bNumEndpoints          0
 +
bInterfaceClass      254 Application Specific Interface
 +
bInterfaceSubClass      1 Device Firmware Update
 +
bInterfaceProtocol      1
 +
iInterface              0
 
</pre>
 
</pre>
  
==== Writing kernel to NAND ====
+
For information on how to do firmware upgrades, please see [[dfu-util]]. For neo 1973 you may see [[Flashing the Neo 1973#Actually_flashing_things_into_the_device]], and for the FreeRunner : [[Flashing the Neo FreeRunner]].
  
The following set of commands loads the file uImage from ext2/mmc and flashes it into the
+
=== Booting files over DFU ===
kernel flash partition:
+
  
 +
To load a file at memory address 0x32000000:
 
<pre>
 
<pre>
QT2410 # ext2load mmc 0 0x32000000 uImage
+
dfu-util -a 0 -D fileToLoad -R
QT2410 # nand erase 0x00034000 0x200000
+
QT2410 # nand write.e 0x32000000 0x00034000 0x200000
+
 
</pre>
 
</pre>
  
==== Writing rootfs to NAND ====
+
After that, send 'bootm 0x32000000' to u-boot or 'bootelf 0x32000000' if
 +
its an elf file.
  
The following set of commands loads the file rootfs.jffs2 from ext2/mmc and flashes it into the
+
Simple python script that can boot an ELF image - avoiding a ACM bug that breaks on large packets.
rootfs flash partition:
+
  
 
<pre>
 
<pre>
QT2410 # ext2load mmc 0 0x32000000 rootfs.jffs2
+
#!/usr/bin/python
QT2410 # nand erase 0x00634000 0x39cc000
+
import sys
QT2410 # nand write.e 0x32000000 0x00634000 real_size_of_rootfs_in_hex
+
import os
</pre>
+
import time
  
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.
+
cmd1 = "neo backlight off\n"
 +
cmd2 = "bootelf 0x32000000\n"
  
=== TFTP on QT2410 ===
+
def output(tty, str):
 +
  for x in str:
 +
    tty.write(x)
 +
    tty.flush()
  
The QT2410 cs8900a Ethernet can be used to download images via network.
+
if len(sys.argv) == 2:
 +
  print "Loading %s..." % sys.argv[1]
  
First, you have to make sure that ''ipaddr'', ''serverip'', ''ethaddr' and ''netmaskk'' are set correctly in the environment:
+
  loadfile = "dfu-util -a 0 -D %s -R" % sys.argv[1]
  
<pre>
+
  os.system(loadfile)
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 ====
+
  time.sleep(3)
  
<pre>
+
  tty = open("/dev/ttyACM0", "a")
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
+
  output(tty, cmd1)
<pre>
+
  output(tty, cmd2)
QT2410# bootm 0x32000000
+
 
 +
  tty.close()
 +
else:
 +
  print "Usage: %s elffile" % sys.argv[0]
 +
  print ""
 +
  sys.exit(2)
 
</pre>
 
</pre>
 +
 +
== Troubleshooting ==
 +
 +
=== USB connectivity problems ===
 +
 +
I once got errors like this (in dmesg or /var/log/messages) on the host side while connecting the Neo in U-Boot:
 +
 +
usb 2-1: device descriptor read/64, error -110
 +
usb usb2: Controller not stopped yet!
 +
 +
or
 +
 +
hub 4-0:1.0: port 1 disabled by hub (EMI?), re-enabling...
 +
usb 4-1: USB disconnect, address 2
 +
 +
A possible solution is given below. Please note that if you have a usb keyboard or mouse then the command might cause trouble.
 +
 +
rmmod uhci_hcd ; modprobe uhci_hcd
 +
 +
Another option is to plug the FR into a different USB port on the host, preferably one on the Motherboard not the hub.
 +
 +
Disconnecting the Neo's USB while powering up may prevent this problem in the future.
 +
 +
== Related pages ==
 +
 +
See [[Flashing the Neo 1973]] and [[Flashing the Neo FreeRunner]] for instructions on using dfu-util to install a new U-Boot in your phone.
 +
 +
[[Category:Bootloaders]]

Latest revision as of 00:26, 15 April 2012

Bootloaders

Just want to note that I (gena2x) decided to provide and support U-Boot as far as I can. To find info on my latest U-Boot version with bug-fixes, description how to setup u-boot, list of known bugs please visit U-boot-gena2x

Outdated warning ! This article or section is significantly outdated, either by significant hardware or software changes. Procedures mentioned in this page may well not work for current hardware/software.


U-Boot menu on Neo 1973

U-Boot is a bootloader which can be used on the Neo 1973 and Neo FreeRunner. It takes care of device functionality until the operating system is booted. This includes USB DFU for Flashing the Neo FreeRunner, a splash screen, a boot menu, a console for U-Boot commands, configuration via U-Boot environment, and loading a kernel.

Contents

[edit] Booting into U-Boot

  • Make sure that your phone has had the battery and USB cable removed for at least 30 seconds.
  • Hold in the AUX button on power-up to access the boot menu.
  • Connect the Neo (ie not Debug Board) to a Linux host with the USB cable.
  • Set the console to USB.
  • Connect to /dev/ttyACM0 with a terminal program on the Linux host (you might need to chown uucp.uucp /dev/ttyACM0; see also below)
  • Note that the cdc_acm /dev/ttyACM0 access disappears as soon as the Neo boots, and is replaced by the cdc_ether usb0 network access.
  • You're now at the U-Boot prompt.
  • Set the bootdelay U-Boot environment variable to -1 if you want it to always halt at the U-Boot on power-up.

[edit] General

More information on U-Boot can be found at

Additions to the vanilla U-Boot already implemented include:

  • Support for boot from NAND flash using S3C2410 Steppingstone
  • Support for S3C2410 NAND flash
  • Support for downloading programs via S3C2410 USB Device Controller
  • Support to display bootup logo / status on S3C2410 Framebuffer

However, U-Boot still doesn't support many of the features that GTA01 needs, such as

  • Support for reading kernel/initrd from SD/Transflash

HaraldWelte is working on those issues, and in fact most of them have already been implemented.

[edit] U-Boot source code

The current U-Boot source can be found at http://git.openmoko.org/?p=u-boot.git;a=shortlog;h=stable .

To get U-Boot by git:

 git clone git://git.openmoko.org/git/u-boot.git openmoko/u-boot

To build U-Boot:

  • Clone the git tree and check out the stable branch (commands from above)
  git checkout origin/stable
  • Set the CROSS_COMPILE environment variable to specify the prefix to your toolchain binaries
  • Run "make gta02v5_config" (or gta01bv4_config, or whatever hardware revision you have)
  • Run "make u-boot.udfu". This will give you an image which you can install with dfu-util, or which you can upload into memory via JTAG (with a debug board)

All together:

 git clone git://git.openmoko.org/git/u-boot.git openmoko/u-boot
 cd openmoko/u-boot
 git checkout origin/stable
 export CROSS_COMPILE=arm-angstrom-linux-gnueabi-
 make gta02v5_config
 make u-boot.udfu

[edit] U-Boot binary

The latest U-Boot binary builds can be found under:

All versions of the GTA02 (Neo FreeRunner) that have been sold to the public are version 5 hardware, so look for a file with "gta02" and "v5" in the name, for example:

uboot-gta02v5-latest.bin

The file should be written to the NAND flash address 0x00000000 (size 0x30000) (the first partition).

[edit] U-Boot development

[edit] QT2410

If you want to do U-Boot development on the QT2410, it's easier to work with a U-Boot image that can be downloaded via USB into RAM instead of flashing.

To do so, you need to edit the u-boot/include/configs/qt2410.h file, and change the "if 0" in Line 32 into a "if 1", then recompile with "make".

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.

[edit] Neo 1973

Doing U-Boot development on the Neo 1973 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.

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

[edit] Neo FreeRunner

Main article: Neo_FreeRunner_Memory_Mapping


[edit] Using JTAG to boot from RAM

So how can we boot from RAM? We use JTAG / OpenOCD to:

  • Reset and halt the cpu at PC=0
> 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
  • Download a small piece of code for low-level SDRAM timing initialization (overwrite 4k SRAM of steppingstone)
> load_binary /space/misc/gta01/u-boot.git/board/gta01/lowlevel_foo.bin 0
downloaded 332 byte in 0s 21899us
  • Assert a break point at address 0x33f80000 (which indicates that the low-level code has finished)
> bp 0x33f80000 4 hw
breakpoint added at address 0x33f80000
  • Run the code up to the break point
> resume
Target 0 resumed
> Target 0 halted
target halted in ARM state due to breakpoint, current mode: Supervisor
cpsr: 0x600000d3 pc: 0x33f80000
MMU: disabled, D-Cache: disabled, I-Cache: enabled
  • Download the U-Boot RAM image to 0x33f80000
> load_binary /space/misc/gta01/u-boot.git/u-boot.bin 0x33f80000
downloaded 135692 byte in 6s 567264us
  • Resume processing
> resume
Target 0 resumed

At this point, the display backlight gets bright and we see the following familiar prompt on the serial console:

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 #

[edit] Creating bootable images

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:

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

[edit] Boot menu

U-Boot boot menu on Neo1973

As of the Phase-0 release, our U-Boot version now features an on-screen boot menu. The items are defined by menu entries in the environment.

[edit] Accessing the boot menu

You can access the boot menu by pressing and holding the Neo1973 AUX Button together with the power button while switching the phone on.

[edit] Using the boot menu

By pressing the Neo1973 AUX Button you can cycle through the menu items. Use the POWER button to select one item.

[edit] U-Boot prompt

[edit] Accessing the U-Boot prompt

The U-Boot 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 is 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.

The U-Boot is currently configured to wait for three seconds. If a key press on the stdin is received within those three seconds, auto-boot is aborted.

[edit] Using usbtty from Linux

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/ttyACM0. If not, check that module cdc_acm is loaded or CONFIG_USB_ACM=y (Device Drivers -> USB support -> USB Modem (CDC ACM) support). (Instructions for MacOS users are here)

Use your favourite terminal emulator (minicom, cu, zc, screen ...) to access it like any other serial port. Clear any modem intialisation strings (minicom).

You can adapt the instructions for USB-serial from the Mac OS page. If you don't have a favorite, try just "cu -l dev/ttyACM0". It is in the taylor-uucp package, use "apt-get install cu" if it is not yet installed

Enter Bootprompt with:

cu -l /dev/ttyACM0

You might need to

chown uucp.uucp /dev/ttyACM0

to get the necessary rights (even as root, must be done each time). For example, if cu prints "cu: /dev/ttyACM0: Line in use", then try chowning /dev/ttyACM0 to uucp.uucp; apparently cu can be pretty picky about permissions.

A nice alternative for cu is Werner Almesberger's neocon.

First, you should try to check whether the USB device shows up in 'lsusb' while you're running in U-Boot mode:

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

Note: The Neo Freerunner (GTA02) has the ID 1d50:5119

Second, let's see some more details about the available endpoints and configurations:

# 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

Next, you can access it using your favourite terminal program.

Then, if the environment is not set correctly, you will need to use the current console (e.g. serial console) to change the console entries in the environment:

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

[edit] Typical U-Boot prompt

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 #

[edit] Commands on the U-Boot prompt

See U-Boot commands.

[edit] What if I borked my U-Boot environment and don't get a prompt anymore?

NOTE: This solution applies to a changed U-Boot environment which prevents NAND U-Boot to successfully boot. The Debian U-Boot configuration script may be a cause of this issue.


Found a solution here: [[1]]

It works the following way:

svn co http://svn.openmoko.org/trunk/src/host/devirginator cd devirginator

  • Read the U-Boot environment from the device:

dfu-util -a u-boot_env -R -U env.in

  • Create a file that contains everything you want to change in your U-Boot environment or get it by issuing the following command:

wget http://svn.openmoko.org/trunk/src/host/devirginator/environment.in

  • Now let devirginator generate a new u-boot_env partition for us, - that contains the partition table from our u-boot_env, - and all changes we wanted to make; Note that the -D GTA02 is needed for the neo FreeRunner only, and has to come before the other options.

./envedit.pl -D GTA02 -i env.in -f environment.in -o env.out

  • On my box the partition layout didn't seem to match the idea of envedit.pl, so it issued 2 warnings:

warning: environment is 262144 bytes, expected 16384 CRC error: expected 0xc33e35fc, got 0x93097bfb

  • In this case jut add an additional argument to the command line - that has to be the 1st argument, though, and that contains the size information we got from the warning:

./envedit.pl -s 262144 -D GTA02 -i env.in -f environment.in -o env.out

  • Now the perl script should produce no more output anything but write a new u-boot_env partition that we can upload to the device by:

dfu-util -a u-boot_env -R -D env.out

[edit] Device Firmware Upgrade

Our version of U-Boot also implements USB DFU. This can be useful to load files and kernel for quick testing.

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:

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

For information on how to do firmware upgrades, please see dfu-util. For neo 1973 you may see Flashing the Neo 1973#Actually_flashing_things_into_the_device, and for the FreeRunner : Flashing the Neo FreeRunner.

[edit] Booting files over DFU

To load a file at memory address 0x32000000:

dfu-util -a 0 -D fileToLoad -R

After that, send 'bootm 0x32000000' to u-boot or 'bootelf 0x32000000' if its an elf file.

Simple python script that can boot an ELF image - avoiding a ACM bug that breaks on large packets.

#!/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)

[edit] Troubleshooting

[edit] USB connectivity problems

I once got errors like this (in dmesg or /var/log/messages) on the host side while connecting the Neo in U-Boot:

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

or

hub 4-0:1.0: port 1 disabled by hub (EMI?), re-enabling... usb 4-1: USB disconnect, address 2

A possible solution is given below. Please note that if you have a usb keyboard or mouse then the command might cause trouble.

rmmod uhci_hcd ; modprobe uhci_hcd

Another option is to plug the FR into a different USB port on the host, preferably one on the Motherboard not the hub.

Disconnecting the Neo's USB while powering up may prevent this problem in the future.

[edit] Related pages

See Flashing the Neo 1973 and Flashing the Neo FreeRunner for instructions on using dfu-util to install a new U-Boot in your phone.

Personal tools

General

The GTA01 uses the u-boot bootloader.

More information on u-boot can be found at [1], [2] and [3].

However, the vanilla u-boot doesn't support many of the features that GTA01 needs, such as

  • Support for boot from NAND flahs using S3C2410 Steppingstone
  • Support for reading kernel/initrd from SD/Transflash
  • Support for S3C2410 NAND flash
  • Support for downloading programs via S3C2410 USB Device Controller
  • Support to display bootup logo / status on S3C2410 Framebuffer

User:HaraldWelte is working on those issues, and in fact most of them have already been implemented.

Bootloader source code

The current bootloader patches can be found at https://svn.openmoko.org/trunk/src/target/u-boot/patches/.

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 binary

The latest bootloader binary (for NAND) can be found at [4]. It should be written to the NAND flash address 0x00000000 (size 0x30000)

Bootloader development

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.

To do so, you need to edit the u-boot/include/configs/qt2410.h file, and change the "if 0" in Line 32 into a "if 1", then recompile with "make".

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

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.

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

Using JTAG to boot from RAM

So how can we boot from RAM? We use JTAG / OpenOCD to

  • reset and halt the cpu at PC=0
> 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
  • download a small piece of code for low-level SDRAM timing initialization (overwrite 4k SRAM of steppingstone)
> load_binary /space/misc/gta01/u-boot.git/foo.bin 0            
downloaded 332 byte in 0s 21899us
  • assert a break point at address 0x33f80000 (which indicates that the low-level code has finished)
> bp 0x33f80000 4 hw
breakpoint added at address 0x33f80000
  • run the code up to the break point
> resume
Target 0 resumed
> Target 0 halted
target halted in ARM state due to breakpoint, current mode: Supervisor
cpsr: 0x600000d3 pc: 0x33f80000
MMU: disabled, D-Cache: disabled, I-Cache: enabled
  • download the u-boot RAM image to 0x33f80000
> load_binary /space/misc/gta01/u-boot.git/u-boot.bin 0x33f80000
downloaded 135692 byte in 6s 567264us
  • resume processing
> resume
Target 0 resumed

At this point, the display backlight gets bright and we see the following familiar prompt on the serial console:

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 # 

Creating bootable images

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:

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

Bootloader prompt

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.

The bootloader is currently configured to waid for three seconds. If a key press on the serial port is received within those three seconds, auto-boot is aborted.

U-Boot 1.1.4-ga2c95a72-dirty (Aug  6 2006 - 22:05:48)

DRAM:  64 MB
Flash: 512 kB
NAND:  64 MiB
In:    serial
Out:   serial
Err:   serial

cs8900a chipid 0x630e
Hit any key to stop autoboot:  0 
QT2410 #

Auto-boot

Auto-boot executes the command[s] specified in the bootcmd environment variable. The default configuration is:

GTA01Bv2 # printenv
bootcmd=nand read.e 0x32000000 kernel; bootm 0x32000000

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.

Environment

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:

QT2410 # printenv
bootcmd=mmcinit; ext2load mmc 0 0x32000000 uImage; bootm 0x32000000
bootdelay=3
baudrate=115200
ipaddr=10.0.0.110
serverip=10.0.0.1
netmask=255.255.255.0
bootargs=root=/dev/mmcblk0p1 console=ttySAC0,115200 loglevel=8 rootdelay=10
stdin=serial
stdout=serial
stderr=serial

Environment size: 271/16380 bytes
QT2410 # setenv bootdelay 10
QT2410 # printenv bootdelay
bootdelay=10
QT2410 # saveenv
Saving Environment to NAND...
Erasing Nand...Writing to Nand... done
QT2410 # 

Note: When setting multiple commands, e.g. for bootcmd, you need to escape the ';', for instance

QT2410 # setenv bootcmd mmcinit\; ext2load mmc 0 0x32000000 uImage\; bootm 0x32000000

As of 2007-02-01, laforge says the correct bootargs are:

rootfstype=jffs2 root=/dev/mtdblock4 console=ttySAC0,115200 console=tty0 loglevel=8

Note that this requires flashing the jffs2 root image into NAND.

MMC/SD

in order to initialize a MMC/SD card, you have to use the ``mmcinit command.

QT2410 # mmcinit
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

afterwards, you can read ext2 filesystems like:

QT2410 # ext2ls mmc 0
<DIR>       1024 .
<DIR>       1024 ..
<DIR>      12288 lost+found
         1544788 uImage

NAND

QT2410 # help nand
nand info                  - show available NAND devices
nand device [dev]     - show or set current device
nand read[.jffs2]     - addr off size
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)

Loading Kernel from NAND

QT2410 # nand read 0x32000000 0x34000 0x200000

NAND read: device 0 offset 212992, size 2097152 ...  2097152 bytes read: OK
QT2410 # bootm 0x32000000
## Booting image at 32000000 ...
   Image Name:   Kernel Image QT2410
   Created:      2006-08-06  20:23:01 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 ...

Writing new bootloader to NAND

The following set of commands loads the file u-boot.bin from ext2/mmc and flashes it into the bootloader flash partition:

QT2410 # ext2load mmc 0 0x32000000 u-boot.bin
QT2410 # nand erase 0x00000000 0x30000
QT2410 # nand write 0x32000000 0x00000000 0x30000

Writing kernel to NAND

The following set of commands loads the file uImage from ext2/mmc and flashes it into the kernel flash partition:

QT2410 # ext2load mmc 0 0x32000000 uImage
QT2410 # nand erase 0x00034000 0x200000
QT2410 # nand write.e 0x32000000 0x00034000 0x200000

Writing rootfs to NAND

The following set of commands loads the file rootfs.jffs2 from ext2/mmc and flashes it into the rootfs flash partition:

QT2410 # ext2load mmc 0 0x32000000 rootfs.jffs2
QT2410 # nand erase 0x00634000 0x39cc000
QT2410 # nand write.e 0x32000000 0x00634000 real_size_of_rootfs_in_hex

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.

TFTP on QT2410

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:

QT2410 # printenv
ethaddr=00:01:02:03:04:05
netmask=255.255.255.0
ipaddr=192.168.100.100
serverip=192.168.100.1

TFTP kernel download

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)

you can then commence booting via

QT2410# bootm 0x32000000