1、解压内核源码
mkdir /home/armtool/kernel-2.6.35
Cd /home/armtool/kernel-2.6.35
cp /mnt/hgfs/share/kernel/linux-2.6.35.tar.bz2 ./
Tar jxvf linux-2.6.35.tar.bz2
Cd linux-2.6.35
2、修改Makefile
Vi makefile
ARCH ?= arm
CROSS_COMPILE ?= arm-mfx-linux-gnueabi-
3、配置内核
Make menuconfig
Kernel Features --->
[*] Use the ARM EABI to compile the kernel
[*] Allow old ABI binaries to run with this kernel (EXPERIMENTAL)
4、添加驱动文件
cp /mnt/hgfs/share/hello.c /dev/char/
vi drivers/char/Kconfig
在menu "Character devices"下添加:
config MFXHELLOTEST
tristate"MFX hello test drv Device Support"
depends on SERIAL_NONSTANDARD
---help---
support hello test device driver on MFX develop loard
vi drivers/char/Makefile
在obj-$(CONFIG_HANGCHECK_TIMER) += hangcheck-timer.o下添加:
obj-$(CONFIG_MFXHELLOTEST) += hello.o
5、动态编译
make distclean
make menuconfig
Device Drivers --->
Character devices --->
<M> MFX hello test drv Device Support //动态编译
make bzImage
生成:arch/arm/boot/zImage
vi drivers/char/Makefile
该obj-$(CONFIG_MFXHELLOTEST) += hello.o为:
obj-m += hello.o
执行:make m=drivers/char/ modules
生成hello.ko
设置u-boot环境变量
#setenv serverip 192.168.160.2
#setenv ipaddr 192.168.160.3
#setenv bootcmd tftp 33000000 zImage\;go 33000000
#setenv bootargs root=nfs nfsroot=192.168.160.2:/source/rootfs console=ttySAC0,115200 init=/linuxrc ip=192.168.160.3
#saveenv
模块加载卸载
Insmd hello.ko 插入模块
Cat /proc/devices 查看模块
Mknod /dev/MFXTEST c 252 0 创建节点
Ls /dev/MFXTEST 查看模块
Lsmod //查看
Rmmod hello.ko 卸载模块
Rm /dev/MFXTEST 删除节点
6、静态编译
vi drivers/char/Makefile
obj-$(CONFIG_MFXHELLOTEST) += hello.o
make menuconfig
Device Drivers --->
Character devices --->
<*> MFX hello test drv Device Support //静态编译
make zImage
生成:arch/arm/boot/zImage
vi drivers/char/Makefile
该obj-$(CONFIG_MFXHELLOTEST) += hello.o为:
obj-m += hello.o
执行:make m=drivers/char/ modules
生成hello.ko