NIOS II 安装uclinux的硬件要求
Hardware requirementsYou should start with a minimal system with only, - Nios II f or s core, with hardware multiplier, (f-core suggested, s-core is slower).
- sdram (minimum requirement 8MB),
- one full featured timer,
- a jtag/serial uart
Note in Linux, irq 0 means auto-detected, so you must not use irq 0 for ANY devices, except for timer. It is possible to use e-core, but it will be very very slow. It is possible to run without hardware multiplier, but you will need some hack. 硬件要求 你开始一个最小系统仅仅需要: 1、NIOS II f 或者s 处理器,带硬件乘法器(建议使用NIOS II /f,使用NIOS II/s很慢) 2、最小8M的SDRAM 3、一个全功能的定时器 4、JTAG/UART 备注:在Linux中,中断0意味着自动辨识,所以你不能把中断0分配给任何器件,除了定时器。没有硬件乘法器运行LINUX是可能的,但你需要一些hack。 nios II架构uclinux的过程 开发环境:
在vmware 中安装centos5.2操作系统(在网上下载安装CentOS-5 2-i386-bin-DVD )
本人所使用的开发板为: altera公司的ep2c35f672c6n
宿主机windows开发平台为: windows xp sp3
在宿主机上安装的linux开发平台为centos5.2 内核为: vmlinuz-2.6.18
开发工具为:quartus7.2安装过程
Ok! 现在开始niosii架构uclinux过程
首先要在centos下挂载window 下的一个共享目录便于centos与宿主机传送文件,不会挂载的朋友google 一下linux 下mount命令的使用
在centos操作系统上我的开发目录设在了/home/zhaozhilei
[root@localhost ~]# cd /home/zhaozhilei
安装架构uclinux时所需要的库
[root@localhost zhaozhilei]# sudo yum install git-all make gcc ncurses-devel bison byacc flex
gawk gettext ccache zlib-devel gtk2-devel lzo-devel一.下载uclinux开发包
[root@localhost zhaozhilei]#wget ftp://ftp.altera.com/outgoing/nios2-linux-20080619.tar二.解压nios2-linux-20080619.tar
[root@localhost zhaozhilei]# tar xf nios2-linux-20080619.tar 三.进入nios2-linux目录
[root@localhost zhaozhilei]# 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四.检查文件是否齐全
[root@localhost nios2-linux]#./checkout五.下载交叉编译工具
[root@localhost nios2-linux]# cd ..
[root@localhost zhaozhilei]# wget ftp://ftp.altera.com/outgoing/nios2g...080203.tar.bz2六.解压文件
[root@localhost zhaozhilei]#sudo tar jxf nios2gcc-20080203.tar.bz2 -C /七.添加PATH路径
[root@localhost zhaozhilei]#cd
[root@localhost ~]# vim ./bash_profile
添加:PATH=$PATH:/opt/nios2/bin (红颜色部分是要添加的部分)八.检查是否加入PATH
[root@localhost ~]#echo $PATH
结果应为:/usr/local/***in:/usr/local/bin:/usr/***in:/usr/bin:/***in:/bin:/usr/games:/opt/nios2/bin十.检查交叉编译环境是否安装成功
[root@localhost ~]#nios2-linux-uclibc-gcc –v
结果应为:
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十一. 编译内核和应用,进入到uclinux-dist目录
[root@localhost ~i]#cd /home/zhaozhilei/nios2-linux
[root@localhost nios2-linux]#cd uClinux-dist
[root@localhost uClinux-dist]#make menuconfig
确保选择以下内容
Vendor/Product Selection --->
--- Select the Vendor you wish to target
Vendor (Altera) --->
--- Select the Product you wish to target
Altera Products (nios2) ---> Kernel/Library/Defaults Selection --->
--- Kernel is linux-2.6.x
Libc Version (None) --->
Default all settings (lose changes)
[ ] Customize Kernel Settings
[ ] Customize Vendor/User Settings
[ ] Update Default Vendor Settings
注意:在成功引导uclinux之前不要改变上面任何设置
然后 十二 .编译硬件配置选择相应的cpu 和sdrma
[root@localhost uClinux-dist]#make vendor_hwselect SYSPTF=/配件配置目录/your_system.ptf
选择cpu(如果是多cpu的话,根据实际情况选择)
选择sdram(在这里我选择的是1即ddr_sdram_0,其它根据实际情况)
十三. 编译内核和应用
[root@localhost uClinux-dis]# make (需要编译一段时间)十四. 将 zImage文件copy到宿主机上
[root@localhost yanfa]# cp ./ images/zImage 你挂载的目录十五. 在宿主机上(windows)打开nios ii eds 7.2 command shell
开始->程序->altera-> nios ii eds 7.2->nios ii eds 7.2 command shell十六.下载你的sof文件到目标板
十七. 下载zImage 到目标板
十八. 打开nios终端
十九. uclinux正确启动时应出现如下信息
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 u***fs none /proc/bus/u***
mount: mounting none on /proc/bus/u*** 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
____ _ _
/ __| ||_|
_ _| | | | _ ____ _ _ _ _
| | | | | | || | _ | | | | / /
| |_| | |__| || | | | | |_| |/
| _______|_||_|_| |_|____|_/_/
| |
|_|呵呵, 恭喜你成功运行了uclinux操作系统现在你可以根据自己的喜好从新配置内核啦!!如下操作:
从新回到虚拟机下的uclinux-dist目录下
[root@localhost uclinux-dist]#make menuconfig
Kernel/Library/Defaults Selection --->
(linux-2.6.x) Kernel Version
(None) Libc Version
[ ] Default all settings (lose changes) Customize Kernel Settings Customize Vendor/User Settings
[ ] Update Default Vendor Settings
Then .
以下可以根据自己的喜好配置内核这里不再叙述
小提示: 在配置内核的过程中如果有朋友在编译内核加入iptables 时若出现如下错误:
include/linux/netfilter_ipv4/ip_tables.h:18:28: linux/compiler.h: No such file or directory
make[3]: *** [iptables.o] 错误 1
make[3]: Leaving directory `/usr/local/yanfa/nios2-linux/uClinux-dist/user/iptables'
make[2]: *** [iptables] 错误 2
make[2]: Leaving directory `/usr/local/yanfa/nios2-linux/uClinux-dist/user'
make[1]: *** [all] 错误 2
make[1]: Leaving directory `/usr/local/yanfa/nios2-linux/uClinux-dist/user'
make: *** [subdirs] 错误 1
解决方法:
把/usr/home/zhaozhilei/nios2-linux/uClinux-dist/user/iptables/include/linux/netfilter_ipv4 中的 ip_tables.h中的#include 注解掉可解决编译uclinux_dist内核时出现的加载iptables 的错误
|