45、关于uClinux浮点支持
1.从/uClinux/lib/libm复制gcvt.c和mathf.h到/uClinux/lib/libc/stdio2
2.修改/uClinux/lib/libc/stidio2/Makefile
2a.增加gcvt.o编译项到
OBJ= $(AOBJ) $(POBJ) $(SOBJ) dputs.o snprintf.o getdelim.o getline.o
gcvt.o
~~~~~~添加项
2b.添加编译参数-DFLOATS=1到all: $(LIBC) $(OBJ)前面
3.可增加make clean相关项
Makefile文件如下:
# Copyright (C) 1995,1996 Robert de Bath
# This file is part of the Linux-8086 C library and is distributed
# under the GNU Library General Public License.
LIBC=../libc.a
ASRC=stdio.c
AOBJ=_stdio_init.o fputc.o fgetc.o fflush.o fgets.o gets.o fputs.o \
puts.o fread.o fwrite.o fopen.o fclose.o fseek.o rewind.o ftell.o \
setbuffer.o setvbuf.o ungetc.o
PSRC=printf.c
POBJ=printf.o sprintf.o fprintf.o snprintf.o vprintf.o vsprintf.o \
vfprintf.o vfnprintf.o vsnprintf.o
SSRC=scanf.c
SOBJ=scanf.o sscanf.o fscanf.o vscanf.o vsscanf.o vfscanf.o
OBJ= $(AOBJ) $(POBJ) $(SOBJ) dputs.o getdelim.o getline.o gcvt.o
CFLAGS += -DFLOATS=1
all: $(LIBC) $(OBJ)
#@$(RM) $(OBJ)
$(LIBC): $(LIBC)($(OBJ))
$(LIBC)($(AOBJ)): $(ASRC)
$(CC) $(CFLAGS) -DL_$* $< -c -o $*.o
$(AR) $(ARFLAGS) $@ $*.o
$(LIBC)($(POBJ)): $(PSRC)
$(CC) $(CFLAGS) -DL_$* $< -c -o $*.o
$(AR) $(ARFLAGS) $@ $*.o
$(LIBC)($(SOBJ)): $(SSRC)
$(CC) $(CFLAGS) -DL_$* $< -c -o $*.o
$(AR) $(ARFLAGS) $@ $*.o
transfer:
-@rm -f ../include/stdio.h
cp -p stdio.h ../include/.
clean:
rm -f *.o libc.a
$(LIBC)($(OBJ)): stdio.h
46、关于用vfork实现多进程
N多客户不停的在问vfork是否真正的多进程,要不就是认为父进程被挂起了。
这里给个明确的答复,vfork+exec是多进程,而且父子进程同时并行执行,下面是个标准的例子代码:
if ((pid=vfork())<0){
;
}
else if (pid==0){//child
//execl("/bin/sh","/bin/sh","/tmp/tmp1",0);
execl("/bin/sh","/bin/sh","/tmp/tmp1",(char*)0);
exit(0);
}
47、在RH7.2上无法make的问题
1.uClinux-dist/linux-2.4.x/scripts
mv mkdep mkdep.bak
gcc -o mkdep mkdep.c
mv split-include split-include.bak
gcc -o split-include split-include.c
2.uClinux-dist/config/scripts
download lxdialog-OK-rh7.2.tgz from HHTech to /
cd uClinux-dist/config/scripts
mv lxdialog lxdialog.bak
tar xzf /lxdialog-OK-rh7.2.tgz
cp lxdialog/lxdialog /
cd uClinux-dist/linux-2.4.x/scripts/lxdialog
mv lxdialog lxdialog.bak
cp /lxdialog .
then
make dep
make menuconfig
works fine!!
Happy hacking:-(.
注意:上面的lxdialog-OK-rh7.2.tgz在华恒目前提供的软件光盘上都有提供。
48、关于uClinux下执行make menuconfig的说明
一般的,在LINUX下执行make menuconfig只是对LINUX内核进行配置。但uClinux将linux-2.4.x内核和应用程序user都整合到uClinux目录下,并将对应用程序的选择也集成到make menuconfig里面,下面给出简单的使用说明:
在字符界面下,不要进入XWindows,
cd uClinux-dist
make menuconfig
出现对话框,内容如下:(注意:下面有许多│ │,这是因为终端软件贴图的缘故)
Target Platform Selection ---> │ │
│ │ --- │ │
│ │ Load an Alternate Configuration File │ │
│ │ Save Configuration to an Alternate File │ │
│
选择Target Platform Selection --->回车,出现如下界面:
--- Choose a Vendor/Product combination. │ │
│ │ (HHtech/M5249) Vendor/Product │ │
│ │ --- Kernel is linux-2.4.x │ │
│ │ (uC-libc) Libc Version │ │
│ │ [ ] Default all settings (lose changes) │ │
│ │ [*] Customize Kernel Settings │ │
│ │ [*] Customize Vendor/User Settings (NEW) │ │
│ │ [*] Update Default Vendor Settings
选择(即 [*] )第二项:[*] Customize Kernel Settings就是要对内核进行裁减配置;选择第三项:[*] Customize Vendor/User Settings (NEW)就是要挑选应用程序,至于第四项可选可不选,选了是当你的这个uClinux版本作为发布版本时,用户选择Default all settings (lose changes)就完全使用你的出厂配置。当然这个对于普通用户而言是没有什么用的。
选择完毕后,选择下面的< Exit > 逐层退出,最后按照提示保存配置,则会分别出现内核和应用程序的选配菜单:
下面是内核配置菜单:
Linux Kernel v2.4.20-uc0 Configuration
Code maturity level options ---> │ │
│ │ Loadable module support ---> │ │
│ │ Processor type and features ---> │ │
│ │ General setup ---> │ │
│ │ Memory Technology Devices (MTD) ---> │ │
│ │ Parallel port support ---> │ │
│ │ Plug and Play configuration ---> │ │
│ │ Block devices ---> │ │
│ │ Networking options ---> │ │
│ │ Telephony Support ---> │ │
│ │ ATA/IDE/MFM/RLL support ---> │ │
│ │ SCSI support ---> │ │
│ │ I2O device support ---> │ │
│ │ Network device support ---> │ │
│ │ Amateur Radio support ---> │ │
│ │ IrDA (infrared) support ---> │ │
│ │ ISDN subsystem ---> │ │
│ │ Old CD-ROM drivers (not SCSI, not IDE) ---> │ │
│ │ Character devices ---> │ │
│ │ File systems --->
......
随便选择一项,回车即可进去配置。配置完内核后保存配置,< Exit >退出则进入应用程序选配菜单:
下面是应用程序配置菜单:
uClinux v1.3.4 Configuration
Core Applications ---> │ │
│ │ Library Configuration ---> │ │
│ │ Flash Tools ---> │ │
│ │ Filesystem Applications ---> │ │
│ │ Network Applications ---> │ │
│ │ Miscellaneous Applications ---> │ │
│ │ BusyBox ---> │ │
│ │ Tinylogin ---> │ │
│ │ MicroWindows ---> │ │
│ │ Games ---> │ │
│ │ Miscellaneous Configuration ---> │ │
│ │ Debug Builds ---> │ │
│ │ --- │ │
│ │ Load an Alternate Configuration File │ │
│ │ Save Configuration to an Alternate File
选择其中一项即可进行选择,例如:要加入一些网络类程序,例如DHCP服务器/客户端,SNMP,pppd/pppoe等都是选择Network Applications --->,回车后进入如下界面:打上*号即表示选中。
[ ] arp │ │
│ │ [*] boa │ │
│ │ [ ] boa uses SSL (NEW) │ │
│ │ [ ] bpalogin │ │
│ │ [ ] br2684ctl │ │
│ │ [ ] brcfg │ │
│ │ [ ] bridge utils │ │
│ │ [ ] dhcpcd │ │
│ │ [ ] dhcpcd-new (2.0/2.4) │ │
│ │ [ ] dhcpd │ │
│ │ [ ] dhcpd(ISC) │ │
│ │ [ ] dhclient(ISC) │ │
│ │ [ ] dhcrelay (ISC) │ │
│ │ [ ] diald │ │
│ │ [*] discard │ │
│ │ [ ] dnsmasq │ │
│ │ [ ] ethattach │ │
│ │ [ ] ez-ipupdate │ │
│ │ [*] ftp │ │
│ │ [ ] ftpd
还有常用的就是busybox的选配:
BusyBox --->
[*] BusyBox │ │
│ │ --- Applets │ │
│ │ [ ] adjtimex │ │
│ │ [ ] ar │ │
│ │ [ ] basename │ │
│ │ [*] cat │ │
│ │ [ ] chgrp │ │
│ │ [ ] chmod │ │
│ │ [ ] chown │ │
│ │ [*] chroot │ │
│ │ [ ] clear │ │
│ │ [*] cmp │ │
│ │ [ ] cp │ │
│ │ [*] cut │ │
│ │ [*] date │ │
│ │ [ ] dc │ │
│ │ [ ] dd │ │
│ │ [*] df │ │
│ │ [ ] dirname │ │
│ │ [ ] dmesg
......
还有就是编译自己在uClinux/user下添加的应用程序时,一定要返回在uClinux目录下执行make
不能直接在这个应用程序目录下执行make,这样做也不会慢的,因为内核和uC-libc库及其它user下的应用程序都已经编译过了,编译过程只是简单的检查一下STAMP,看它们都已经编译过了,就不再理睬,而直接找到你刚改动的应用程序目录进行编译,比单独编译这个应用程序慢一点点而已。
对于armlinux和ppclinux而言,则应用程序就要逐个单独编译了,有人觉得这样方便,但也有人喜欢前者,呵呵,萝卜青菜各有所爱:-)
49、关于uClibc和pThread库的一个BUG(感谢杭州客户李渊先生提供资料)
uCLibc/libc/stdlib/malloc/free.c里面有个小错误,这个错误只有在大程序,大数据并且使用了pthread库的时候才会出现,
现象是malloc会死锁不动,改正的方法是在 __free_to_heap函数最后加一句 "__heap_unlock(heap);" 就可以了。
50、关于目前uClinux for MCF52XX中断处理的一个BUG纠正
就是要修改原来清除中断的方式由 |= 改为 = 即可。
以HHCF5249的IDE驱动为例:uClinux-dist/linux-2.4.x/include/asm/ide.h
修改的地方仅一行,参见下面加红加粗代码:
static IDE_INLINE void
ide_get_lock(
int *ide_lock,
void (*handler)(int, void *, struct pt_regs *),
void *data)
{
#ifdef CONFIG_M5249C3
/* Clear interrupts for GPIO5 */
*((volatile unsigned long *) 0x800000c0) = 0x00002020;
#endif
}
再看以太网驱动:
uClinux-dist/linux-2.4.x/drivers/net/dm9000x.c修改如下:
static void dmfe_interrupt(int irq, void *dev_id, struct pt_regs *regs) 函数中:
*((volatile unsigned long *) (MCF_MBAR2+MCFSIM2_GPIOINTCLEAR)) = 0x00004040;
51、关于HHCF5249读写CS2~CS6死机的问题
发现怪现象,无法将CSOR1的数值改为0x3d80,怎么改都还是0x3c80,这样一读就死机。这时,用MEMORY读写工具(user/memtools)mt来手工读写这些CPU寄存器地址:
/> mt
Please input your command :>>>
gl 10000090 1
00FF0021
Please input your command :>>>
gw 10000096 1
3C80
Please input your command :>>>
pw 10000096 3d80
Please input your command :>>>
gw 10000096 1
3C80
Please input your command :>>>
gw 10000096 1
3C80
Please input your command :>>>
pw 10000096 3d80
Please input your command :>>>
gw 10000096 1
3C80
经查,在uClinux-dist/linux-2.4.x/arch/m68knommu/platform/5249/HHTECH/crt0_ram.S里面设置的CSOR1还是正确的0x3d80:
/*
* Setup CS1 for ethernet controller.
* (Setup as per M5249C3 doco).
*/
move.l #0x30000000, %d0 /* CS1 mapped at 0x30000000 */
move.l %d0, 0x8c(%a0)
move.l #0x00ff0021, %d0 /* CS1 size of 16Mb */
move.l %d0, 0x90(%a0)
move.w #0x3d80, %d0 /* CS1 = 16bit port, AA */
move.w %d0, 0x96(%a0)
但在LINUX内核启动过程中就不知哪里自动给变成0x3c80了,最后确认是在以太网DM9000驱动中给改掉了,见下面红字标注的代码:
#define NEEDCHANGE 1
......
inline void outw(unsigned short value, unsigned long addr)
{
cli();
#if NEEDCHANGE
*(volatile unsigned short*)0x10000096 |=0x0100;
#endif
// udelay(10);
*(volatile unsigned short*)addr = value;
#if NEEDCHANGE
*(volatile unsigned short*)0x10000096 &=0xfeff;
#endif
sti();
}
将uClinux-dist/linux-2.4.x/drivers/net/dm9000x.c 文件前面的一行改为:(原来是1,改为下面的0)
#define NEEDCHANGE 0
然后重新编译,重烧即可。
【注意】
并不是所有的版本的dm9000x.c都是这个样子的,有的就没有上面的问题。
52、关于init: /bin/boa respawning too fast问题
/etc/inittab文件:由init进程监护执行,保证inittab文件中列出的服务进程任何时候都有一份拷贝在内存中运行。它的作用就在于维护一些系统中非常关键的后台服务进程,使之永远有一份在运行,即使发生致命错误导致进程死掉退出,init进程会负责自动再重新启动一个。下面给出/etc/inittab文件的内容:
inet:unknown:/bin/inetd 【启动inet服务】
有时我们在板子启动后,可看到minicom里不停打印类似下面的信息:
init: /bin/boa respawning too fast
这就是因为在板子的/etc/inittab文件里面有这样一行:
boa:unknown:/bin/boa
而你make menuconfig选择应用程序时又没有选中boa,导致烧到板子上的/bin目录里面没有boa这个程序,init进程就会不停的试图启动boa,但又没有,它就不停的尝试,所以才会有这样的信息出来。所以,要么你就把boa编进去,要么就把/etc/inittab里面这一行用#号注释掉,重编重烧后就没有问题了。
