liyongjie 发表于 2010-9-30 11:30:36

DE2_115 uclinux 移植

本帖最后由 liyongjie 于 2010-9-30 11:55 编辑

移植过程:
1.建立交叉编译开发环境(包括安装linux操作系统,安装uclinux编译器)
2.SOPC系统配置(生成基于nios II 处理器的sopc系统)
3.配置uclinux内核(根据SOPC系统配置内uxlinux核)
4.编译生产image文件,并下载测试

下面是对上述步骤的分部详细阐述:
1.建立交叉编译开发环境
      #首先需要一个linux操作系统环境的机器,我们一般有XP,vista,win7等windows开发环境的情况下,可以选择安装虚拟机,在虚拟机上面订制linux操作系统我选择的是在XP开发环境下,安装VMware workstation虚拟机,然后订制cent OS 5.5 linux开发环境,订制虚拟后注意安装vmware tools(安装不成功是因为需要安装gcc编译器),这个主要是在linux虚拟机下完成的,然后再在建立的虚拟机下建立一个共享文件夹,这样可以很方便的在XP和linux环境间传递文件,另外还可以不用对linux虚拟机关机 只需挂起,下次直接打开虚拟机很方便!

liyongjie 发表于 2010-9-30 13:21:15

本帖最后由 liyongjie 于 2010-9-30 13:31 编辑

#linux开发环境建立后,需要安装支持niosII 处理器的uclinux编译器,这里我们选择安装已经预编译好的。下面用到的所有软件包,建议放到linux环境下的/usr/src路径下,以下操作都是基于这个路径进行,而且建议在root用户下操作。
       只需下载:nios2gcc.tar.bz2
http://www.terasic.com.cn/~xyli/nios2gcc.tar.bz2
       打开terminal,输入命令行进行解压安装:
       # cd /usr/src
       # tar -jxvf nios2gcc.tar.bz2 -C /
       然后编辑bash_profile,添加编译器路径,相当于注册。
       # gedit ~/.bash_profile
       打开后出现为:
       # .bash_profile
       # Get the aliases and functions
       if [ -f ~/.bashrc ]; then
          . ~/.bashrc
       fi
       # User specific environment and startup programs
       PATH=$PATH:$HOME/bin
      
       PATH=$PATH:/opt/nios2/bin:$HOME/bin

       export PATH
       unset USERNAME
       修改添加 PATH=$PATH:/opt/nios2/bin:$HOME/bin,然后再输入命令行保存即可
       # source ~/.bash_profile
       输入命令
       # echo $PATH
       即可显示刚编辑后的路径信息
       这样编译器就安装完毕了。

liyongjie 发表于 2010-9-30 13:28:15

本帖最后由 liyongjie 于 2010-9-30 14:17 编辑

2.SOPC系统配置(生成基于nios II 处理器的sopc系统)
   #建议直接引用DE2-115 CD里面demo中的生成好的ptf文件,我这里是引用                                          DE2_115_demonstrations\DE2_115_Web_Server\DE2_115_WEB_SERVER_MII_ENET0中的ptf文档 DE2_115_SOPC.ptf
经过测试可以直接使用。

liyongjie 发表于 2010-9-30 13:50:11

本帖最后由 liyongjie 于 2010-9-30 13:51 编辑

3. 配置uclinux内核(根据SOPC系统配置内uxlinux核)
   #用户需要下载内核源码:
      uClinux-dist-20070130.tar.gz 文件大小 282 MB
      另外需下载uCLinux-dist-20070130补丁文件:
      uClinux-dist-20070130-nios2-02.diff.gz
      http://www.terasic.com.cn/~xyli/uClinux-dist-20070130-nios2-02.diff.gz
连续输入以下命令进行解压安装
      # cd /usr/src
      # tar -zxvf uClinux-dist-20070130.tar.gz
打补丁:
       # cd uClinux-dist
      # gunzip -c uClinux-dist-20070130-nios2-02.diff.gz | patch -p0
进行完以上操作后,就可以订制内核了:
       首先输入内核配置命令:
       这里选用菜单化配置:
       # 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

按Y为选中项目,N为取消,M是动态加载,按2次ESC为退出到上一级菜单,最后退出的时候会提示保存设置,根据上面设置并保存退出。
然后进行硬件配置:
输入命令:
# make vendor_hwselect SYSPTF=DE2_115_SOPC.ptf   
注意:需要把DE2_115_SOPC.ptf文件放入/uClinux-dist/linux-2.6.x/文件夹下。
这样会出现ptf文件里面所描述的最小系统,包括CPU,存储器,选择对应的cpu以及供内核运行的存储器,cpu只有altera_nios2一个,但是板上的存储器类型很多,这里选择使用SDRAM来运行内核。
配置完毕,接下来就可以编译生成image文件了

