3

My customer send me the prebuilt kernel output directory(They can not release the kernel source tree to us). This output directory is as below(under /home/michael/Clients/android_p_Hzh/kernel/kernel/):

  • arch
  • block
  • build-in.o
  • certs
  • ...
  • .config
  • Makefile
  • Module.symvers
  • source (symbol link to a local source tree in my customer's file system)

Is it possible to build my external module against with this directory?

/home/michael/Source/Linux/br_driver is my driver's directory. I have tried to build my driver under this directory as below make command:

make CROSS_COMPILE=x86_64-poky-linux- -C /home/michael/Clients/android_p_Hzh/kernel/kernel/ M=pwd $1

It fails with below output:

*** No rule to make target '/home/michael/Source/Linux/br_driver/common.o' needed by ...

The Makefile under br_driver is like below:

brt-objs := $(BRTOFILES)
obj-$(DRIVER_TYPE)   += brt.o

all:
    @echo "$(MAKE) --no-print-directory -C $(KDIR) SUBDIRS=$(CURDIR) modules"
    @$(MAKE) --no-print-directory -C $(KDIR) SUBDIRS=$(CURDIR) modules

clean:
    rm -rf *.o *.ko *.mod.c *~ .*.cmd *.o.cmd .*.o.cmd \
    Module.symvers modules.order .tmp_versions modules.builtin

install:
    @$(MAKE) --no-print-directory -C $(KDIR) \
        SUBDIRS=$(CURDIR) modules_install
Micheal.zu
  • 85
  • 1
  • 11
  • 1
    Yes, it is possible to build kernel module against such directory. If you want us to help you with the error you got, you need to provide more information: what is directory `/home/michael/Source/Linux/` means for your machine, is `br_driver`, how your Makefile looks like and so on. – Tsyvarev Feb 28 '19 at 12:42
  • /home/michael/Source/Linux is my workspace diretory. /home/michael/Source/Linux/br_driver is the source directory of my driver. I run "make CROSS_COMPILE=..." under this directory. – Micheal.zu Mar 01 '19 at 01:21
  • Makefile looks like as below: ... brt-objs := $(BRTFILES) obj-$(DRIVER_TYPE) += brt.o all: @echo "$(MAKE) --no-print-directory -C $(KDIR) SUBDIRS=$(CURDIR) modules" @$(MAKE) --no-print-directory -C $(KDIR) SUBDIRS=$(CURDIR) modules clean: rm -rf *.o *.ko *.mod.c *~ .*.cmd *.o.cmd .*.o.cmd \ Module.symvers modules.order .tmp_versions modules.builtin install: @$(MAKE) --no-print-directory -C $(KDIR) \ SUBDIRS=$(CURDIR) modules_install – Micheal.zu Mar 01 '19 at 01:24
  • 2
    Needed **information** should be in the **question post**, not in the *comments*. (As you can see, comments are badly suited for represent multiline files and logs). Please, [edit] you question post and add all required information into it. – Tsyvarev Mar 01 '19 at 07:45
  • @Tsyvarev Thanks you for reminding. I have edited my question. – Micheal.zu Mar 04 '19 at 04:46
  • What is content of `BRTOFILES` variable used in the Makefile? According to the error message, this variable contains `common.o` element, but you have no `common.c` file under your driver's directory. Also, I am not sure what is `$1` in your command line. – Tsyvarev Mar 04 '19 at 07:48
  • @Tsyvarev BRTOFILES := common.o ip.o custom_gpio.o. $1 is empty or **clean**. – Micheal.zu Mar 11 '19 at 08:17
  • Where do you have `common.c` file? Kbuild system expects it at `/home/michael/Source/Linux/br_driver/common.c` (near the Makefile). – Tsyvarev Mar 11 '19 at 08:50

1 Answers1

0

I have resolved this problem. The only things I need is the .config and Modules.symvers. The key operation is make oldconfig and modules_prepare.

Micheal.zu
  • 85
  • 1
  • 11