Linux on FPGA4U/Quick Start

From Fpga4u

Jump to: navigation, search

This page is about quickly programming your FPGA4U with a working hardware design and an embedded Linux.

It may be possible to run these steps on Windows.

Download

Download linux-fgpa4u-20080803-prog.tar.bz2, and extract it, you will get 2 files:

  • nios2test.sof: A programming file containing a system with a Nios II (f), support the SDRAM, the Ethernet PHY, the EPCS flash and the various PIO (LEDs, buttons, switches) on board.
  • zImage: A basic kernel with a ramfs filesystem.

Program and run

Make sure the PATH is set correctly:

export PATH=$PATH:/opt/altera8.0/quartus/bin
export PATH=$PATH:/opt/altera8.0/nios2eds/bin:/opt/altera8.0/nios2eds/bin/nios2-gnutools/H-i686-pc-linux-gnu/bin/

(update the paths as needed)

Then simply run:

nios2-configure-sof nios2test.sof 
nios2-download -g zImage && nios2-terminal

(the first command programs the FPGA, the second downloads the Linux image, then starts a terminal so you can see the kernel booting)

And you should see something like this:

> export PATH=$PATH:/opt/altera8.0/quartu 
> export PATH=$PATH:/opt/altera8.0/nios2eds/bin:/opt/altera8.0/nios2eds/bin/nios2-gnutools/H-i686-pc-linux-gnu/bin/
> nios2-configure-sof nios2test.sof 
Searching for SOF file:
in .
  nios2test.sof
Info: *******************************************************************
Info: Running Quartus II Programmer
Info: Command: quartus_pgm --no_banner --mode=jtag -o p;./nios2test.sof
Info: Using programming cable "USB-Blaster [USB 5-1.1]"
Info: Started Programmer operation at Sun Aug  3 23:18:07 2008
Info: Configuring device index 1
Info: Device 1 contains JTAG ID code 0x020B30DD
Info: Configuration succeeded -- 1 device(s) configured
Info: Successfully performed operation(s)
Info: Ended Programmer operation at Sun Aug  3 23:18:11 2008
Info: Quartus II Programmer was successful. 0 errors, 0 warnings
    Info: Processing ended: Sun Aug  3 23:18:11 2008
    Info: Elapsed time: 00:00:05
    Info: Total CPU time (on all processors): 00:00:01
> nios2-download -g zImage && nios2-terminal
Using cable "USB-Blaster [USB 5-1.1]", device 1, instance 0x00
Pausing target processor: OK
Initializing CPU cache (if present)
OK
Downloaded 1199KB in 32.5s (36.8KB/s)
Verified OK                         
Starting processor at address 0x02500000

nios2-terminal: connected to hardware target using JTAG UART on cable
nios2-terminal: "USB-Blaster [USB 5-1.1]", device 1, instance 0
nios2-terminal: (Use the IDE stop button or Ctrl-C to terminate)
Uncompressing Linux... Ok, booting the kernel.
Linux version 2.6.26 (nicolas@nunuche) (gcc version 3.4.6) #80 PREEMPT Sun Aug 3 22:40:45 SGT 2008
uClinux/Nios II
Built 1 zonelists in Zone order, mobility grouping off.  Total pages: 8128
Kernel command line: 
PID hash table entries: 128 (order: 7, 512 bytes)
Dentry cache hash table entries: 4096 (order: 2, 16384 bytes)
Inode-cache hash table entries: 2048 (order: 1, 8192 bytes)
Memory available: 30332k/2138k RAM, 0k/0k ROM (1392k kernel code, 746k data)
Mount-cache hash table entries: 512
net_namespace: 180 bytes
NET: Registered protocol family 16
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 1024 (order: 1, 8192 bytes)
TCP bind hash table entries: 1024 (order: 0, 4096 bytes)
TCP: Hash tables configured (established 1024 bind 1024)
TCP reno registered
JFFS2 version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
io scheduler noop registered
io scheduler deadline registered (default)
ttyJ0 at MMIO 0x4022070 (irq = 1) is a Altera JTAG UART
console [ttyJ0] enabled
res->start=4010300 len=10
smc91x.c: v1.1, sep 22 2004 by Nicolas Pitre <nico@cam.org>
eth0: SMC91C11xFD (rev 2) at 84010300 IRQ 2 [nowait]
eth0: Ethernet addr: 00:60:d7:03:00:c7
m25p80 spi0.0: m25p16 (2048 Kbytes)
Creating 2 MTD partitions on "m25p80":
0x00080000-0x00200000 : "romfs/jffs2"
0x00000000-0x00080000 : "fpga configuration"
NET: Registered protocol family 17
Freeing unused kernel memory: 560k freed (0x218a000 - 0x2215000)
Shell invoked to run file: /etc/rc
Command: hostname uClinux
Command: mount -t proc proc /proc
Command: mount -t sysfs sysfs /sys
Command: mount -t usbfs none /proc/bus/usb
mount: mounting none on /proc/bus/usb failed: No such file or directory
Command: mkdir /var/tmp
Command: mkdir /var/log
Command: mkdir /var/run
Command: mkdir /var/lock
Command: mkdir /var/empty
Command: ifconfig lo 127.0.0.1
Command: route add -net 127.0.0.0 netmask 255.0.0.0 lo
Command: ifconfig eth0 10.0.0.1 netmask 255.255.255.0
eth0: link down
Command: inetd &
[20]
Command: hello &
[21]
Command: cat /etc/motd
Welcome to
          ____ _  _
         /  __| ||_|                 
    _   _| |  | | _ ____  _   _  _  _ 
   | | | | |  | || |  _ \| | | |\ \/ /
   | |_| | |__| || | | | | |_| |/    \
   |  ___\____|_||_|_| |_|\____|\_/\_/ (on FPGA4U)
   | |
   |_|

For further information check:
http://www.uclinux.org/
http://fgpa4u.epfl.ch/

Command: 
Execution Finished, Exiting

Sash command shell (version 1.1.1)
/> eth0: link up, 100Mbps, full-duplex, lpa 0xCDE1

Now, the LEDs should display something meaningful.

nios2-terminal is a bit annoying to use (e.g. no Ctrl-C), so connect the Ethernet cable (the board's IP address is 10.0.0.1 with netmask 255.255.255.0), and

telnet 10.0.0.1

There is also an FTP server (user:ftp, password:<blank>, uploaded files will be in /home/ftp)

Burn it to the flash

If you want to use this Linux system as your default programming file (i.e. Linux will boot when the board is powered on), you can download linux-fgpa4u-20080803-epcs.tar.bz2.

nios2-configure-sof nios2test.sof 
nios2-flash-programmer --epcs --base=0x04021800 config.flash
nios2-flash-programmer --epcs --base=0x04021800 epcs_controller.flash

Power-cycle the board, run nios2-terminal if you like (or wait until the telnet server is ready), the board should boot.

Personal tools