0

For a lpc3250 board, we had to developer a Linux kernel module to control the PWM output. I've created a 'helper' module which contains methodes like PMW1_ENABLE which set the correct bit at 1.

Unfortunately I run into problems when I create multiple .c and .h files. When I put all the code in just 1 file, the solution works fine. When I split it nicely in additional .c and .h files, something weird is happening. Even just printk statements do not show up on the console.

Most weird part, during cross compiling, no errors are shown so it looks like the binary is ok but it isn't.

Does this sound familiair? Could it be an issue with my makefile?

ARCH := arm
CROSS_COMPILE := /usr/local/xtools/arm-unknown-linux-uclibcgnueabi/bin/arm-linux-
CC= $(CROSS_COMPILE)gcc

obj-m := pwmdriver.o
pwmdriver-objs := pwmhelper.o pwmdriver.o

KDIR := /home/student/felabs/sysdev/tinysystem/linux-2.6.34
WORKINGDIRFIXED := /home/student/PRT/5_AssigPWM

export
all:
    $(MAKE) -C $(KDIR) M=$(WORKINGDIRFIXED) modules

clean:
    $(MAKE) -C $(KDIR) M=$(WORKINGDIRFIXED) clean
Twan
  • 39
  • 9
  • This is known limitation of the Linux kernel build system, that you cannot have **several source files** when a **name** of the one source is the **same** as a name of the **module**. In that case, given source file is silently ignored. Just rename `pwmdriver.c` file to something else. See [that question](https://stackoverflow.com/questions/13606075/building-a-kernel-module-from-several-source-files-which-one-of-them-has-the-sam) for more options. – Tsyvarev Sep 26 '18 at 08:24
  • Is there a difference when I just rename obj-m := pwmdriver.o to obj-m :=pwmdrv.o ? – Twan Sep 26 '18 at 08:42
  • Tried this, but I seems to understand, there has to be a pwmdriver.c file too otherwise the build fails. Should that be an empty file? – Twan Sep 26 '18 at 08:55
  • If you want to **rename the module**, aside from changing `obj-m := pwmdriver.o` to `obj-m :=pwmdrv.o` you need to change `pwmdriver-objs` to `pwmdrv-objs`. If you want to **rename a file** `pwmdriver.c` to `pwmdrvr.c`, you need also change the line `pwmdriver-objs := pwmhelper.o pwmdriver.o` to `pwmdriver-objs := pwmhelper.o pwmdrvr.o`. – Tsyvarev Sep 26 '18 at 10:07

0 Answers0