Hi, Iβm the Toradex AI Assistant.
I might make mistakes. Our support team will step in if needed. If I answered your question, please tick the βSolutionβ checkbox. For follow-up questions to me, please use @ToradexAI in your post.
Did you like my answer?

Creating a Hello World Kernel Module with Yocto
Hello Raju,
Iβll help you create a hello world kernel module for your Verdin AM62 with Mallow carrier board setup. The Mallow carrier board is compatible with the Verdin AM62 module(1), so this configuration is supported.
File Structure and Code
Based on the Toradex documentation(2), hereβs the exact file structure and code you need:
1. Create Meta Layer Structure
First, create your meta layer directory structure(2):
$ cd ../layers/meta-customer/
$ mkdir -p recipes-customer/hello-world/hello-world
(2)
2. Create the Recipe File
Create the recipe file recipes-customer/hello-world/hello-world_1.0.0.bb(2):
# Package summary
SUMMARY = "Hello World"
# License, for example MIT
LICENSE = "MIT"
# License checksum file is always required
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
# hello-world.c from local file
SRC_URI = "file://hello-world.cpp"
# Set LDFLAGS options provided by the build system
TARGET_CC_ARCH += "${LDFLAGS}"
# Change source directory to workdirectory where hello-world.cpp is
S = "${WORKDIR}"
# Compile hello-world from sources, no Makefile
do_compile() {
${CXX} -Wall hello-world.cpp -o hello-world
}
# Install binary to final directory /usr/bin
do_install() {
install -d ${D}${bindir}
install -m 0755 ${S}/hello-world ${D}${bindir}
}
(2)
3. Create the Source Code
Add the hello world source code to recipes-customer/hello-world/hello-world/hello-world.cpp(2):
#include <stdio.h>
int main(int argc, char *argv[]){
printf("Hello world!\n");
return 0;
}
(2)
4. Add Layer to Build Configuration
Add your meta layer to the build/conf/bblayers.conf file(2):
# LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf
# changes incompatibly
LCONF_VERSION = "7"
BBPATH = "${TOPDIR}"
BBFILES ?= ""
BBLAYERS ?= " \
${TOPDIR}/../layers/meta-toradex-nxp \
${TOPDIR}/../layers/meta-freescale \
${TOPDIR}/../layers/meta-freescale-3rdparty \
${TOPDIR}/../layers/meta-toradex-bsp-common \
${TOPDIR}/../layers/meta-openembedded/meta-oe \
${TOPDIR}/../layers/meta-openembedded/meta-filesystems \
${TOPDIR}/../layers/meta-openembedded/meta-gnome \
${TOPDIR}/../layers/meta-openembedded/meta-xfce \
${TOPDIR}/../layers/meta-openembedded/meta-networking \
${TOPDIR}/../layers/meta-openembedded/meta-multimedia \
${TOPDIR}/../layers/meta-openembedded/meta-python \
${TOPDIR}/../layers/meta-freescale-distro \
${TOPDIR}/../layers/meta-toradex-demos \
${TOPDIR}/../layers/meta-qt5 \
${TOPDIR}/../layers/meta-toradex-distro \
${TOPDIR}/../layers/meta-yocto/meta-poky \
${TOPDIR}/../layers/openembedded-core/meta \
${TOPDIR}/../layers/meta-customer \
"
(2)
5. Initialize Git Project (Mandatory for Torizon OS)
Since youβre building for Torizon, initialize your custom layer as a Git project(2):
$ git init
$ git commit -m "Initial Commit" -m "Add <meta-mylayer> from template"
(2)
6. Add Package to Image
To add your hello-world package to the existing multimedia image, append it to the IMAGE_INSTALL variable in your build/conf/local.conf file(2):
IMAGE_INSTALL:append = " hello-world"
(2)
7. Build the Package and Image
Build your package first(2):
$ cd build/
$ bitbake hello-world
(2)
Then build your complete image(2):
$ bitbake <your-image>
(2)
Automatic Module Loading
Once built and deployed, your hello-world binary will be located under /usr/bin/hello-world on the target system(2). Since this is a user-space application rather than a kernel module, it wonβt automatically load at boot like a kernel module would.
If you need to create an actual kernel module that loads automatically at boot, you would need to create a proper Linux kernel module with .ko extension using kernel module development practices.
Best regards,
Toradex AI Assistant.