Timesys Getting Started Guide for Altera Cyclone-III DK
Contents
- Introduction
- Prerequisites
- Preparing the Target
- Preparing the Host
- Booting the Board
- Additional Information
Introduction
This document will describe in detail the procedures for booting a Linux kernel image and mounting a root file system over NFS on the Altera Cyclone-III DK.
Prerequisites
Host Requirements
To properly boot the Altera Cyclone-III DK using software from Timesys, your host machine must meet the following requirements:
- Modern GNU/Linux Distribution. Timesys recommends one of the following distributions:
- Ubuntu (Most recent release or LTS)
- Fedora (Most recent release)
- An internet connection on the Development Host.
- Root or sudo permission on the Development Host.
- A copy of the Linux Kernel (uImage-2.6.30-ts-nios2) and Root File System (rootfs.tar.gz) for the Target Board downloaded from Factory. These are found in the output directory of your online build, or in the directory build_nios2-timesys-linux-<libc>/images/ on the command line.
- If you are booting your root file system over the network, you will need two network cards installed and configured in the Development Host. One to communicate normally with your LAN/WAN while installing host packages, the other to communicate solely with the target board.
- Quartus II Software from Altera
Target Requirements
To boot the Altera Cyclone-III DK, you will need the following items:
- Altera Cyclone-III DK Board
- Ethernet Crossover Cable or Ethernet hub/switch and Ethernet Patch Cables
- USB A to B Cable
- NIOS2 design project. Projects corresponding to Timesys Starting Points are available at: http://www.altera.com/products/devkits/altera/kit-emb-dev-cyc3.html
Once you have all of the necessary components, you should perform the following steps:
- Connect the USB B port of the board to the USB Type-A port of your workstation using the USB A to B cable.
- If you are using a cross-over cable, connect the Ethernet port of the board to the second Ethernet port of your workstation.
- If you are using an Ethernet hub or switch, connect the board to the hub with a straight-through Ethernet cable, then connect the hub to the second Ethernet port of your workstation.
- Connect the power supply to your board.
Preparing the Target
Loading the Hardware Design
First verify that the JTAG connection is working correctly.
1) USB-Blaster [USB 1-1.2]
020F70DD EP3C120
[NiosII EDS]$
With a working USB connection, we can load the SOF onto the Altera Cyclone-III DK.
Searching for SOF file:
in .
nios2_linux_3c120_125mhz_top.sof
Info: *******************************************************************
Info: Running Quartus II Programmer
Info: Command: quartus_pgm -no_banner -mode=jtag -o p;./nios2_linux_3c120_125mhz_top.sof
Info: Using programming cable "USB-Blaster [USB 1-1.2]"
Info: Started Programmer operation at Wed Sep 16 11:02:41 2009
Info: Configuring device index 1
Info: Device 1 contains JTAG ID code 0x020F70DD
Info: Configuration succeeded - 1 device(s) configured
Info: Successfully performed operation(s)
Info: Ended Programmer operation at Wed Sep 16 11:02:47 2009
Info: Quartus II Programmer was successful. 0 errors, 0 warnings
Info: Peak virtual memory: 62 megabytes
Info: Processing ended: Wed Sep 16 11:02:47 2009
Info: Elapsed time: 00:00:18
Info: Total CPU time (on all processors): 00:00:11
[NiosII EDS]$
Loading the Bootloader
The U-Boot ELF file is loaded using the Quartus II Programmer.
Using cable "USB-Blaster [USB 1-1.2]", device 1, instance 0x00
Pausing target processor: OK
Initializing CPU cache (if present)
OK
Downloaded 145KB in 2.1s (69.0KB/s)
Verified OK
Starting processor at address 0xF7F80000
[NiosII EDS]$
Use the following command to begin interacting with U-Boot:
nios2-terminal: connected to hardware target using JTAG UART on cable
nios2-terminal: "USB-Blaster [USB 1-1.2]", device 1, instance 0
nios2-terminal: (Use the IDE stop button or Ctrl-C to terminate)
U-Boot 2009.03 (Sep 15 2009 - 12:42:30)
CPU : Nios-II
SYSID : 0x45ff1c2a, Fri Jan 30 03:53:01 2009
BOARD : Altera 3C120
Net: board eth init
Altera TSE init
Marvell 88E1111S found
tse0
Hit any key to stop autoboot: 0
Preparing the Host
Setting up the network
The commands discussed in this section are meant to be performed by a privileged user account. This requires the root login or prepending each command with sudo.Identify the network adapter connecting the Host to the Target
Timesys only supports direct Ethernet connections from the development Host to the Target board. Ideally, the development Host would have two network adapters; one adapter to connect to your LAN, and one Ethernet card to connect directly to the Target board with a crossover cable or Ethernet hub. If your development Host only has one network interface it must be directly connected to the Target board. The Ethernet adapter connected directly to the target board must be:- Configured with a proper static IP address and Subnet Mask.
- Connected directly to the target board with either a crossover cable or its own Ethernet hub.
inet addr:192.168.3.244 Bcast:192.168.3.255 Mask:255.255.254.0
inet6 addr: fe80::219:bbff:fe49:ff0e/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:57214 errors:0 dropped:0 overruns:0 frame:0
TX packets:47272 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:43109083 (41.1 MB) TX bytes:6308206 (6.0 MB)
Interrupt:16
eth1 Link encap:Ethernet HWaddr 00:10:b5:4a:c1:a9
inet addr:10.0.0.1 Bcast:10.0.0.255 Mask:255.0.0.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Interrupt:21 Base address:0x1100
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:1974 errors:0 dropped:0 overruns:0 frame:0
TX packets:1974 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:226637 (221.3 KB) TX bytes:226637 (221.3 KB)
Installing the server daemons on the development host
- On Ubuntu 11.04 and newer:
# apt-get install xinetd tftp tftpd isc-dhcp-server \
nfs-kernel-server portmap
- On Ubuntu 10.11 and older:
# apt-get install xinetd tftp tftpd dhcp3-server \NOTE: Older versions of Ubuntu use nfs-common and nfs-user-server in place of nfs-kernel-server
nfs-kernel-server portmap
- On Fedora Core:
# yum install xinetd tftp tftp-server dhcp nfs-utils
Important:
After installing these packages the DHCP server software may start automatically. Having the DHCP server running while you are connected to a LAN can interfere with the operation of other computers. After the DHCP service installs and starts issue these commands to stop the DHCP service and prevent it from starting automatically at boot:
- To stop the dhcp service:
- On Ubuntu 11.04 and newer:
# service isc-dhcp-server stop
- On Ubuntu 10.11 and older:
# service dhcp3-server stop
- On Fedora Core:
# /etc/init.d/dhcp stop
- On Ubuntu 11.04 and newer:
- To prevent the service from starting automatically:
- On Ubuntu 11.04 and newer:
# chmod 644 /etc/init.d/isc-dhcp-server
- On Ubuntu 10.11 and older:
# chmod 644 /etc/init.d/dhcp3-server
- On Fedora Core:
- Click the System Menu
- Select Administration
- Select Services
- Select dhcpd
- Click the Customize button
- Uncheck Runlevel 2, 3, 4 and 5
- On Ubuntu 11.04 and newer:
Disable SELinux and Firewall on Fedora Core
On Fedora Core, SELinux and the firewall will interfere with many of the services that are needed to work with the target board. These should be disabled before continuing.
Generally Ubuntu does not have these services running by default.
- Disable SELinux:
- Click the System Menu
- Select Administration
- Select SELinux Management
- Change System Default Enforcing Mode to Disabled
- Disable Firewall:
- Click the System Menu
- Select Administration
- Select Services
- Select iptables
- Click the Customize button
- uncheck Runlevel 2, 3, 4 and 5
Setting up DHCP
- Edit the dhcpd configuration file:
- On Ubuntu, edit /etc/dhcp/dhcpd.conf and include the following lines (note: on older versions of Ubuntu this file is at either /etc/dhcp3/dhcpd.conf or /etc/dhcpd.conf):
subnet 10.0.0.0 netmask 255.0.0.0 {
host targetboard {
fixed-address 10.0.0.10;
hardware ethernet 12:34:56:78:9a:bc;
option root-path "/full/path/to/rfs";
filename "uImage-2.6.30-ts-nios2";
}
}
- On Fedora Core, edit /etc/dhcpd.conf and include the following lines:
ddns-update-style ad-hoc;
subnet 10.0.0.0 netmask 255.0.0.0 {
host targetboard {
fixed-address 10.0.0.10;
hardware ethernet 12:34:56:78:9a:bc;
option root-path "/full/path/to/rfs";
next-server 10.0.0.1;
filename "uImage-2.6.30-ts-nios2";
}
}
- On Ubuntu, edit /etc/dhcp/dhcpd.conf and include the following lines (note: on older versions of Ubuntu this file is at either /etc/dhcp3/dhcpd.conf or /etc/dhcpd.conf):
- Test the DHCP server on the network card that is connected to your
development board. For this example assume eth1. This command will
start the DHCP server in the foreground and output any status or error
messages to the screen.
- On Ubuntu up to 12.04 LTS:
# service dhcp3-server restart
- On Ubuntu 12.04 LTS and later:
# service isc-dhcp-server restart
- On Fedora Core:
# /usr/sbin/dhcpd -d eth1
- It is recommended to start the DHCP server in this manner each time you need to boot your Target board.
- On Ubuntu up to 12.04 LTS:
Setting up TFTP
- Edit the xinetd.conf file
- On Ubuntu, edit /etc/xinetd.conf and add the following lines just above the line
that reads includedir /etc/xinetd.d.
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /tftpboot
disable = no
}
- On Fedora Core, the tftp-server package creates a /etc/xinetd.d/tftp file. Edit this
file and change the disable line from
yes to no. The contents of the file are:
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /tftpboot
disable = no
per_source = 11
cps = 100 2
flags = IPv4
}
- On Ubuntu, edit /etc/xinetd.conf and add the following lines just above the line
that reads includedir /etc/xinetd.d.
- Create the /tftpboot folder if it does not exist:
# mkdir /tftpboot
- Copy the kernel image to the /tftpboot directory:
# cp /path/to/kernel/image/uImage-2.6.30-ts-nios2 \
/tftpboot/uImage-2.6.30-ts-nios2
NOTE Also copy other files that are required for booting, such as a device tree blob, to /tftpboot.
- Restart the xinetd server with the following command:
# /etc/init.d/xinetd restart
- Test the TFTP server with the following commands
# tftp localhost
tftp> get uImage-2.6.30-ts-nios2
Received 1456898 bytes in 0.4 seconds
tftp> quit
- Set xinetd to start automatically on Fedora Core.
Ubuntu users will skip this step.
- Click the System Menu
- Select Administration
- Select Services
- Select xinetd
- Click the Customize button
- Check Runlevel 2, 3, 4 and 5
Setting up NFS
- As root, extract rootfs.tar.gz to a directory
and note the path. This path will be referred to as /full/path/to/rfs
in this document.
# mkdir /full/path/to/rfs
# cd /full/path/to/rfs
# sudo tar xvf rootfs.tar.gz
- Export this path by editing /etc/exports to include a line similar
to the following:
/full/path/to/rfs 10.0.0.10(rw,no_root_squash)
- Restart the NFS services
- On Ubuntu issue the following commands in order:
# service portmap stopNOTE: Older versions of Ubuntu use nfs-common and nfs-user-server in place of nfs-kernel-server
# service nfs-kernel-server stop
# service portmap start
# service nfs-kernel-server start
- On Fedora Core:
# /etc/init.d/nfs restart
- On Ubuntu issue the following commands in order:
- Set nfsd to start automatically on Fedora Core. Ubuntu users will
skip this step.
- Click the System Menu
- Select Administration
- Select Services
- Select NFS
- Click the Customize button
- Check Runlevel 2, 3, 4 and 5
Booting the Board
The Altera Cyclone-III DK board can be booted in a number of ways. The typical process is:
- Load the design onto the FPGA using the USB Cable and Quartus II Programmer
- Load U-Boot into memory
- Run U-Boot
- Load the uImage-2.6.30-ts-nios2 file into memory
- Run the uImage-2.6.30-ts-nios2 file
This document explains how to boot a Linux System on a Altera Cyclone-III DK using the USB Cable and Quartus II Programmer.
Please consult the Altera documentation for loading designs from other types of flash.
Booting the Kernel
Use the following command to begin interacting with U-Boot:
nios2-terminal: connected to hardware target using JTAG UART on cable
nios2-terminal: "USB-Blaster [USB 1-1.2]", device 1, instance 0
nios2-terminal: (Use the IDE stop button or Ctrl-C to terminate)
U-Boot 2009.03 (Sep 15 2009 - 12:42:30)
CPU : Nios-II
SYSID : 0x45ff1c2a, Fri Jan 30 03:53:01 2009
BOARD : Altera 3C120
Net: board eth init
Altera TSE init
Marvell 88E1111S found
tse0
Hit any key to stop autoboot: 0
You can boot the kernel from memory within U-Boot by using the following U-Boot commands:
Using tse0 device
TFTP from server 10.10.0.2; our IP address is 10.10.0.25
Filename 'kernel'.
Load address: 0xf4000000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#######################################
done
Bytes transferred = 2525928 (268ae8 hex)
==> setenv bootargs noinitrd ip=dhcp rw root=/dev/nfs console=ttyJ0 tsemac0=00:07:11:01:02:03 @ 0xf7f3fe48
==> bootm
The kernel should boot within a few seconds.
Additional Information
Factory Documentation
- /docs/wiki/factory/FactoryGSG
- /docs/wiki/factory/FactoryBestPractices
- /docs/wiki/nirvana-workflow/Workflow
- /docs/wiki/factory/FactoryTroubleshooting
- /docs/wiki/factory/FactoryOutput
- /docs/wiki/factory/FactoryArchitecture
Altera NIOS2 Documentation