error message "-mrecord-mcount" when cross-compile out of kernel module - linux

I'm trying to build an out-of-kernel module and cross-compile it.
So, I'm working on VM, Ubuntu, and I upgraded the running kernel to 5.15.6.
Now, I'm trying to cross-compile my very simple "Hello world" module.
Its Makefile is simply:
obj-m += yanivModule.o
and the building command is:
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -C /lib/modules/5.15.6/build/ M=$PWD modules
and I keep running into this error message:
arm-linux-gnueabihf-gcc: error: unrecognized command line option ‘-mrecord-mcount’; did you mean ‘-frecord-marker=4’?
Does anyone know what "-mrecord-mcount" means how to fix it?
I tried to disable the "CONFIG_FTRACE_MCOUNT_RECORD" and "CONFIG_HAVE_FTRACE_MCOUNT_RECORD" configuration flag as I read somewhere it might be related (and by name it actually might be), but it didn't solve the error.
I'm kind of lost here since in the tutorial video I'm following, it's done with no issues at all.
Update:
I managed to fix the issue, but I'm not sure why it got fixed that way, and why the way I described before didn't work.
I downloaded the kernel of beaglebone board from github:
https://github.com/beagleboard/linux/tree/5.10
and then built it using:
make ARCH=arm bb.org_defconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- C /home/.../beaglebone-linux-5.10/ M=$PWD modules
and only then, building the module, when -C is the new downloaded kernel tree - has succeeded with no issues.
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -C /home/.../beaglebone-linux-5.10/ M=$PWD modules
So now, I'm left with 2 questions:
What, step fixed the issue and what was missing from the previous way I tried? was it using the bb.org_defconfig configuration file?
Why this bb.org_defconfig configuration file is missing from the latest Linux kernel source tree?

Related

Arch Linux: make - no such file or directory

I have a problem by compiling a driver (WLAN-dongle Edimax ac600).
I´m using an Archlinux on my raspberry-pi and want to install my dongle for 5Ghz. During comiling the driver I get this message. I tried to install the linux-headers without success. (in other threads it will be a solution)
Here is my output of make:
[root#raspberry_pi_1 rtl8812AU]# make make ARCH=arm CROSS_COMPILE= -C
/lib/modules/4.9.43-1-ARCH/build M=/root/rtl8812AU modules make[1]:
*** /lib/modules/4.9.43-1-ARCH/build: No such file or directory. Stop. make: *** [Makefile:1576: modules] Error 2
I found out that my pi has a two-arch...-directories:
4.9.43-1-ARCH/
4.9.51-1-ARCH/
Only the second one has the build directory...
How can I fix the problem?!
thanks a lot,
a Linux noob...
[Reputation is too low to post comment]
Use uname -r to make sure which version of the kernel you use.
If it's 4.9.43 : you have newer version of the kernel and this confuse your installer. You should reboot on the 51 one
If it's 4.9.51 : You messed up your installation step and are trying to compile for an old target. You should review the compilation process and change every mention of the 4.9.43 to 4.9.51 since it's the version you use.
If you upgrade your kernel, you may have to rebuild the thing again (You may like to have script in the future ;) ) with the new kernel version.

Intel Galileo adding kernel header files to the cross compile toolchain

