显示标签为“linux”的博文。显示所有博文
显示标签为“linux”的博文。显示所有博文

2011年8月3日星期三

AM Copter Control Screen Shot




2011年7月17日星期日

Linux 0.11 内核完全注释 笔记(三)

>2 fork 做什么?
>半斤回答:准备LDT,TSS,页目录,页表...

在Linux内核中,一个进程是用struct task_struct类型的变量来标记。所以fork首先是创建了一个新的struct task_struct类型的变量,对其进行相应的赋值。

重要的是,新建进程的TSS,LDT表,页目录和页表是全新创建的,在存储上和父进程完全没有关系,不同的两个实体。但新进程LDT所指向的数据段和代码段完全照抄父亲进程,指令指针也同父进程一致。也就是说,父子进程共享代码段,数据段和堆栈段都是相同的地址空间。好比两个锦囊装着同一妙计,嘿嘿!

插一句:从这里看fork的两次返回是那么的自然,两个进程指令指针(EIP)都一样,能没有两个返回吗?

更重要的事,fork过程中将父子进程所有页表都设置成了Read Only, 为啥子啊? 为了实现Copy On Write技术。由于页表项设置成了只读模式,每次写页表项所对应的页面时(比如函数调用把参数放入堆栈)都会引起写保护页异常,CPU会自动执行异常处理函数,进而调用 do_wp_page 函数来分配一个新的页面,挂载到引起写异常的页表项目,之后设置页表项可读可写。这个技术就叫Copy On Write。Copy On Write 完全是一种按需分配的技术,缺页/写保护页面异常是伟大的设计,因为它缔造了Copy On Write,缔造了虚拟内存技术!

这里还有一个问题值得思考,假设fork之后的程序马上会对数据段进行写动作,进而导致CPU进入写保护页面异常处理程序,谁的页表项会指向新分配的空间呢?父 or 子?

答案取决于谁先引起写保护页面异常。假设儿子引起了异常,那么儿子的页表项会指向新的分配空间;假设是父亲引起了异常,父亲的页表项会指向新空间,这样之前父亲占用的空间就归儿子所有了。很有趣的逻辑啊!

代码参考:
sys_fork -> copy_process
http://oldlinux.org/lxr/http/source/kernel/fork.c#L68
un_wp_page
http://oldlinux.org/lxr/http/source/mm/memory.c#L221

2011年7月16日星期六

Linux 0.11 内核完全注释 笔记(二)

有句话说提出问题比解决问题重要。是啊,我想看书也是一样。能预先提出问题,带着问题去看书会事半功倍。这次我再读此书想先问自己N多关心的问题,在阅读的时候去求索,然后写出笔记一一解开自己的心结。虽然这些问题我大概略之一二,但是半斤八两的感觉和我此次刨根问底的原则不吻合。目前能想到的关键问题如下:


进程管理

1 进程如何切换?
半斤回答:JMP 到预切换到任务的 TSS

2 fork 做什么?
半斤回答:准备LDT,TSS,页目录,页表...

3 exec 做什么?

4 进程调度算法?

内存管理

5 系统的发动机,缺页异常具体实现?
半斤回答:就是从SWAP/FS往内存放数据

设备管理

6 磁盘请求队列算法?
半斤回答:电梯算法,插入使链表排序。

7 键盘驱动?

8 显示器如何折腾?

文件系统

9 fd管理与pipe通信?

10 知识盲区啊,提不出什么好问题了?!

2011年7月13日星期三

Linux 0.11 内核完全注释 笔记(一)

有人说:”初恋不懂爱情!“。的确,五年前我读了《Linux 0.11 内核完全注释》一书,茫然的看完,悄然的离去。所幸的是种下了一个Idea:“这书还是不错的。”

五年后,再读此书,感触颇多,当读到move_to_user_mode这个神器时不由自主在weibo上像文人骚客一样发出如下感叹:

