U-Boot Quick Start

1. U-Boot Boot Log

U-Boot 1.2.0-emma-8 (Sep 21 2007 - 11:24:10)

Board: EMMA3P et10068 (CPU Speed 328 MHz, DRMA Size 768 MB)
BHIF version = 0x0000f010 (EMMA3P 1.0)
Realtek Ethernet MAC support = enable
DRAM:  160 MB
Flash: 32 MB
In:    serial
Out:   serial
Err:   serial
Net:   RTL8139#0, NEC-Candy
Hit any key to stop autoboot:  0

2. Config to bootstrap

2.0 Display enviroment variables

Using ‘printenv’ to display enviroment variables:

U-Boot> printenv
baudrate=115200
ethaddr=12:34:56:78:9a:bb
eth1addr=12:34:56:78:9a:bc
eeprom=off
bootdelay=5
ethact=RTL8139#0
bootfile=/vlm-boards/14726/kernel
hostname=nec_emmap3p-1
autoload=yes
autostart=no
bootcmd=tftp 0x80600000 vlm-boards/14726/test;bootm
filesize=2640c5
fileaddr=80600000
gatewayip=192.168.29.1
netmask=255.255.255.0
ipaddr=192.168.29.243
serverip=192.168.29.11
bootargs=console=ttyS0,115200 root=/dev/nfs rw nfsroot=192.168.29.11:/export/pxeboot/vlm-boards/14726/rootfs ip=dhcp
stdin=serial
stdout=serial
stderr=serial

Using following command to only display ipaddr:

U-Boot> pri ipaddr
ipaddr=192.168.29.243

2.1 Set ethernet variables

U-Boot does not supply explicit ethernet configure commands. You need to set following environment variables (U-Boot predefine) for supporting ethernet:

ipaddr
netmask
gatewayip

Using ‘setenv’ to set these variables:

U-Boot> setenv ipaddr 192.168.29.243 U-Boot> setenv netmask 255.255.255.0 U-Boot> setenv gatewayip  192.168.29.1

NOTE: In U-Boot, ‘setenv’ dose not store the environment variable permanently in the NVRAM. If you want to make setting permanent you need to execute ‘saveenv’:

U-Boot> saveenv
Saving Environment to Flash...
. done
Un-Protected 1 sectors
Erasing Flash...
. done
Erased 1 sectors
Writing to Flash... done
. done
Protected 1 sectors

After seting the ethernet, you can use the ‘ping’ command to test the network:

U-Boot> ping 192.168.29.11

If the setting is OK, it’ll output like following:

Using RTL8139#0 device host 192.168.29.11 is alive

2.2 Load & execute

U-Boot supply ‘tftpboot’ command to load image from Ethernet into RAM.

‘tftpboot’ use ‘serverip’ environment varible as its default tftp server, so you need to set the ‘serverip’ varible before you use ‘tftpboot’:

U-Boot> setenv serverip 192.168.29.11
U-Boot> tftpboot 0x80400000 vlm-boards/14726/uImage
Using RTL8139#0 device
TFTP from server 192.168.29.11; our IP address is 192.168.29.243
Filename 'vlm-boards/14726/uImage'.
Load address: 0x80400000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         ######
done
Bytes transferred = 5017797 (4c90c5 hex)

You can use following U-Boot predefined variable to specify the default value:

serverip                       -------> specify the default TFTP server ip
bootfile                       -------> specify the default TFTP file

So after executing following commands:

U-Boot> setenv bootfile vlm-boards/15440/uImage

We only need type ‘tftpboot’ without long strings:

U-Boot> tftp
Using RTL8139#0 device
TFTP from server 192.168.29.11; our IP address is 192.168.29.243
Filename 'vlm-boards/14726/uImage'.
Load address: 0x80400000
Loading: #################################################################
         #################################################################
         #################################################################
         ######################################################
done
Bytes transferred = 4600006 (4630c6 hex)

You can also use the ‘nfs’ to load the kernel from nfs server:

U-Boot> nfs 0x80400000 192.168.29.11:/export/pxeboot/vlm-boards/14726/uImage
Using RTL8139#0 device
File transfer via NFS from server 192.168.29.11; our IP address is 192.168.29.243
Filename '/export/pxeboot/vlm-boards/14726/uImage'.
Load address: 0x80400000
Loading: #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 ######################################################
done
Bytes transferred = 4600006 (4630c6 hex)

If you set the ‘serverip’ you only need to type:

U-Boot> nfs 0x80400000 /export/pxeboot/vlm-boards/14726/uImage

If you have dhcp server, you can simply type ‘dhcp’ to get the ipaddr, netmask, gatewayip, serverip, bootfile and can load the boot file automatically.

If you want to load the file via serial you can use ‘loadb’/'loads’:

U-Boot> loadb 0x400000 115200                       ----------> load binary file over serial line with baudrate 115200 and place the file at 0x400000
U-Boot> loads 0x400000 115200                       ----------> load S-Record file over serial line with baudrate 115200 and convert the S-Record to binary

Execute:

After loading image, we need to parse the image header and jump to the entry address.

In U-Boot we use ‘bootm’ to parse the uboot image header and jump to the entry address:

U-Boot> bootm 0x80400000 console=ttyS0,115200 root=/dev/nfs nfsroot=192.168.29.11:/export/rootfs ip=dhcp
## Booting image at 80400000 ...
    Image Name:   Linux-2.6.21.7-hrt1-WR2.0bl_stan
    Created:      2008-04-08   8:49:42 UTC
    Image Type:   MIPS Linux Kernel Image (uncompressed)
    Data Size:    4599942 Bytes =  4.4 MB
    Load Address: 80040000
    *Entry Point:  80478000*
    Verifying Checksum ... OK
OK

Starting kernel ...

Linux version 2.6.21.7-hrt1-WR2.0bl_standard (gcc version 4.1.2) #2 PREEMPT Tue Apr 8 01:49:27 PDT 2008
CPU revision is: 00005610
FPU revision is: 00035610
Determined physical RAM map:
 memory: 0a000000 @ 00000000 (usable)
 memory: 10000000 @ 20000000 (usable)
Initrd not found or empty - disabling initrd
......

‘bootm’ use the ‘bootargs’ enviroment variable as the default argument passed to the kernel and use ‘fileaddr’ varible as the default image file start address. So:

U-Boot> setenv bootargs console=ttyS0,115200 root=/dev/nfs nfsroot=192.168.29.11:/export/rootfs ip=dhcp
U-Boot> bootm

‘fileaddr’ is automatically set by any load command.

If you know the entry address, you can use the ‘go’:

U-Boot> go 0x80848000 root=/dev/nfs rw nfsroot=192.168.29.11:/export/rootfs ip=dhcp

‘go’ don’t parse the image header.

NOTE: If you set the variable ‘autostart’ to yes, tftpboot/nfs will be internally calling the bootm command

2.3 Automatic bootstrap

U-Boot use predefined variable ‘bootcmd’ as the automatic bootstrap command, U-Boot will give the user the option to press Ctrl-C within 10 seconds to cancel execution of the start command.

We can set ‘bootdelay’ variable to specify the delay seconds. But if set ‘bootdelay’ to -1, the start command will not be executed.

U-Boot> setenv bootcmd tftp 0x80400000\; bootm 0x80400000 root=/dev/nfs rw nfsroot=192.168.29.11:/export/rootfs ip=dhcp console=ttyS0,115200
U-Boot> setenv bootdelay 4
U-Boot> reset

If you predefine some variables like following:

U-Boot> setenv bootargs root=/dev/nfs rw nfsroot=192.168.29.11:/export/rootfs ip=dhcp console=ttyS0,115200 U-Boot> setenv serverip 192.168.29.11 U-Boot> setenv bootfile vlm-boards/14726/uImage U-Boot> setenv bootcmd tftp 0x80400000\; bootm

You can type ‘run bootcmd’ or ‘bootd’:

U-Boot> run bootcmd

3. Memory commands

3.1 Dump memory

U-Boot> md.b 0x80400000 0x40
80400000: 27 05 19 56 4a e2 a0 89 47 fb 31 a6 00 46 30 86    '..VJ...G.1..F0.
80400010: 80 04 00 00 80 47 80 00 ea b4 24 c7 05 05 02 00    .....G....$.....
80400020: 4c 69 6e 75 78 2d 32 2e 36 2e 32 31 2e 37 2d 68    Linux-2.6.21.7-h
80400030: 72 74 31 2d 57 52 32 2e 30 62 6c 5f 73 74 61 6e    rt1-WR2.0bl_stan

U-Boot> md.w 0x80400000 0x20
80400000: 2705 1956 4ae2 a089 47fb 31a6 0046 3086    '..VJ...G.1..F0.
80400010: 8004 0000 8047 8000 eab4 24c7 0505 0200    .....G....$.....
80400020: 4c69 6e75 782d 322e 362e 3231 2e37 2d68    Linux-2.6.21.7-h
80400030: 7274 312d 5752 322e 3062 6c5f 7374 616e    rt1-WR2.0bl_stan

U-Boot> md.l 0x80400000 0x10
80400000: 27051956 4ae2a089 47fb31a6 00463086    '..VJ...G.1..F0.
80400010: 80040000 80478000 eab424c7 05050200    .....G....$.....
80400020: 4c696e75 782d322e 362e3231 2e372d68    Linux-2.6.21.7-h
80400030: 7274312d 5752322e 30626c5f 7374616e    rt1-WR2.0bl_stan

3.2 Memory Copy

cp [.b, .w, .l] source target count
U-Boot> cp.b 0x80400000 0xbe000000 0x100000

