日本免费全黄少妇一区二区三区-高清无码一区二区三区四区-欧美中文字幕日韩在线观看-国产福利诱惑在线网站-国产中文字幕一区在线-亚洲欧美精品日韩一区-久久国产精品国产精品国产-国产精久久久久久一区二区三区-欧美亚洲国产精品久久久久

Linux 2.6.12內(nèi)核上加載一個(gè)簡(jiǎn)單的模塊

;運(yùn)行環(huán)境:linux-2.6.12 編譯環(huán)境:arm-linux-gcc(3.4.1) 運(yùn)行平臺(tái):AT91RM9200 一、編寫模塊程序testmodule.c #include #include #include 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)"前面要空一個(gè)"Tab" KDIR 為內(nèi)核的路徑 , 這個(gè)內(nèi)核要與AT91RM9200運(yùn)行的內(nèi)核先同(編譯器也要相同的 , 要不運(yùn)行不了) 。三、編譯 在linux下執(zhí)行:make CC=/src/3.4.1/bin/arm-linux-gcc /*注釋:/src/3.4.1/bin/arm-linux-gcc 為交叉編譯環(huán)境的路徑*/ 生成testmodule.ko 四、運(yùn)行 1、將testmodule.ko通過(guò)串口或者網(wǎng)口下載到AT91RM9200的板子上 2、執(zhí)行:chmodx testmodule.ko修改模塊的屬性將其設(shè)為可執(zhí)行文件 3、執(zhí)行:insmod testmodule.ko Hello! This is the first test module! 執(zhí)行:rmmod testmodule.ko Module exit! Bye Bye!

    推薦閱讀