You are viewing outdated content for BUG. If you have a BUG Y.T. edition or 2.0 series device, please visit our updated wiki: http://wiki.buglabs.net



U-boot

From BUG Wiki

Jump to: navigation, search

Contents

Overview

As of BUG Software R1.4.1, Das U-boot has been incorporated into the Kernel and Rootfs Build System. Users now have the option of overwriting RedBoot (which currently ships with the BUG from the factory) with U-boot. Benefits to this include the ability to boot the kernel from the SD card, thereby making the upgrade process simpler by removing the need to overwrite a kernel in flash. Users wishing to overwrite RedBoot with U-boot should proceed with extreme caution. Incorrectly following the procedure below could result in "bricking" your BUG.

Prerequisites

Please note: Any BUG shipped after May 15th, 2009 is already running u-boot The tutorial below assumes that you have a

  1. u-boot image (download here: http://bugcommunity.com/downloads/files/r1.4.1/uboot-latest.bin).
  2. Using Linux
  3. Using minicom
  4. install lrzsz (on ubuntu/debian: apt-get install lrzsz)
  5. A recently built rootfs with uImage in /boot/ (on your flash card)
  6. A Handylink to DB9 cable.

Steps for Upgrading from Redboot

Boot BUG

  1. Power up your bug and ctrl+C out of Redboot.
+:+
Clock input is 26 MHz
Ethernet eth0: MAC address 00:50:c2:69:c0:24
IP: 192.168.0.111/255.255.255.0, Gateway: 192.168.0.121
Default server: 192.168.0.121

RedBoot(tm) bootstrap and debug environment [ROMRAM]
Non-certified release, version FSL 200617 - built 11:08:01, Feb 26 2008

Platform: BUG2 (Freescale i.MX31 based) PASS 1.1 [x32 DDR]
Copyright (C) 2000, 2001, 2002, 2003, 2004 Red Hat, Inc.

RAM: 0x00000000-0x04000000, [0x00014c20-0x03fed000] available
FLASH: 0xa0000000 - 0xa2000000, 2048 blocks of 0x00004000 bytes each.
== Executing boot script in 1.000 seconds - enter ^C to abort
^C
BUG_RedBoot>

Load uboot-latest.bin

NOTE: The following commands contain numbers that must be entered exactly as defined.  
It's best to copy/paste the commands directly into the console to minimize the chance 
of incorrectly entering a value.
  1. At prompt, enter the command load -b 0x100000 -m ymodem -v -r
BUG_RedBoot> load -b 0x100000 -m ymodem -v -r
C
  1. Hit Ctrl+A, then S, choosing ymodem, then use the arrows and spacebar to navigate to uboot-latest.bin.
    Note: THIS IS NOT a kernel image. Do NOT send it anything but uboot-latest.bin. The file is 195K (as of 3/10/2009). If you send it anything other than a uboot image, and overwrite redboot, your BUG will be bricked. The only way to unbrick it is by removing the board from its case and connecting via JTAG.
42949374.890000] RNG Driver: Loading       +-------------------[Select one or more files for upload]-------------------+
[42949374.890000] SEC: mxc_sec_mod_init() ca|Directory: /opt/build/qa/com.buglabs.build.oe/build/tmp/deploy/images      |
[42949374.900000] bmi_init() - enter        | [..]                                                                      |
[42949374.960000] bmi_init() - exit         | bug-image-production-bug-20090305151241.rootfs.ext3                       |
[42949374.960000] Advanced Linux Sound Archi| bug-image-production-bug-20090305151241.rootfs.tar.bz2                    |
[42949374.970000] ALSA device list:         | bug-image-production-bug.ext3                                             |
[42949374.980000]   No soundcards found.    | bug-image-production-bug.tar.bz2                                          |
[42949374.980000] TCP cubic registered      | modules-2.6.27.2-bug.tgz                                                  |
[42949374.980000] NET: Registered protocol f| u-boot-1.3.2+svnr8393-r4.bin                                              |
[42949374.990000] Mobile IPv6               | uImage-2.6.27.2+svnr8179-bug-20090305145359.bin                           |
[42949374.990000] IPv6 over IPv4 tunneling d| uImage-bug.bin                                                            |
[42949375.000000] NET: Registered protocol f| uboot-latest.bin                                                          |
[42949375.000000] Power Management for Frees| zImage-2.6.27.2+svnr8179-bug-20090305145359.bin                           |
[42949375.010000] VFP support v0.3: implemen| zImage-bug.bin                                                            |
[42949375.020000] drivers/rtc/hctosys.c: una|                                                                           |
[42949375.240000] mmc0: host does not suppor|                                                                           |
[42949375.250000] mmc0: new SD card at addre|                                                                           |
[42949375.260000] mmcblk0: mmc0:8fe4 SU02G 1|                                                                           |
[42949375.260000]  mmcblk0: p1              |                                                                           |
[42949375.600000] eth0: link down           |                                                                           |
[42949375.600000] ADDRCONF(NETDEV_UP): eth0:|                                                                           |
[42949376.610000] IP-Config: Complete:      |                                                                           |
[42949376.610000]      device=eth0, addr=192|                                                                           |
[42949376.620000]      host=BUG, domain=, ni|                                                                           |
[42949376.620000]      bootserver=192.168.0.|                                                                           |
[42949376.630000] Waiting 1sec before mounti|                                                                           |
+:+                                         |                                                                           |
Clock input is 26 MHz                       |                                                                           |
Ethernet eth0: MAC address 00:50:c2:69:c0:24|                                                                           |
IP: 192.168.0.111/255.255.255.0, Gateway: 19|                                                                           |
Default server: 192.168.0.121               |                                                                           |
                                            |                                                                           |
