eric_jia的个人空间 https://blog.eetop.cn/208662 [收藏] [复制] [分享] [RSS]

空间首页 动态 记录 日志 相册 主题 分享 留言板 个人资料

日志

uclinux nios2

已有 2488 次阅读| 2008-7-10 12:20 |个人分类:资料

UClinuxDist

Version 145, changed by hippo5329@yahoo.com.tw. 01/29/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 older buildroot guide approach. DO NOT MIX UP)

First, you should (recommended for newbie) install the BinaryToolchain
(Or you can build the cross compiler from sources with BuildrootGuide , but it might be difficult for beginner)

Install required package, as root or via sudo
On Fedora,RHEL,
yum install gcc make ncurses-devel bison flex gawk lynx
On Debian/Ubuntu, (via sudo)
apt-get install gcc make ncurses-dev bison flex gawk lynx


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

Please follow step 0..7 in GitServer to prepare the uClinux sources.
In step 6, check out source of master branch, which is uClinux-dist-20070130 stable release.

In uClinux-dist dir, perform. the config. DO NOT cd linux-2.6.x
make menuconfig

Select the target:  Altera, nios2nommu
NOTE, Libc MUST be (None) !!!  Because we will use the uClibc built in the cross gcc with buildroot
. We don't use the uClibc come with uClinux-dist.

Vendor/Product Selection --->
--- Select the Vendor you wish to target
(Altera) Vendor
--- Select the Product you wish to target
(nios2nommu) Altera Products 

Kernel/Library/Defaults Selection --->
(linux-2.6.x) Kernel Version
(None) Libc Version    # MUST be None !!!
[*] Default all settings (lose changes)

[ ] 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) .
(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 path to ptf, no space allowed in path

Compile kernel and apps,
make

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 now the images/zImage file of ELF format. You can follow TryOutuClinux to run the new zImage .


Below is the the start up message of Altera University Program DE2  dev board.

Using make vendor_hwselect SYSPTF=~/donwload/system_0.ptf . The zImge, ptf and sof are attached in TryOutuClinux .


#nios2-download -g /home/hippo/uClinux-dist/images/zImage
Using cable "USB-Blaster [USB 4-1.2]", device 1, instance 0x00
Pausing target processor: OK
Initializing CPU cache (if present)
OK
Downloaded 1201KB in 19.2s (62.5KB/s)
Verified OK                        
Starting processor at address 0x00D00000
# nios2-terminal
nios2-terminal: connected to hardware target using JTAG UART on cable
nios2-terminal: "USB-Blaster [USB 4-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.19-uc1 (hippo@darkstar) (gcc version 3.4.6) #10 PREEMPT Wed Mar 28 20:44:34 CST 2007


uClinux/Nios II
Altera Nios II support (C) 2004 Microtronix Datacom Ltd.

setup_arch: No persistant network settings signature at 003F0000
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: 5948k/8192k RAM, 0k/0k ROM (1471k kernel code, 683k 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
<DM9KS> I/O: 806810f8, VID: 90000a46
TCP cubic registered
NET: Registered protocol family 1
NET: Registered protocol family 17
Freeing unused kernel memory: 572k freed (0x97c000 - 0xa0a000)
Shell invoked to run /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 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


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 :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 :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: <anything> , dir : /home/ftp
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/nios2nommu/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/nios2nommu/ 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 "!<d>" , d=1..20, to recall one of the history, eg "!3" for the 3rd cmd line.

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
/>

update git to the latest

In your uClinux-dist dir,
git pull

点赞

评论 (0 个评论)

facelist

您需要登录后才可以评论 登录 | 注册

  • 关注TA
  • 加好友
  • 联系TA
  • 0

    周排名
  • 0

    月排名
  • 0

    总排名
  • 0

    关注
  • 1

    粉丝
  • 0

    好友
  • 0

    获赞
  • 5

    评论
  • 访问数
关闭

站长推荐 上一条 /1 下一条

小黑屋| 关于我们| 联系我们| 在线咨询| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2024-5-6 01:37 , Processed in 0.024091 second(s), 18 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
返回顶部