在nios II中移植linux系统.docx
- 文档编号:12580545
- 上传时间:2023-04-20
- 格式:DOCX
- 页数:12
- 大小:90.67KB
在nios II中移植linux系统.docx
《在nios II中移植linux系统.docx》由会员分享,可在线阅读,更多相关《在nios II中移植linux系统.docx(12页珍藏版)》请在冰豆网上搜索。
在niosII中移植linux系统
移植全过程
我们采用的方法,是在windows下进行sopcbuilder的设计,在linux进行uclinux的内核的编译,以及交叉编译环境的建立。
从而产生uClinux的镜像文件(机器码流)。
需要准备的文件:
A、nios2gcc.tar.bz2(交叉编译环境的linux安装文件,可以是其他格式的)。
B、uclinux-dist20060803(uclinux内核文件,可以是别的版本)
C、uclinux-dist20060803-nios2-diff.tar.bz2(目前没有明白为什么要有这个文件,没有还不行)
一:
交叉编译环境的建立
1、把nios2gcc.tar.bz2放在目录:
/usr/local/src里面,将nios2gcc.tar.bz2解压进/opt/nios2目录下(这个默认的,不用进行目录操作)
[root@localhost src]# tar -jxvf nios2gcc.tar.bz2 -C /
2、设定交叉编译器的路径:
[root@localhost src]# vi ~/.bash_profile
修改bash_profile的內容如下所示,加上/opt/nios2/bin路径
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:
$HOME/bin:
/opt/nios2/bin
export PATH
unset USERNAME
3、执行下面一条命令,使设置的路径有效
[root@localhost src]# source ~/.bash_profile
注:
这里你可以进行一下测试。
看看你的交叉编译环境是否已经建成,也可以略过不做。
方法:
[root@localhost src]# 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内核
1、把uclinux-dist20060803放进/usr/local/src,解压缩。
[root@localhost src]# tar -zxvf uClinux-dist-20070130.tar.tar
如果你是在linux系统下(意思是指不是虚拟机),硬盘够大的话,就不应该有问题出现。
解压缩之后,一般应该接近1.9G大小。
2、给uclinux打补丁
把μClinuxkernelpatchforNiosII:
uClinux-dist-20070130-nios2-02.7z到/usr/local/src/uClinux-dist。
安裝μClinuxkernelpatchforNiosII
[root@localhost src]# cd uClinux-dist
[root@localhost uClinux-dist]# gunzip -c uClinux-dist-20070130-nios2-02.diff.gz | patch -p0
出现以下的结果就表明,补丁打成功。
patching file vendors/Altera/nios2nommu/config.arch
patching file vendors/Altera/nios2nommu/config.linux-2.6.x
patching file lib/libpng/Makefile
patching file linux-2.6.x/include/asm-nios2nommu/ide.h
patching file linux-2.6.x/include/linux/elf-em.h
patching file linux-2.6.x/usr/Makefile
patching file linux-2.6.x/arch/nios2nommu/kernel/vmlinux.lds.S
patching file linux-2.6.x/arch/nios2nommu/drivers/Kconfig
patching file linux-2.6.x/arch/nios2nommu/drivers/altcf.c
patching file linux-2.6.x/arch/nios2nommu/drivers/pci/Kconfig
patching file linux-2.6.x/arch/nios2nommu/drivers/pci/pci-auto.c
patching file linux-2.6.x/arch/nios2nommu/drivers/pci/pci.c
patching file linux-2.6.x/arch/nios2nommu/drivers/pci/Makefile
patching file linux-2.6.x/arch/nios2nommu/drivers/spi.c
patching file linux-2.6.x/arch/nios2nommu/drivers/Makefile
patching file linux-2.6.x/drivers/mtd/maps/altera.c
patching file linux-2.6.x/drivers/mtd/maps/Kconfig
patching file linux-2.6.x/drivers/net/Kconfig
patching file linux-2.6.x/drivers/net/Makefile
patching file linux-2.6.x/drivers/net/dm9ks.c
patching file linux-2.6.x/drivers/net/open_eth.c
patching file linux-2.6.x/drivers/net/dm9000.c
patching file linux-2.6.x/drivers/net/Space.c
patching file linux-2.6.x/drivers/net/smc91x.c
patching file linux-2.6.x/drivers/net/smc911x.c
patching file linux-2.6.x/drivers/net/mtip1000.c
patching file linux-2.6.x/drivers/usb/Kconfig
patching file linux-2.6.x/drivers/usb/host/Kconfig
patching file linux-2.6.x/drivers/usb/host/isp1362-hcd.c
patching file linux-2.6.x/drivers/usb/host/Makefile
patching file linux-2.6.x/drivers/usb/host/isp1362.h
patching file linux-2.6.x/drivers/usb/Makefile
patching file linux-2.6.x/drivers/ide/ide.c
patching file user/microwin/src/fonts/X6x13.c
patching file user/microwin/src/demos/nxroach/Makefile
patching file user/microwin/src/demos/nanox/nxterm.c
patching file user/microwin/src/demos/nanox/nterm.c
patching file user/microwin/src/demos/nxkbd/keynum.c
patching file user/microwin/src/demos/nxkbd/keyctrl.c
patching file user/microwin/src/demos/nxkbd/keyshft.c
patching file user/microwin/src/Makefile.rules
patching file user/microwin/src/drivers/kbd_ttyscan.c
patching file user/microwin/src/drivers/scr_fb.c
patching file user/microwin/src/drivers/mou_ser.c
patching file user/ftpd/ftpcmd.c
patching file user/ftpd/Makefile
出现的顺序可能不同,出现类似的画面,就应该没有问题。
三、进行内核配置(基本都是默认配置)
需要注意的是:
里面的每一步,都应该和界面的配置一致。
如果有后面make时,有什么error,最好回来仔细检查一下这些默认配置(这些网上找的)。
[root@localhost uClinux-dist]# make menuconfig
在Vendor/ProductSelection如下設定
在Kernel/Library/DefaultsSelection如下設定
最後選
Step6:
將SOPCBuilder設定檔system_0.ptf複製到/usr/local/src
Step7:
根據DE2硬體配置設定makefile
[root@localhost uClinux-dist]# make vendor_hwselectSYSPTF=/usr/local/src/system_0.ptf
最後會有選擇動作,分別選擇1(CPU_0),1(cfi_flash_0),2(sdram)。
--- Please select which CPU you wish to build the kernel against:
(1) cpu_0 - Class:
altera_nios2 Type:
f Version:
7.071
Selection:
1
--- Please select a device to upload the kernel to:
(1) cfi_flash_0
Class:
altera_avalon_cfi_flash
Size:
4194304 bytes
Selection:
1
--- Please select a device to execute kernel from:
(1) sram_0
Class:
sram_16bit_512k
Size:
524288 bytes
(2) sdram_0
Class:
altera_avalon_new_sdram_controller
Size:
8388608 bytes
(3) epcs_controller
Class:
altera_avalon_epcs_flash_controller
Size:
2048 bytes
Selection:
2
最後成功的結果如下所示
--- Summary using
PTF:
/usr/local/src/system_0.ptf
CPU:
cpu_0
Device to upload to:
cfi_flash_0
Program memory to execute from:
sdram_0
--- Settings written to /usr/local/src/uClinux-dist/linux-2.6.x/arch/nios2nommu/hardware.mk
make[3]:
Leaving directory `/usr/local/src/uClinux-dist/linux-2.6.x'
make[2]:
Leaving directory `/usr/local/src/uClinux-dist/vendors/Altera/nios2nommu'
make[1]:
Leaving directory `/usr/local/src/uClinux-dist/vendors'
Step8:
建立romfs資料夾,過程會有錯誤訊息,可忽略。
[root@localhost uClinux-dist]# make romfs
Step9:
編譯μClinux核心
[root@localhost uClinux-dist]# make
Step10:
產生image
[root@localhost uClinux-dist]# makelinuximage
最後會在/usr/local/src/uClinux-dist/linux-2.6.x/arch/nios2nommu/boot/下找到zImage
注意:
zImage文件是make时,就已经产生,那个只是一个初步的,没有bootloader的文件,如果你想使你的uClinux在硬件上运行,必须进行makelinuximage这条命令,从而加上bootloader。
四:
将uClinux写入硬件
1、把你的.ptf文件对应的.sof文件和生成的镜像文件zImage一起放在\altera\72\nios2eds\examples下。
2、启动altera的commandshell。
开始->程序->altera->nios2EDS->mandshell
3、先进行硬件配置(注意必须先在quartus中把.sof文件烧进去)
[SOPC Builder]$ nios2-configure-sof DE2_NIOS.sof
执行结果:
Searching for SOF file:
in .
DE2_NIOS.sof
Info:
*******************************************************************
Info:
Running Quartus II Programmer
Info:
Command:
quartus_pgm --no_banner --mode=jtag -o p;DE2_NIOS.sof
Info:
Using programming cable "USB-Blaster [USB-0]"
Info:
Started Programmer operation at Mon Jun 09 03:
01:
45 2008
Info:
Configuring device index 1
Info:
Device 1 contains JTAG ID code 0x020B40DD
Info:
Configuration succeeded -- 1 device(s) configured
Info:
Successfully performed operation(s)
Info:
Ended Programmer operation at Mon Jun 09 03:
01:
46 2008
Info:
Quartus II Programmer was successful. 0 errors, 0 warnings
Info:
Allocated 54 megabytes of memory during processing
Info:
Processing ended:
Mon Jun 09 03:
01:
46 2008
Info:
Elapsed time:
00:
00:
02
4、把zImage下到sdram里面
[SOPC Builder]$ nios2-download-gzImage
执行的结果:
Using cable "USB-Blaster [USB-0]", device 1, instance 0x00
Pausing target processor:
OK
Initializing CPU cache (if present)
OK
Downloaded 1197KB in 14.4s (83.1KB/s)
Verified OK
Starting processor at address 0x00D00000
5、启动uClinux
[SOPC Builder]$ nios2-terminal
执行结果:
Uncompressing Linux
Ok, booting the kernel.
Linux version 2.6.19-uc1 (root@localhost.localdomain) (gcc version 3.4.6) #2 PR
EMPT Sun Jun 8 23:
28:
30 CST 2008
uClinux/Nios II
Altera Nios II support (C) 2004 Microtronix Datacom Ltd.
Built 1 zonelists. Total pages:
2032
Kernel command line:
PID hash table entries:
32 (order:
5, 128 bytes)
Dentry cache hash table entries:
1024 (order:
0, 4096 bytes)
Inode-cache hash table entries:
1024 (order:
0, 4096 bytes)
Memory available:
5956k/8192k RAM, 0k/0k ROM (1465k kernel code, 680k 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)
Serial:
JTAG UART driver $Revision:
1.3 $
ttyJ0 at MMIO 0x806810f0 (irq = 1) is a jtag_uart
TCP cubic registered
NET:
Registered protocol family 1
NET:
Registered protocol family 17
Freeing unused kernel memory:
572k freed (0x97a000 - 0xa08000)
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)
/>
如果你看到上面的结果,表明你的uClinux移植成功了。
但是反映在硬件上的效果不明显,这个要看你的具体的linux应用程序了。
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 在nios II中移植linux系统 nios II 移植 linux 系统
![提示](https://static.bdocx.com/images/bang_tan.gif)