Custom driver not building with the package

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Custom driver not building with the package

1,909 Views
chandraevolute
Contributor V

I am writing my own driver for switches for IMX6ulEVK. I followed the below steps while writing the driver

  1. 1. Create a directory like my_drvr inside drivers(which is in the Linux source code) for your driver and put your driver (my_driver.c) file inside this directory. It will looks like /linux_source_code/drivers/my_drvr/my_driver.c
  2. 2. Create one Makefile inside your driver directory (using vi any editor) and inside this put obj-$(CONFIG_MY_DRIVER) += my_driver.o and save this file. This will appears like /linux_source_code/drivers/my_drvr/Makefile
  3. 3. Create one Kconfig file inside your driver directory (using vi any editor) and inside this put
  4. 4.  config MY_DRIVER
  5. 5.  tristate "my driver" //gives your driver description like vendor name etc.
  6. 6.  depends on ARM
  7. 7.  default y if ARM
  8. 8.  help

  my driver module.

  1. 9. Save this file, this will appears like /linux_source_code/drivers/my_drvr/Kconfig
  2. 10. Add both Makefile and Kconfig file in the Linux source drivers Makefile and Kconfig file which are at /linux_source_code/drivers/Makefile and /linux_source_code/drivers/Kconfig
  3. 11. In the Makefile add below in last line

obj-y += my_drvr/

or

obj-$(CONFIG_MY_DRIVER)   += my_drvr/

  1. 12. In Kconfig file add below in last line

source "drivers/my_drvr/Kconfig"

  1. 13. Finally have to add Kconfig file into architecture specific config file which will be at kernel_source/arch/arm/configs/--defconfig in this add below line in the last

CONFIG_MY_DRIVER=y

After compiling the kernel using bitbake linux-imx i am able to see my driver gopt compiled and .ko file is generated. But it is not included in the sdcard package. Is there anything I need to do additionally other than the above steps. I am using bitbake core-image-base for 3.14.38 bsp version

Labels (3)
4 Replies

1,282 Views
qinghuazhu
Contributor III

I'd like to share my rebuild script here

#!/bin/sh

rm tmp/stamps/imx6sxsabresd-poky-linux-gnueabi/linux-imx/3.14.28-r0.do_compile.*

bitbake linux-imx -c compile

if [ $? -ne 0 ];then

        exit

fi

rm sstate-cache/ab/sstate:linux-imx:imx6sxsabresd-poky-linux-gnueabi:3.14.28:r0:imx6sxsabresd:3:abcaddfad744af88c57ba3e6769b28dc_deploy.tgz

rm tmp/stamps/imx6sxsabresd-poky-linux-gnueabi/linux-imx/3.14.28-r0.do_deploy.abcaddfad744af88c57ba3e6769b28dc

rm tmp/stamps/imx6sxsabresd-poky-linux-gnueabi/linux-imx/3.14.28-r0.do_deploy_setscene.abcaddfad744af88c57ba3e6769b28dc

bitbake linux-imx -c deploy

if [ $? -ne 0 ];then

        exit

fi

rm tmp/stamps/imx6sxsabresd-poky-linux-gnueabi/core-image-minimal/1.0-r0.do_rootfs.*

bitbake core-image-minimal

and I don't like "bitbake  xxxxx  -f"

1,282 Views
chandraevolute
Contributor V

thank you very much for the script.

will the above script will make sure that my custom driver and added with final image

0 Kudos

1,282 Views
SergioSolis
NXP Employee
NXP Employee

Hello Chandra, did you try the script from Qinghua?

0 Kudos

1,282 Views
chandraevolute
Contributor V

yes tried and it is working with minor changes

0 Kudos