I am trying to learn kernel programming but while trying to compile a simple hello world program i am getting the following error.
make −C /lib/modules/3.2.0-67-generic/build M=/home/arun/KPrograms modules
make[1]: Entering directory /home/arun/KPrograms'
make[1]: *** No rule to make target−C'. Stop.
make[1]: Leaving directory `/home/arun/KPrograms'
make: * [all] Error 2
my Makefile is
obj−m += hello−1.o
all:
make −C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make −C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
You should replace all the −C in Makefile into -C. The dash character is incorrect.
Hi all,
You must type your code on your own. In some cases copy paste does not work. You must enter it like this:
obj-m............<enter>
all:....<enter>
<tab>make -C.............<enter>
clean:..............<enter>
<tab>make -C...........<esc> <:wq>
That will probably solve your problem.
good luck
Related
I was re-implementing a simple linux file system and got this error when I ran make:
No rule to make target 'arch/x86/entry/syscalls/syscall_32.tbl', needed by 'arch/x86/include/generated/uapi/asm/unistd_32.h'. Stop.
More specifically, the error was like this:
This is my Makefile:
ifneq (${KERNELRELEASE},)
obj-m += evanfs.o
else
KERNEL_SOURCE := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
default:
$(MAKE) -C ${KERNEL_SOURCE} SUBDIRS=$(shell pwd) modules
clean:
rm *.o *.ko
endif
I've seen many similar posts but the solutions provided did not work for me.
Plus, I was actually following instructions from link and it was using kernel 2.6, however, my kernel is 5.15.0-53-generic, so maybe it's a matter of version?
Please help me fix this, thanks in advance!
I've scoured on the Internet and found no solutions that work for me...
I am trying to build a Xilinx XDMA driver for Yocto, using their supplied makefile. When I run my recipe the build fails with the following errors:
DEBUG: Executing shell function do_compile
NOTE: make -j 32 KERNEL_SRC=./tmp/work-shared/intel-corei7-64/kernel-source
KERNEL_PATH=./tmp/work-shared/intel-corei7-64/kernel-source
KERNEL_VERSION=5.10.78-intel-pk-standard CC=x86_64-poky-linux-gcc
-fuse-ld=bfd
-fmacro-prefix-map=./tmp/work/intel_corei7_64-poky-linux/xdma-driver-mod/1.0+gitAUTOINC+8d75946900-r0=/usr/src/debug/xdma-driver-mod/1.0+gitAUTOINC+8d75946900-r0
-fdebug-prefix-map=./tmp/work/intel_corei7_64-poky-linux/xdma-driver-mod/1.0+gitAUTOINC+8d75946900-r0=/usr/src/debug/xdma-driver-mod/1.0+gitAUTOINC+8d75946900-r0
-fdebug-prefix-map=./tmp/work/intel_corei7_64-poky-linux/xdma-driver-mod/1.0+gitAUTOINC+8d75946900-r0/recipe-sysroot=
-fdebug-prefix-map=./tmp/work/intel_corei7_64-poky-linux/xdma-driver-mod/1.0+gitAUTOINC+8d75946900-r0/recipe-sysroot-native=
-fdebug-prefix-map=./tmp/work-shared/intel-corei7-64/kernel-source=/usr/src/kernel LD=x86_64-poky-linux-ld.bfd
AR=x86_64-poky-linux-ar
O=./tmp/work-shared/intel-corei7-64/kernel-build-artifacts KBUILD_EXTRA_SYMBOLS=
Makefile:17: XVC_FLAGS: .
make -C /lib/modules/5.13.0-40-generic/build
M=./tmp/work/intel_corei7_64-poky-linux/xdma-driver-mod/1.0+gitAUTOINC+8d75946900-r0/git/linux_driver/xdma modules
make[1]: Entering directory '/usr/src/linux-headers-5.13.0-40-generic'
make[2]: Entering directory './tmp/work-shared/intel-corei7-64/kernel-build-artifacts'
./tmp/work/intel_corei7_64-poky-linux/xdma-driver-mod/1.0+gitAUTOINC+8d75946900-r0/git/linux_driver/xdma/Makefile:17: XVC_FLAGS: .
CC [M] ./tmp/work/intel_corei7_64-poky-linux/xdma-driver-mod/1.0+gitAUTOINC+8d75946900-r0/git/linux_driver/xdma/libxdma.o
CC [M] ./tmp/work/intel_corei7_64-poky-linux/xdma-driver-mod/1.0+gitAUTOINC+8d75946900-r0/git/linux_driver/xdma/xdma_cdev.o
x86_64-poky-linux-gcc: error: missing argument to '-gdwarf-'
CC [M] ./tmp/work/intel_corei7_64-poky-linux/xdma-driver-mod/1.0+gitAUTOINC+8d75946900-r0/git/linux_driver/xdma/cdev_ctrl.o
make[3]: *** [/usr/src/linux-headers-5.13.0-40-generic/scripts/Makefile.build:281: ./tmp/work/intel_corei7_64-poky-linux/xdma-driver-mod/1.0+gitAUTOINC+8d75946900-r0/git/linux_driver/xdma/libxdma.o] Error 1
make[3]: *** Waiting for unfinished jobs....
x86_64-poky-linux-gcc: error: missing argument to '-gdwarf-'
ERROR: oe_runmake failed
WARNING: exit code 1 from a shell command.
I have no idea why this happens as it is not something I have specifically enabled. I have searched through the module.bbclass file but I couldn't see anything obvious. I believe that something needs to be configured such that the -gdwarf- actual ends up being set to a valid value (e.g. -gdwarf-2 or -gdwarf-4 etc.)
A grep through the poky repo for dwarf did not reveal anything neither did a search of /usr/src/linux-headers-5.13.0-40-generic/scripts/.
My bitbake recipe is as follows:
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://LICENSE;md5=441c1ecbc199a036abf37f3aa47c5f34"
SRC_URI += https://github.com/Xilinx/dma_ip_drivers.git;protocol=ssh;nobranch=1;branch=master"
# Modify these as desired
PV = "1.0+git${SRCPV}"
SRCREV = "8d7594690058dfa828accc02ac81348e416ffe38"
S = "${WORKDIR}/git/xdma/linux-driver/xdma"
RPROVIDES_${PN} += "xdma"
inherit module
EXTRA_OEMAKE_task-install:append = " -C ${STAGING_KERNEL_DIR} M=${S}"
EXTRA_OEMAKE += "KDIR=${STAGING_KERNEL_DIR}"
The makefile is the standard one from GitHub. The driver builds correctly for Ubuntu using make and I can also build the module if I change my recipe such that it does not include inherit module; this change will build the module (xdma.ko) but does to install it in the roofs. I am also not sure if inherit module includes additional functionality which may be rewired.
How to I either:
prevent / disable the -gdwarf flag being generated
configure the recipe that the -gdwarf- resolves to something valid
View the actual command being invoked that is causing the issue.
Attempts to build the xdma.ko module without the inherit module result in an invalid binary being built, i.e. when I try an load the module on the target I get:
insmod xdma.ko
insmod: ERROR: could not insert module xdma.ko: Invalid module format
Which indicates that the module is compiled from the wrong target.
inherit module is required when building kernel modules for Yocto. If it is omitted the build modules is not compatible with the target.
Workaround for the -gdwarf- error was to manually write a new makefile which is compatible with Yocto:
TARGET_MODULE:=xdma
topdir := $(shell cd $(src)/.. && pwd)
EXTRA_CFLAGS := -I$(topdir)/include
SRC := $(shell pwd)
$(TARGET_MODULE)-objs := libxdma.o xdma_cdev.o cdev_ctrl.o cdev_events.o cdev_sgdma.o cdev_xvc.o cdev_bypass.o xdma_mod.o xdma_thread.o
obj-m := $(TARGET_MODULE).o
all :
$(MAKE) -C $(KERNEL_SRC) M=$(SRC)
modules_install:
$(MAKE) -C $(KERNEL_SRC) M=$(SRC) modules_install
clean:
rm -f *.o *~ core .depend .*.cmd *.ko *.mod.c
rm -f Module.markers Module.symvers modules.order
rm -rf .tmp_versions Modules.symvers
This makefile correctly builds the Xilinx XDMA driver for Yocto. I can confirm that the driver works with Kintex-KC705 FPGA development card.
Have you ever experienced a situation when an object file was not present after successful compilation?
Running on windows using gnumake-4.2.1 and gcc-arm-none-eabi-5_4-2016q3 toolchain
I have a makefile which I am not full author of
this is interesting part
DEPFLAGS = -MT $# -MMD -MP -MF $#.d
$(OBJS_OUTPUT_FOLDER)/%.o : %.cpp
#$(CXX) -c $< -o $# $(CFLAGS) $(DEPFLAGS) $(INC_FOLDERS_INT) $(LANGUAGE_STANDARD_CPP) \
&& echo $# OK && $(CP) $# C:/build/
and this is the console output
build/bar.o OK
build/baz.o OK
build/foo.o OK
cp: can't stat 'build/foo.o': No such file or directory
make[1]: *** [Makefile:223: build/foo.o] Error 1
make[1]: *** Waiting for unfinished jobs....
Checking the file system shows that the foo.o really is not present, sometimes other files are missing as well (for example baz.o.d).
I don't really think its fault of the makefile because it gets done eventually (usually on the second to third try without cleaning).
When all of the objects are done I usually get linker error
aaa.hh:183: undefined reference to `MyNamespace::MyFun(short, short, short)'
MyFun is not in bar, baz neither in foo. The object file that should contain MyFun is present, but the size of it is total nonsense (556B), but if I manually delete it (as suggested elsewhere on SO when dealing with undefined references (as a corrupted one)) and make all again it gets done (now the size is around 1.5MB) and creates the binary.
Edit:
As the incorrect files have stable size (well, for the time being it seems so) I have added
#test `wc -c <$#` -ne 556;
to the rule(Checking file size in makefile, stopping if file is too short), this catches the wrong objects (I know specific case) and together with .DELETE_ON_ERROR: I don't have to manually delete the bad ones I find after linking the output of the console in this case is
[ CXX ] build/bar.o
make[1]: *** [Makefile:219: build/bar.o] Error 1
make[1]: *** Deleting file 'build/bar.o'
while in the other case
[ CXX ] build/foo.o
/spt/resources/sh: can't open build/foo.o: no such file
sh: 556: unknown operand
make[1]: *** [Makefile:220: build/foo.o] Error 2
so it probably is not makefile deleting it (I believe it would announce it as in the first case)
Edit2:
After setting a virtual machine (Windows 7) and making the project again (same makefile, same toolchain, same make) it goes smoothly. I guess there really is something on the host computer, maybe an antivirus or some other corporate security software...
Thanks in advance
I wish to access some registers of my ARM Cortex-A8 board which are by default in a non-accessible state. Ubuntu 9.10 runs on this board. So, to access them I have to in-turn change 1 other register settings (Allow-access-register) first. To change this Allow-access-register, I found out that I must do it only in Kernel mode and not in the user mode.
So, I referred how to program in Kernel mode and I got to this wonderful tutorial. I wrote this small hello world program and a make file. Note that I'm still running this program on my x86 Desktop (Ubutnu 10.04) and not YET on my ARM processor. Not until I get a hang over Kernel level programming.
I get these errors. Whats going wrong here?
Help!
Errors I get on my i.MX515 board
ubuntu#ubuntu-desktop:~/Documents/Kernel_Programming$ make
make -C /lib/modules/2.6.31-203-gee1fdae/build M=/home/ubuntu/Documents/Kernel_Programming modules
make[1]: Entering directory `/usr/src/linux'
make[1]: *** No rule to make target `modules'. Stop.
make[1]: Leaving directory `/usr/src/linux'
make: *** [all] Error 2
Errors I get
ubuntu#ubuntu-desktop:~/Documents$ make
make -C /lib/modules/2.6.32-23-generic/build M=/home/ubuntu/Documents modules
make[1]: Entering directory `/usr/src/linux-headers-2.6.32-23-generic'
make[2]: *** No rule to make target `/home/ubuntu/Documents/hello-1.c',
needed by `/home/ubuntu/Documents/hello-1.o'. Stop.
make[1]: *** [_module_/home/ubuntu/Documents] Error 2
make[1]: Leaving directory `/usr/src/linux-headers-2.6.32-23-generic'
make: *** [all] Error 2
Program
#include <linux/module.h>
#include <linux/kernel.h>
int init_module(void)
{
printk(KERN_INFO "\nHello World! I'm programming in Kernel Mode\n");
return 0;
}
void cleanup_module(void)
{
printk(KERN_INFO "\nBye Bye blue bird\n");
}
makefile
obj-m +=hello-1.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
I don't know if it's just the formatting of your post or not, but the kernel build scripts are looking for "Makefile" and you have "makefile" (difference in case). Could that really be the problem? Plus, is your username "ubuntu"?
There is a typo in your make command like:
It should be:
make -C /lib/modules/2.6.32-23-generic/build M=/home/ubuntu/Documents modules
not
make -C /lb/modules/2.6.32-23-generic/build M=/home/ubuntu/Documents modules
I have a makefile with a target clean:
clean:
$(MAKE) -f <other makefile location> clean
When I call make clean in this makefile, it tells me that in the other makefile there is no rule 'clean-linux'. Specifically here is the output.
make -f /root/ovaldi-5.5.25-src/project/linux/Makefile clean
make[1]: Entering directory '/root/ovaldi-5.5.25-src'
make[2]: Entering directory '/root/ovaldi-5.5.25-src'
make[2]: *** No rule to make target 'clean-linux'. Stop.
make[2]: Leaving directory '/root/ovaldi-5.5.25-src'
make[1]: Leaving directory '/root/ovaldi-5.5.25-src'
Why is it giving it the clean-linux target and not just clean like I specified?
When you make (or $(MAKE)), by default you use whatever makefile is there. So here's what I think is happening.
You cd to some location.
You 'make -f Makefile_A clean'.
make runs with Makefile_A, and does '$(MAKE) -f Makefile_B clean'.
make[1] runs with Makefile_B, and does '$(MAKE) clean-linux'.
make[2] runs with whatever makefile is here which might be anything (I suspect it's Makefile_A) but whatever it is it has no rule for clean-linux.
The solution: rewrite your second makefile (the one that has clean-linux) so that clean-linux becomes a prerequisite of clean (if/when you're on a linux system). That way it won't run make[2].
ifeq ($(PLATFORM), LINUX)
clean: clean-linux
endif
ifeq ($(PLATFORM), SUNOS)
clean: clean-sunos
endif
clean:;
Just a guess but maybe the 'clean' target in the second makefile calls 'clean-linux'?
Can you post the clean target of the second makefile?
Edit:
In light of your posted clean target it seems you're just calling the clean-linux target incorrectly.
Beta has posted the correct way of dealing with your problem in their answer so I'm going to +1 that.