RedBoot(tm) bootstrap and debug environment |                                                                           |
Non-certified release, version FSL 200617 - |                                                                           |
                                            |                                                                           |
Platform: BUG2 (Freescale i.MX31 based) PASS|                                                                           |
Copyright (C) 2000, 2001, 2002, 2003, 2004 R|                                                                           |
                                            |                                                                           |
RAM: 0x00000000-0x04000000, [0x00014c20-0x03|                                                                           |
FLASH: 0xa0000000 - 0xa2000000, 2048 blocks |              ( Escape to exit, Space to tag )                             |
== Executing boot script in 1.000 seconds - +---------------------------------------------------------------------------+
^C
BUG_RedBoot> load -b 0x100000 -m ymodem -v -               [Goto]  [Prev]  [Show]   [Tag]  [Untag] [Okay]

Sending (it's only about 200K so it shouldn't take too long):


         +-----------[ymodem upload - Press CTRL-C to quit]------------+
         |Sending: uboot-latest.bin                                    |
         |Ymodem sectors/kbytes sent:   0/ 0k                          |
         |                                                             |
         |                                                             |
         |                                                             |
         |                                                             |
         |                                                             |
         +-------------------------------------------------------------+

Transfer complete:

         +-----------[ymodem upload - Press CTRL-C to quit]------------+
         |Sending: uboot-latest.bin                                    |
         |Bytes Sent: 199296   BPS:5813                                |         
         |Sending:                                                     |         
         |Ymodem sectors/kbytes sent:   0/ 0k                          | 
         |Transfer complete                                            |
         |                                                             |
         | READY: press any key to continue...                         |
         +-------------------------------------------------------------+

Unlock NOR

Use the command fi unlock -f 0xA0000000 -l 0x40000 to unlock the section of flash that will house uBoot.

BUG_RedBoot> fi unlock -f 0xA0000000 -l 0x40000
... Unlock from 0xa0000000-0xa0040000: flash_unlock_block dev a0000000 block a0000000 size 00004000 count 00000800
.flash_unlock_block dev a0000000 block a0004000 size 00004000 count 00000800
.flash_unlock_block dev a0000000 block a0008000 size 00004000 count 00000800
.flash_unlock_block dev a0000000 block a000c000 size 00004000 count 00000800
.flash_unlock_block dev a0000000 block a0010000 size 00004000 count 00000800
.flash_unlock_block dev a0000000 block a0014000 size 00004000 count 00000800
.flash_unlock_block dev a0000000 block a0018000 size 00004000 count 00000800
.flash_unlock_block dev a0000000 block a001c000 size 00004000 count 00000800
.flash_unlock_block dev a0000000 block a0020000 size 00004000 count 00000800
.flash_unlock_block dev a0000000 block a0024000 size 00004000 count 00000800
.flash_unlock_block dev a0000000 block a0028000 size 00004000 count 00000800
.flash_unlock_block dev a0000000 block a002c000 size 00004000 count 00000800
.flash_unlock_block dev a0000000 block a0030000 size 00004000 count 00000800
.flash_unlock_block dev a0000000 block a0034000 size 00004000 count 00000800
.flash_unlock_block dev a0000000 block a0038000 size 00004000 count 00000800
.flash_unlock_block dev a0000000 block a003c000 size 00004000 count 00000800
.
BUG_RedBoot>

Write uBoot to NOR

Use the command fi wr -f 0xA0000000 -b 0x100000 -l 0x40000 to write the uBoot image to the flash chip. Type "y" at the warning.

BUG_RedBoot> fi wr -f 0xA0000000 -b 0x100000 -l 0x40000
* CAUTION * about to program FLASH
            at 0xa0000000..0xa003ffff from 0x00100000 - continue (y/n)? y
flash_erase(): addr = a0000000, len = 40000
flash_erase(): end_addr = a0040000, block = a0000000
flash_erase(): end_addr = a0040000, block = a0000000
... Erase from 0xa0000000-0xa0040000: flash_erase(): block = a0000000, block_size = 4000

flash_erase_block(): block = a0000000, block_size = 4000
flash_unlock_block dev a0000000 block a0000000 size 00004000 count 00000001
.flash_erase(): block = a0004000, block_size = 4000
.flash_erase(): block = a0008000, block_size = 4000

flash_erase_block(): block = a0008000, block_size = 4000
flash_unlock_block dev a0000000 block a0008000 size 00004000 count 00000001
.flash_erase(): block = a000c000, block_size = 4000
.flash_erase(): block = a0010000, block_size = 4000

flash_erase_block(): block = a0010000, block_size = 4000
flash_unlock_block dev a0000000 block a0010000 size 00004000 count 00000001
.flash_erase(): block = a0014000, block_size = 4000
.flash_erase(): block = a0018000, block_size = 4000

flash_erase_block(): block = a0018000, block_size = 4000
flash_unlock_block dev a0000000 block a0018000 size 00004000 count 00000001
.flash_erase(): block = a001c000, block_size = 4000
.flash_erase(): block = a0020000, block_size = 4000

flash_erase_block(): block = a0020000, block_size = 4000
flash_unlock_block dev a0000000 block a0020000 size 00004000 count 00000001
.flash_erase(): block = a0024000, block_size = 4000
.flash_erase(): block = a0028000, block_size = 4000
.flash_erase(): block = a002c000, block_size = 4000
.flash_erase(): block = a0030000, block_size = 4000
.flash_erase(): block = a0034000, block_size = 4000
.flash_erase(): block = a0038000, block_size = 4000
.flash_erase(): block = a003c000, block_size = 4000
.
... Program from 0x00100000-0x00140000 at 0xa0000000: ................
BUG_RedBoot>

Reset RedBoot (for the last time)

Type the command reset to restart the bootloader. This time uBoot should come up. Hit any key while uBoot is loading to break out of autoload.

BUG_RedBoot> reset

... Resetting.


U-Boot 1.3.2 (Mar  5 2009 - 09:54:31)

CPU:   Freescale i.MX31 at 531 MHz
Board: Bug2
DRAM:  128 MB
Flash: 32 MB
In:    serial
Out:   serial
Err:   serial
Registering MXC MMC
Debug: mmc_register
MMC:   MXC MMC: 0
Hit any key to stop autoboot:  0
BUGBoot>


Review uBoot settings

Use the uBoot command printenv to review the settings.

BUGBoot> printenv
bootdelay=3
baudrate=115200
ipaddr=192.168.23.168
serverip=192.168.23.2
netmask=255.255.255.0
bootfromnor=cp.b 0xA0400000 0x80800000 0x200000
bootmmc=mmcinfo; ext2load mmc 0:1 0x80800000 /boot/uImage
bootargs=noinitrd console=ttymxc4,115200 rootdelay=1 root=/dev/mmcblk0p1 mem=128M
bootcmd=run bootmmc;bootm 0x80800000
stdin=serial
stdout=serial
stderr=serial

Environment size: 360/32763 bytes

Note that the bootmmc and bootargs are very important. Let's examine the syntax: bootmmc: These are the parameters used to tell uBoot where to find and how to load your kernel image. ext2load means that the flash card must be formatted as ext3/ext2. 0:1 refers to the device and partition that uBoot should look for the kernel image. This means that your SD card's first partition should be of type ext3 (or ext2), housing the uImage in /boot/ 0x80800000 refers to the memory location into which the kernel image should be loaded. Do not change this. /boot/uImage refers to the location of the kernel uImage. bootargs: These are the paramters passed to your kernel upon load.

Steps for Upgrading from U-boot

There may be circumstances where you want a newer version of uboot. Earlier builds of BUG's uboot had ethernet problems, for example.

Load uboot image

loady

Use yModem to upload the new uboot image:

Follow the instructions in this section above #Load_uboot-latest.bin, starting with "Hit Ctrl+A, then S" until you get "Transfer Complete", then continue with the instructions below.

  • Note: It can sometimes take a couple of retries, especially if the handylink connection isn't perfect.

Unlock NOR

protect off 0xA0000000 +0x40000

Erase NOR

erase 0xA0000000 +0x40000 

Copy from RAM to NOR

cp.b 0x80000000 0xA0000000 0x40000

Handylink Ethernet U-boot Environment

Don't forget that when you overwrite your boot loader, you will need to set an environment variable in U-boot. This initializes the eth0 (Handylink Ethernet) device with a provided MAC Address. Example:

setenv ethaddr 00:00:00:FF:FF:FF

This will set your MAC address for this session. Save it to flash by:

saveenv

Reload U-boot:

reset

NOTE: Use a real MAC address, preferably from your old eth0 MAC Addr you have noted before your upgrade to U-boot.


Notes

uBoot will only "work" if you have a working uImage for it to load. Your boot configuration must match with your rootfs flash card. This is the default as of RC1.4.10. It goes without saying that zImages will not work, as they are of a different format than uImage. For more information about how to upgrade your kernel, please see an updated Upgrading BUG Kernel wiki. If you have trouble following this procedure, please drop into our irc channel at [[1]].

Props

Thanks to Chris Wade in his efforts to port uBoot to BUG. Matt Isaacs & Chris followed up with SD support. These instructions have been adapted from Chris' initial tutorial at [2].