国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Linux > 正文

Linux 2.6.12內核上加載一個簡單的模塊

2024-07-26 00:37:43
字體:
來源:轉載
供稿:網友
 

運行環境:linux-2.6.12

編譯環境:arm-linux-gcc(3.4.1)

運行平臺:AT91RM9200

一、編寫模塊程序testmodule.c

#include <linux/init.h>#include <linux/kernel.h>#include <linux/module.h>static int hello_init(void){     PRintk("Hello! This is the first test module!/n");    return 0;}static void hello_exit(void){ printk("Module exit! Bye Bye!/n");    return;}module_init(hello_init);module_exit(hello_exit);MODULE_LICENSE("GPL");

二、編寫Makefile

obj-m := testmodule.oKDIR := /src/linux-2.6.12PWD := $(shell pwd)default: $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules#################################################

注意:"$(MAKE)"前面要空一個"Tab"

KDIR 為內核的路徑,這個內核要與AT91RM9200運行的內核先同(編譯器也要相同的,要不運行不了)。

三、編譯

在linux下執行:make CC=/src/3.4.1/bin/arm-linux-gcc

/*注釋:/src/3.4.1/bin/arm-linux-gcc 為交叉編譯環境的路徑*/

生成testmodule.ko

四、運行

1、將testmodule.ko通過串口或者網口下載到AT91RM9200的板子上

2、執行:chmod +x testmodule.ko修改模塊的屬性將其設為可執行文件

3、執行:insmod testmodule.ko

Hello! This is the first test module!

執行:rmmod testmodule.ko

Module exit! Bye Bye!


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 合阳县| 建湖县| 凌海市| 咸宁市| 江北区| 绍兴县| 大厂| 桓台县| 石渠县| 承德县| 枣庄市| 县级市| 牙克石市| 阳山县| 荆门市| 温州市| 沈阳市| 思茅市| 砀山县| 虎林市| 临桂县| 澎湖县| 水城县| 勃利县| 宣汉县| 多伦县| 永兴县| 乌兰县| 浏阳市| 资阳市| 毕节市| 乐都县| 红河县| 湘乡市| 新安县| 壶关县| 北碚区| 汉源县| 香格里拉县| 赤城县| 分宜县|