linux-yocto: build out-of-tree drivers with SDK
PATCH v2 1/1 linux-yocto: build out-of-tree drivers with SDK
Attached patch enables the compilation
of out-of-tree drivers whilst utilizing
the Yocto built SDK.
--- ...-add-KCFLAGS-to-build-with-Yocto-SDK.patch | 65 +++++++++++++++++++ meta/recipes-kernel/linux/linux-yocto-dev.bb | 4 ++ .../linux/linux-yocto-rt_6.12.bb | 4 ++ .../linux/linux-yocto-tiny_6.12.bb | 4 ++ meta/recipes-kernel/linux/linux-yocto_6.12.bb | 4 ++ 5 files changed, 81 insertions(+) create mode 100644 meta/recipes-kernel/linux/files/0001-Makefile-add-KCFLAGS-to-build-with-Yocto-SDK.patch
meta/recipes-kernel/linux/files/0001-Makefile-add-KCFLAGS-to-build-with-Yocto-SDK.patch new file +65 -0
@@ -0,0 +1,65 @@ +From e48021f480428b5e34d299261029bfafdf0e3a2f Mon Sep 17 00:00:00 2001 +From: Vincent Davis Jr <[email protected]> +Date: Sun, 11 May 2025 19:57:46 -0400 +Subject: [PATCH] Makefile: add KCFLAGS to build with Yocto SDK + +Upstream-Status: Pending + +When running + +make -C \ +"${SDKTARGETSYSROOT}/lib/modules/<kernel version>/build" \ +modules_prepare + +Issues that are encountered include + +make -f ./Makefile syncconfig +make -f ./scripts/Makefile.build obj=scripts/basic + 92 | #include <sys/types.h> + | ^~~~~~~~~~~~~ +compilation terminated. + +ld: cannot find Scrt1.o: No such file or directory +ld: cannot find crti.o: No such file or directory +ld: cannot find crtbeginS.o: No such file or directory +ld: cannot find -lgcc: No such file or directory +ld: cannot find -lgcc_s: No such file or directory +ld: cannot find -lc: No such file or directory +ld: cannot find -lgcc: No such file or directory +ld: cannot find -lgcc_s: No such file or directory +ld: cannot find crtendS.o: No such file or directory +ld: cannot find crtn.o: No such file or directory + +Solved by setting KCFLAGS as the yocto project SDK +KCFLAGS is set to --sysroot="${SDKTARGETSYSROOT}". + +Signed-off-by: Vincent Davis Jr <[email protected]> +--- + Makefile | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/Makefile b/Makefile +index 64c514f4bc19..bbe7b0503841 100644 +--- a/Makefile ++++ b/Makefile +@@ -459,7 +459,7 @@ HOSTRUSTC = rustc + HOSTPKG_CONFIG = pkg-config + + KBUILD_USERHOSTCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes \ +- -O2 -fomit-frame-pointer -std=gnu11 ++ -O2 -fomit-frame-pointer -std=gnu11 $(KCFLAGS) + KBUILD_USERCFLAGS := $(KBUILD_USERHOSTCFLAGS) $(USERCFLAGS) + KBUILD_USERLDFLAGS := $(USERLDFLAGS) + +@@ -491,7 +491,7 @@ KBUILD_HOSTCXXFLAGS := -Wall -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS) \ + -I $(srctree)/scripts/include + KBUILD_HOSTRUSTFLAGS := $(rust_common_flags) -O -Cstrip=debuginfo \ + -Zallow-features= $(HOSTRUSTFLAGS) +-KBUILD_HOSTLDFLAGS := $(HOST_LFS_LDFLAGS) $(HOSTLDFLAGS) ++KBUILD_HOSTLDFLAGS := $(HOST_LFS_LDFLAGS) $(HOSTLDFLAGS) $(KCFLAGS) + KBUILD_HOSTLDLIBS := $(HOST_LFS_LIBS) $(HOSTLDLIBS) + KBUILD_PROCMACROLDFLAGS := $(or $(PROCMACROLDFLAGS),$(KBUILD_HOSTLDFLAGS)) + +-- +2.43.0 +
meta/recipes-kernel/linux/linux-yocto-dev.bb +4 -0
@@ -20,6 +20,10 @@ KMETA = "kernel-meta" SRC_URI = "git://git.yoctoproject.org/linux-yocto-dev.git;branch=${KBRANCH};name=machine;protocol=https \ git://git.yoctoproject.org/yocto-kernel-cache;type=kmeta;name=meta;branch=master;destsuffix=${KMETA};protocol=https" +# Appears to be the only way to build out-of-tree +# kernel drivers with the yocto project SDK. +SRC_URI += "file://0001-Makefile-add-KCFLAGS-to-build-with-Yocto-SDK.patch" + # Set default SRCREVs. Both the machine and meta SRCREVs are statically set # to the korg v3.7 tag, and hence prevent network access during parsing. If # linux-yocto-dev is the preferred provider, they will be overridden to
meta/recipes-kernel/linux/linux-yocto-rt_6.12.bb +4 -0
@@ -20,6 +20,10 @@ SRCREV_meta ?= "a50ff542f8d79235030741f9e850d34768907d2d" SRC_URI = "git://git.yoctoproject.org/linux-yocto.git;branch=${KBRANCH};name=machine;protocol=https \ git://git.yoctoproject.org/yocto-kernel-cache;type=kmeta;name=meta;branch=yocto-6.12;destsuffix=${KMETA};protocol=https" +# Appears to be the only way to build out-of-tree +# kernel drivers with the yocto project SDK. +SRC_URI += "file://0001-Makefile-add-KCFLAGS-to-build-with-Yocto-SDK.patch" + LINUX_VERSION ?= "6.12.27" LIC_FILES_CHKSUM = "file://COPYING;md5=6bc538ed5bd9a7fc9398086aedcd7e46"
meta/recipes-kernel/linux/linux-yocto-tiny_6.12.bb +4 -0
@@ -25,6 +25,10 @@ PV = "${LINUX_VERSION}+git" SRC_URI = "git://git.yoctoproject.org/linux-yocto.git;branch=${KBRANCH};name=machine;protocol=https \ git://git.yoctoproject.org/yocto-kernel-cache;type=kmeta;name=meta;branch=yocto-6.12;destsuffix=${KMETA};protocol=https" +# Appears to be the only way to build out-of-tree +# kernel drivers with the yocto project SDK. +SRC_URI += "file://0001-Makefile-add-KCFLAGS-to-build-with-Yocto-SDK.patch" + COMPATIBLE_MACHINE = "^(qemux86|qemux86-64|qemuarm64|qemuarm|qemuarmv5)$" # Functionality flags
meta/recipes-kernel/linux/linux-yocto_6.12.bb +4 -0
@@ -43,6 +43,10 @@ KBRANCH:class-devupstream = "v6.12/base" SRC_URI = "git://git.yoctoproject.org/linux-yocto.git;name=machine;branch=${KBRANCH};protocol=https \ git://git.yoctoproject.org/yocto-kernel-cache;type=kmeta;name=meta;branch=yocto-6.12;destsuffix=${KMETA};protocol=https" +# Appears to be the only way to build out-of-tree +# kernel drivers with the yocto project SDK. +SRC_URI += "file://0001-Makefile-add-KCFLAGS-to-build-with-Yocto-SDK.patch" + LIC_FILES_CHKSUM = "file://COPYING;md5=6bc538ed5bd9a7fc9398086aedcd7e46" LINUX_VERSION ?= "6.12.27"
Signature · 1 line
2.43.0
Hello,
Wanted to propose a method to fix SDK out-of-tree kernel driver compilation problems. Know a patch here may not be the best route as there's zero patches for a reason.
Wanted to know how we want to solve issue described in patch 0001-Makefile-add-KCFLAGS-to-build-with-Yocto-SDK.patch. Or do we want to just document it somewhere for future people?
Attempting to get above patch merged.
Quoted 80 lines · Vincent Davis Jr via lists.openembedded.org
Attached patch enables the compilation
of out-of-tree drivers whilst utilizing
the Yocto built SDK.Signed-off-by Vincent Davis Jr <[email protected]>--- ...-add-KCFLAGS-to-build-with-Yocto-SDK.patch | 65 +++++++++++++++++++ meta/recipes-kernel/linux/linux-yocto-dev.bb | 4 ++ .../linux/linux-yocto-rt_6.12.bb | 4 ++ .../linux/linux-yocto-tiny_6.12.bb | 4 ++ meta/recipes-kernel/linux/linux-yocto_6.12.bb | 4 ++ 5 files changed, 81 insertions(+) create mode 100644
meta/recipes-kernel/linux/files/0001-Makefile-add-KCFLAGS-to-build-with-Yocto-SDK.patchdiff --git
a/meta/recipes-kernel/linux/files/0001-Makefile-add-KCFLAGS-to-build-with-Yocto-SDK.patchb/meta/recipes-kernel/linux/files/0001-Makefile-add-KCFLAGS-to-build-with-Yocto-SDK.patchnew file mode 100644
index 0000000000..edf6a8480f
---/dev/null
+++b/meta/recipes-kernel/linux/files/0001-Makefile-add-KCFLAGS-to-build-with-Yocto-SDK.patchmeta/recipes-kernel/linux/files/0001-Makefile-add-KCFLAGS-to-build-with-Yocto-SDK.patch new file +54
-0@@ -0,0 +1,65 @@ +From e48021f480428b5e34d299261029bfafdf0e3a2f Mon Sep 17 00:00:00 2001 +From: Vincent Davis Jr <[email protected]> +Date: Sun, 11 May 2025 19:57:46 -0400 +Subject: [PATCH] Makefile: add KCFLAGS to build with Yocto SDK + +Upstream-Status: Pending + +When running + +make -C \ +"${SDKTARGETSYSROOT}/lib/modules/<kernel version>/build" \ +modules_prepare + +Issues that are encountered include + +make -f ./Makefile syncconfig +make -f ./scripts/Makefile.build obj=scripts/basic + 92 | #include <sys/types.h> + | ^~~~~~~~~~~~~ +compilation terminated. + +ld: cannot find Scrt1.o: No such file or directory +ld: cannot find crti.o: No such file or directory +ld: cannot find crtbeginS.o: No such file or directory +ld: cannot find -lgcc: No such file or directory +ld: cannot find -lgcc_s: No such file or directory +ld: cannot find -lc: No such file or directory +ld: cannot find -lgcc: No such file or directory +ld: cannot find -lgcc_s: No such file or directory +ld: cannot find crtendS.o: No such file or directory +ld: cannot find crtn.o: No such file or directory + +Solved by setting KCFLAGS as the yocto project SDK +KCFLAGS is set to --sysroot="${SDKTARGETSYSROOT}". + +Signed-off-by: Vincent Davis Jr <[email protected]> +--- + Makefile | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/Makefile b/Makefile +index 64c514f4bc19..bbe7b0503841 100644 +--- a/Makefile ++++ b/Makefile +@@ -459,7 +459,7 @@ HOSTRUSTC = rustc + HOSTPKG_CONFIG = pkg-config + + KBUILD_USERHOSTCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes \ +- -O2 -fomit-frame-pointer -std=gnu11 ++ -O2 -fomit-frame-pointer -std=gnu11 $(KCFLAGS) + KBUILD_USERCFLAGS := $(KBUILD_USERHOSTCFLAGS) $(USERCFLAGS) + KBUILD_USERLDFLAGS := $(USERLDFLAGS) + +@@ -491,7 +491,7 @@ KBUILD_HOSTCXXFLAGS := -Wall -O2 $(HOST_LFS_CFLAGS)$(HOSTCXXFLAGS) \
meta/recipes-kernel/linux/files/0001-Makefile-add-KCFLAGS-to-build-with-Yocto-SDK.patch line 59
Quoted 5 lines
meta/recipes-kernel/linux/files/0001-Makefile-add-KCFLAGS-to-build-with-Yocto-SDK.patch new file +5
-0+ -I $(srctree)/scripts/include + KBUILD_HOSTRUSTFLAGS := $(rust_common_flags) -O -Cstrip=debuginfo \ + -Zallow-features= $(HOSTRUSTFLAGS) +-KBUILD_HOSTLDFLAGS := $(HOST_LFS_LDFLAGS) $(HOSTLDFLAGS) ++KBUILD_HOSTLDFLAGS := $(HOST_LFS_LDFLAGS) $(HOSTLDFLAGS) $(KCFLAGS)
This needs to be explained more.
our eSDK and ontarget building and testing of out of tree kernel modules work fine
without this. The eSDK uses the sysroot, and that is done via the definition of
the compiler.
Is there a reason why that won't work here ?
You could also just overload the HOST_* flags variables versus adding something
completely new.
Quoted 97 lines
+
KBUILD_HOSTLDLIBS:= $(HOST_LFS_LIBS) $(HOSTLDLIBS)
+KBUILD_PROCMACROLDFLAGS:= $(or
$(PROCMACROLDFLAGS),$(KBUILD_HOSTLDFLAGS))meta/recipes-kernel/linux/files/0001-Makefile-add-KCFLAGS-to-build-with-Yocto-SDK.patch new file +4
-0+ +-- +2.43.0 +meta/recipes-kernel/linux/linux-yocto-dev.bb +0
-0@@ -20,6 +20,10 @@ KMETA = "kernel-meta" SRC_URI = "git://git.yoctoproject.org/linux-yocto-dev.git;branch=${KBRANCH};name=machine;protocol=https
<http://git.yoctoproject.org/linux-yocto-dev.git;branch=$%7BKBRANCH%7D;name=machine;protocol=https>\ git://git.yoctoproject.org/yocto-kernel-cache;type=kmeta;name=meta;branch=master;destsuffix=${KMETA};protocol=https
<http://git.yoctoproject.org/yocto-kernel-cache;type=kmeta;name=meta;branch=master;destsuffix=$%7BKMETA%7D;protocol=https>
"meta/recipes-kernel/linux/linux-yocto-dev.bb +3
-0+# Appears to be the only way to build out-of-tree +# kernel drivers with the yocto project SDK. +SRC_URI +="file://0001-Makefile-add-KCFLAGS-to-build-with-Yocto-SDK.patch" +
# Set default SRCREVs. Both the machine and meta SRCREVs are statically
set# to the korg v3.7 tag, and hence prevent network access during parsing. If # linux-yocto-dev is the preferred provider, they will be overridden tometa/recipes-kernel/linux/linux-yocto-rt_6.12.bb +0
-0@@ -20,6 +20,10 @@ SRCREV_meta ?="
a50ff542f8d79235030741f9e850d34768907d2d"
SRC_URI= "git://
git.yoctoproject.org/linux-yocto.git;branch=${KBRANCH};name=machine;protocol=https
<http://git.yoctoproject.org/linux-yocto.git;branch=$%7BKBRANCH%7D;name=machine;protocol=https>\ git://git.yoctoproject.org/yocto-kernel-cache;type=kmeta;name=meta;branch=yocto-6.12;destsuffix=${KMETA};protocol=https
<http://git.yoctoproject.org/yocto-kernel-cache;type=kmeta;name=meta;branch=yocto-6.12;destsuffix=$%7BKMETA%7D;protocol=https>
"meta/recipes-kernel/linux/linux-yocto-rt_6.12.bb +3
-0+# Appears to be the only way to build out-of-tree +# kernel drivers with the yocto project SDK. +SRC_URI +="file://0001-Makefile-add-KCFLAGS-to-build-with-Yocto-SDK.patch"
meta/recipes-kernel/linux/linux-yocto-rt_6.12.bb +1
-0+ LINUX_VERSION ?= "6.12.27" LIC_FILES_CHKSUM = "file://COPYING;md5=6bc538ed5bd9a7fc9398086aedcd7e46"meta/recipes-kernel/linux/linux-yocto-tiny_6.12.bb +0
-0@@ -25,6 +25,10 @@ PV = "${LINUX_VERSION}+git" SRC_URI = "git://git.yoctoproject.org/linux-yocto.git;branch=${KBRANCH};name=machine;protocol=https
<http://git.yoctoproject.org/linux-yocto.git;branch=$%7BKBRANCH%7D;name=machine;protocol=https>\ git://git.yoctoproject.org/yocto-kernel-cache;type=kmeta;name=meta;branch=yocto-6.12;destsuffix=${KMETA};protocol=https
<http://git.yoctoproject.org/yocto-kernel-cache;type=kmeta;name=meta;branch=yocto-6.12;destsuffix=$%7BKMETA%7D;protocol=https>
"meta/recipes-kernel/linux/linux-yocto-tiny_6.12.bb +3
-0+# Appears to be the only way to build out-of-tree +# kernel drivers with the yocto project SDK. +SRC_URI +="file://0001-Makefile-add-KCFLAGS-to-build-with-Yocto-SDK.patch"
meta/recipes-kernel/linux/linux-yocto-tiny_6.12.bb +1
-0+ COMPATIBLE_MACHINE = "^(qemux86|qemux86-64|qemuarm64|qemuarm|qemuarmv5)$" # Functionality flagsmeta/recipes-kernel/linux/linux-yocto_6.12.bb +0
-0@@ -43,6 +43,10 @@ KBRANCH:class-devupstream = "v6.12/base" SRC_URI = "git://git.yoctoproject.org/linux-yocto.git;name=machine;branch=${KBRANCH};protocol=https
<http://git.yoctoproject.org/linux-yocto.git;name=machine;branch=$%7BKBRANCH%7D;protocol=https>\ git://git.yoctoproject.org/yocto-kernel-cache;type=kmeta;name=meta;branch=yocto-6.12;destsuffix=${KMETA};protocol=https
<http://git.yoctoproject.org/yocto-kernel-cache;type=kmeta;name=meta;branch=yocto-6.12;destsuffix=$%7BKMETA%7D;protocol=https>
"meta/recipes-kernel/linux/linux-yocto_6.12.bb +3
-0+# Appears to be the only way to build out-of-tree +# kernel drivers with the yocto project SDK. +SRC_URI +=
Quoted 3 lines
"file://0001-Makefile-add-KCFLAGS-to-build-with-Yocto-SDK.patch" +
linux-yocto patches go to the linux-yocto mailing list for integration.
But I think there are other ways to solve / work around this, so no need to send it there immediately.
Bruce
Quoted 18 lines
LIC_FILES_CHKSUM= "file://COPYING;md5=6bc538ed5bd9a7fc9398086aedcd7e46"LINUX_VERSION?= "6.12.27"--
2.43.0-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#216393):
https://lists.openembedded.org/g/openembedded-core/message/216393
Mute This Topic: https://lists.openembedded.org/mt/113084730/1050810
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
Signature · 3 lines
- Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end - "Use the force Harry" - Gandalf, Star Trek II
Quoted 2 lines · Bruce Ashfield
KBUILD_USERHOSTCFLAGS
Hello this patch may be dropped. May just have been an issue with the way I build the standard SDK in my setup. Cloning poky and building bellow recipe generates a standard SDK who's kernel source tree can be prepared for out-of-tree driver development. Should of tried this first.
Quoted 10 lines
cat >> recipes-sdk/images/base-devel-sdk.bb <<EOF
SUMMARY = "Some Development Standard SDK"
LICENSE = "MIT"
inheritpopulate_sdkTOOLCHAIN_TARGET_TASK+= "kernel-devsrc"
EOF
Quoted 4 lines
KBUILD_USERHOSTCFLAGS="${KCFLAGS}" make -e -C sysroots/core2-64-poky-linux/lib/modules/6.12.27-yocto-standard/build/
modules_prepare
Appears to work for me
Thanks,
Vincent
Correction,
Above gets me to the m2c command which is further
than originally issue.
Probably more an issue on my end.