Welcome, guest ( Login )

WikiHome » OperatingSystems » µClinux » DasUBoot

DasUBoot

Version 13, changed by hippo5329@yahoo.com.tw. 11/22/2007.   Show version history

http://www.denx.de/wiki/UBoot

http://sourceforge.net/projects/u-boot/  u-boot-1.1.5.tar.bz2

Manual

http://www.psyent.com/download

Das u-boot is a fancy bootloader with net support and scripting capabilities. 

Get the source

You can download the source from above, but to get the latest updates and support for nios2, you should get the source from the psyent git repository. To download the source code, use the following command:
git clone http://www.psyent.com/git/uboot u-boot.git

For more details see: http://forum.niosforum.com/forum/index.php?showtopic=4093

Compile

To compile run:
make distclean
make <board>_config
make


where <board> should be replaced with the board you want to compile for (e.g. make EP1C20_config will compile for the EP1C20 board). You can see which boards are supported in the board/altera folder.

Test, store in flash

To test, just load u-boot with nios2-download -g u-boot
See manual for fun stuff to do.

To write to flash:
protect off 0 1ffff
erase 0 1ffff
tftp 5000000 u-boot.bin
cp.b 5000000 0 $filesize


In this example, flash starts at address 0 and the file u-boot.bin is stored temporarily at 500_0000 which is in sdram (this is for the EP2C35 board)

Starting uClinux from u-boot:

Find your uncompressed version of your uClinux kernel (vmlinux) and run the following commands:
nios2-elf-objcopy -O binary vmlinux vmlinux.bin
gzip -9 vmlinux.bin       # Creates vmlinux.bin.gz
mkimage -A nios2 -O linux -T kernel -C none -a 0x4500000 -e 0x4500000 -n "Insert your name here" -d vmlinux.bin.gz vmlinux.img


where 0x450_0000 is the address you want the image to load too (again, 450_0000 is in the sdram for EP2C35 board). In my setup, I can find vmlinux.bin.gz under uClinux-dist/linux-2.6.x/arch/nios2nommu/boot/compressed/, so that I can skip the two first steps. The mkimage program is found under the tools folder of the u-boot source code. You might have to adjust some Makefiles to compile it.

In u-boot, tftp the image and bootm it:
tftp 5000000 vmlinux.img
bootm 5000000

Board not supported?

At the time of writing, only three boards are supported. If you're not among the lucky ones, you can start by modifying one of the existing boards (I will use EP1C20 as an example) to make it run on your board:
  1. Modify include/configs/EP1C20.h to make it reflect the setup in your system. You should be able to find all the addresses you need from your .ptf file, but it might be easier to look some of it up in your Quartus project.
  2. Modify board/altera/ep1c20/config.mk and update TEXT_BASE to reflect your system. This should normally be the end of your sdram - 256k (e.g. EP2C35 sdram start at 0x400_0000 and has length 0x200_0000 = 0x600_0000, subtract 0x4_0000 (256k) = 0x5fc0000). This is were u-boot will be placed.
  3. Either find and use an appropriate flash.c file, or just modify flash_init to return a non-zero value without probing the actual flash. If you choose to modify, your flash utilities won't work. But you'll have everything else ;-) For EP2C35, read the following post: http://forum.niosforum.com/forum/lofiversion/index.php/t4194.html 
  4. Compile
Once you get this working, you can do a real port (not covered here - yet).

Various bits and pieces

Use nios2-terminal

You should use serial uart as console in most cases. If you want to use nios2-terminal, you have to define "CONFIG_CONSOLE_JTAG" in include/configs/your_board.h to use jtag uart as console. But if you didn't connect nios2-terminal with this configuration, the nios2 will hang.

Default environment variables

You can change the default values of the environment values by adding them/modifying them in include/configs/<board>.h. The names of the defines doesn't always match, but a quick google search will usually give you what you need. Example, to set default values for bootdelay and bootcmd add the following lines:
#define CONFIG_BOOTDELAY 3
#define CONFIG_BOOTCOMMAND "tftp 5000000 zImage.img; bootm 5000000"

Change environment variable from uClinux

Look at the program found under u-boot.git/tools/env

Compiling on linux

In the main Makefile change the CROSS_COMPILE for nios2 to this:
ifeq ($(ARCH),nios2)
CROSS_COMPILE = nios2-linux-uclibc-

You might also have to do the following if the compiler complains about srec and bin files:
In the examples/Makefile change
%.srec: %
to
%.srec: %.o
and
%.bin: %
to
%.bin: %.o
This is due to a syntax change in make and will probably be corrected in later versions of u-boot (see: https://dev.openwrt.org/ticket/1680).


Old stuff:


To boot nios2 uclinux, you need the load address of zImage, which is sdram base + boot link offset (in kernel config, may be 0x500000 or 0x800000) . You may find the load address of zImage with
nios2-linux-uclibc-objdump -h zImage
The load addres is the vma of .text .

You need to use mkimage to convert zImage,with compress none.


kernel command line

To pass "bootargs" for kernel command line on NiosII uClinux, please apply the patch u-boot-1.1.5-nios2-01.diff.gz, attached at the end of this page. You have to use uClinux-dist-20060803 with uClinux-dist-20060803-nios2-02 patch ver 9, or later . Both vmlinux and compressed image are supported.

tar jxf u-boot-1.1.5.tar.bz2
cd u-boot-1.1.5
zcat u-boot-1.1.5-nios2-01.diff.gz  | patch -p0

Then in kernel config,
Processor type and features  --->
()  Default kernel command string
[*] Passed kernel command line from u-boot

Files changed,
u-boot-1.1.5/lib_nios2/nios_linux.c
linux-2.6.x/arch/nios2nommu/Kconfig
linux-2.6.x/arch/nios2nommu/kernel/setup.c
linux-2.6.x/arch/nios2nommu/kernel/head.S
linux-2.6.x/arch/nios2nommu/boot/compressed/head.S

Attachments (2)

  File By Size Attached Ver.
 u-boot-nios2-src-050811.zip hippo5329@yahoo.com.tw 1M 06/10/2006 1 Delete attachment
 u-boot-1.1.5-nios2-01.diff.gz hippo5329@yahoo.com.tw 2K 11/08/2006 2 Delete attachment