From 17e72682044b54e27f2bbb53ced773a711527e56 Mon Sep 17 00:00:00 2001
From: guowenxue <guowenxue@gmail.com>
Date: Mon, 15 Jul 2024 11:30:00 +0800
Subject: [PATCH] Yocto:IGKBoard-All: Add hello application and hello module example recipes
---
yocto/meta-igkboard/recipes-hello/hello-app/files/hello-app.c | 22 +++++++
yocto/meta-igkboard/images/yocto-image-full.bb | 2
yocto/meta-igkboard/recipes-hello/hello-app/hello-app_1.0.bb | 25 ++++++++
yocto/meta-igkboard/recipes-hello/hello-app/files/Makefile | 10 +++
yocto/meta-igkboard/recipes-kernel/hello-mod/files/hello.c | 34 +++++++++++
yocto/meta-igkboard/recipes-kernel/hello-mod/hello-mod.bb | 26 ++++++++
yocto/meta-igkboard/recipes-kernel/hello-mod/files/Makefile | 14 ++++
7 files changed, 132 insertions(+), 1 deletions(-)
diff --git a/yocto/meta-igkboard/images/yocto-image-full.bb b/yocto/meta-igkboard/images/yocto-image-full.bb
index a98c7b4..a437d61 100644
--- a/yocto/meta-igkboard/images/yocto-image-full.bb
+++ b/yocto/meta-igkboard/images/yocto-image-full.bb
@@ -44,7 +44,7 @@
"
CORE_IMAGE_EXTRA_INSTALL_BASE += " \
- kernel-modules \
+ kernel-modules hello-app hello-mod \
firmwared linux-firmware \
powertop tzdata ppp vim \
xz lrzsz rsync dos2unix \
diff --git a/yocto/meta-igkboard/recipes-hello/hello-app/files/Makefile b/yocto/meta-igkboard/recipes-hello/hello-app/files/Makefile
new file mode 100644
index 0000000..17d6a8f
--- /dev/null
+++ b/yocto/meta-igkboard/recipes-hello/hello-app/files/Makefile
@@ -0,0 +1,10 @@
+
+APP_NAME=hello-app
+
+# Must add LDFLAGS, or Yocto will complain about missing GNU_HASH
+${APP_NAME}:
+ ${CC} -o $@ $@.c ${LDFLAGS}
+
+.PHONY: clean
+clean:
+ rm -rf ${APP_NAME}
diff --git a/yocto/meta-igkboard/recipes-hello/hello-app/files/hello-app.c b/yocto/meta-igkboard/recipes-hello/hello-app/files/hello-app.c
new file mode 100644
index 0000000..56cbf42
--- /dev/null
+++ b/yocto/meta-igkboard/recipes-hello/hello-app/files/hello-app.c
@@ -0,0 +1,22 @@
+/*********************************************************************************
+ * Copyright: (C) 2024 LingYun IoT System Studio.
+ * All rights reserved.
+ *
+ * Filename: hello.c
+ * Description: This file is hello example application build in yocto
+ *
+ * Version: 1.0.0(2024/07/14)
+ * Author: Guo Wenxue <guowenxue@gmail.com>
+ * ChangeLog: 1, Release initial version on "2024/07/14 10:34:45"
+ *
+ ********************************************************************************/
+
+#include <stdio.h>
+
+int main (int argc, char **argv)
+{
+ printf("Hello, LingYun IoT System Studio!\n");
+
+ return 0;
+}
+
diff --git a/yocto/meta-igkboard/recipes-hello/hello-app/hello-app_1.0.bb b/yocto/meta-igkboard/recipes-hello/hello-app/hello-app_1.0.bb
new file mode 100644
index 0000000..bcba75d
--- /dev/null
+++ b/yocto/meta-igkboard/recipes-hello/hello-app/hello-app_1.0.bb
@@ -0,0 +1,25 @@
+SUMMARY = "My Custom Hello Example Application"
+
+# Linces file is in poky/meta/files/common-licenses/ and use `md5sum` command to get the MD5 value
+LICENSE = "GPL-2.0-or-later"
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/GPL-2.0-or-later;md5=fed54355545ffd980b814dab4a3b312c"
+
+# recipe version
+PV = "1"
+PR = "r0"
+
+# There is /usr/bin/hello link to hello.lmbench, so can not use application name 'hello' here
+SRC_URI = "file://hello-app.c \
+ file://Makefile \
+ "
+
+S = "${WORKDIR}"
+
+do_compile() {
+ make
+}
+
+do_install() {
+ install -d ${D}${bindir}
+ install -m 0755 hello-app ${D}${bindir}/
+}
diff --git a/yocto/meta-igkboard/recipes-kernel/hello-mod/files/Makefile b/yocto/meta-igkboard/recipes-kernel/hello-mod/files/Makefile
new file mode 100644
index 0000000..4ded35f
--- /dev/null
+++ b/yocto/meta-igkboard/recipes-kernel/hello-mod/files/Makefile
@@ -0,0 +1,14 @@
+obj-m := hello.o
+
+SRC := $(shell pwd)
+
+all:
+ $(MAKE) -C $(KERNEL_SRC) M=$(SRC)
+
+modules_install:
+ $(MAKE) -C $(KERNEL_SRC) M=$(SRC) modules_install
+
+clean:
+ rm -f *.o *~ core .depend .*.cmd *.ko *.mod.c
+ rm -f Module.markers Module.symvers modules.order
+ rm -rf .tmp_versions Modules.symvers
diff --git a/yocto/meta-igkboard/recipes-kernel/hello-mod/files/hello.c b/yocto/meta-igkboard/recipes-kernel/hello-mod/files/hello.c
new file mode 100644
index 0000000..772988e
--- /dev/null
+++ b/yocto/meta-igkboard/recipes-kernel/hello-mod/files/hello.c
@@ -0,0 +1,34 @@
+/*********************************************************************************
+ * Copyright: (C) 2024 LingYun IoT System Studio.
+ * All rights reserved.
+ *
+ * Filename: hello.c
+ * Description: This file is hello example kernel module build in yocto
+ *
+ * Version: 1.0.0(2024/07/14)
+ * Author: Guo Wenxue <guowenxue@gmail.com>
+ * ChangeLog: 1, Release initial version on "2024/07/14 10:34:45"
+ *
+ ********************************************************************************/
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+
+int hello_init(void)
+{
+ printk("Hello, hello-module loaded!\n");
+ return 0;
+}
+
+void hello_exit(void)
+{
+ printk("Goodbye, hello-module unloaded!\n");
+}
+
+module_init(hello_init);
+module_exit(hello_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Guo Wenxue");
+MODULE_DESCRIPTION("A Simple Hello Kernel Module");
diff --git a/yocto/meta-igkboard/recipes-kernel/hello-mod/hello-mod.bb b/yocto/meta-igkboard/recipes-kernel/hello-mod/hello-mod.bb
new file mode 100644
index 0000000..f6694a5
--- /dev/null
+++ b/yocto/meta-igkboard/recipes-kernel/hello-mod/hello-mod.bb
@@ -0,0 +1,26 @@
+SUMMARY = "My Custom Linux Kernel Hello Module"
+DESCRIPTION = "${SUMMARY}"
+
+LICENSE = "GPLv2"
+LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/GPL-2.0-only;md5=801f80980d171dd6425610833a22dbe6"
+
+SRC_URI = "file://Makefile \
+ file://hello.c \
+ "
+
+S = "${WORKDIR}"
+
+inherit module
+
+KERNEL_MODULE_AUTOLOAD = "hello"
+
+do_compile() {
+ unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS
+ oe_runmake -C ${STAGING_KERNEL_DIR} M=${S}
+}
+
+do_install() {
+ install -d ${D}${base_libdir}/modules/${KERNEL_VERSION}/extra
+ install -m 0644 ${S}/hello.ko ${D}${base_libdir}/modules/${KERNEL_VERSION}/extra/
+}
+
--
Gitblit v1.9.1