Add wilc3000 driver to Yocto raspberry pi - linux

I want to build my own yocto image for a raspberry (cm3). I use the meta-raspberry (dunfell) layer and poky dunfell-23.0.0.
For installing the microchip wilc3000 module I have to modify the kernel following this guide. In that way, I change the kernel conf (Kconfig) to add the mchp driver in the menu and later selecting it.
I have generated a patch to the kernel using this guide (Patch-based workflow). After generating the patch, I have modified and generated a new kernel config (defconfig). All the changes are applied in my own layer with this recipe (linux-raspberrypi_%.bbappend):
FILESEXTRAPATHS_prepend := "${THISDIR}/patchs:"
SRC_URI += "file://0001-Add-wilc3000-driver.patch \
file://defconfig_my \
"
PACKAGE_ARCH = "${MACHINE_ARCH}"
# PR="r2"
INTREE_DEFCONFIG_pn-linux-ti = "defconfig_my"
kmoddir = "/lib/modules/${KERNEL_VERSION}/kernel/drivers/net/wireless/mchp"
# do_configure_append() {
# cat ${WORKDIR}/*.cfg >> ${B}/.config
# }
do_install_append() {
install -d ${D}${kmoddir}
install -m 0755 ${WORKDIR}/wilc-spi.ko ${D}${kmoddir}
}
FILES_${PN}_append += " \
${kmoddir}/wilc-spi.ko \
"
The patchs folder contains the patch for the kernel and the new kernel configuration generated
When I generate the image:
bitbake -v core-image-base
The generation fails in do_install task when it tries to copy wilc-spi.ko, which is not generated.
Which is the way to compile and deploy the kernel with my own configuration? if I download and compile the kernel in a separate folder, it successfully generates the wilc-spi.ko, but inside build folder in yocto there is no trace of the file generation.
Please, help me to add this driver to the kernel, Thanks a lot.

As #qschulz pointed out, the solution was to change defconfig_my to defconfig and remove all the extra code. Finally, the code looks like this:
FILESEXTRAPATHS_prepend := "${THISDIR}/patchs:"
SRC_URI += "file://0001-Add-wilc3000-driver.patch \
file://defconfig \
"
PACKAGE_ARCH = "${MACHINE_ARCH}"
PR="r3"
FILES_${PN}_append += " \
${kmoddir}/wilc-spi.ko \
"
KERNEL_MODULE_AUTOLOAD += "wilc-spi.ko"
And add in the layer.conf the instruction to load the module:
MACHINE_EXTRA_RDEPENDS += " kernel-module-wilc-spi "

Related

How to integrate hddimg function to wic image Yocto

