Linux Kernel Driver Compilation Error on STM32MP1 - linux

I'm trying to compile a kernel module in Yocto on a STM32MP1 target. I can compile a helloworld example without problem. But as soon as I want to compile following:
#include <linux/platform_device.h>
#include <linux/module.h
#include <linux/types.h>
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Robert W. Oliver II");
MODULE_DESCRIPTION("A simple example Linux module.");
MODULE_VERSION("0.01");
static struct platform_device *pdev;
static int __init fake_eth_add(void)
{
int inst_id = 0;
pdev = platform_device_alloc("fake-eth", inst_id);
return 0;
}
static void __exit fake_eth_put(void)
{
}
module_init(fake_eth_add);
module_exit(fake_eth_put);
I'm getting the following error:
root#txmp-1570:/home/rdm/ethtest# make
make -C /lib/modules/5.7.1/build M=/home/rdm/ethtest modules
make[1]: Entering directory '/lib/modules/5.7.1/build'
MODPOST 1 modules
ERROR: modpost: "platform_device_alloc" [/home/rdm/ethtest/eth-ins.ko] undefined!
make[2]: *** [scripts/Makefile.modpost:94: __modpost] Error 1
make[1]: *** [Makefile:1642: modules] Error 2
make[1]: Leaving directory '/lib/modules/5.7.1/build'
make: *** [Makefile:9: modules] Error 2
The header platform_device.h file is there, but no *.c module as it should be in a platform_device.c file.
My question is, do I need to do any parameter settings in the kernel? If yes, which would it be? So far I didn't find anything with google help regarding platform_device and kernel settings.

Related

Implementing a system call for CPU hotplug

My goal is to implement a system call in linux kernel that enables/disables a CPU core.
First, I implemented a system call that disbales CPU3 in a 4-core system.
The system call code is as follows:
#include <linux/kernel.h>
#include <linux/slab.h>
#include <asm/uaccess.h>
#include <asm/unistd.h>
#include <linux/cpumask.h>
#include <linux/smp.h>
asmlinkage long sys_new_syscall(void)
{
unsigned int cpu3;
set_cpu_online (cpu3, false) ; /* clears the CPU in the cpumask */
printk ("CPU%u is offline\n", cpu3);
return 0;
}
The system call was registered correctly in the kernel and I enabled 'cpu hotplug' feature during kernel configuration. See picture
However, the kernel failed to compile in the last stage and I got this error:
gzip: stdout: No space left on device
E: mkinitramfs failure cpio 141 gzip 1
update-initramfs: failed for /boot/initrd.img-4.6.7-rt13-v7+ with 1.
run-parts: /etc/kernel/postinst.d/initramfs-tools exited with return code 1
arch/arm/boot/Makefile:99: recipe for target 'install' failed
make[1]: *** [install] Error 1
arch/arm/Makefile:333: recipe for target 'install' failed
make: *** [install] Error 2
What am I doing wrong ?
gzip: stdout: No space left on device
This issue has nothing to do with your code. Your /boot filesystem is full.

Killing a process using pid and finding user tied to pid in system call

I'm trying to develop a system call that is able to receive pid as argument, kill the pid and print to the kernel log. So far I have the code below but i get this error when trying to compile the kernel. How do i fix this? And is there a way to find the username of that killed the pid that is to be killed in this case?
kill_log/kill_log.c:2:24: fatal error: signal.h: No such file or directory
compilation terminated.
scripts/Makefile.build:289: recipe for target 'kill_log/kill_log.o' failed
make[1]: * [kill_log/kill_log.o] Error 1
Makefile:968: recipe for target 'kill_log' failed
make: * [kill_log] Error 2
#include <linux/kernel.h>
#include <signal.h>
asmlinkage long sys_kill_log(pid_t pid)
{
kill(pid, SIGUSR1);
printk(KERN_WARNING "The process %d has been killed\n", pid);
return 0;
}
Based on your error message, you're missing signal.h. On debian-based systems, you would need to install libc6-dev.
In regards to retrieving the username, you could try with getpwuid.

