How to compile a charDevDevice driver for colibri iMX6

Hi, I have wrote a charDevDriver for linux, I am able to compile and work with it on ubuntu with the following make file:

obj-m += chardrv.o


make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules


make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean

I have followed the second step of this answer to compile kernel sources in SDK. what changes should I do in my make file to be able to compile my driver for colibri iMX6DL? I want to load it in my device for testing it and debugging.

Hi @ara_tz

Thanks for writing to the Toradex Community!

what changes should I do in my make file to be able to compile my driver for colibri iMX6DL

Is this Makefile working on Ubuntu? Please have a look here to create a Makefile.
The only difference between making a driver for your host or the module, is just you need to cross-compile the driver with the SDK for Colibri iMX6DL.

Best regards,

thank you jaski, yes this make file works on Ubuntu and almost any other Linux to make a kernel module.

The problem is not exactly the make file, I followed the instructions in this link to make SDK with kernel sources. Compilation succeeded and I installed the SDK, but there is no Linux source files in the SDK directory! what else should I do when I want to make SDK?

If the Linux sources were available, when I set the ARCH and compilers the make File I use compiles the kernel module for that linux and target device.

You are welcome.

Did you add TOOLCHAIN_TARGET_TASK_append = " kernel-devsrc" to your conf/local.conf file.?

Which OpenEmbedded Branch did you compile?

Best regards,

I use console-tdx-image for SDK, and yes I added TOOLCHAIN_TARGET_TASK_append = " kernel-devsrc" into local.conf file.

Which branch did you compile?

I downloaded linux kernel from and compiled it, I extracted the modules of compiled kernel as described here:
after modules extracted I changed my make file to this:

PWD := $(shell pwd)
obj-m += chardrv.o
	make -C ~/linux-toradex/modules/lib/modules/4.9.166/build SUBDIRS=$(PWD) modules
	make -C ~/linux-toradex/modules/lib/modules/4.9.166/build SUBDIRS=$(PWD) clean

I cross compiled driver for imx6 and it works perfectly.

Perfect that it works. Thanks for the feedback.