[ELDK] building .ko objects

Markus Klotzbücher mk at denx.de
Fri Apr 25 18:04:26 CEST 2008


Dear John,

"Price, John @ SDS" <john.p.price at l-3com.com> writes:

> The exact steps I took from the top of the kernel source tree were;
>
>>make mrproper
>
>>make ARCH=powerpc CROSS_COMPILE=ppc_4xx- kilauea_defconfig
>
>>make ARCH=powerpc CROSS_COMPILE=ppc_4xx- menuconfig
>
>>make ARCH=powerpc CROSS_COMPILE=ppc_4xx- uImage

This is fine. Remember you can avoid having to pass the ARCH and
CROSS_COMPILE if you set them once using export:

$ export ARCH=powerpc
$ export CROSS_COMPILE=ppc_4xx-

> While this step executed I saw the sample/kobject built as builtin, even
> though I selected modules from the menuconfig.  Looking at the .config
> file located at the top of the kernel source tree I saw this;
>
> [root at ma-dhcp-125 linux-2.6-denx]# grep KOBJECT .config

Oh oh. Compiling kernels is not exactly the kind of task you need root
privileges for.

> # CONFIG_DEBUG_KOBJECT is not set
> CONFIG_SAMPLE_KOBJECT=m
>
> So then I cd'd to samples/kobject and typed the following line;
>
> [root at ma-dhcp-125 kobject]# cat Makefile
> obj-$(CONFIG_SAMPLE_KOBJECT) += kobject-example.o kset-example.o
> [root at ma-dhcp-125 kobject]# make -C /data/denxSrc/linux-2.6-denx M=`pwd`
> modules
> make: Entering directory `/data/denxSrc/linux-2.6-denx'
>   CC [M]  /data/denxSrc/linux-2.6-denx/samples/kobject/kobject-example.o
> cc1: error: unrecognized command line option "-mno-red-zone"
> cc1: error: unrecognized command line option "-mcmodel=kernel"
> cc1: error: unrecognized command line option
> "-maccumulate-outgoing-args"
> make[1]: ***
> [/data/denxSrc/linux-2.6-denx/samples/kobject/kobject-example.o] Error 1
> make: *** [_module_/data/denxSrc/linux-2.6-denx/samples/kobject] Error 2
> make: Leaving directory `/data/denxSrc/linux-2.6-denx'

So whats going wrong here? Errors like these are usually an indication
that you're using the wrong compiler. Try adding ARCH and CROSS_COMPILE
as you did before or export as described above.

> After seeing this I modified the Makefile as follows and tried to build
> the two modules;
>
> [root at ma-dhcp-125 kobject]# cat Makefile
> obj-m += kobject-example.o kset-example.o
>
> [root at ma-dhcp-125 kobject]# make -C /data/denxSrc/linux-2.6-denx M=`pwd`
> modules
> make: Entering directory `/data/denxSrc/linux-2.6-denx'
>   CC [M]  /data/denxSrc/linux-2.6-denx/samples/kobject/kobject-example.o
> cc1: error: unrecognized command line option "-mno-red-zone"
> cc1: error: unrecognized command line option "-mcmodel=kernel"
> cc1: error: unrecognized command line option
> "-maccumulate-outgoing-args"
> make[1]: ***
> [/data/denxSrc/linux-2.6-denx/samples/kobject/kobject-example.o] Error 1
> make: *** [_module_/data/denxSrc/linux-2.6-denx/samples/kobject] Error 2
> make: Leaving directory `/data/denxSrc/linux-2.6-denx'

Same problem as above. You're trying to compile with you host GCC using
powerpc cross compiler options.

> Sorry about "m:", a typo on my part after a very frustrating afternoon
> trying to get kobject modules to build.
>
> Also from the top of the kernel source tree building modules prior to
> any makefile modifications;
>
>>make ARCH=powerpc CROSS_COMPILE=ppc_4xx- modules
>
> This line builds scsi_wait_scan.ko object just fine, but again not the
> samples/kobject.

The samples are not regular modules, so they don't get built for the
"modules"  but for the default target. Try:

make ARCH=powerpc CROSS_COMPILE=ppc_4xx-

at the root of the kernel tree and the examples will be compiled.

> So a makefile with the  "obj-m += module.o" and the command "make -C
> /top/of/kernel/src M=`pwd` modules" should allow me to build external
> modules with your linux distribution?

Yes, but please note that all these features are standard Linux features
and are not specific to the Denx kernel tree, so this is really of topic
here.

Best regards

Markus Klotzbuecher

--
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de


More information about the eldk mailing list