CROSS_COMPILE a driver

cancel
Showing results for 
Search instead for 
Did you mean: 

CROSS_COMPILE a driver

Jump to solution
626 Views
houtpeng
Contributor I

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

0 Kudos
1 Solution
320 Views
Pavel
NXP TechSupport
NXP TechSupport

It looks like that you want to compile kernel module.

See the following pages for this task.

http://docs.oracle.com/cd/E19253-01/817-5789/emjjr/index.html

http://www.yoctoproject.org/docs/1.6.1/kernel-dev/kernel-dev.html

https://software.intel.com/sites/default/files/m/4/d/8/5/8/42868-11__Developing_Kernel_Module_on_Yoc...

Have a great day,
Pavel Chubakov

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

0 Kudos
3 Replies
321 Views
Pavel
NXP TechSupport
NXP TechSupport

It looks like that you want to compile kernel module.

See the following pages for this task.

http://docs.oracle.com/cd/E19253-01/817-5789/emjjr/index.html

http://www.yoctoproject.org/docs/1.6.1/kernel-dev/kernel-dev.html

https://software.intel.com/sites/default/files/m/4/d/8/5/8/42868-11__Developing_Kernel_Module_on_Yoc...

Have a great day,
Pavel Chubakov

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

0 Kudos
320 Views
Pavel
NXP TechSupport
NXP TechSupport

Use the similar command sequence for toolchain installed and standalone file compiling using SDK 1.9.

  1. 1. Build and install the standalone toolchain with Yocto:

$ source ./fsl-setup-poky -m <machine>

$ bitbake fsl-toolchain

$ cd build_<machine>_release/tmp/deploy/sdk

$ ./fsl-networking-eglibc-<host-system>-<core>-toolchain-<release>.sh

Note: The default installation path for standalone toolchain is /opt/fsl-networking/. The install folder can be specified during the installation procedure.

  1. 2. Standalone file compiling test.c file.

QorIQ P2020

source /opt/fsl-qoriq/1.9/environment-setup-ppce500v2-fsl-linux-gnuspe

gcc test.c --sysroot=/opt/fsl-qoriq/1.9/sysroots/ppce500v2-fsl-linux-gnuspe -o test.c


Have a great day,
Pavel Chubakov

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
320 Views
houtpeng
Contributor I

Thanks Pavel for your answer,

you cross_compile the user program[test.c] with the standalone toolchain, but i want to cross_compile a driver program[hello.c] with the standalone toolchain, can you help me?

0 Kudos