”一生至少该有一次,为了某段代码而陶醉自己,不求年代,不求国籍,不求编程语言,甚至不求编译运行,只求在我思索的年华里,遇到你。“
http://oldlinux.org/lxr/http/source/include/asm/system.h#L1

言归正传,笔记开始!

写操作系统不读CPU手册和上厕所不带纸是一个概念,不是扯淡就是高手!所以此书上来先介绍了X86保护模式编程的东东,只有弄清楚这些东东,才能9浅1深的去理解Kernel。X86的保护模式编程个人感觉还是挺复杂的,毕竟要游走于N多概念之间。

Q1 逻辑地址如何转换到物理地址?

Logical Address (逻辑地址)
Linear Address (线性地址)
Physical Address (物理地址)

这些是地址,我们的程序编译完的地址可以粗略理解成逻辑地址,在开启保护模式的情况下,CPU在指令运算时,都需要把程序的逻辑地址转换到真实的物理地址上。怎么转换?靠查表!怎么查?要查表首先要知道表在哪里,然后要知道表的Index,进而得到表项,得到表项后再分析就可以得到真实的物理地址。顺藤摸瓜也!Intel的X86 CPU已经把藤和瓜所需的数据结构都准备好了。

Local Descriptor Table (局部描述符表)LDT
Gloal Descriptor Table (全局描述符表)GDT
Local Descriptor Table Register (局部描述符表寄存器)LDTR
Gloal Descriptor Table Register (全局描述符表寄存器)GDTR
LDT/GDT是表,表的线性地址放在了LDTR/GDTR寄存器中,这是“藤1”。


Code Segment Selector (代码断选择符) CS
Data Segment Selector (数据段选择符) DS
Stack Segment Selector (堆栈段选择符) SS
{C|D|S}S这些是段选择符,Bit2标识使用GDT or IDT,bit3~15是Index信息,这是“藤2”。

Code Segment Descriptor (代码段描述符)
Data Segment Descriptor (数据段描述符)
System Segment Descriptor (系统段描述符)
系统断描述符又可分为:
1 LDT段描述符
2 TSS(Task State Segment)描述符
3 中断门描述符
4 调用门描述符
5 任务门描述符
6 陷阱门描述符
LDT/GDT中的表项就是这些{断|门}描述符,每个描述符都占用8个Byte空间,这是“藤3”。

所以CPU在逻辑地址转换到物理地址过程中,顺着藤1,藤2,找到了藤3。
找到藤3之后,CPU解剖了藤3,挖出了段基地址,然后与逻辑地址相加,这样就得出线性地址。

在没有开启分页机制情况下,线性地址就是真实的物理地址。如果已经开启分页,那就要再顺着“藤4”去摸。CR3寄存器存放着当前任务使用页目录的物理地址。这是"藤4“。经过分析后直接找到物理地址,顺藤摸瓜结束。

Intel还算厚道,没来个18摸,最多也就是Inception的3重梦境。累了,以后再写!

2010年6月19日星期六

GTK+ OpenGL Extension 折腾日记

最近在做一个姿态模拟系统,端午节前请Lynn帮我设计了传感器的PCB,昨天刚刚送去打板。今天早上又收到咸蛋帮我画了个3D Max的十字架。貌似万事俱备,就差我开工了!

这套系统的作用就是根据传感器的输出数据来判定传感器所依附物体的姿态,然后在PC上以3D效果显示出来。核心的东东就是一个姿态的识别算法,其他什么数据传输,图像显示都是绿叶。