I need to create wic image with enable secureboot. Then I changed in local.conf to "IMAGE_FSTYPES = "wic" " then bitbake-core-image-sato-sdk to get the image.
The generated image able to boot but cannot boot with secureboot. I investigated and found that the layer in my meta-secureboot had a secureboot.class. This class was calling do_efi_populate and efi_iso_populate_append .
In this two function contains a line that control to generate bzImage.signed for secureboot. Therefore, there is no way I can change to wic image because this two function stuck with do_efi_populate and efi_iso_populate that only call for iso and hddimg . Do you guys have any idea to call function from hddimg/iso to wic.
Step done:
Create core-image-sato-sdk.bbappend . Then adding:
inherit image_types_wic
do_image_wic[recrdeptask] += "do_efi_iso_populate".
example of secureboot.class:
efi_populate_append() {
#Sign bzImage and deploy as bzImage.signed
sb-keymgmt.py -c sign -kn ${DEPLOY_DIR_IMAGE}/yocto.key -cn ${DEPLOY_DIR_IMAGE}/yocto.crt -
usf ${DEPLOY_DIR_IMAGE}/bzImage -sf ${DEPLOY_DIR_IMAGE}/bzImage.signed
install -m 0644 ${DEPLOY_DIR_IMAGE}/bzImage.signed ${DEST}/bzImage.signed}
efi_iso_populate_append()
iso_dir=$1
efi_populate $iso_dir
# Build a EFI directory to create efi.img
mkdir -p ${EFIIMGDIR}/${EFIDIR}
cp $iso_dir/${EFIDIR}/* ${EFIIMGDIR}${EFIDIR}

Yocto Bitbake doesn't include kernel config fragment in build

I am currently trying to setup docker on my yocto (thud - 2.6) project. For that, I need to enable some kernel configuration.
The problem is that the kernel config fragment is not included in the build.
To include the config fragment I created a custom layer with the following structure
meta-edge_controller
|__conf
| |__layer.conf
|__recipes-kernel
|__linux
|__linux-intel
| |__docker_required.cfg
|__linux-intel_4.14.bbappend
linux-intel_4.14.bbappend
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
SRC_URL += "file://docker_required.cfg"
docker_required.cfg
CONFIG_CGROUP_DEVICE=y
CONFIG_IP_MULTICAST=y
CONFIG_IP_ADVANCED_ROUTER=y
CONFIG_NETFILTER=y
CONFIG_NF_CONNTRACK=y
CONFIG_NF_TABLES=y
CONFIG_NF_NAT=y
CONFIG_NETFILTER_XT_MATCH_ADDRTYPE=y
CONFIG_NETFILTER_XT_MATCH_COMMENT=y
CONFIG_NETFILTER_XT_MATCH_HL=y
CONFIG_NETFILTER_XT_MATCH_IPRANGE=y
CONFIG_NETFILTER_XT_MATCH_LIMIT=y
CONFIG_NETFILTER_XT_MATCH_MULTIPORT=y
CONFIG_NETFILTER_XT_MATCH_RECENT=y
CONFIG_IP_VS=y
CONFIG_NF_TABLES_IPV4=y
CONFIG_IP_NF_IPTABLES=y
CONFIG_IP_NF_NAT=y
CONFIG_IP_NF_FILTER=y
CONFIG_IP_NF_MANGLE=y
CONFIG_IP6_NF_IPTABLES=y
CONFIG_IP6_NF_FILTER=y
CONFIG_IP6_NF_MANGLE=y
CONFIG_BTRFS_FS=y
CONFIG_OVERLAY_FS=y
I am builing for an Intel based Board (Atom E3940) and I have integrated the meta-intel layer, using the machine type "intel-corei7-64".
How can I further debug or investigate why bitbake doesn't include the kernel config fragment?
I also tried rebuilding the kernel manually: bitbake -c cleanall linux-intel and bitbake linux-intel
I see a typo in your snippet. SRC_URL should be SRC_URI instead. More info here.

Kernel Build Caching/Nondeterminism

I run a CI server which I use to build a custom linux kernel. The CI server is not powerful and has a time limit of 3h per build. To work within this limit, I had the idea to cache kernel builds using ccache. My hope was that I could create a cache once every minor version release and reuse it for the patch releases e.g. I have a cache I made for 4.18 which I want to use for all 4.18.x kernels.
After removing the build timestamps, this works great for the exact kernel version I am building for. For the 4.18 kernel referenced above, building that on the CI gives the following statistics:
$ ccache -s
cache directory
primary config
secondary config (readonly) /etc/ccache.conf
stats zero time Thu Aug 16 14:36:22 2018
cache hit (direct) 17812
cache hit (preprocessed) 38
cache miss 0
cache hit rate 100.00 %
called for link 3
called for preprocessing 29039
unsupported code directive 4
no input file 2207
cleanups performed 0
files in cache 53652
cache size 1.4 GB
max cache size 5.0 GB
Cache hit rate of 100% and an hour to complete the build, fantastic stats and as expected.
Unfortunately, when I try to build 4.18.1, I get
cache directory
primary config
secondary config (readonly) /etc/ccache.conf
stats zero time Thu Aug 16 10:36:22 2018
cache hit (direct) 0
cache hit (preprocessed) 233
cache miss 17658
cache hit rate 1.30 %
called for link 3
called for preprocessing 29039
unsupported code directive 4
no input file 2207
cleanups performed 0
files in cache 90418
cache size 2.4 GB
max cache size 5.0 GB
That's a 1.30% hit rate and the build time reflects this poor performance. That from only a single patch version change.
I would have expected the caching performance to degrade over time but not to this extent, so my only thought is that there is more non-determinism than simply the timestamp. For example, are most/all of the source files including the full kernel version string? My understanding is that something like that would break the caching completely. Is there a way to make the caching work as I'd like it to or is it impossible?
There is include/generated/uapi/linux/version.h header (generated in the top Makefile https://elixir.bootlin.com/linux/v4.16.18/source/Makefile)
which includes exact kernel version as macro:
version_h := include/generated/uapi/linux/version.h
old_version_h := include/linux/version.h
define filechk_version.h
(echo \#define LINUX_VERSION_CODE $(shell \
expr $(VERSION) \* 65536 + 0$(PATCHLEVEL) \* 256 + 0$(SUBLEVEL)); \
echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))';)
endef
$(version_h): $(srctree)/Makefile FORCE
$(call filechk,version.h)
$(Q)rm -f $(old_version_h)
So, version.h for linux 4.16.18 will be generated like (266258 is (4 << 16) + (16 << 8) + 18 = 0x41012)
#define LINUX_VERSION_CODE 266258
#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
Later, for example in module building there should be way to read LINUX_VERSION_CODE macro value https://www.tldp.org/LDP/lkmpg/2.4/html/lkmpg.html (4.1.6. Writing Modules for Multiple Kernel Versions)
The way to do this to compare the macro LINUX_VERSION_CODE to the macro KERNEL_VERSION. In version a.b.c of the kernel, the value of this macro would be 2^{16}a+2^{8}b+c. Be aware that this macro is not defined for kernel 2.0.35 and earlier, so if you want to write modules that support really old kernels
How version.h is included? The sample module includes <linux/kernel.h> <linux/module.h> and <linux/modversions.h>, and one of these files probably indirectly includes global version.h. And most or even all kernel sources will include version.h.
When your build timestamps were compared, version.h may be regenerated and disables ccache. When timestamps are ignored, LINUX_VERSION_CODE is same only for exactly same linux kernel version, and it is changed for next patchlevel.
Update: Check gcc -H output of some kernel object compilation, there will be another header with full kernel version macro definition. For example: include/generated/utsrelease.h (UTS_RELEASE macro), include/generated/autoconf.h (CONFIG_VERSION_SIGNATURE).
Or even do gcc -E preprocessing of same kernel object compilation between two patchlevels and compare the generated text. With simplest linux module I have -include ./include/linux/kconfig.h directly in gcc command line, and its includes include/generated/autoconf.h (but this is not visible in -H output, is it bug or feature of gcc?).
https://patchwork.kernel.org/patch/9326051/
... because the top Makefile forces to include it with:
-include $(srctree)/include/linux/kconfig.h
It actually does: https://elixir.bootlin.com/linux/v4.16.18/source/Makefile
# Use USERINCLUDE when you must reference the UAPI directories only.
USERINCLUDE := \
-I$(srctree)/arch/$(SRCARCH)/include/uapi \
-I$(objtree)/arch/$(SRCARCH)/include/generated/uapi \
-I$(srctree)/include/uapi \
-I$(objtree)/include/generated/uapi \
-include $(srctree)/include/linux/kconfig.h
# Use LINUXINCLUDE when you must reference the include/ directory.
# Needed to be compatible with the O= option
LINUXINCLUDE := \
-I$(srctree)/arch/$(SRCARCH)/include \
-I$(objtree)/arch/$(SRCARCH)/include/generated \
$(if $(KBUILD_SRC), -I$(srctree)/include) \
-I$(objtree)/include \
$(USERINCLUDE)
LINUXINCLUDE is exported to env and used in source/scripts/Makefile.lib to define compiler flags https://elixir.bootlin.com/linux/v4.16.18/source/scripts/Makefile.lib
c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE)

How to put an extra file in the kernel image by yocto

I have a trouble of putting my initramfs.cpio in my kernel image by yocto.
I have two bb files, one is used to build an initramfs, and the other one is used to build a fitimage.
I successful to build the fitimage bundled with my initramfs image.
But it always failed to build a fitImage that has an initramfs.cpio.gz in the /usr directory in the fitImage.
( I mean, I want to see a file named initramfs.cpio in the /usr when I use my fitImage booting to console )
====================================================================
Here are my error message..
ERROR: linux-mine-1_4.9.27+gitAUTOINC+d87116e608-r0 do_package: QA Issue: linux-mine: Files/directories were installed but not shipped in any package:
/usr
/usr/initramfs-mine-qemu.cpio
Please set FILES such that these items are packaged. Alternatively if they are unneeded, avoid installing them or delete them within do_install.
linux-mine: 2 installed and not shipped files. [installed-vs-shipped]
ERROR: linux-mine-1_4.9.27+gitAUTOINC+d87116e608-r0 do_package: Fatal QA errors found, failing task.
ERROR: linux-mine-1_4.9.27+gitAUTOINC+d87116e608-r0 do_package: Function failed: do_package
ERROR: Logfile of failure stored in: /home/paul/projects/Test/yocto/build/tmp/work/mine-poky-linux-gnueabi/linux-mine/1_4.9.27+gitAUTOINC+d87116e608-r0/temp/log.do_package.26149
ERROR: Task (/home/paul/projects/Test/yocto/yocto-2.2/poky/../meta-mine/recipes-kernel/linux/linux-mine_4.9.bb:do_package) failed with exit code '1'
====================================================================
Here is my kernel image bb file
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}-${PV}:"
LINUX_VERSION ?= "4.9.27"
SRCREV = "d87116e608e94ad684b5e94d46c892e33b9e2d78"
SRC_URI = "git://local/kernel;protocol=ssh;branch=master"
#FILES_${PN} += "/usr /usr/initramfs-mine-${MACHINE_ARCH}.cpio"
#FILES_${PN}-${PV} += "/usr /usr/initramfs-mine-${MACHINE_ARCH}.cpio"
#IMAGE_INSTALL = "initramfs-mine"
do_install_append () {
echo "WangPaul : S=[${S}]"
echo "WangPaul : B=[${B}]"
echo "WangPaul : D=[${D}]"
install -d ${D}/usr/
install -m 0444 ${B}/usr/initramfs-mine-${MACHINE_ARCH}.cpio ${D}/usr/
}
====================================================================
Here is my initramfs bb file
LICENSE = "GPLv2"
PACKAGE_INSTALL = "initramfs-live-boot ${VIRTUAL-RUNTIME_base-utils} udev ${ROOTFS_BOOTSTRAP_INSTALL}"
IMAGE_FSTYPES = "${INITRAMFS_FSTYPES}"
inherit core-image
====================================================================
I have found similar questions:
Ship extra files in kernel module recipe and
An example of using FILES_${PN}
The way in aboves discussion are not work...
Any information would be appreciate !!
Thanks !!
The error seems to QA issues it means the source is compiled but not adding to rootfs. Add below line to yourkernel-image.bb. it will solve the issue.
FILES_${PN} += "${exec_prefix}/*"
Note: may be In your kernel.bb file you have given wrong format

mkbundle System.ComponentModel.Win32Exception error

I'm trying to bundle an application I've made in monodevelop on archlinux.
Once I build the application in monodevelop I go to make a bundle with the following command:
mkbundle --deps file.exe --static
But the output is:
OS is: Linux
Note that statically linking the LGPL Mono runtime has more licensing restrictions than dynamically linking.
See http://www.mono-project.com/Licensing for details on licensing.
Sources: 1 Auto-dependencies: True
embedding: /home/test/Test/Test/bin/Release/file.exe
embedding: /usr/lib/mono/gac/gtk-sharp/2.12.0.0__35e10195dab3c99f/gtk-sharp.dll
config from: /usr/lib/mono/gac/gtk-sharp/2.12.0.0__35e10195dab3c99f/gtk-sharp.dll.config
embedding: /usr/lib/mono/4.5/mscorlib.dll
embedding: /usr/lib/mono/gac/gdk-sharp/2.12.0.0__35e10195dab3c99f/gdk-sharp.dll
config from: /usr/lib/mono/gac/gdk-sharp/2.12.0.0__35e10195dab3c99f/gdk-sharp.dll.config
embedding: /usr/lib/mono/gac/glib-sharp/2.12.0.0__35e10195dab3c99f/glib-sharp.dll
config from: /usr/lib/mono/gac/glib-sharp/2.12.0.0__35e10195dab3c99f/glib-sharp.dll.config
embedding: /usr/lib/mono/gac/System/4.0.0.0__b77a5c561934e089/System.dll
embedding: /usr/lib/mono/gac/Mono.Security/4.0.0.0__0738eb9f132ed756/Mono.Security.dll
embedding: /usr/lib/mono/gac/System.Configuration/4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
embedding: /usr/lib/mono/gac/System.Xml/4.0.0.0__b77a5c561934e089/System.Xml.dll
embedding: /usr/lib/mono/gac/System.Security/4.0.0.0__b03f5f7f11d50a3a/System.Security.dll
embedding: /usr/lib/mono/gac/Mono.Cairo/4.0.0.0__0738eb9f132ed756/Mono.Cairo.dll
embedding: /usr/lib/mono/gac/pango-sharp/2.12.0.0__35e10195dab3c99f/pango-sharp.dll
config from: /usr/lib/mono/gac/pango-sharp/2.12.0.0__35e10195dab3c99f/pango-sharp.dll.config
embedding: /usr/lib/mono/gac/atk-sharp/2.12.0.0__35e10195dab3c99f/atk-sharp.dll
config from: /usr/lib/mono/gac/atk-sharp/2.12.0.0__35e10195dab3c99f/atk-sharp.dll.config
embedding: /usr/lib/mono/gac/Mono.Posix/4.0.0.0__0738eb9f132ed756/Mono.Posix.dll
Compiling:
AS = as (default)
as -o temp.o temp.s
as -o temp.o temp.s
Unhandled Exception:
System.ComponentModel.Win32Exception: ApplicationName='cmd', CommandLine='/c "as -o temp.o temp.s "', CurrentDirectory='', Native error= Cannot find the specified file
at System.Diagnostics.Process.Start_noshell (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process) <0x40c2f420 + 0x00637> in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.ComponentModel.Win32Exception: ApplicationName='cmd', CommandLine='/c "as -o temp.o temp.s "', CurrentDirectory='', Native error= Cannot find the specified file
at System.Diagnostics.Process.Start_noshell (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process) <0x40c2f420 + 0x00637> in <filename unknown>:0
Being that I'm statically linking mono I had to install mono-git from the AUR to ensure I had the static libraries.
I'm also not sure why it has two as -o temp.o temp.s listed.
Any help would be appreciated.
EDIT 23NOV:
I have just re-confirmed that as and cc have been installed. The version output is located at: http://pastebin.com/ka25tjWZ
EDIT 24NOV:
As explained in the accepted answer; my mono wasn't compiled correctly.
I rebuilt using abs with the following PKGBUILD and its now working as expected.
# $Id: PKGBUILD 246414 2015-09-16 21:25:15Z daniel $
# Maintainer: Daniel Isenmann <daniel#archlinux.org>
# Contributor: Brice Carpentier <brice#dlfp.org>
pkgname=mono
pkgver=4.0.4.1
_pkgver=4.0.4
pkgrel=1
pkgdesc="Free implementation of the .NET platform including runtime and compiler"
arch=(i686 x86_64)
license=('GPL' 'LGPL2.1' 'MPL' 'custom:MITX11')
url="http://www.mono-project.com/"
depends=('zlib' 'libgdiplus>=3.8' 'sh' 'python' 'ca-certificates')
options=('!makeflags' 'staticlibs')
provides=('monodoc')
conflicts=('monodoc')
source=(http://download.mono-project.com/sources/mono/${pkgname}-${pkgver}.tar.bz2
mono.binfmt.d
sgen_fix.patch
build_fix.patch
Microsoft.Portable.Common.targets
fix-zlib-helper.patch)
md5sums=('f598b60a664dfebb1a5eef3e66a9a178'
'b9ef8a65fea497acf176cca16c1e2402'
'8a700b94bff7a913f920e95890d2fb4c'
'30a5af1a4ff50b98f9e73cc2ae554115'
'acbffadb0ac233c494b40dd5e79209a5'
'62912ad289535bf841c140727e5c1165')
install="${pkgname}.install"
build() {
cd "${srcdir}"/${pkgname}-${_pkgver}
# build mono
./configure --prefix=/usr \
--sysconfdir=/etc \
--bindir=/usr/bin \
--sbindir=/usr/bin \
--disable-quiet-build \
--disable-system-aot \
--enable-static \
--with-static_mono=yes \
--with-mcs-docs=no
make
# build jay
cd "${srcdir}"/${pkgname}-${_pkgver}/mcs/jay
make
}
package() {
cd "${srcdir}"/${pkgname}-${_pkgver}
make DESTDIR="${pkgdir}" install
# install jay
pushd "${srcdir}"/${pkgname}-${_pkgver}/mcs/jay
make DESTDIR="${pkgdir}" prefix=/usr INSTALL=../../install-sh install
popd
# install binfmt conf file and pathes
install -D -m644 "${srcdir}"/mono.binfmt.d "${pkgdir}"/usr/lib/binfmt.d/mono.conf
#install license
mkdir -p "${pkgdir}"/usr/share/licenses/${pkgname}
install -m644 mcs/MIT.X11 "${pkgdir}"/usr/share/licenses/${pkgname}/
#fix .pc file to be able to request mono on what it depends, fixes #go-oo build
sed -i -e "s:#Requires:Requires:" "${pkgdir}"/usr/lib/pkgconfig/mono.pc
}
Update:
So I ssh'd a friend's ArchLinux and mkbundle works fine there, so I went back to your error:
System.ComponentModel.Win32Exception: ApplicationName='cmd',
CommandLine='/c "as -o temp.o temp.s "', CurrentDirectory='', Native
error= Cannot find the specified file at
System.Diagnostics.Process.Start_noshell
Originally I thought you were on Windows due to this error, but you said Linux so I disregarded it. I went to the source of mkbundle and I can see that your ArchLinux box and/or the Mono install is not correctly reporting the 'IsUnix' as false and thus it is not executing the AS cmd via a system call but is trying to use the Windows' cmd to execute it and thus is failing....
static bool IsUnix {
get {
int p = (int) Environment.OSVersion.Platform;
return ((p == 4) || (p == 128) || (p == 6));
}
}
static void Execute (string cmdLine)
{
if (IsUnix) {
Console.WriteLine (cmdLine);
int ret = system (cmdLine);
if (ret != 0)
{
Again, the ArchLinux 4.2.5-1 that I have access to has Mono 4.0.4.1 and works as expected.....
What is returned on your system for each of these lines?:
int p = (int) Environment.OSVersion.Platform;
var islinux = ((p == 4) || (p == 128) || (p == 6));
Original:
ENVIRONMENT VARIABLES
AS Assembler command. The default is "as".
CC C compiler command. The default is "cc" under Linux and "gcc" under
Windows.
Ref: man mkbundle
This is the same requirement as you would need if you were building mono itself, besides the temp.s assembler code it will also create temp.c file that needs a c compiler. This is the bootstrap code to load/execute your CIL-based code.
If you are missing an assembler on your system, there are a number of packages, such as binutils that will satisfy the requirement.

Resources