liyongjie 发表于 2010-9-30 14:03:00

4.编译生产image文件,并下载测试
      输入以下命令:
      # make romfs
      # make
如果出现错误,再次make
       # make
然后生成image
       # make linux image
然后到/uClinux-dist/images 复制出生成的image文件zimage即可进行下载测试

liyongjie 发表于 2010-9-30 14:13:30

下载测试时需要提前下载好ptf所对应的sof文件,然后下载zimage文件即可,把这两个文件保存到同一个路径下,然后打开NIOS II Command Shell,切换到文件保存的路径下,然后输入如下指令下载sof文件:
$ nios2-configure-sof DE2_115_WEB_SERVER.sof
配置成功后烧写image文件,输入以下命令:
$ nios2-download –g zImage
最后,输入
$ nios2-terminal
启动调试,就可以看到uClinux启动的画面了

liyongjie 发表于 2010-9-30 14:19:04

最后再上传一个测试文档,在DE2-115开发板接通电源,接上usbblaster以后,就可以测试了

llsun 发表于 2010-9-30 14:28:57

楼主辛苦啦 :lol

liyongjie 发表于 2010-9-30 15:35:56

补上uCLinux-dist-20070130的下载地址:
http://www.terasic.com.cn/~xyli/uClinux-dist-20070130.tar.gz

liyongjie 发表于 2010-9-30 17:00:28

:$等于:   $
注意中间没空格,被页面转化成表情了。

kay54068 发表于 2010-10-10 01:15:03

請問我在make menuconfig 時出現
make -C /usr/local/src/uClinux-dist/config/scripts/lxdialog all
make: Entering directory `/usr/local/src/uClinux-dist/config/scripts/lxdialog'
/bin/sh: cc: command not found

>> Unable to find the Ncurses libraries.
>>
>> You must have Ncurses installed in order
>> to use 'make menuconfig'

make: *** Error 1
make: Leaving directory `/usr/local/src/uClinux-dist/config/scripts/lxdialog'
make: *** Error 2

請問要如何解決?

liyongjie 发表于 2010-10-26 16:32:55

请确认下你是否装了gcc

liyongjie 发表于 2011-8-11 20:45:55

回复 11# kay54068
Ncurses libraries没有安装

wing 发表于 2011-9-30 16:59:35

赞一个:victory:

littlehit 发表于 2011-10-9 21:23:46

回复 1# liyongjie

你好,我按你的步骤坐下来后,我的DE2_115板子显示如下信息,没能启动成功,好像是文件系统没有挂载成功,请问我应该怎么做呢?非常感谢你的回复。littlehit@126.com

Uncompressing Linux... Ok, booting the kernel.
Linux version 2.6.19-uc1 (root@localhost.localdomain) (gcc version 3.4.6) #15 PREEMPT Fri Oct 7 19:50:00 CST 2011

uClinux/Nios II
Altera Nios II support (C) 2004 Microtronix Datacom Ltd.
Built 1 zonelists.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: 30832k/32768k RAM, 0k/0k ROM (1461k kernel code, 177k data)
Mount-cache hash table entries: 512
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: 0, 4096 bytes)
TCP bind hash table entries: 1024 (order: 0, 4096 bytes)
TCP: Hash tables configured (established 1024 bind 1024)
TCP reno registered
io scheduler noop registered
io scheduler deadline registered (default)
NIOS serial driver version 0.0
ttyS0 (irq = 4) is a builtin NIOS UART
TCP cubic registered
NET: Registered protocol family 1
NET: Registered protocol family 17
VFS: Cannot open root device "<NULL>" or unknown-block(0,0)
Please append a correct "root=" boot option
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)

liyongjie 发表于 2011-10-28 17:36:20

回复 15# littlehit
看起来是的VFS 没过去,你检查下SOPC 里面NIOS 指定的存储器,看是不是验证可以run的

tianfuehe 发表于 2011-11-30 11:49:11

赞 下次试一试

504472832 发表于 2011-12-4 12:07:10

遇到了和15楼同样的问题,而且生成的zImage文件也比lz小了很多
页: [1]
查看完整版本: DE2_115 uclinux 移植