'fatal error: linux/compiler-gcc5.h: No such file or directory' during bitbake

I am attempting to run bitbake on a recipe with a non-yocto custom source. Using a linux-yocto source works fine, but when I attempt to use the linux-yocto-custom skeleton file provided by the yocto project files, I run into problems.
My file structure looks a little like this:
meta-test
|
.
.
.
+--recipes-kernel/
|
+--linux/
|
+--linux-yocto-custom_3.16.bb
+--linux-yocto-custom/
|
+--defconfig
Here's my modified skeleton file (linux-yocto-custom_3.16.bb):
inherit kernel
require recipes-kernel/linux/linux-yocto.inc
SRC_URI = "git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git;protocol=git;nocheckout=1;name=machine"
SRC_URI += "file://defconfig"
LINUX_VERSION ?= "3.16"
LINUX_VERSION_EXTENSION_append = "-custom"
SRCREV_test="19583ca584d6f574384e17fe7613dfaeadcdc4a6"
PV = "${LINUX_VERSION}+git${SRCPV}"
COMPATIBLE_MACHINE = "test"
Here's the error log:
DEBUG: Executing shell function do_compile
NOTE: make -j 4 bzImage CC=i586-poky-linux-gcc -fuse-ld=bfd LD=i586-poky-linux-ld.bfd
make[1]: Entering directory `/home/me/poky/build/tmp/work/test-poky-linux/linux-yocto-custom/3.16+gitAUTOINC+19583ca584-r0/linux-test-standard-build'
GEN ./Makefile
scripts/kconfig/conf --silentoldconfig Kconfig
SYSTBL arch/x86/syscalls/../include/generated/asm/syscalls_32.h
SYSHDR arch/x86/syscalls/../include/generated/uapi/asm/unistd_32.h
CHK include/config/kernel.release
SYSHDR arch/x86/syscalls/../include/generated/uapi/asm/unistd_64.h
UPD include/config/kernel.release
SYSHDR arch/x86/syscalls/../include/generated/uapi/asm/unistd_x32.h
GEN ./Makefile
WRAP arch/x86/include/generated/asm/clkdev.h
WRAP arch/x86/include/generated/asm/early_ioremap.h
WRAP arch/x86/include/generated/asm/cputime.h
WRAP arch/x86/include/generated/asm/mcs_spinlock.h
CHK include/generated/uapi/linux/version.h
UPD include/generated/uapi/linux/version.h
CHK include/generated/utsrelease.h
UPD include/generated/utsrelease.h
HOSTCC scripts/kallsyms
HOSTCC scripts/pnmtologo
CC scripts/mod/empty.o
HOSTCC scripts/mod/mk_elfconfig
CC scripts/mod/devicetable-offsets.s
In file included from /home/me/poky/build/tmp/work-shared/test/kernel-source/include/linux/compiler.h:54:0,
from /home/me/poky/build/tmp/work-shared/test/kernel-source/include/uapi/linux/stddef.h:1,
from /home/me/poky/build/tmp/work-shared/test/kernel-source/include/linux/stddef.h:4,
from /home/me/poky/build/tmp/work-shared/test/kernel-source/include/uapi/linux/posix_types.h:4,
from /home/me/poky/build/tmp/work-shared/test/kernel-source/include/uapi/linux/types.h:13,
from /home/me/poky/build/tmp/work-shared/test/kernel-source/include/linux/types.h:5,
from /home/me/poky/build/tmp/work-shared/test/kernel-source/include/linux/mod_devicetable.h:11,
from /home/me/poky/build/tmp/work-shared/test/kernel-source/scripts/mod/devicetable-offsets.c:2:
/home/me/poky/build/tmp/work-shared/test/kernel-source/include/linux/compiler-gcc.h:106:30: fatal error: linux/compiler-gcc5.h: No such file or directory
compilation terminated.
make[4]: *** [scripts/mod/devicetable-offsets.s] Error 1
make[3]: *** [scripts/mod] Error 2
make[3]: *** Waiting for unfinished jobs....
make[2]: *** [scripts] Error 2
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [sub-make] Error 2
make: *** [__sub-make] Error 2
WARNING: /home/me/poky/build/tmp/work/test-poky-linux/linux-yocto-custom/3.16+gitAUTOINC+19583ca584-r0/temp/run.do_compile.32722:1 exit 1 from
exit 1
ERROR: oe_runmake failed
ERROR: Function failed: do_compile (log file is located at /home/me/poky/build/tmp/work/test-poky-linux/linux-yocto-custom/3.16+gitAUTOINC+19583ca584-r0/temp/log.do_compile.32722)
I believe the most relevant portion is this part of the above log:
compiler-gcc.h:106:30: fatal error: linux/compiler-gcc5.h: No such file or directory
I'm really stumped because a file is generated during the build 'compiler-gcc5.h' at location build/tmp/work/test-poky-linux/core-image-test/1.0-r0/rootfs/usr/src/kernel/include/linux/compiler-gcc5.h. What's going on here? It seems to me that this header file's being requested before being fetched but I don't know how to fix that.
As you're fetching the kernel directly from Linus' tree, the 3.16 version does not support building with gcc5.
If you change to instead fetch from git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git, i.e. the stable tree, and change to v3.16.7:
SRC_URI = "git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git;protocol=git;nocheckout=1;name=machine;branch=linux-3.16.y"
SRCREV_test = "d0335e4feea0d3f7a8af3116c5dc166239da7521"
then you should be able to build the kernel without any issue.

Missing soft link to linux source tree

In /lib/modules/xx.xx.xx-xx there is supposed to be two soft links one called source and one called build. The source one is there and its fine but the build one is missing and I have no idea where it is supposed to point to and I need to install a driver for my video card. Is there any way to find out where that is supposed to point if so how and where. I know there are a lot of other questions out there but not of them actually discribe where they are supposed to be pointing in the end.
Updated the link and now it is having build errors that I can't fix because I can't even find the struct its talking about
make -C /lib/modules/3.16.0-4-amd64/build M=/home/gibsont/gpuTempDriver modules
make[1]: Entering directory '/usr/src/linux-headers-3.16.0-4-amd64'
Makefile:10: *** mixed implicit and normal rules: deprecated syntax
make[1]: Entering directory `/usr/src/linux-headers-3.16.0-4-amd64'
CC [M] /home/gibsont/gpuTempDriver/base.o
/home/gibsont/gpuTempDriver/base.c: In function ‘_rtl_init_mac80211’:
/home/gibsont/gpuTempDriver/base.c:319:6: error: ‘IEEE80211_HW_BEACON_FILTER’ undeclared (first use in this function)
IEEE80211_HW_BEACON_FILTER |
^
/home/gibsont/gpuTempDriver/base.c:319:6: note: each undeclared identifier is reported only once for each function it appears in
/home/gibsont/gpuTempDriver/base.c:349:4: error: ‘struct ieee80211_hw’ has no member named ‘channel_change_time’
hw->channel_change_time = 100;
^
/home/gibsont/gpuTempDriver/base.c: In function ‘rtl_action_proc’:
/home/gibsont/gpuTempDriver/base.c:858:32: error: ‘struct ieee80211_conf’ has no member named ‘channel’
rx_status.freq = hw->conf.channel->center_freq;
^
/home/gibsont/gpuTempDriver/base.c:859:32: error: ‘struct ieee80211_conf’ has no member named ‘channel’
rx_status.band = hw->conf.channel->band;
^
/home/gibsont/gpuTempDriver/base.c:861:25: error: ‘RX_FLAG_MACTIME_MPDU’ undeclared (first use in this function)
rx_status.flag |= RX_FLAG_MACTIME_MPDU;
^
/home/gibsont/gpuTempDriver/base.c: In function ‘rtl_beacon_statistic’:
/home/gibsont/gpuTempDriver/base.c:1132:2: error: implicit declaration of function ‘compare_ether_addr’ [-Werror=implicit-function-declaration]
if (compare_ether_addr(hdr->addr3, rtlpriv->mac80211.bssid))
^
/home/gibsont/gpuTempDriver/base.c: In function ‘rtl_send_smps_action’:
/home/gibsont/gpuTempDriver/base.c:1414:16: error: ‘struct <anonymous>’ has no member named ‘sta’
info->control.sta = sta;
^
/home/gibsont/gpuTempDriver/base.c:1415:24: error: ‘struct ieee80211_conf’ has no member named ‘channel’
info->band = hw->conf.channel->band;
^
cc1: some warnings being treated as errors
/usr/src/linux-headers-3.16.0-4-common/scripts/Makefile.build:262: recipe for target '/home/gibsont/gpuTempDriver/base.o' failed
make[4]: *** [/home/gibsont/gpuTempDriver/base.o] Error 1
/usr/src/linux-headers-3.16.0-4-common/Makefile:1350: recipe for target '_module_/home/gibsont/gpuTempDriver' failed
make[3]: *** [_module_/home/gibsont/gpuTempDriver] Error 2
Makefile:181: recipe for target 'sub-make' failed
make[2]: *** [sub-make] Error 2
Makefile:8: recipe for target 'all' failed
make[1]: *** [all] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-3.16.0-4-amd64'
Makefile:27: recipe for target 'all' failed
make: *** [all] Error 2
I copied it from the disk because it was a read only and placed it into my home directory.
I feel like this has become a whole new issues or possibly the link is wrong and is causing this issue.
this is mine:
2509142 lrwxrwxrwx 1 root root 37 Apr 24 15:02 build -> /usr/src/linux-headers-3.16.0-4-amd64
actually it's managed by package manager. I install linux headers using apt-get. I think you should do the same, unless you are advanced kernel developer.

