Jump to content
Electronics-Lab.com Community

Compilation Method for Rockchip Driver


Recommended Posts

Compile the driver to the kernel:

Create the hello folder for the kernel driver source code, add the hello. c and Makefile file, modify the parent directory/kernel/drivers/Makefile file, and execute the full compilation operation.

Modify as follows:

/hello/Makefile is:obj-y += hello.o

/kernel/drivers/Makefile; add the following code:obj-y += hello

Compile the driver as a module:

Method 1:

Create the hello folder for the kernel driver source code, add the hello. c and Makefile file, modify the parent directory/kernel/drivers/Makefile file, and execute the full compilation operation.

Modify as follows:

/hello/Makefile is:obj-m += hello.o

/kernel/drivers/Makefile; add the following code:obj-y += hello

If wanting to compile the driver but not wanting to perform a full compile operation that takes too much time, the following method can be chosen.

Method 2:

Create a hello folder in the kernel driver source code, add the hello. c and Makefile file, modify the parent directory/kernel/drivers/Makefile file, modify the/kernel/Makefile file to add the architecture and cross-compiler, and execute the make modules command.

Modify as follows:

/hello/Makefile is:obj-m += hello.o

/kernel/drivers/Makefile; add the following code:obj-y += hello

/kernel/Makefile, add the following code:

ARCH?= arm64

CROSS_COMPILE?=

$(srctree)/../prebuilts/gcc/linux-x86/aarch64/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-

Advantages: When executing the make modules command, only the modules will be compiled, and the compilation time will be shortened.

Disadvantages: The driver source code needs to be added to the kernel, which is not easy to find and modify. In addition, the make modules command will determine that the source code is configured as a module and will be compiled.

Issues encountered:

Compilation Method for Rockchip Driver

Solution: The kernel top-level Makefile file specifies the architecture and cross-compiler.

Method 3:

Create a folder named "hello" at any path, and add the files ''hello.c'' and ''Makefile''. In the ''/hello/Makefile'', add the architecture and cross-compiler. Then, execute the ''make'' command in the directory where ''hello.c'' is located.

/hello/Makefile to write the following code.

Compilation Method for Rockchip Driver

Advantages: Execute the make command, and only hello. C driver files will be compiled separately.

Issues encountered:

Compilation Method for Rockchip Driver

Solution: The kernel top-level Makefile file specifies the architecture and cross-compiler.

 


Appendix:

hello.c
#include 
#include 
MODULE_LICENSE("Dual BSD/GPL");
static int hello_init(void)
{
printk(KERN_ALERT "Hello World enter\n");
return 0;
}
static void hello_exit(void)
{
printk(KERN_ALERT "Hello World exit\n");
}
module_init(hello_init);
module_exit(hello_exit);
MODULE_DESCRIPTION("A Sample Hello World Module");
MODULE_ALIAS("A Sample module");
Link to comment
Share on other sites


Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
  • Create New...