Assume the 0xbe000000 is the flash address.

3.3 Modify memory

U-Boot> mm.w 0x80000000
80000000: 0000 ? 55aa
80000002: 0000 ? 66bb
80000004: 0000 ? 77cc
80000006: 0000 ? 88dd
80000008: 0000 ? .

Type ‘.’ to exit, ‘-’ to back up

U-Boot> md.w 0x80000000
80000000: 55aa 66bb 77cc 88dd 0000 0000 0000 0000    U.f.w...........
80000010: 0000 0000 0000 0000 0000 0000 0000 0000    ................

3.4 Memory Fill

U-Boot> md.w 0x80000000 10
80000000: 5678 5678 5678 5678 5678 5678 5678 5678    VxVxVxVxVxVxVxVx
80000010: 5678 5678 5678 5678 5678 5678 5678 5678    VxVxVxVxVxVxVxVx
U-Boot> mw.w 0x80000000 55aa 10
U-Boot> md.w 0x80000000 10
80000000: 55aa 55aa 55aa 55aa 55aa 55aa 55aa 55aa    U.U.U.U.U.U.U.U.
80000010: 55aa 55aa 55aa 55aa 55aa 55aa 55aa 55aa    U.U.U.U.U.U.U.U.

3.5 Memory Compare

cmp [.b, .w, .l] addr1 addr2 count

4. Flash commands

4.1 show flash infomation

U-Boot> flinfo

Bank # 1: CFI conformant FLASH (16 x 16)  Size: 32 MB in 256 Sectors
  AMD Standard command set, Manufacturer ID: 0x01, Device ID: 0x7E2201
  Erase timeout: 4096 ms, write timeout: 1 ms
  Buffer write timeout: 3 ms, buffer size: 64 bytes

  Sector Start Addresses:
  BE000000    BE020000    BE040000    BE060000    BE080000
  BE0A0000    BE0C0000    BE0E0000    BE100000    BE120000
  ........................
  ........................
  BFE00000   RO   BFE20000    BFE40000    BFE60000 E    BFE80000 E
  BFEA0000 E    BFEC0000 E    BFEE0000 E    BFF00000 E    BFF20000 E
  BFF40000 E    BFF60000 E    BFF80000 E    BFFA0000 E    BFFC0000 E
  BFFE0000 E

There is only one Bank (# 1) on current board. Sector size is 0×20000.

4.2 erase flash

NOTE: Before you erase the flash, you must to know the U-Boot code residing area (start address and size) and avoid to erase this area in case of you are not going to update the U-Boot.

U-Boot> erase BE000000 BE07FFFF

... done
Erased 4 sectors

Or:

U-Boot> era 0xBE000000 +0x80000

Another way to select certain areas of the flash memory is using banks and sectors. Following commands has the same function:

U-Boot> era 1:1-4
Erase Flash Sectors 1 - 4 in Bank # 1
..done

A bank is an area of memory implemented by one or more memory chips that are connected to the same chip select signal.

A sector or erase unit is the smallest area that can be erased in one operation.

4.3 Protect flash

Use ‘protect’ command to enable or disable FLASH write protection:

U-Boot> protect off 0xBE000000 +0x80000          # or protect off 1:1-4

U-Boot> erase 1:1-4

U-Boot> protect on 0xBE000000 0xBE07FFFF

4.3 Update flash

U-Boot> tftp 0x81000000 vlm-boards/14726/rootfs-jffs2                      # load rootfs (jffs2 format) image to memory

U-Boot> protect off 0xBE000000 +0x1500000
U-Boot> erase 0xBE000000 +0x1500000

U-Boot> cp.b 0x81000000 0xBE000000 ${filesize}                             # write image to flash

U-Boot> protect on 1:6-255

5. Miscellaneous

5.1 Reset system

U-Boot> reset

5.2 Show PCI

U-Boot> pci
Scanning PCI devices on bus 0
BusDevFun  VendorId   DeviceId   Device Class       Sub-Class
_____________________________________________________________
00.0e.00   0x1033     0x0035     Serial bus controller   0x03
00.0f.00   0x10ec     0x8139     Network controller      0x00
00.14.00   0x1033     0x0177     Multimedia device       0x80

5.3 Help

U-Boot> help pci
pci [bus] [long]
    - short or long list of PCI devices on bus 'bus'
pci header b.d.f
    - show header of PCI device 'bus.device.function'
pci display[.b, .w, .l] b.d.f [address] [# of objects]
    - display PCI configuration space (CFG)
pci next[.b, .w, .l] b.d.f address
    - modify, read and keep CFG address
pci modify[.b, .w, .l] b.d.f address
    -  modify, auto increment CFG address
pci write[.b, .w, .l] b.d.f address value
    - write to CFG address

6. Reference

U-Boot user manual

评论关闭