Loading kernel module in Android kernel

前端 未结 2 1048
慢半拍i
慢半拍i 2021-02-08 00:51

I am listing my problem here.

I have a Google Nexus one a.k.a. \"passion\" phone with me. Fastboot and adb tools are installed in the phone. And the boot loader is unl

2条回答
  •  北荒
    北荒 (楼主)
    2021-02-08 01:16

    Kernel modules (KO's) are much easier to work with than a static kernel - as long as the kernel has enabled them. The easiest way to tell is do an "adb shell lsmod". Second is to see if the kernel .config has enabled CONFIG_MODULES=y and CONFIG_MODULE_UNLOAD=y. Lots of info on the web about linux KO development.

    Hummm, you're close but it looks like the makefile is screwy. First try to build the hello KO on your host for unit test, then build on your target. Here's a sample makefile I use on an OMAP36xx running gingerbread:

    # Makefile for trivial android kernel module
    
    obj-m += mod_hello.o
    
    CROSS_COMPILE=/opt/distros/ARM/bin/arm-none-linux-gnueabi-
    TARG_KDIR ?= /opt/android/dal/nook_kernel
    
    HOST_KDIR=/lib/modules/$(shell uname -r)/build
    
    # target creates:
    #  ..o: CC command line for the .o, including dependencies
    #  ..mod.o.cmd: CC command line for the mod.o, including dependencies
    #  ..ko.cmd: LD command line which links the .o and .mod.o to create the .ko
    target:
        @echo "Make module for target arm"
        make -C $(TARG_KDIR) M=$(PWD) ARCH=arm CROSS_COMPILE=$(CROSS_COMPILE) modules
    
    host:
        @echo "Make module for host"
        make -C $(HOST_KDIR) M=$(PWD) modules
    
    clean:
        @echo "cleaning target"
        make -C $(TARG_KDIR) M=$(PWD) clean
        @echo "cleaning host"
        make -C $(HOST_KDIR) M=$(PWD) clean
    

提交回复
热议问题