Cross compiling a kernel module

后端 未结 6 2015
囚心锁ツ
囚心锁ツ 2020-12-04 18:22

I\'m trying to cross compile a helloworld kernel (2.6.x) module for ARM architecture on my intel x86 host.

The codesourcery tool chain for ARM is located at: /ho

相关标签:
6条回答
  • 2020-12-04 18:33

    could you try, you forgot to add ARCH and CROSS_COMPILE into the default and clean

    ARCH=arm
    COMPILER=arm-none-linux-gnueabi
    obj-m := Hello.o
    KERNELDIR := /home/ravi/workspace/hawk/linux-omapl1
    PWD := $(shell pwd)
    default:
        $(MAKE) -C $(KERNELDIR) M=$(PWD) ARCH=$(ARCH) CROSS_COMPILE=$(COMPILER) modules
    
    clean:
        $(MAKE) -C $(KERNELDIR) M=$(PWD) ARCH=$(ARCH) clean
    
    0 讨论(0)
  • 2020-12-04 18:36

    Sidenote: SUBDIRS= is deprecated in favor of M=.

    0 讨论(0)
  • 2020-12-04 18:47

    Putting ARCH and CROSS_COMPILE in the Makefile doesn't work. You need to put them on the command line:

    make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi-
    
    0 讨论(0)
  • 2020-12-04 18:49
    MODULES := hola_kern.o
    
    #guest architecture
    ARCH := arm
    
    CROSS_COMPILE := arm-linux-gnueabi-
    obj-m := $(MODULES)
    
    #path of the arm compiled kernel
    ROOTDIR := /home/aldo/c/proyectos/prefixa/work/kernels/linux-omap-5f0a6e2
    
    MAKEARCH := $(MAKE) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE)
    
    all: modules
    modules:
        $(MAKEARCH) -C $(ROOTDIR) M=${shell pwd} modules
    
    clean:
        $(MAKEARCH) -C $(ROOTDIR) M=${shell pwd} clean
    
    0 讨论(0)
  • 2020-12-04 18:50

    adding export at the end of your Makefile variable declarations will make them available to subshells. and add the dash to the CROSS_COMPILE prefix as JayM pointed out, and M instead of SUBDIRS as user502515 answered.

    and it's generally a good idea to use := rather than = in a Makefile, so the variable only gets interpolated once. really doesn't matter in this particular case though.

    ARCH := arm
    CROSS_COMPILE := arm-none-linux-gnueabi-
    obj-m := Hello.o
    KDIR := /home/ravi/workspace/hawk/linux-omapl1
    PWD := $(shell pwd)
    export
    default:
              $(MAKE) -C $(KDIR) M=$(PWD) modules
    clean:
              $(MAKE) -C $(KDIR) M=$(PWD) clean
    
    0 讨论(0)
  • 2020-12-04 18:52

    Replace

    ARCH=arm
    CROSS_COMPILE=arm-none-linux-gnueabi

    by

    export ARCH:=arm
    export CROSS_COMPILE:=arm-none-linux-gnueabi-

    this will also work if you do not want to give these parameter command line each time.

    0 讨论(0)
提交回复
热议问题