由于软件是在Linux上编写,我采用了GTK+。为了显示3D效果,我google调查了一下,需要GTK+ OpenGL Extension。OK,问题就是找到3D Sample了。可是我下载GTK+ OpenGL Extension的Release版本1.2.0编译上就遇到了问题。gtkglext-1.2.0是2006年的版本,我现在用的GTK+还是比较新的版本,很显然gtkglext-1.2.0版本太老了。当时的思路是google解决掉所有出错点。经过一番恶战,我的确解决了编译的错误,但是运行起来依然有问题,总是说"gtkglext example 'GDK_IS_GL_DRAWABLE (gldrawable)' failed"。再google,貌似是gtkglext自己的问题。最后决定用git抓取最新版本。抓下来后configure那里又不过,晕死了!提示configure: error: Invalid target for GDK: use x11 or win32。怎么办呢?干脆Merge一下1.2.0和git的版本算了,我首先Merge了gtk/gtkglwidget.c,毕竟之前报错总来自这里。看来是人品爆发了,merge完这个文件,编译,执行再不出错了!哈哈!看来root cause找到了!Yeah!

GTK+ OpenGL Extension 的shapes例子还不错,可以3D显示并旋转一个茶壶,这正是我想要的东西^_^。



后记: 2011/08/10已经实现当时的想法,详见 AMCC 1.0 release


2010年3月16日星期二

likely & unlikey

GCC的likely和unlikely功能就是让很可能被执行的分支代码紧跟着je或jne这样的条件跳转指令后面。为何非要跟在条件跳转指令屁股后?主要是更好利用CPU指令Cache。想想看:如果要执行的语句都在Cache里,省去从Memory抓数据的时间直接去执行,速度岂不是快了?所以likely和unlikely这种功能主要是为了提速,去掉不会影响功能。

http://kerneltrap.org/node/4705

2010年3月12日星期五

Comparison of Hard Link and Symbolic Link

Comparison of Hard Link and Symbolic Link

ItemHard LinkSymbolic Link
Name resolution Faster. A hard link contains a direct reference to the object.Slower. A symbolic link contains a path name to the object, which must be resolved to find the object.
Object existenceRequired. An object must exist in order to create a hard link to it. Optional. A symbolic link can be created when the object it refers to does not exist.
Object deletion Restricted. All hard links to an object must be unlinked (removed) to delete the object.Unrestricted. An object can be deleted even if there are symbolic links referring to it.
Dynamic objects (attributes change)Slower. Many of the attributes of an object are stored in each hard link. Changes to a dynamic object, therefore, are slower as the number of hard links to the object increases. Faster. Changes to a dynamic object are not affected by symbolic links.
Static objects (attributes do not change) Faster. For a static object, name resolution is the primary performance concern. Name resolution is faster when hard links are used. Slower. Name resolution is slower when symbolic links are used.
ScopeRestricted. Hard links cannot cross file systems. Unrestricted. Symbolic links can cross file systems.

2010年3月7日星期日

LockMeter

