Compile the kernel driver steps - based platform aio-3399j

Compile the kernel driver steps - based on firefly's aio-3399j platform

1. Go kernel / device directory, create a directory name, such as lowfree

2. Go lowfree, create a hello.c, write the following code

#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/module.h> 
#include <linux/delay.h>

static int __init hello_init(void)
{
    int i;
    for(i=0;i<=10;i++)
    {
	printk("============================================== Hello , this is lowfree's work ============================================== %d\n",i);		
	mdelay(1000);
	}
    return 0;
}

static void __exit hello_exit(void)
{
    printk("Exit Hello world\n");
}

subsys_initcall(hello_init);
module_exit(hello_exit);

MODULE_AUTHOR("lowfree");
MODULE_DESCRIPTION("hello driver");
MODULE_LICENSE("GPL");

3. Create a Makefile, write

obj-$(CONFIG_HELLO)			+= hello.o

4. Create a Kconfig, write

 config HELLO

 	tristate "Hello for Firefly --- lowfree"

 	help

 	  Hello for Firefly --- lowfree


5. Return to the drivers directory into the Makefile, add

 obj-y				+= lowfree/

6. Enter Kconfig, adding

 source "drivers/lowfree/Kconfig"

7. Return kernel directory, enter make ARCH = arm64 menuconfig, and then proceeds to the next Drivers, see lowfree

Here Insert Picture Description

8. Back sdk root directory, input

 ./build.sh kernel

Compile the kernel, of course, if not the whole sdk compile case, use the make command to compile

============Start build kernel============
TARGET_ARCH          =arm64
TARGET_KERNEL_CONFIG =firefly_linux_defconfig
TARGET_KERNEL_DTS    =rk3399-firefly-aio
==========================================
#
# configuration written to .config
#
scripts/kconfig/conf  --silentoldconfig Kconfig
  CHK     include/config/kernel.release
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
  CHK     scripts/mod/devicetable-offsets.h
  CHK     include/generated/timeconst.h
  CHK     include/generated/bounds.h
  CHK     include/generated/asm-offsets.h
make[1]: 'arch/arm64/boot/dts/rockchip/rk3399-firefly-aio.dtb' is up to date.
  CALL    scripts/checksyscalls.sh
make[1]: 'include/generated/vdso-offsets.h' is up to date.
  CHK     include/generated/compile.h
make[1]: 'arch/arm64/boot/Image.lz4' is up to date.
  Image:  kernel.img is ready
w  CHK     include/config/kernel.release
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
  CHK     scripts/mod/devicetable-offsets.h
  CHK     include/generated/timeconst.h
  CHK     include/generated/bounds.h
  CHK     include/generated/asm-offsets.h
  CALL    scripts/checksyscalls.sh
make[2]: 'include/generated/vdso-offsets.h' is up to date.
  Building modules, stage 2.
  MODPOST 1 modules
Pack to resource.img successed!
  Image:  resource.img (with rk3399-firefly-aio.dtb logo.bmp ) is ready
  Image:  boot.img (with Image resource.img) is ready
  Image:  zboot.img (with Image.lz4 resource.img) is ready
/home/lowfree/doc/rk3399_camera/aiork3399j/linux/repo/linux-sdk
====Build kernel ok!====

9. The resulting boot.img burned to aio-3399j

Note that using Android programming tool v2.58, there is no kernel and information resource can only be programmed to boot.img

Here Insert Picture Description

Published 47 original articles · won praise 108 · views 80000 +

Guess you like

Origin blog.csdn.net/Lagrantaylor/article/details/103495540