From 9e937cc7b61f38c774df5a003048eefbf6186a51 Mon Sep 17 00:00:00 2001 From: guowenxue <guowenxue@gmail.com> Date: Sat, 18 Dec 2021 13:42:27 +0800 Subject: [PATCH] add hello driver module and makefile --- bsp/drivers/users/hello.c | 35 +++++++++++++++++ bsp/drivers/users/Makefile | 39 +++++++++++++++++++ 2 files changed, 74 insertions(+), 0 deletions(-) diff --git a/bsp/drivers/users/Makefile b/bsp/drivers/users/Makefile new file mode 100644 index 0000000..46bdd9d --- /dev/null +++ b/bsp/drivers/users/Makefile @@ -0,0 +1,39 @@ +#********************************************************************************* +# Copyright: (C) 2021 LingYun IoT System Studio <www.weike-iot.com> +# All rights reserved. +# +# Filename: Makefile +# Description: This Makefile used to compile all the drivers here +# +# Version: 1.0.0(18/12/2021~) +# Author: Guo Wenxue <guowenxue@gmail.com> +# ChangeLog: 1, Release initial version on "18/12/2021 01:29:33 PM" +# +#********************************************************************************/ + +CROSS_COMPILE=/opt/buildroot/cortexA7/bin/arm-linux- + +LINUX_SRC = ${shell pwd}/../../kernel/linux-imx/ +DRV_INSTPATH = ${shell pwd}/../../rootfs/driver/ + +EXTRA_INSTPATH=/tftp + +PWD := $(shell pwd) + +obj-m += hello.o + +modules: + @echo ${LINUX_SRC} + @make -C $(LINUX_SRC) M=$(PWD) modules + @make -C $(LINUX_SRC) M=$(PWD) modules_install INSTALL_MOD_PATH=${DRV_INSTPATH} INSTALL_MOD_STRIP=1 + @make clear + +install: + cp -af *.ko ${EXTRA_INSTPATH} + +clear: + @rm -f *.o *.mod* .*.cmd *.symvers *.order + +clean: clear + @rm -f *.ko + diff --git a/bsp/drivers/users/hello.c b/bsp/drivers/users/hello.c new file mode 100644 index 0000000..49acb63 --- /dev/null +++ b/bsp/drivers/users/hello.c @@ -0,0 +1,35 @@ +/********************************************************************************* + * Copyright: (C) 2021 LingYun IoT System Studio <www.weike-iot.com> + * All rights reserved. + * + * Filename: hello.c + * Description: This file is the linux kernel sample hello module + * + * Version: 1.0.0(18/12/2021~) + * Author: Guo Wenxue <guowenxue@gmail.com> + * ChangeLog: 1, Release initial version on "18/12/2021 10:50:26 AM" + * + ********************************************************************************/ + +#include <linux/init.h> +#include <linux/module.h> +#include <linux/kernel.h> + +static __init int hello_init(void) +{ + printk(KERN_ALERT "Hello, LingYun IoT System Studio!\n"); + return 0; +} + +static __exit void hello_exit(void) +{ + printk(KERN_ALERT "Goodbye, I have found a good job!\n"); +} + +module_init(hello_init); +module_exit(hello_exit); + +MODULE_AUTHOR("GuoWenxue <guowenxue@gmail.com>"); +MODULE_DESCRIPTION("Linux Kernel hello module"); +MODULE_LICENSE("Dual BSD/GPL"); +MODULE_INFO(intree, "Y"); -- Gitblit v1.9.1