最近在系统学习LDD3(以前都是临时抱佛脚),在第五章看到了关于LockMeter(http://oss.sgi.com/projects/lockmeter/)。LockMeter可以分析出不同Linux版本在SMP支持上的性能的差异,分析Lock
Hold/Wait Time。我很想在我的Kernel里面玩玩,但是看到LockMeter网站上支持的内核不够新(2.6.16
Latest),我的Kernel是2.6.32.3,或许Kernel已经加入了这个功能?于是我开始在我的2.6.32.3内核中找寻是否有相关的东西。在Document目录中发现了lockstat.txt,很像LockMeter,OK!menuconfig->Kernel
Hacking->Lock usage statistics,make bzImage/Update
grub.confg,一切妥当,boot新的内核,意外发生了:

Give up waiting for root device. Common problem:
- Boot args (cat /proc/cmdline)
- Check rootdelay = (did the system wait log enough?)
- Check root = (did the system wait for the right device)
- Missing modules (cat /proc/modules; ls /dev)
ALERT! /dev/dist/by-uuid/xxxxx doest not exist. Dropping to a shell!


奇怪,怎么就找不到硬盘了呢?我把rootdelay设置到了200都不OK!忙活了几个小时,不知道为何,思路有点乱,改天再研究!

2010年1月8日星期五

给ubuntu904升级内核

[2010_0107]

1 在kernel.org下载了2.6.32.3的内核,放置到了下面的路径中
anders@ubuntu:/media/Data/anders/ing/linux/linux-2.6.32.3$
2 为了减少折腾的时间,我使用之前ubuntu904系统的config档案
anders@ubuntu:/media/Data/anders/ing/linux/linux-2.6.32.3$ cp
/boot/config-2.6.28-11-generic .config
3 制作软连接
ln -s /media/Data/anders/ing/linux/linux-2.6.32.3 /usr/src/linux
3 配置内核 (其实什么都没配置直接退出保存,然后shell提示内核压缩算法,我选择了gzip压缩,之后一路回车逃避一大堆提示^^)
anders@ubuntu:/usr/src/linux$make menuconfig
4 编译内核 (这一步骤我用了2个小时,23:40编译,知道第2天凌晨1:40,汗!)
anders@ubuntu:/usr/src/linux$make

[2010_0108]

5 安装内核 (/boot目录会长出来 vmlinuz-2.6.32.3)
anders@ubuntu:/usr/src/linux$make install
6 安装内核Module (/lib/module/会长出2.6.32.3目录)
anders@ubuntu:/usr/src/linux$make modules_install
7 制作initrd文件
anders@ubuntu:/usr/src/linux$mkinitramfs -o /boot/initrd.img-2.6.32.3 2.6.32.3
8 修改grub启动选项
vi /boot/grub/menu.lst, 加入如下文字:
title Ubuntu 9.04, kernel 2.6.32.3(by Anders)
145 root ()/ubuntu/disks
146 kernel /boot/vmlinuz-2.6.32.3 root=UUID=E218500B184FDD63
loop=/ubuntu/disks/root.disk ro quiet splash
147 initrd /boot/initrd.img-2.6.32.3
然后设置 default 2 (因为我上面添加这个启动选项的顺序是第3个(0为index,所以为2)
9 reboot

ok,一切搞掂!使用新Kernel还是不错的,启动速度提高了10s,嘿嘿!

2009年7月10日星期五

遥控Ubuntu8.04电脑攻略

原始帖
http://groups.google.com/group/szdiy/msg/4e2f708239d360a7


经过一段时间DIY,我可以用我家电视的遥控器遥控我的Ubuntu8.04 Linux系统了,目前可以实现鼠标移动,鼠标按键点击,下面把DIY的过程和经验分享给大家!

一 红外接收器制作
1 元器件:DB9串口(带外壳),4.7uF电解电容,100ma78L05稳压器,1N4148开关二极管,4.7K电阻,1738红外接收头
2 原理图:参考附件schematics.png

二 安装LIRC(ubuntu8.04)
https://help.ubuntu.com/community/InstallLirc/Hardy

三 分析摇控器按键编码
使用irrecord程序分析,最终形成我的遥控器配置文件lircd.conf (参考附件)

四 添加红外鼠标
在/etc/X11/xorg.conf添加LIRC鼠标设备,具体参考附件xorg.conf。

五 配置lircmd.conf文件
配置/etc/lirc/lircmd.conf来设定遥控器的按键与鼠标的移动方向和鼠标按键的对应关系,具体参考附件lircmd.conf。

六 Ubuntu8.04集成LIRC有BUG
安装LIRC后,默认启动顺序是先启动X再执行/etc/init.d/lirc,这样导致了启动X的时候找不到/dev/lircm文件,致使添加鼠标失败,具体调整办法如下:
anders@anders-desktop:~$sudo update-rc.d -f lirc remove
anders@anders-desktop:~$sudo update-rc.d lirc start 50 S .

七 用mode2/xmode2进行红外编码分析
启动xmode2程序,按动遥控器的按键,就可以看到红外方波了,是不是很COOL?具体参考附件图片xmode2.png

八 总结
红外接收器的元器件非常简单,但配合LIRC后却显得无比强大!可以完成红外编码分析和遥控电脑的功能。在玩弄这个LIRC过程中,我遇到很多问题,大都是从官方的文档和Mailing List获取帮助,最终得以解决。
下面给大家提几点注意事项:
1 LIRC不支持USB转串口这种方式,所以必须要把红外接收器连接到真正的串口上
2 在配置LIRC之前最好搞清楚原理,请参考http://www.lirc.org/html/technical.html#overview
3 出现问题请参考相关LOG信息进行DEBUG,比如我发现"六"中提及的BUG就是看到xorg的LOG才知晓的。

最后,祝大家DIY愉快!

2009年4月10日星期五

2009年3月16日星期一

[转] 删除c/c++中注释的shell脚本

下面这个脚本实现了删除c/c++ source code中注释的功能。它接收一个命令行参数,该命令行参数或者是一个c/c++源文件,或者是一个目录。当参数是一个目录时,该脚本删除该目录下及子目录下所有源文件中的注释。

delcomment.sh
------------------------------------
#!/bin/bash

#delcomment.sh
#function: this shell script delete the comment in c/c++ source file


function del_comment_file()
{
#delete the comment line begin with '//comment'
sed -i "/^[ \t]*\/\//d" $file

#delete the commnet line end with '//comment'
sed -i "s/\/\/[^\"]*//" $file

#delete the comment only occupied one line '/* commnet */'
sed -i "s/\/\*.*\*\///" $file

#delete the comment that occupied many lines '/*comment
# *comment
# */
sed -i "/^[ \t]*\/\*/,/.*\*\//d" $file

}

function del_comment()
{
for file in `ls `; do
case $file in
*.c)
del_comment_file
;;
*.cpp)
del_comment_file
;;
*.h)
del_comment_file
;;
*)
if [ -d $file ]; then
cd $file
del_comment
cd ..
fi
;;
esac
done
}


