Hardware/ARMEBS/3/u-boot
u-boot
for Linux < 2.6.26 see : u-boot before 2.6.26
u-boot is a bootloader, we've choosen it because it supports usb and network operations.
It has been adapted to support our board, especially an auto-update function, using an USB flash drive.
As any bootloader, u-boot can be used (and this is it's main purpose) to start another program (or operating system), for instance Linux. The application we want to run must be in a special form called image and can be generated using mkimage (in u-boot/tools/), for instance generating a Linux kernel image is done using the following command :
mkimage -A ARM -T kernel -C none -O Linux -a 0x20008000 -d /opt/armebs3/linux-2.6.15/output/arch/arm/boot/zImage linux.img
After r641 of our Linux kernel, make uImage will build this image for you.
Automatic startup bootcmd
At boot, u-boot does this:
- By default, it runs the command in the bootcmd variable.
- If the first button (S1 on the ARMEBS3) is pressed, it tries to do AutoUpdate on the USB key. If it fails, it runs bootcmd}.
- If the third button (S3 on the ARMEBS3) is pressed, it jumps to 0x10060000, after disabling instruction cache.
Settings for the technical informatics laboratories
The instruction cache must be shut-down before downloading a software via the JTAG interface.
set bootcmd icache off save
Get the Linux kernel from tftp (using a static ip address), and launch it
- the kernel image (uImage) is at the root of the tftp server
- the tftp server IP is 153.109.5.233
- the armebs3 IP is 153.109.5.232
- don't forget to set the LinuxCommandLine in the bootargs variable
set ipaddr 153.109.5.232 set serverip 153.109.5.233 setenv bootcmd "tftpboot 0x21000000 uImage ; bootm 0x21000000" save
Get the Linux kernel from tftp (using DHCP), and launch it
- the kernel image (uImage) is at the root of the tftp server
- the tftp server IP is 153.109.5.233
- don't forget to set the LinuxCommandLine in the {{{bootargs}}} variable
set serverip 153.109.5.233 setenv bootcmd "bootp 0x21000000 uImage ; bootm 0x21000000" save
Get the Linux kernel from flash, and launch it
- The kernel image is supposed to be flashed at 0x10060000
- Download the kernel to ram (using tftp for instance)
- Flash it
erase 0x10060000 +0x200000 cp.b 0x21000000 0x10060000 0x200000
- don't forget to set the LinuxCommandLine in the bootargs variable
setenv bootcmd "bootm 0x10060000" save
Get the Linux kernel from an USB key, and launch it
- The USB key must be FAT16 formated, without partitions
- don't forget to set the LinuxCommandLine in the bootargs variable
set bootcmd "usb start ; fatload usb 0 0x21000000 uImage ; bootm 0x21000000"
Configuration
The first time you start u-boot there are some things to configure.
Connect with a terminal emulator on the first serial port (115200,8,n,1).
Basic commands
here is a small list of usefull commands:
- help : gives you help for built-in commands (without argument, display a list of all commands)
- bmp : used to display a bmp on the screen (example: bmp 0x10f00000 will display the bitmap at address 0x10f00000). This command support standard bmp or gzipped bmp.
- usb : used to manage usb for instance: usb start, then usb storage to see which storage has been attached.
- fatload : load a file from a fat file system into memory, example : fatload usb 0 0x21000000 linux.img will load the linux kernel image at 0x21000000, don't forget to do usb start before that :-)
- erase : erase flash, for instance erase 0x10060000 +0x200000 for erasing flash from 0x10060000 to 0x10260000
- cp![.size] : copy from memory to memory (or to flash), for instance cp.b 0x21000000 0x10060000 0x200000 for copying 0x20000 byte from 0x21000000 (SDRAM) to 0x10060000 (flash)
u-boot works with environment variables for storing configuration options, and here are the basic commands for setting/reading variables:
- setting a variable (v1)
setenv toto hello world toto=hello world
- printing a variable (v1)
printenv toto toto=hello world
- printing a variable (v2)
echo ${toto} hello world
- saving variables (to flash)
save Saving Environment to Flash... Un-Protected 1 sectors Erasing Flash... . done Erased 1 sectors Writing to Flash... . done Protected 1 sectors
Well known variables
u-boot uses some known variables names for it's own use, here is an overview.
- board (armebs3 specific) and protected* variable
name (type of the board), used to init board specific hardware. u-boot is compiled to support ALL ARMEBS3 based board and uses this variable to know which board it is running on. possible values are : armebs3, ipresenter, sidney, proto.
- ethadd protected* variable
Ethernet address, MUST be set-up for boards using network, example : setenv ethaddr 00:00:17:00:00:00.
- bootdelay
delay after reset before the bootcmp is run
- bootcmd
command to run automatically after a reset, example : setenv bmp display 0x10f00000 \; bootm 0x10060000 to diplay the bitmap located at 0x10f00000 and run the software from 0x10060000. unset it (setenv bootcmd) to do nothing at boot.
- bootargs ( see also [wiki:LinuxCommandLine linux command line])
boot arguments, passed to the application to be run (at least passed to linux as the kernel command line), example setenv bootargs root=1f03 ro rootfstype=romfs console=ttyS0,9600 video=s1d13x06fb:crt,mode:800x600-16
- baudrate
The baudrate for the console
- sdtin, stdout, stderr
Defines where the standard input, output and error stream are sent by u-boot, values can be : serial, vga (for the mezza_lcd and it's keyborard) and vga-serial (for both serial AND mezza_lcd).
- video : Setup the vga output, values can be :
- video=lcd,640x480-16 for the mezza_lcd + the laboratory LCD screen.
- video=crt,800x600-16 for the mezza_lcd + vga output
- video=lcd,320x240-16 for the sidney board.
*protected variables can only be set once. To reset this variables, the flash configuration area must be erased and the system rebooted (flash protect off all ; erase 0x10040000 + 0x20000 ; boot), then the protected variables can be set again.
compiling/installing
- checkout the sources from https://svn.hevs.ch/svn/uit/armebs3/u-boot/trunk
cd /opt/armebs3 /opt/armebs3 svn checkout https://svn.hevs.ch/svn/uit/armebs3/u-boot/trunk u-boot
- compile it
/opt/armebs3 cd u-boot /opt/armebs3/u-boot make armebs3_config /opt/armebs3/u-boot make /opt/armebs3/u-boot
- flash it
/opt/armebs3/u-boot cp u-boot.bin /opt/armebs3/tftp reset mm 0xfffffc20 0x0000ff01 mm 0xffffff70 0x000030ff mm 0xfffffc30 0x00000001 unlock 0x10000000 0x20000 2 erase 0x10000000 0x20000 2 Erasing flash at 0x10000000 Erasing flash at 0x10020000 Erasing flash passed prog 0x10000000 u-boot.bin bin Programming u-boot.bin , please wait .... Programming flash passed
u-boot, step by step, file by file
here is a small overview of what is done in which file
- /u-boot/trunk/cpu/arm920t/start.S u-boot/cpu/arm920t/start.S
- reset vectors -> reset
- reset
- do cpu init
- call lowlevel_init from [source:/u-boot/trunk/cpu/arm920t/at91rm9200/lowlevel_init.S u-boot/cpu/arm920t/at91rm9200/lowlevel_init.S]
- init sdram, chip select, ...
- relocates to sdram, setup stack, clear bss section
- jump to start_armboot (relocated)
- start_armboot from /u-boot/trunk/lib_arm/board.c u-boot/cpu/arm920t/lib_arm/board.c
- init global data sturcture (gd)
- call every functions from the init_sequence[] table
- basic cpu dependent setup cpu_init u-boot/trunk/cpu/arm920t/cpu.c u-boot/cpu/arm920t/cpu.c
- basic board dependent setup board_init u-boot/trunk/board/armebs3/armebs3.c u-boot/board/armebs3/armebs3.c
- set up exceptions interrupt_init /u-boot/trunk/cpu/arm920t/at91rm9200/interrupts.c u-boot/cpu/arm920t/at91rm9200/interrupts.c
- initialize environment env_init /u-boot/trunk/common/env_flash.c u-boot/common/env_flash.c
- initialze baudrate settings init_baudrate /u-boot/trunk/lib_arm/board.c u-boot/lib_arm/board.c
- serial communications setup serial_init /u-boot/trunk/cpu/arm920t/at91rm9200/serial.c u-boot/cpu/arm920t/at91rm9200/serial.c
- stage 1 init of console console_init_f /u-boot/trunk/board/armebs3/armebs3.c u-boot/board/armebs3/armebs3.c
- say that we are here display_banner /u-boot/trunk/lib_arm/board.c u-boot/lib_arm/board.c
- configure available RAM banks dram_init (only setup how many sdram is here for u-boot, no sdram initialization) /u-boot/trunk/board/armebs3/armebs3.c u-boot/board/armebs3/armebs3.c
- display dram info display_dram_config /u-boot/trunk/lib_arm/board.c u-boot/lib_arm/board.c
- ...
- run u-boot
- call every functions from the init_sequence[] table
- init global data sturcture (gd)
External link(s)
here is the u-boot home page: http://u-boot.sourceforge.net/.