本文主要介绍两个例子:1-系统调用打印“hello kernel” 2-驱动开发板的蜂鸣器
使用的是友善之臂(Friendly ARM)的开发板,三星2440
========================================================================================
1. 进入linux-2.6.32.2 目录,新建mysyscall 文件夹,并进入。然后新建.c 文件
2. myadd.c 文件的内容
3. 新建, vi Kconfig 内容如下:
4. vi makefile
5. $ cd ..
$ vi Kconfig
6. $ vi makefile
7. $ cd ..
$ vi arch/arm/include/asm/unistd.h
8. $ vi arch/arm/kernel/calls.S
9. $ make menuconfig (必须在~/sq1600/linux-2.6.32.2 目录下)
10. 回车进入my sys call ---> ,空格选择 *
之后选择<Exit>退出并保存
11. $ cat .config|grep CONFIG_MY_SYSCALL - (会有CONFIG_MY_SYSCALL=出现,则正确)
$ make zImage - 编译
=====================================================
[email protected]:~/sq1600/linux-2.6.32.2$ ls drivers/mysyscall/
built-in.o Kconfig Makefile myadd.c myadd.o
=====================================================
12. $ cp arch/arm/boot/zImage /tftpboot - 复制到tftp的目录下
13. 进入开发板的【u-boot】,依次执行如下命令:
ping 192.168.0.1 - 网络是否通畅
tftp 0x30008000 zImage -- 拷贝到开发板
nand erase 0x60000 0x500000 -- 擦除缓存区内容
nand write 0x30008000 0x60000 0x500000 -- 写入内容
14. 进入目录~/sq1600/07/1_syscall的目录下
新建test_syscall.c 文件输入如下内容:
// 以下是控制蜂鸣器的 新建test_buzzer.c 文件输入如下内容:
15. [email protected]:~/sq1600/07/1_syscall$ arm-linux-gcc test_syscall.c -o test_syscall
[email protected]:~/sq1600/07/1_syscall$ cp test_syscall /tftpboot/
16. 重启开发板,
进入开发板的/home/plg目录下
[[email protected] plg]#
[[email protected] plg]# ifconfig eth0 192.168.0.230 - 设置开发板ip地址
[[email protected] plg]# ping 192.168.0.1 - 查看网络是否通
[[email protected] plg]# ping 192.168.0.1
=================================================
PING 192.168.0.1 (192.168.0.1): 56 data bytes
64 bytes from 192.168.0.1: seq=0 ttl=64 time=2.797 ms
64 bytes from 192.168.0.1: seq=1 ttl=64 time=0.775 ms
^C
--- 192.168.0.1 ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max = 0.775/1.786/2.797 ms
==================================================
结果如上,表示网络通畅
17. [[email protected] plg]# tftp -r test_syscall -g 192.168.0.1
[[email protected] plg]# ./test_syscall