What is the replacement of i_blksize member in struct inode?

I am compiling a stackable filesystem wrapfs and i got an error regardign missing member i_blksize in struct inode datastructure ? I looked up and found that after kernel version 2.6 it has been modified significantly and i_blksize has been removed. What is the replacement for that member ?
kunal#Baweja:~/Documents/wrapfs$ make
make -C /lib/modules/3.13.0-40-generic/build SUBDIRS=/home/kunal/Documents/wrapfs modules
make[1]: Entering directory `/usr/src/linux-headers-3.13.0-40-generic'
CC [M] /home/kunal/Documents/wrapfs/fist_wrapfs.o
In file included from /home/kunal/Documents/wrapfs/fist_wrapfs.c:15:0:
/home/kunal/Documents/wrapfs/wrapfs.h: In function ‘fist_copy_attr_all’:
/home/kunal/Documents/wrapfs/wrapfs.h:203:6: error: ‘inode_t’ has no member named ‘i_blksize’
dest->i_blksize = src->i_blksize;
^
/home/kunal/Documents/wrapfs/wrapfs.h:203:23: error: ‘inode_t’ has no member named ‘i_blksize’
dest->i_blksize = src->i_blksize;
^
make[2]: *** [/home/kunal/Documents/wrapfs/fist_wrapfs.o] Error 1
make[1]: *** [_module_/home/kunal/Documents/wrapfs] Error 2
make[1]: Leaving directory `/usr/src/linux-headers-3.13.0-40-generic'
make: *** [all] Error 2
Looks like it was an unnecessary duplicate
inode->i_blksize == (1 << inode->i_blkbits)
Check-out this mailing thread

Resources