DIR=$1

if [ ! -e $DIR ]; then
echo "The file or directory does not exist."
exit 1;
fi

if [ -f $DIR ]; then
file=`basename $DIR`
if [[ `echo $DIR | grep /` == $DIR ]]; then
cd `echo $DIR | sed -e "s/$file//"`
del_comment_file
else
del_comment_file
fi

exit 0;
fi

if [ -d $DIR ]; then
cd $DIR
del_comment
exit 0;
fi



------------------------------------
# delcomment.sh arg
注: 脚本delcomment.sh的参数可以:
(1) 当前目录下的文件;
(2) 目录;
(3) 带路径的文件。
(4) 原文 http://hi.baidu.com/zengzhaonong/blog/item/e85dbcccd844771300e92846.html

2009年3月5日星期四

BASH 笔记

2009年2月15日星期日

用SKYEYE来模拟uClinux

2009/02/23
发现之前做的网络提速工作有问题,其实速度主要和skyeye模拟ARM指令有关,skyeye里面有两套模拟ARM指令的方法;一个是ARMul_Emulate32, 另一个是ARMul_Emulate32_dbct, 我有拜读过dbct的算法,打算从dbct入手看看为何我用skyeye模拟网络速度这么慢的问题,不过编译skyeye提示我的gcc不支持inline x86 asm. 查看skyeye README说需要gcc3.3 / gcc3.4,于是我上网下载并编译了gcc3.4, skyeye还是提示我的gcc3.4不支持inline x86 asm,今天写了一段x86 asm的代码在我Office的Fedora6下编译过了, 回家看看ubunut下的gcc能否编译过, 要是过的话, 看来skyeye在检查inline x86 asm这个特性上有问题.
int main(void)
{
int x = 10, y;

__asm ("movl %1, %%eax;"
"movl %%eax, %0;"
:"=r"(y) /* y is output operand */
:"r"(x) /* x is input operand */
:"%eax"); /* %eax is clobbered register */
printf("x=%d, y=%d\n", x, y);
return 0;
}
PS: 晚上发现我的ubuntu gcc果然支持inline x86 asm,是skyeye的check-x86-asm.sh检测代码有问题,直接exit 0绕过检测,顺利编译带有dbct的skyeye,初步感觉效率有一点点提高吧 :-)