im on BSP v1.1
yocto is 1.6
I'm trying to set up the cross compile toolchain to compile character driver code
but the output i get is
[mark#localhost ~]$ ${CC} first.c -o first
first.c:1:24: fatal error: linux/init.h: No such file or directory
.#include
^ compilation terminated.
I think the issue is that
the header is not in the toolchain
/opt/iot-devkit/1.6.1/sysroots/i586-poky-linux/usr/include/linux/~
there is no at this location
I think something has to be added as IMAGE_INSTALL or IMAGE_FEATURE but i dont know what
am I on the right track ?
does anyone know what i have to add ?
or am i completely off tracks altogether?
Well, first and foremost, you can never build a kernel module by just running ${CC} on it. You should always use a Makefile, which redirects most of its work to the kernel source Makefil.
Create a Makefile for you module, consisting of something similar to:
obj-m += hello-1.o
all:
make -C $(KERNEL_SRC M=$(PWD) modules
clean:
make -C $(KERNEL_SRC) M=$(PWD) clean
Example taken from The Linux Kernel Module Programming Guide (Note that the actual commands needs to have a tab character for indentation).
Then you'll have to define KERNEL_SRC to be /opt/iot-devkit/1.6.1/sysroots/i586-poky-linux/usr/src/kernel/, either in the Makefile, or from your make call. (Using a variable like KERNEL_SRC will ensure that your module recipe automatically picks the right location when building using bitbake).
To manually build your kernel module:
Source the environment-* file for your SDK.
Go to you modules directory.
KERNEL_SRC=/opt/iot-devkit/1.6.1/sysroots/i586-poky-linux/usr/src/kernel LDFLAGS="" make
However, this will fail, as fixdep can't be found. We'll fix this manually.
cd /opt/iot-devkit/1.6.1/sysroots/i586-poky-linux/usr/src/kernel
make silentoldconfig scripts
Go back to your modules directory.
KERNEL_SRC=/opt/iot-devkit/1.6.1/sysroots/i586-poky-linux/usr/src/kernel LDFLAGS="" make
This should now produce hello.ko which you should be able to insmod on the Galileo board.

cross compile raspberry pi kernel module

So I have been trying to learn more about developing linux drivers with Linux Device Drivers version 3. Using a spare Rasberry Pi (b) I had kicking around.
I used http://www.raspberrypi.org/documentation/linux/kernel/building.md to build the the kernel in my ~/kernelWork/kernel folder. I have also compiled the kernel and have it running on my raspberry pi to avoid compatibility issues.
The issue I have is I know I need to cross compile the module source to work with the ARM architecture, but I'm not sure where to point the -C flag of the command
make -C ~/kernel-2.6 M=`pwd` modules
command to make my module with. I took a look into my arch folder of my kernel, and looked in the ARM directory included there, but from there I'm not sure where to go.
So in short, after I have built my kernel where do I point the -C flag to cross compile my module.
I had to set my Makefile to cross compile with the settings
all:
make ARCH=arm CROSS_COMPILE=${CCPREFIX} -C /home/jacob/kernelWork/kernel M=$(PWD) modules
clean:
make -C /home/jacob/kernelWork/kernel M=$(PWD) clean
As well as setting my environment variables KERNEL_SRC and CCPREFIX to my kernel source, and the raspberry compiler I pulled from the git source. This page has the full details
http://bchavez.bitarmory.com/archive/2013/01/16/compiling-kernel-modules-for-raspberry-pi.aspx

Can't figure out how to compile Linux kernel module

I have been trying to figure out how to compile a kernel module. I started with http://www.tldp.org/LDP/lkmpg/2.6/lkmpg.pdf to learn. I then found Compiling a kernel module, header problems, makefile problems to get my makefile going. After running make. I get the following output:
Building target module 2.6 kernel.
PLEASE IGNORE THE "Overriding SUBDIRS" WARNING
make -C /lib/modules/2.6.32-431.el6.i686/build SUBDIRS=/root/kerntest/hello modules
make[1]: Entering directory `/usr/src/kernels/2.6.32-431.20.3.el6.i686'
Building modules, stage 2.
MODPOST 1 modules
make[1]: Leaving directory `/usr/src/kernels/2.6.32-431.20.3.el6.i686'
I see the .ko file, but don't see any kernel messages showing the module was activated. I also checked in /lib/modules/2.6.32-431.20.3.el6.i686/extra but there is nothing there. I also tried 'dmesg' and 'lsmod' but didn't see it.
Can anyone point me in the right direction?
I am trying this on CentOS 6.5
You need to actually load the module into the kernel after compiling by using insmod or modprobe :)

Trouble Configuring Linux Kernel

I am trying to recompile the Linux kernel, but before I do this, I need to configure it. I use the following command to try to do this:
make ARCH=arm CROSS_COMPILE=arm-xilinx-linux-gnueabi- gconfig
where arm-xilinx-linux-gnueabi- is the prefix of the version of gcc I'm using. Unfortunately, instead of popping up the configuration window, this gives me the message:
make: *** No rule to make target `gconfig'. Stop.
Does anyone know what the problem is?
Is anyone of make xconfig, make gconfig and make menuconfig working?
I guess you aren't on the right kernel directory.
Please read this again: HOWTO compile linux kernel

Resources