AnsweredAssumed Answered

CROSS_COMPILE a driver

Question asked by hou tpeng on Apr 15, 2016
Latest reply on Apr 15, 2016 by Pavel Chubakov

I have install the QorIQ-SDK-V1.9-20151210-yocto at /home/Yocto/QorIQ_SDK_V1.9/Project/QorIQ-SDK-V1.9-20151210-yocto. In addition to making bitbake fsl-image-minimal/fsl-image-mfgtoo/fs-toolchain  success,  I have installed the standalone toolchain at /opt/fsl-qoriq/1.9/. I write a helloworld driver program :

 

#include <linux/module.h>

#include <linux/init.h>

 

MODULE_LICENSE("GPL");

 

static int __init hello_init(void)

{

    printk("\r\n\r\n 1 Hello world, begin");

 

    return 0;

}

 

static void __exit hello_exit(void)

{

    printk("\r\n 1 Hello world, exit\r\n");

 

    return;

}

 

module_init(hello_init);

module_exit(hello_exit);

 

the Makefile:

ifneq ($(KERNELRELEASE),)

    obj-m := hello.o

else

    KERNELDIR := /lib/modules/$(shell uname -r)/build

    PWD := $(shell pwd)

all:

    make -C $(KERNELDIR) M=$(PWD) modules

clean:

    rm -rvf *.o *.mod.c *.mod.o

endif

 

the question is where the location should i give to KERNELDIR, and make the hello,ko can runing success at the demo board

thanks

Outcomes