2009/02/15
kernel/softirq.c : 367
+// Anders 2009_0215,raise rx & tx riq priority
+if ((nr == NET_RX_SOFTIRQ) || (nr == NET_TX_SOFTIRQ))
+ raise_softirq(nr);
sudo nice -n -20 skyeye -e linux 本来ping可以控制在1s内有echo了,telnet也进去了,可以重新来过又是不行了,昙花一现的成功 :-(

2009年2月2日星期一

一个MODULE引起的血汗

采用让模组直接编译到内核的方式来进行编译,但是文件中却define了MODULE,我掉进了同一条河里.

//Anders 2008_0526, we don't need this macro.
//For this macro I spend 4 hours on tracing why xxx_init_module function doesn't execute. :-(
//Anders 2009_0203, havn't update this for xxx's new driver.
//For this macro, I spend 2 hours again :-(
//#ifndef MODULE
//#define MODULE
//#endif

2009年1月30日星期五

[uClinux-dev mailing list] 摘录之 "如何驾驭uclinux-dist开发包?"

挺不错的一个帖子,告诉大家如何驾驭uClinux-dist这套开发包.用skyeye模拟硬件,无须任何实体硬件资源,适合初学者入门!

Message: 8
Date: Fri, 30 Jan 2009 22:02:42 +1000
From: Greg Ungerer <gerg@snapgear.com>
Subject: Re: [uClinux-dev] why no-mmu cannot support binfmt_aout.c
To: uClinux development list <uclinux-dev@uclinux.org>
Message-ID: <4982EC62.8020408@snapgear.com
>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

loody wrote:
>> What target did you use as your base for this?
>> (What I really want to know is what is set in the
>> config.arch file).
>>
>> Regards
>> Greg
> Dear Greg:
> I use GDB/armulator.
> attach the config and config.arch for your reference.
> Thanks for your help,

Here is what I did:

1. downloaded uClinux-dist-20080808.tar.gz
2. downloaded arm-linux-tools-20061213.tar.gz
3. mkdir user/hello
4. vi user/hello/hello.c and put in it:

int main()
{
printf("hello world\n");
}

5. vi user/hello/Makefile and put in it:

all: hello

romfs:
$(ROMFSINST) /bin/hello

clean:
-rm -f hello *.elf *.gdb *.o

6. vi user/Kconfig, adding in the "Miscellaneous Applications section:

config USER_HELLO_HELLO
bool "hello"

7. vi user/Makefile, adding in a line:

dir_$(CONFIG_USER_HELLO_HELLO) += hello

8. configured uClinux-dist to build "GDB/ARMulator" selecting to
use a linux-2.6.x kernel, and selected the new "hello" program
for inclusion as well

9. make
10. cd images
11. cp .
12. run "skyeye -e linux" and see:

Your elf file is little endian.
arch: arm
cpu info: armv3, arm7tdmi, 41007700, fff8ff00, 0
mach info: name at91, mach_init addr 0x4189a0
uart_mod:0, desc_in:, desc_out:, converter:
SKYEYE: use arm7100 mmu ops
Loaded ROM boot.rom
exec file "linux"'s format is elf32-little.
load section .text.head: addr = 0x01008000 size = 0x00000190.
load section .init: addr = 0x010081a0 size = 0x0000ee60.
load section .text: addr = 0x01017000 size = 0x000ce870.
not load section .rodata: addr = 0x010e6000 size = 0x00000000 .
not load section .pci_fixup: addr = 0x010e6000 size = 0x00000000 .
not load section .rio_route: addr = 0x010e6000 size = 0x00000000 .
not load section __ksymtab: addr = 0x010e6000 size = 0x00000000 .
not load section __ksymtab_gpl: addr = 0x010e6000 size = 0x00000000 .
not load section __ksymtab_unused: addr = 0x010e6000 size = 0x00000000 .
not load section __ksymtab_unused_gpl: addr = 0x010e6000 size =
0x00000000 .
not load section __ksymtab_gpl_future: addr = 0x010e6000 size =
0x00000000 .
not load section __kcrctab: addr = 0x010e6000 size = 0x00000000 .
not load section __kcrctab_gpl: addr = 0x010e6000 size = 0x00000000 .
not load section __kcrctab_unused: addr = 0x010e6000 size = 0x00000000 .
not load section __kcrctab_unused_gpl: addr = 0x010e6000 size =
0x00000000 .
not load section __kcrctab_gpl_future: addr = 0x010e6000 size =
0x00000000 .
load section __param: addr = 0x010e6000 size = 0x00001000.
load section .data: addr = 0x010e8000 size = 0x00009f98.
not load section .bss: addr = 0x010f1fa0 size = 0x00008f20 .
not load section .comment: addr = 0x00000000 size = 0x000013b0 .
call ARMul_InitSymTable,kernel filename is linux.
start addr is set to 0x01008000 by exec file.
Linux version 2.6.25-uc0 (gerg@goober) (gcc version 3.4.4) #2 Fri Jan 30
21:38:07 EST 2009
CPU: Atmel-AT91M40xxx [14000040] revision 0 (ARMvundefined/unknown),
cr=00000000
Machine: Atmel AT91 EB01
Built 1 zonelists in Zone order, mobility grouping off. Total pages: 4064
Kernel command line:
PID hash table entries: 64 (order: 6, 256 bytes)
console [ttyS0] enabled
Dentry cache hash table entries: 2048 (order: 1, 8192 bytes)
Inode-cache hash table entries: 1024 (order: 0, 4096 bytes)
Memory: 16MB = 16MB total
Memory: 15268KB available (832K code, 75K data, 60K init)
Mount-cache hash table entries: 512
io scheduler noop registered (default)
Atmel USART driver version 0.99
ttyS0 at 0xfffd0000 (irq = 2) is a builtin Atmel APB USART
ttyS1 at 0xfffcc000 (irq = 3) is a builtin Atmel APB USART
brd: module loaded
uclinux[mtd]: RAM probe address=0x1400000 size=0x103000
Creating 1 MTD partitions on "ROM":
0x00000000-0x00103000 : "ROMfs"
uclinux[mtd]: set ROMfs to be root filesystem
VFS: Mounted root (romfs filesystem) readonly.
Freeing init memory: 60K
Shell invoked to run file: /etc/rc
Command: hostname GDB-ARMulator
Command: /bin/expand /etc/ramfs.img /dev/ram0
Command: mount -t proc proc /proc
Command: mount -t ext2 /dev/ram0 /var
Command: mkdir /var/tmp
Command: mkdir /var/log
Command: mkdir /var/run
Command: mkdir /var/lock
Command: mkdir /var/empty
Command: cat /etc/motd
Welcome to
____ _ _
/ __| ||_|
_ _| | | | _ ____ _ _ _ _
| | | | | | || | _ \| | | |\ \/ /
| |_| | |__| || | | | | |_| |/ \
| ___\____|_||_|_| |_|\____|\_/\_/
| |
|_|

GDB/ARMulator support by <davidm@snapgear.com>
For further information check:
http://www.uclinux.org/

Execution Finished, Exiting

Sash command shell (version 1.1.1)
/>




13. from the command line I run "hello":

/> hello
hello world
/>


All seems to work...

Regards
Greg

--
Anders Remark:

//-----tools & package-----
http://ftp.snapgear.org/pub/snapgear/tools/arm-linux/
http://www.uclinux.org/uClinux/dist/uClinux-dist-20080808.tar.gz
//-----end of tools & package-----

//-----skyeye.conf-----
cpu: arm7tdmi
mach: at91
mem_bank: map=M, type=RW, addr=0x00000000, size=0x00004000
mem_bank: map=M, type=RW, addr=0x01000000, size=0x00400000
mem_bank: map=M, type=R, addr=0x01400000, size=0x00400000, file=boot.rom
mem_bank: map=M, type=RW, addr=0x02000000, size=0x00400000
mem_bank: map=M, type=RW, addr=0x02400000, size=0x00008000
mem_bank: map=M, type=RW, addr=0x04000000, size=0x00400000
mem_bank: map=I, type=RW, addr=0xf0000000, size=0x10000000
lcd: state=on
//-----end of skyeye.conf-----

2009年1月29日星期四

BASH练习之“目录轮回”

写了一个bash脚本当作练习内容,为bash添加了qu和hui命令.

qu "去"
hui "回"

anders@~#qu .tencent/
/home/anders /home/anders/.tencent/
anders@~/.tencent#qu qq
/home/anders /home/anders/.tencent/ /home/anders/.tencent/qq
anders@~/.tencent/qq#hui
anders@~/.tencent#hui
anders@~#

--------.bashrc-------
# anders bash exercise
declare -a FOLDER_ARRAY
export FOLDER_ARRAY
FOLDER_ARRAY[0]=$(pwd)

qu ()
{
dirname=$1

if [ $# -eq 0 ] || [ ! -d $1 ]; then
echo "usage:qu "
return
else
if [ ${dirname:0:1} != "/" ]; then
dirname=$(pwd)/$dirname
fi
FOLDER_ARRAY[${#FOLDER_ARRAY[@]}]=$dirname
cd $dirname
echo ${FOLDER_ARRAY[@]}
fi
}

hui ()
{
if [ ${#FOLDER_ARRAY[@]} -le 1 ]; then
echo "no back way"
return
else
unset FOLDER_ARRAY[$((${#FOLDER_ARRAY[@]}-1))]
cd ${FOLDER_ARRAY[$((${#FOLDER_ARRAY[@]}-1))]}
fi
}

2009年1月18日星期日

Unix shell 家谱

Thompson shell
The Thompson shell was the first Unix shell, introduced in the first version of Unix in 1971, and was written by Ken Thompson.

Bourne shell
The Bourne shell, or sh, was the default Unix shell of Unix Version 7, and replaced the Thompson shell, whose executable file had the same name, sh.

Korn shell
The Korn shell (ksh) is a Unix shell which was developed by David Korn (AT&T Bell Laboratories) in the early 1980s. It is backwards-compatible with the Bourne shell and includes many features of the C shell as well, such as a command history, which was inspired by the requests of Bell Labs users.

Bash(derive for Bourne shell)
Bash is a free software Unix shell written for the GNU Project. Its name is an acronym which stands for Bourne-again shell.[1] The name is a pun on the name of the Bourne shell (sh), an early and important Unix shell written by Stephen Bourne and distributed with Version 7 Unix circa 1978,[2] and the concept of being "born again". Bash was created in 1987 by Brian Fox. In 1990 Chet Ramey became the primary maintainer.[3]

Almquist shell(derive for Bourne shell)
The Almquist shell (also known as A Shell, ash and sh) was originally Kenneth Almquist's clone of the SVR4-variant of the Bourne shell; it is a fast, small, POSIX-compatible Unix shell designed to replace the Bourne shell in later BSD distributions. By intention it did not feature line editing or command history mechanisms originally, because Almquist felt that such should be moved into the terminal driver. Current variants have emacs and vi modes.

Debian Almquist shell(derive for Almquist shell)
Debian Almquist shell (dash) is a Unix shell, much smaller than bash but still aiming at POSIX-compliancy. It requires less disk space but is also less feature-rich. Some missing features, such as the $LINENO variable, are required by POSIX.

/bin/sh != /bin/bash

继续研究bash,惊奇发现自己是个白痴.原来以为/bin/sh和/bin/bash是一个东西,可是发现绝对不是那么回事.我还没搞懂这个dash是什么东西.晕!

2008年12月31日星期三

Screen

09/01/01
screen是个好东西!
C-a c 创建新窗口
C-a 0-9 切换窗口
C-a d 进行detach动作
screen -ls 查看
screen -r 进行attach动作