歡迎您光臨本站 登入註冊首頁

nios II架構uclinux的過程

admin @ 2014-03-26 , reply:0

概述

前言: 最近在論壇上有一些朋友提出我上傳的”nios2架構uclinux(nios2-linux-20080619開發包)的過程”是英文版的不好讀.碰巧我最近整理資料……

前言:
 最近在論壇上有一些朋友提出我上傳的”nios2架構uclinux(nios2-linux-20080619開發包)的過程”是英文版的不好讀.碰巧我最近整理資料就把架構過程重新整理了一篇.便於朋友參考. 對於英語閱讀能力比較好的朋友建議參考我整理的英文版.內容比較詳細.由於作者水平有限,在整理過程中難免會出現一些錯誤,望朋友們批評並指正.轉貼的朋友請註明出處http://blog.ednchina.com/chong_lang/   (本博客正在完善中歡迎交流學習)

開發環境:
在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/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/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之前不要改變上面任何設置
然後 <exit> <exit> <yes>

十二 .編譯硬體配置選擇相應的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 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
          ____ _  _
         /  __| ||_|                 
    _   _| |  | | _ ____  _   _  _  _ 
   | | | | |  | || |  _ | | | | / /
   | |_| | |__| || | | | | |_| |/    
   |  ___\____|_||_|_| |_|\____|\_/\_/
   | |
   |_|

呵呵, 恭喜你成功運行了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 <exit> <exit> <yes> .

以下可以根據自己的喜好配置內核這裡不再敘述

小提示: 在配置內核的過程中如果有朋友在編譯內核加入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 <linux/compiler.h> 註解掉可解決編譯uclinux_dist內核時出現的載入iptables 的錯誤


[admin via 研發互助社區 ] nios II架構uclinux的過程已經有4078次圍觀

http://cocdig.com/docs/show-post-42963.html