Home > other >  Add the driver in the buildroot
Add the driver in the buildroot

Time:09-26

1, in the./package directory increased need to add a directory (in this directory for the hello world);

2, in the./package/Config. Add this directory in the Config file: the source package/hello - world/Config. "" in", suggested to "Hardware handling" directory

3 in the./package/hello - Config configuration file was added into the world. In the sample is as follows:

The config BR2_PACKAGE_HELLO_WORLD
Bool "hello - world"
Depends on BR2_LINUX_KERNEL
Help
The Test for adding driver in buildroot

The comment "hello - the world driver needs a Linux kernel to be built"
Depends on! BR2_LINUX_KERNEL

4, in the./package/hello - add compiled file hello world - world. Mk, sample is as follows:

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#

Hello - world

#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

HELLO_WORLD_VERSION=1.0
HELLO_WORLD_SITE_METHOD=local
HELLO_WORLD_SITE=$(TOPDIR)/dl/hello - world
HELLO_WORLD_LICENSE=GPL - 2.0
HELLO_WORLD_LICENSE_FILES=LICENSE

$(eval $(kernel module))
$(eval $(generic - package))

5, in the./dl add hello - world directory

6, in the./dl/hello - add driver code hello world - world. C, the sample is as follows:

# include & lt; Linux/init. H>
# include & lt; Linux/module. H>
# include & lt; Linux/kernel. H>

Static int __init hello_init (void) {
Printk (KERN_ALERT "hello driver init! \n");
return 0;
}

The static void __exit hello_exit (void) {
Printk (KERN_ALERT "hello driver exit \ n");
}

The module_init (hello_init);
Module_exit (hello_exit);

7 in./dl/hello - increase Makefile in the world, the sample is as follows:

CC=arm - none - Linux - gnueabi - GCC
Ifeq ($(KERNELRELEASE),)
KERNELDIR?=/home/freedom/tq2416_platform buildroot 2019.08.1/output/build/Linux - custom
The PWD:=$(shell PWD)
Modules:
$(MAKE) - C $(KERNELDIR) M=$(PWD) modules
Modules_install:
$(MAKE) - C $(KERNELDIR) M=$(PWD) modules_install
Clean:
Rm - rf *. * ~ o core. Depend. *. CMD *. Ko *. Mod. C. tmp_versions
The else
Obj - m:=hello - world. O
Endif

8, in buildroot directory make menuconfig, enter the Target packages - & gt; After the Hardware configuration of handling for interface, choose the hello - world configuration items;

9, execute the make compilation (if you want to compile this drive alone, executable make hello - world command), the compiler generated after successful hello - world. Ko driver files will be integrated into the file system/lib/modules/3.1.0 - EmbedSky/extra directory;

10, on the target machine only needs to execute modprobe hello - world can load the driver;

11, also can add the ordinary package through this way,
  • Related