最后编辑于: 2008-11-06 00:23 | 分类: linux | 标签: FPGA 软核 NIOS | 浏览数: 590 | 评论数: 0
同一个网站(此网站当年就被屏蔽了无法访问, 用了些科技)的4篇文章, 当年就是参考这4篇文章成功地在NIOS2上装上了uClinux, 当时还蛮有成就感的. 估计现在这些都过时了, 也没多少价值了, 权当记录一下留个纪念.
Version 35, changed by jai.dhar@gmail.com. 10/19/2008. Show version history
Here we will setup the source to build Nios2 uClinux. branch "test-nios2" , per 20080619.
If you already have the toolchain and working uClinux-dist git repo, then you can skip the "new install" below and go to the second half, "Distro upgrade".
You must have a Linux desktop with software development packages. Login as root or use sudo to install these packages.
On Fedora,RHEL,Centos
sudo yum install git-core make gcc ncurses-devel bison byacc flex gawk gettext ccache zlib-devel gtk2-devel lzo-devel
On Suse,
sudo zypper install git-core make gcc ncurses-devel bison byacc flex gawk gettext ccache zlib-devel lzo-devel
On Debian/Ubuntu,
sudo apt-get update
sudo apt-get install git-core make gcc ncurses-dev bison flex gawk gettext ccache zlib1g-dev libx11-dev texinfo lzo-dev
Please check your git version with git --version
. If it is older than 1.5.3.x, please update to the latest.
On Ubuntu, check if the default shell is "bash"
ls -l /bin/sh
This should give /bin/sh -> bash
,
Otherwise, change it with,
sudo rm /bin/sh
sudo ln -s bash /bin/sh
followed by a logout and log back in again.
As root, check if you have cc
which is a symlink to gcc
?
which gcc
gcc -v
which cc
cc -v
if not,
cd /usr/bin
ln -s gcc cc
Make sure you have 5GB or more free disk space. Please use wget to download the tar file nios2-linux-20080619.tar
, 842MB. Best thanks to Altera's kindly hosting these files. Please verify the sha1sum after download.
(but don't use Windows ftp, it corrupt the files)
wget ftp://ftp.altera.com/outgoing/nios2-linux-20080619.tar
(SHA1SUM bb851b5494b4ae5c6ccdcfa5625b0f4d9340252a nios2-linux-20080619.tar)
这里下载uClinux dist包(nios2-linux-20080619.tar中包含的有,最新版的只能此途径下载),下载之后,可用SHA1SUM验证一下校验和。
We use git
to keep the source. You make check out GitServer later. The git database inside the tar file was compressed, so we don't do compression on the tar file.
You can build in any working directory as a user account, eg. in your home (say /home/hippo). The tar file contains a nios2-linux dir.
tar xf <path_to>nios2-linux-20080619.tar # untar the package
cd nios2-linux
ls # see what's in
binutils gcc3 README uClibc use_http_for_update
checkout insight toolchain-build uClinux-dist
elf2flt linux-2.6 u-boot update
# check out the source
./checkout
Now the source for the Nios2 uClinux and gnutools was ready.
We will proceed to build the toolchain. If you don't want or fail to build it yourself, you may use the prebuild BinaryToolchain.
这里是 自己build 交叉编译工具链 or 是下载现成的(即BinaryToolchain链接)。下载现成的工具链BinaryToolchain的具体方法可见下面的另一篇文章BinaryToolchain 。
If you work on x86_64, 64 bits platform, you will need to change the arch to 32 bits , with setarch i386
, to build gcc.
cd toolchain-build
git clean -f -x -d # clean on restart
make gcc elf2flt gdb-host # setarch i386 make gcc elf2flt gdb-host, if you work on x86_64 platform
cd ..
It might take hours to build.
好了,不管是自己build的还是用的现成的toolchain,准备好了toolchain工具链之后,就要设置一下 环境路径 并验证一下,见下面的:
The default installation path is toolchain-build/build/nios2
. Then setup the PATH for the tools, you can add a line at the end of file ~/.bash_profile
(or ~/.profile
on Debian/Ubuntu) ( the file is hidden, you have to use ls -a
to find it . For gedit
use open Location, and enter the file name), like this
PATH=$PATH:/home/hippo/nios2-linux/toolchain-build/build/nios2/bin
Logout and login again. You can use the tools now. Run this to verify that you have it in your command search path,
nios2-linux-uclibc-gcc -v
Try to compile a simple hello.c like this,
#include <stdio.h>
int main(void)
{
printf("hello world\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\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\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n");
}
nios2-linux-uclibc-gcc hello.c -o hello -elf2flt
The compiled object format is FLAT.
You may check it with,
nios2-linux-uclibc-flthdr hello
Optionally, add links for ccache, as root or via sudo
ln -s /usr/bin/ccache /usr/lib/ccache/nios2-linux-uclibc-gcc
ln -s /usr/bin/ccache /usr/lib/ccache/nios2-linux-uclibc-g++
ln -s /usr/bin/ccache /usr/lib/ccache/nios2-linux-uclibc-c++
When you compile something, the cache will be used and the compilation run faster. You can check cache status with,
ccache -s
Now you can follow UClinuxDist to build the kernel. You should build in the new source tree, nios2-linux/uClinux-dist .
cd uClinux-dist
make menuconfig
make vendor_hwselect SYSPTF=<path to your system ptf>
make
Important changes in this release, nios2-linux-20080619
,
include/asm-nios2/nios2.h
, and now the port/memory address is physical address , without cache-bypass, ie no address bit 31 set.
The latest branch is "test-nios2". Despite the "test" in the name, this does not mean "unstable". All future works and support will base on this branch. I won't update those older branches with the limited time available. Please migrate to the new branch.
The uClinux-dist dose not contain the kernel now. It should stick with "test-nios2" branch. It will merge updates from uclinux.org and blackfin uclinux.
The development of nios2 kernel will stick with mainly the "test-nios2" branch, with proper tags follow Linus' releases. eg "v2.6.26-nios2" tag when Linus release "v2.6.26" stable. Then it will move on to v2.6.27-rc1, but not with a new branch. It is still "test-nios2" branch.
Though there will be some experimental branches from time to time, but they will be merged into the main branch "test-nios2" at proper time. And then deleted.
If you need a "stable" branch, you can create local branch off the stable tags. You might apply patches from stable-queue git. Or you want to freeze. It is all up to you.
git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git # patches for stable releases
After you have first successful boot, you can get updates from server.
Change to the nios2-linux dir,
(Only if you are behind a proxy firewall and cannot use git protocol, you can change the git to use http to get updates from community server with this command, ./use_http_for_update
. You will need to add the setup of proxy to your login profile (.bash_profile or .profile),
export http_proxy=http://proxy_server:port_number
)
Now fetch updates from server with, ./update
.
++++++++++++++++++++++++++++++
(note) if the kernel couldn't start after update..
Please disable optimize for size, or start with default config again.
General setup -->
[ ] Optimize for size <== unselect
++++++++++++++++++++++++++++++
If you got such error in updating,
~/nios2-linux/uClinux-dist$ git pull
.
vendors/Altera/nios2/config.vendor: needs update
fatal: Entry 'vendors/Altera/nios2/config.vendor' not uptodate. Cannot merge.
Please do a git checkout -f
. Then `git pull" again.
If you already have the toolchain and working uClinux-dist git repo, you don't have to download the new tar ball nios2-linux-20080619.tar .
As the kernel source is removed from the uClinux-dist dir, you need a kernel source dir. At the same dir level of uClinux-dist, don't cd uClinux-dist. Clone the kernel source from the Linus' git.
git clone -n git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
Or if you are behind a proxy firewall,
git clone -n http://www.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
ls # see what's in
linux-2.6 uClinux-dist
cd linux-2.6
Edit the file .git/config
, change the origin url to sopc server,
[remote "origin"]
url = git://sopc.et.ntust.edu.tw/git/linux-2.6.git
fetch = +refs/heads/*:refs/remotes/origin/*
Or if you are behind a proxy firewall,
[remote "origin"]
url = http://sopc.et.ntust.edu.tw/git/linux-2.6.git
fetch = +refs/heads/*:refs/remotes/origin/*
Next, create the new branch test-nios2
and checkout,
git fetch origin
git branch --track test-nios2 origin/test-nios2
git checkout test-nios2
cd ..
Then, checkout the test-nios2
branch of uClinux-dist,
cd uClinux-dist
git clean -f -x -d
git fetch origin
git branch --track test-nios2 origin/test-nios2
git checkout -f test-nios2 # forced
Now, you may build as before in this uClinux-dist
dir,
make menuconfig
make vendor_hwselect SYSPTF=<your_system.ptf>
make
The important point is that the kernel source tree was removed from uClinux-dist, and used external linux-2.6 (from git). And the old arch name nios2nommu
is changed to nios2
.
If you have local commit in older branches, either v2.6.26-nios2 or pre v2.6.26-nios2, you will have to move the local kernel patches from uClinux-dist/linux-2.6.x/ to linux-2.6/ .
First, find your local commit sha1 id in the old branch of uClinux-dist, using
git log <old branch> <dir of interest>
or
gitk <old branch> <dir of interest>
eg,
cd uClinux-dist
gitk v2.6.24-uc-myabc linux-2.6.x/
Take down the sha1 ID of the commit, 7-8 digits is enough. say, abc6789.
Use git-format-patch to generate patches for cherry-pick,
git format-patch abc6789^..abc6789
Or you can use a range, and pick only you need.
git format-patch <from>..<to>
Some 0001-……patch will be generated.
Filter the patches to change the path and arch reference,
sed -i -e szlinux-2.6.x/zzg 0*patch
sed -i -e sznios2nommuznios2zg 0*patch
Then create your local branch from test-nios2 branch of linux-2.6/
Now you can apply these patches
cd ../linux-2.6
# create and checkout local branch from test-nios2
# track the remote, depend on how you set remote,
# in the new tar ball, the origin is sopc.et.ntust.edu.tw
git branch --track test-nios2-myabc origin/test-nios2
git checkout test-nios2-myabc
git am <path_to_the_patches>
For other dir in uClinux-dist, eg, vendors/Altera, generate patches from your local commit.
cd uClinux-dist
gitk v2.6.24-uc-myabc vendors/Altera
gitk format-patch <from>..<to>
Filter the patches to change the arch reference,
sed -i -e sznios2nommuznios2zg 0*patch
Now create your local branch from test-nios2 of uClinux-dist, and apply the patches,
git branch --track test-nios2-myabc origin/test-nios2
git checkout test-nios2-myabc
git am <path_to_the_patches>
原文地址:http://nioswiki.jot.com/WikiHome/OperatingSystems/BinaryToolchain
Version 41, changed by hippo5329@yahoo.com.tw. 09/29/2008. Show version history
Linked from UClinuxDist
Attached are binary of the tools to run on Linux PC and root fs from buildroot. You can use it to compile kernel and apps.
Login as a user account on Linux PC, eg, hippo. The user home dir will be /home/hippo
, short form as ~/
.
Use wget to download the cross tools (69MB). Best thanks to Altera's kindly hosting these files. (but don't use Windows ftp, it corrupt the files)
wget ftp://ftp.altera.com/outgoing/nios2gcc-20080203.tar.bz2
(sha1sum 6873249d8eae7c2981aac6791f044ddaab507566 nios2gcc-20080203.tar.bz2)
Open a terminal. Run as root or use sudo,
sudo tar jxf nios2gcc-20080203.tar.bz2 -C /
The cross gcc tools was expected to be installed in /opt/nios2
dir. But you may install in any other dirs. Then setup the PATH for the cross gcc, you can add a line at the end of file ~/.bash_profile
(or ~/.profile
on Debian/Ubuntu) ( the file is hidden, you have to use ls -a
to find it . For gedit
use open Location, and enter the file name)
PATH=$PATH:/opt/nios2/bin
After you change the .bash_profile
or .profile
, you need to logout and login again. So that it will be in the PATH when you login.
Check with,
echo $PATH
It should display like this, with nios2 path at the end,
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/opt/nios2/bin
To verify the cross gcc, try out,
nios2-linux-uclibc-gcc -v
It should display the info,
Reading specs from /opt/nios2/lib/gcc/nios2-linux-uclibc/3.4.6/specs
Configured with: /root/buildroot/toolchain_build_nios2/gcc-3.4.6/configure --prefix=/opt/nios2 --build=i386-pc-linux-gnu --host=i386-pc-linux-gnu --target=nios2-linux-uclibc --enable-languages=c --enable-shared --disable-__cxa_atexit --enable-target-optspace --with-gnu-ld --disable-nls --enable-threads --disable-multilib --enable-cxx-flags=-static
Thread model: posix
gcc version 3.4.6
Then try build kernel and apps as in the UClinuxDist .
Optionally, you can install ccache
, the compiler cache, which can reduce the compilation time a lot.
Install required package, as root or via sudo
On Fedora,RHEL,
yum install ccache
On Debian/Ubuntu, (via sudo)
apt-get install ccache
Then add links, still as root or via sudo
ln -s /usr/bin/ccache /usr/lib/ccache/nios2-linux-uclibc-gcc
ln -s /usr/bin/ccache /usr/lib/ccache/nios2-linux-uclibc-g++
ln -s /usr/bin/ccache /usr/lib/ccache/nios2-linux-uclibc-c++
When you compile something, the cache will be used, you can check cache status with,
ccache -s
原文地址:http://nioswiki.jot.com/WikiHome/OperatingSystems/UClinuxDist
uClinux-dist包准备好了,toolchain也准备好了,下面可以编译了,具体的编译步骤如下:
这篇文章给出了按 "默认来编译" 和 "custom编译" 的几个例子。
Version 157, changed by hippo5329@yahoo.com.tw. 06/15/2008. Show version history
This is about building the kernel and apps using uClinux-dist sources.
If you got any problems, please post over the nios forum.
(This is different from the very old buildroot guide approach. DO NOT MIX UP)
To begin, you must have followed InstallNios2Linux , downloaded the nios2-linux-20080616.tar
and checked out the source. Older version dose NOT apply to the procedures described here.
In uClinux-dist dir, perform the menuconfig. DO NOT cd linux-2.6.x
cd uClinux-dist
make menuconfig
In the menuconfig, make sure it is selected as follows:
Vendor/Product Selection ---> # select
--- Select the Vendor you wish to target
Vendor (Altera) ---> # should have default to Altera
--- Select the Product you wish to target
Altera Products (nios2) ---> # should have defaulted to nios2
Kernel/Library/Defaults Selection ---> # select
(linux-2.6.x) Kernel Version
Libc Version (None) ---> # should have defulat to None - very important.
[*] Default all settings (lose changes) # select
[ ] Customize Kernel Settings
[ ] Customize Vendor/User Settings
[ ] Update Default Vendor Settings
Then <exit> <exit> <yes>
DO NOT change any other setting until first successful boot.
Run vendor_hwselect to setup the memory and io port address map of your Nios II board (see LinuxHwselect for details) . Select the nios2 cpu and sdram.
(still in uClinux-dist dir, DO NOT cd linux-2.6.x)
make vendor_hwselect SYSPTF=/path_to_your_hardware_project/your_system.ptf # you must give the absolute path to ptf, no space allowed in path
Compile kernel and apps,
make
(this will take a while)
If you meet errors, you can use NON_SMP_BUILD=1 make
, which avoids parallel make. The messages will be cleaner.
The compressed kernel is stored in the images folder, is called zImage and is in ELF format. You can follow TryOutuClinux to run the new zImage.
编译好了image,往板子上烧写的方法,参见文章TryOutuClinux,见后面一篇文章。
In case you want a real clean restart, use "git clean",
git clean -f -x -d
Below is the the start up message of an Altera NEEK dev board.
# nios2-download -g images/zImage
Using cable "USB-Blaster [USB 2-1.2]", device 1, instance 0x00
Pausing target processor: OK
Initializing CPU cache (if present)
OK
Downloaded 1272KB in 7.7s (165.1KB/s)
Verified OK
Starting processor at address 0x00500000
# nios2-terminal
nios2-terminal: connected to hardware target using JTAG UART on cable
nios2-terminal: "USB-Blaster [USB 2-1.2]", 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-rc6 (hippo@darkstar) (gcc version 3.4.6) #2 PREEMPT Mon Jun 16 14:30:09 CST 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: 30136k/2333k RAM, 0k/0k ROM (1552k kernel code, 781k 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
NET: Registered protocol family 1
io scheduler noop registered
io scheduler deadline registered (default)
ttyJ0 at MMIO 0x8009340 (irq = 8) is a Altera JTAG UART
console [ttyJ0] enabled
ttyS0 at MMIO 0x8008e00 (irq = 7) is a Altera UART
dm9000 Ethernet Driver, V1.30
TCP cubic registered
NET: Registered protocol family 17
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
Freeing unused kernel memory: 572k freed (0x1b8000 - 0x246000)
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: cat /etc/motd
Welcome to
____ _ _
/ __| ||_|
_ _| | | | _ ____ _ _ _ _
| | | | | | || | _ \| | | |\ \/ /
| |_| | |__| || | | | | |_| |/
| ___\____|_||_|_| |_|\____|\_/\_/
| |
|_|
For further information check:
http://www.uclinux.org/
Execution Finished, Exiting
Sash command shell (version 1.1.1)
/>
Now, you can config uClinux-dist for costmize kernel and select your apps. I enabled only SMC91C111 and DM9000 Ethernet device drivers for Altera dev board in default config, you should enable your EtherNet driver in kernel config otherwise. see LinuxConfig for kernel config items.
Still in uClinux-dist dir, DO NOT cd linux-2.6.x
make menuconfig
Kernel/Library/Defaults Selection --->
(linux-2.6.x) Kernel Version
(None) Libc Version
[ ] Default all settings (lose changes)
[*] Customize Kernel Settings <== to change kernel config
[*] Customize Vendor/User Settings <== to change user apps config
[ ] Update Default Vendor Settings
Then <exit> <exit> <yes>
.
It will enter kernel config first, then it will enter user apps config, you can select more apps.
After you change config,
make
You may want to now run your own program on the uClinux system.
An example Hello World program is here: CompileHello
There are more example programs linked under Then More Fun here: ?Clinux
Here is more usage about uClinux,
/> ifconfig eth0 192.168.1.85 # staic ip
/> route add default gw 192.168.1.254 # gateway
/> ifconfig
eth0 Link encap:Ethernet HWaddr 00:07:ED:00:00:00
inet addr:192.168.1.85 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST NOTRAILERS RUNNING MULTICAST MTU:1500 Metric:1
RX packets:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:7 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2260 (2.2 KiB) TX bytes:2854 (2.7 KiB)
Interrupt:8
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 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:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
/> inetd & # start inetd to invoke telnetd and ftpd services
[22]
/> boa & # start httpd with cgi-demo
[23]
/> netstat -a # show network services
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 *:http *:* LISTEN
tcp 0 0 *:ftp *:* LISTEN
tcp 0 0 *:telnet *:* LISTEN
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags Type State I-Node Path
/> free
MemTotal: 6520 kB
MemFree: 4340 kB
Buffers: 0 kB
/> ps
PID PORT STAT SIZE SHARED %CPU COMMAND
1 S 147K 0K 2.8 /init
2 S 0K 0K 0.0 ksoftirqd/0
3 S 0K 0K 0.0 events/0
4 S 0K 0K 0.0 khelper
5 S 0K 0K 0.0 kthread
6 S 0K 0K 0.0 kblockd/0
7 S 0K 0K 0.0 pdflush
8 S 0K 0K 0.0 pdflush
9 S 0K 0K 0.0 kswapd0
10 S 0K 0K 0.0 aio/0
17 R 147K 0K 0.3 -/bin/sh
19 S 147K 0K 0.2 dhcpcd
22 S 95K 0K 0.1 inetd
23 S 275K 0K 0.4 boa
/>
ftpd usage, user : ftp, password:
boa and cgi usage, dir : /home/httpd
You can check what is in busybox, by running "busybox" on uClinux.
You can check what is in sash, by "help" .
We use initramfs instead of the default romfs . The initramfs is generated from romfs dir and the dev file in vendors/Altera/nios2/romfs_list . See InitramfsUpdate .
The simplified "init" program will run etc/rc and etc/inittab during startup.
If you want to customize startup, eg inet servers and eth config, you should update the files vendors/Altera/nios2/ rc and inittab.
We arrange to minimize the memory usage. We use sash as default shell, it is smaller than busybox and take less memory. We include some standalone networking servers, such as inetd and telnetd. We build some networking utility into busybox, such as ifconfig,route,netstat,telnet,wget..etc. We don't use sh in busybox, and don't use servers in busybox as it takes a lot of memory.
You may use the simple history in sash. Use "h" to list history. Use "!
Use control-H for backspace.
/> h
1: netstat -a
2: date
3: ntpdate pool.ntp.org
4: date
5: boa &
6: inetd &
7: ifconfig
8: dhcpcd &
9: free
10: ps
/> !10
PID PORT STAT SIZE SHARED %CPU COMMAND
1 S 147K 0K 1.7 /init
2 S 0K 0K 0.0 ksoftirqd/0
3 S 0K 0K 0.0 events/0
4 S 0K 0K 0.0 khelper
5 S 0K 0K 0.0 kthread
6 S 0K 0K 0.0 kblockd/0
7 S 0K 0K 0.0 pdflush
8 S 0K 0K 0.0 pdflush
9 S 0K 0K 0.0 kswapd0
10 S 0K 0K 0.0 aio/0
11 S 0K 0K 0.0 mtdblockd
18 R 147K 0K 0.1 /bin/sh
19 S 147K 0K 0.0 dhcpcd
22 S 95K 0K 0.0 inetd
23 S 275K 0K 0.0 boa
/>
After you have first successful boot, you may use "git pull" to update the kernel and uClinux-dist. Please refer to GitServer .
cd uClinux-dist
git pull
cd ..
cd linux-2.6
git pull
cd ..
原文地址:http://nioswiki.jot.com/WikiHome/OperatingSystems/TryOutuClinux
这篇文章介绍了有了现成的可烧写的uclinux的image之后,烧写到板子上的方法。
Version 54, changed by mschnell. 08/08/2008. Show version history
You may try out the uClinux on your Altera Nios dev board before compiling anything. You can learn how to run a compiled program on your board. It is a very basic and important step. The kernel image was built from uClinux-dist with the default config. Both the sof and ptf files come from the example project, and there is no change. The sof and kernel image version must match, otherwise it will not run.
Please check UClinuxDist for booting up message and usage. After you get uClinux boot up successfully, you can build the kernel image with the ptf file of the same hardware project.
You will need Quartus and Nios2eds installed. Download the sof and zImage files for your board to a working dir, eg c:download on Windows or ~/download on Linux. Note the drives mapping in Nios II command shell (cygwin), drive c: is named as /cygdrive/c/ and c:download is /cygdrive/c/download.
Open a Nios II command shell on Windows from Windows Start-->Programs-->Altera-->Nios II 7.2 -->Nios II Command Shell, and change to the download dir.
cd /cygdrive/c/download
Or open a shell terminal on Linux and change to the download dir.
cd ~/download
Note: If you don't have a Nios II license and have generated the .sof file yourself then its usage will be restricted. Follow the following instructions but run the nios2-configure-sof
instruction from one command shell and run the nios2-download
and nios2-terminal
instructions from another. This allows the nios2-configure-sof
to keep in contact with the processor so as to allow it to keep running.
step 1. Configure the FPGA,
nios2-configure-sof DE2_NIOS_HOST_MOUSE_VGA.sof
下载sof文件的时候,可以在quartus软件里作,可不必用命令行方式。
step 2. Download and run the kernel image,
nios2-download -g zImage_DE2_NIOS_HOST_MOUSE_VGA_v1.6
nios2-terminal
The kernel image was built with DE2_NIOS_HOST_MOUSE_VGA.ptf (was system_0.ptf) in the project DE2_System_v1.6/DE2_demonstrations/DE2_NIOS_HOST_MOUSE_VGA of the DE2 v1.6 CD.
step 1. Configure the FPGA,
nios2-configure-sof DE2_70_NIOS_HOST_MOUSE_VGA.sof
step 2. Download and run the kernel image,
nios2-download -g zImage_DE2_70_NIOS_HOST_MOUSE_VGA_v1.1
nios2-terminal
The kernel image was built with DE2_70_NIOS_HOST_MOUSE_VGA.ptf (was DE2_70_SOPC.ptf) in the project DE2_70_SYSTEM_cd_v1.1/DE2_70_demonstrations/DE2_70_NIOS_HOST_MOUSE_VGA of the DE2-70 v1.1 CD.
step 1. Configure the FPGA,
nios2-configure-sof DE1_SD_Card_Audio.sof
step 2. Download and run the kernel image,
nios2-download -g zImage_DE1_SD_Card_Audio_v0.6
nios2-terminal
The kernel image was built with DE1_SD_Card_Audio.ptf (was system_0.ptf) in the project DE1_CD_v0.6/DE1_demonstrations/DE1_SD_Card_Audio of the DE1 v0.6 CD.
Easiest way to run Linux on the NEEK:
step 1: Copy the unzipped content of the NEEK-uCLinux-eek.zip file as a subdirectory ("uCLinux") into the "Altera_EEK_Applications" directory on the SD-card provided with the kit.
step 2: With the Application Selector you now can select and start "uCLinux"
View the embedded file info.txt (e.g. in the Application Selector) to see what it can do and how it's done.
Another Application Selector Application is SLS_Console.zip uploaded with permission of SLS Corp. This distribution shows the Linux starting messages on the NEEK's LCD screen and opens a shell that is displayed on the LCD screen and can be used with a PS2 keyboard attached to the NEEK.
Without using the SD-Card you can do this:
step 1. Configure the FPGA,
nios2-configure-sof
cycloneIII_embedded_evaluation_kit_web_server.sof
step 2. Download and run the kernel image,
nios2-download -g
zImage_cycloneIII_embedded_evaluation_kit_web_server
nios2-terminal
The kernel image was built with cycloneIII_embedded_evaluation_kit_web_server_sopc.ptf in the Cyclone III Embedded Evaluation Kit Web Server files.
However, the TSE MAC driver is not ready yet, and the ethernet won't work.
step 1. Configure the FPGA,
nios2-configure-sof
cycloneIII_embedded_evaluation_kit_web_server.sof
step 2. Download and run the kernel image,
nios2-download -g
zImage_cycloneIII_embedded_evaluation_kit_web_server
nios2-terminal
The kernel image was built with cycloneIII_embedded_evaluation_kit_web_server_sopc.ptf in the Cyclone III Embedded Evaluation Kit Web Server files.
However, the ethernet won't work as there isn't one on this board.
Useful wiki page: Cyclone III - Nios II - Starter board
step 1. Configure the FPGA,
nios2-configure-sof
NiosII_cycloneII_2c35_full_featured.sof
step 2. Download and run the kernel image,
nios2-download -g
zImage_NiosII_cycloneII_2c35_full_featured_v7.2
nios2-terminal
The kernel image was built with NiosII_cycloneII_2c35_full_featured_sopc.ptf in the Nios2eds v7.2 installation dir, nios2eds/examples/verilog/niosII_cycloneII_2c35/full_featured .
step 1. Configure the FPGA,
nios2-configure-sof
NiosII_cyclone_1c20_full_featured.sof
step 2. Download and run the kernel image,
nios2-download -g
zImage_NiosII_cyclone_1c20_full_featured_v7.2
nios2-terminal
The kernel image was built with NiosII_cyclone_1c20_full_featured_sopc.ptf in the Nios2eds v7.2 installation dir, nios2eds/examples/verilog/niosII_cyclone_1c20/full_featured .
step 1. Configure the FPGA,
nios2-configure-sof
NiosII_stratixII_2s60_RoHS_full_featured.sof
step 2. Download and run the kernel image,
nios2-download -g
zImage_NiosII_stratixII_2s60_RoHS_full_featured_v7.2
nios2-terminal
The kernel image was built with NiosII_stratixII_2s60_RoHS_full_featured_sopc.ptf in the Nios2eds v7.2 installation dir, nios2eds/examples/verilog/niosII_stratixII_2s60_RoHS/full_featured .
But the ethernet port on 2S60 may not work , due an issue in the design file v7.2.
step 1. Configure the FPGA,
nios2-configure-sof
NiosII_stratix_1s10_full_featured.sof
step 2. Download and run the kernel image,
nios2-download -g
zImage_NiosII_stratix_1s10_full_featured_v7.2
nios2-terminal
The kernel image was built with NiosII_stratix_1s40_full_featured.ptf in the Nios2eds v7.2 installation dir, nios2eds/examples/verilog/niosII_stratix_1s10/full_featured .
step 1. Configure the FPGA,
nios2-configure-sof
NiosII_stratix_1s40_full_featured.sof
step 2. Download and run the kernel image,
nios2-download -g
zImage_NiosII_stratix_1s40_full_featured_v7.2
nios2-terminal
The kernel image was built with NiosII_stratix_1s40_full_featured.ptf in the Nios2eds v7.2 installation dir, nios2eds/examples/verilog/niosII_stratix_1s40/full_featured .
If you are using time-limited sof , read opencore plus,
http://www.altera.com/literature/an/an320.pdf
Tethered Mode
Tethered mode requires an Altera serial joint test actions group (JTAG)
cable connected between the JTAG port on your board and the host
computer, which runs the Quartus II Programmer for the duration of the
hardware evaluation period. The Quartus II Programmer only requires a
minimum installation of the Quartus II software—no license is required.