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.
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.
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?
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 http://git.toradex.com/cgit/linux-toradex.git/refs/tags?h=colibri and compiled it, I extracted the modules of compiled kernel as described here: https://developer.toradex.com/knowledge-base/build-u-boot-and-linux-kernel-from-source-code#kernel-module-compilation-all-modules
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.