Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have a 3rd party device driver which I am trying to cross-compile. When I build the driver everything goes smooth but I don't see any driver.ko file, however driver.o file is generated fine and I don't see any error during the build process. I have also tried with the option V=1 and I see following error

echo; 
echo "  ERROR: Kernel configuration is invalid.";
echo "         include/generated/autoconf.h or include/config/auto.conf are         missing.";
echo "         Run 'make oldconfig && make prepare' on kernel src to fix  it.";
echo;

But my kernel configuration is correct and I have tried a simple hello world module with this configuration, in that case I can build my module but still see this error message. Also I can see both the files include/generated/autoconf.h and include/config/auto.conf in the kernel sources. Still why I am unable to build my driver module.

I am cross-compiling the driver for ARM platform so /lib/modules will not be good in this environment. Secondly here is the output of the build.

LD [M]  /home/farshad/Work/CSP/boards/imx6q/ar6k3/ar6003_3.1_RC_Linux_release_[posted_2011_8_19_olca3.1RC_553/imx6build/host/os/linux/ar6000.o                                                          
Building modules, stage 2.
MODPOST 0 modules
make[2]: Leaving directory  `/home/farshad/Work/CSP/projects/phase_1/farshad/cspbox/platform/imx6/mel5/fs/workspace/linux-2.6.38-imx6'

As you can see above ar6000.o is built properly without any error, but why ar6000.ko is not being built otherwise it should report "MODPOST 1 modules". Since ar6000.ko is not being built at the end of the complete build process I also get the following error

cp: cannot stat `/home/farshad/Work/CSP/boards/imx6q/ar6k3/ar6003_3.1_RC_Linux_release_[posted_2011_8_19_olca3.1RC_553/imx6build/host/os/linux/ar6000.ko': No such file or directory
2404 make[1]: *** [install] Error 1

Which is obvious. My problem is why I am not getting a ar6000.ko in the first place. Searching over google someone also faced this issue and mentioned that running make with sudo resolved it but it brought no luck for me!

I am wandering is there any problem in my kernel configuration (i.e the driver is looking for some configuration setting which I haven't enabled in my kernel, but in that case it should give compiler error looking for required #define), the other point can be that there is a problem with the driver build system, which I am trying to figure out. My cross-compile environment is good as I am seeing exactly the same issue while building the same driver for my (Ubuntu x86) machine!

Update # 1

Its a 3rd party driver package which also build other utilities along with the driver module. Here is the output of the driver module build process

make CT_BUILD_TYPE=MX6Q_ARM CT_OS_TYPE=linux CT_OS_SUB_TYPE=  CT_LINUXPATH=~/Work/CSP/projects/phase_1/farshad/cspbox/platform/imx6/mel5/fs/workspace/linu x-2.6.38-imx6 CT_BUILD_TYPE=MX6Q_ARM CT_CROSS_COM      PILE_TYPE=~/bin/mgc/CodeSourcery/Sourcery_CodeBench_for_ARM_GNU_Linux/bin/arm-none-linux- gnueabi- CT_ARCH_CPU_TYPE=arm CT_HC_DRIVERS=pci_std/ CT_MAKE_INCLUDE_OVERRIDE=  CT_BUILD_OUTPUT_OVERRIDE=/home/far      shad/Work/CSP/boards/imx6q/ar6k3/ar6003_3.1_RC_Linux_release_[posted_2011_8_19_olca3.1RC_553 /imx6build/host/.output/MX6Q_ARM-SDIO/image  -C   /home/farshad/Work/CSP/boards/imx6q/ar6k3/ar6003_3.1_RC_Linux      _release_[posted_2011_8_19_olca3.1RC_553/imx6build/host/sdiostack/src default
make[3]: Entering directory  `/home/farshad/Work/CSP/boards/imx6q/ar6k3/ar6003_3.1_RC_Linux_release_[posted_2011_8_19_olc a3.1RC_553/imx6build/host/sdiostack/src'
make  -C ~/Work/CSP/projects/phase_1/farshad/cspbox/platform/imx6/mel5/fs/workspace/linux-2.6.38-imx6 SUBDIRS=/home/farshad/Work/CSP/boards/imx6q/ar6k3/ar6003_3.1_RC_Linux_release_[posted_2011_8_19_olca     3.1RC_553/imx6build/host/sdiostack/src ARCH=arm CROSS_COMPILE=~/bin/mgc/CodeSourcery/Sourcery_CodeBench_for_ARM_GNU_Linux/bin/arm-none-linux-gnueabi- EXTRA_CFLAGS="-DLINUX -I/home/farshad/Work/CSP/board     s/imx6q/ar6k3/ar6003_3.1_RC_Linux_release_[posted_2011_8_19_olca3.1RC_553/imx6build/host/sdiostack/src/include  -DDEBUG" modules
make[4]: Entering directory `/home/farshad/Work/CSP/projects/phase_1/farshad/cspbox/platform/imx6/mel5/fs/workspace/linux-2.6.38-imx6'
    Building modules, stage 2.
    MODPOST 0 modules
make[4]: Leaving directory  `/home/farshad/Work/CSP/projects/phase_1/farshad/cspbox/platform/imx6/mel5/fs/workspace/linu x-2.6.38-imx6'

Here is the Makefile of the driver module.

ifdef CT_MAKE_INCLUDE_OVERRIDE
-include $(CT_MAKE_INCLUDE_OVERRIDE)
else
-include localmake.$(CT_OS_TYPE).inc
-include localmake.$(CT_OS_TYPE).private.inc
endif

export CT_OS_TYPE
export CT_OS_SUB_TYPE
export CT_OS_TOP_LEVEL_RULE 
export CT_PASS_CFLAGS
export CT_SRC_BASE
export CT_BUILD_SUB_PROJ

# this makefile can only be invoked from the /EMSDIO/src base
CT_SRC_BASE :=$(shell pwd)

# export flags for which HCDs to build. Set the hcd driver name in hcd/ in your     localmake.*.inc file.
export CT_HC_DRIVERS
export PDK_BUILD
export HDK_BUILD
export ALL_BUILD
export ATHRAW_FD_BUILD
export BUS_BUILD

# For Linux
ifeq ($(CT_OS_TYPE),linux) 

#make a copy for linux 2.4
EXTRA_CFLAGS += -DLINUX -I$(CT_SRC_BASE)/include 
ifneq ($(CT_RELEASE),1)
EXTRA_CFLAGS += -DDEBUG
endif  
export EXTRA_CFLAGS 

CT_SRC_OUTPUT :=$(CT_SRC_BASE)/../output

ifdef CT_BUILD_OUTPUT_OVERRIDE
_CT_COMPILED_OBJECTS_PATH :=$(CT_BUILD_OUTPUT_OVERRIDE)
_MAKE_OUTPUT_DIR :=
_CLEAN_OUTPUT_DIR :=
else
_CT_COMPILED_OBJECTS_PATH := $(CT_SRC_OUTPUT)/$(CT_BUILD_TYPE)
_MAKE_OUTPUT_DIR := mkdir --parents $(_CT_COMPILED_OBJECTS_PATH)
_CLEAN_OUTPUT_DIR := rm -R -f $(CT_SRC_OUTPUT)
endif

ifeq ($(CT_OS_SUB_TYPE),linux_2_4)

CT_PASS_CFLAGS := $(EXTRA_CFLAGS)
_CT_MOD_EXTENSION :=o
ifeq ($(ALL_BUILD),1)
subdir-m += busdriver/ lib/ hcd/ function/   
else 
ifeq ($(BUS_BUILD),1)
subdir-m += busdriver/ lib/ hcd/
else
ifeq ($(PDK_BUILD),1)
subdir-m += function/
else
ifeq ($(HDK_BUILD),1)
subdir-m += hcd/ function/ 
endif
endif
endif
endif

# add in rules to make modules
CT_OS_TOP_LEVEL_RULE :=$(CT_LINUXPATH)/Rules.make
include $(CT_OS_TOP_LEVEL_RULE)
else
#2.6+
_CT_MOD_EXTENSION :=ko
ifeq ($(ALL_BUILD),1)
obj-m += busdriver/ lib/ hcd/ function/  
else 
ifeq ($(BUS_BUILD),1)
obj-m += busdriver/ lib/ hcd/
else 
ifeq ($(PDK_BUILD),1)
obj-m += function/
else
ifeq ($(HDK_BUILD),1)
obj-m += hcd/ function/ 
endif
endif
endif
endif

endif

ifdef CT_BUILD_SUB_PROJ
_CT_SUBDIRS=$(CT_BUILD_SUB_PROJ)
else
_CT_SUBDIRS=$(CT_SRC_BASE)
endif

ifdef CT_CROSS_COMPILE_TYPE 
CT_MAKE_COMMAND_LINE=$(CT_OUTPUT_FLAGS) -C $(CT_LINUXPATH) SUBDIRS=$(_CT_SUBDIRS)     ARCH=$(CT_ARCH_CPU_TYPE) CROSS_COMPILE=$(CT_CROSS_COMPILE_TYPE)
else   
CT_MAKE_COMMAND_LINE=$(CT_OUTPUT_FLAGS) -C $(CT_LINUXPATH) SUBDIRS=$(_CT_SUBDIRS)
endif

makeoutputdirs:
$(_MAKE_OUTPUT_DIR)

default: makeoutputdirs
echo " ************ BUILDING MODULE ************** "
$(MAKE) $(CT_MAKE_COMMAND_LINE) EXTRA_CFLAGS="$(EXTRA_CFLAGS)" modules
echo " *** MODULE EXTENSION = $(_CT_MOD_EXTENSION)"
$(CT_SRC_BASE)/../scripts/getobjects.scr $(CT_SRC_BASE) $(_CT_COMPILED_OBJECTS_PATH)     $(_CT_MOD_EXTENSION)

ifeq ($(CT_OS_SUB_TYPE),linux_2_4)
# on 2.4 we can't invoke the linux clean with SUBDIRS, it will just clean out the kernel
clean:
find $(_CT_SUBDIRS) \( -name '*.[oas]' -o -name core -o -name '.*.flags' -o -name   '.ko' -o -name '.*.cmd' \) -type f -print \
    | grep -v lxdialog/ | xargs rm -f
$(_CLEAN_OUTPUT_DIR)
else 
clean:
$(MAKE) $(CT_MAKE_COMMAND_LINE) clean
find $(_CT_SUBDIRS) \( -name '*.[oas]' -o -name core -o -name '.*.flags' \) -type f  -print \
    | grep -v lxdialog/ | xargs rm -f
$(_CLEAN_OUTPUT_DIR)
endif
endif 

# For QNX
ifeq ($(CT_OS_TYPE),qnx)  
LIST=VARIANT
EARLY_DIRS=lib
##ifndef QRECURSE
QRECURSE=./recurse.mk
##ifdef QCONFIG
###QRDIR=$(dir $(QCONFIG))
##endif
##endif
include $(QRDIR)$(QRECURSE)

endif
share|improve this question
    
Does ls -l /lib/modules/$(uname -r)/build point to the correct directory and do the mentioned files exist in that directory? –  scai Dec 6 '12 at 8:39
    
I have given Update # 1 to give more details. Thanks for your time. –  Farrukh Arshad Dec 6 '12 at 13:51
    
The output before that “Kernel configuration is invalid” message might be relevant. Please post the full compilation log. The third-party driver's Kbuild file may be buggy with your kernel version or configuration. Is it publicly available? What kernel version are you compiling? –  Gilles Dec 6 '12 at 23:02
    
There is no KBuild file, since its a standalone module using my kernel sources. My kernel version is 2.6.38. Please see Updated # 1 for build output & Makefile. –  Farrukh Arshad Dec 7 '12 at 13:13

1 Answer 1

up vote 1 down vote accepted

Ok, I have figured out the problem. I am having square bracket character "[" in the module source directory

LD [M]  /home/farshad/Work/CSP/boards/imx6q/ar6k3/ar6003_3.1_RC_Linux_release_[posted_2011_8_19_olca3.1RC_553/imx6build/host/os/linux/ar6000.o  

Removing this from the path worked well and I got my kernel module object files. I have renamed

ar6003_3.1_RC_Linux_release_[posted_2011_8_19_olca3.1RC_553 

to

ar6003, 

and also tested with

ar6003_3.1_RC_Linux_release_posted_2011_8_19_olca3.1RC_553

Both worked fine. I was building on Ubuntu 10.04. A colleague of mine has built from the same sources having "[" character in his path on Ubuntu 11.04 and kernel module object file was building nicely, this also suggest the changed behavior of grep / find / awk or such utility among their different versions, which kernel build system is using, resulting in this issue.

Regards, Farrukh Arshad.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.