How to build kernel module?


alexparser
 Share

1 1

Recommended Posts

Hi all!

Try build the kernel module on the Lime2 Debian jessie 4.6.3, but failed.

I use src files from here - https://github.com/linux-sunxi/linux-sunxi/tree/sunxi-3.4/sound/soc/sunxi/i2s

 

Makefile

KERNELDIR := /lib/modules/4.6.3-sunxi/build
obj-m += sndi2s.o

all:
    $(MAKE) -C $(KERNELDIR) M=`pwd` modules
clean:
    $(MAKE) -C $(KERNELDIR) M=`pwd` clean

Ouput

make all
make -C /lib/modules/4.6.3-sunxi/build M=`pwd` modules
make[1]: Entering directory '/usr/src/linux-headers-4.6.3-sunxi'
  CC [M]  /root/src/sndi2s.o
/root/src/sndi2s.c:24:29: fatal error: plat/sys_config.h: No such file or directory
 #include <plat/sys_config.h>
                             ^
compilation terminated.
scripts/Makefile.build:297: recipe for target '/root/src/sndi2s.o' failed
make[2]: *** [/root/src/sndi2s.o] Error 1
Makefile:1429: recipe for target '_module_/root/sunxi-i2s-src' failed
make[1]: *** [_module_/root/sunxi-i2s-src] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-4.6.3-sunxi'
Makefile:5: recipe for target 'all' failed
make: *** [all] Error 2

Why the compiler can not find the file sys_config.h?

Any recommendations by the module assembly...

 

 

Link to post
Share on other sites

Donate and support the project!

Maybe you can give me recommendation, how to compile sndi2s.c on the legacy kernel (3.4)?

It should be built-in in latest Armbian legacy kernel

$ grep SND_SUNXI_SOC_I2S_INTERFACE config/kernel/linux-sun7i-default.config
CONFIG_SND_SUNXI_SOC_I2S_INTERFACE=y

For a Lime2 board you need to enable I2S in fex file (and recompile it to bin file afterwards), setting

i2s_used = 1

in [i2s_para] section.

 

Whether it does work or not I don't know (don't have any I2S hardware).

Link to post
Share on other sites

It should be built-in in latest Armbian legacy kernel

$ grep SND_SUNXI_SOC_I2S_INTERFACE config/kernel/linux-sun7i-default.config
CONFIG_SND_SUNXI_SOC_I2S_INTERFACE=y

For a Lime2 board you need to enable I2S in fex file (and recompile it to bin file afterwards), setting

i2s_used = 1

in [i2s_para] section.

 

Whether it does work or not I don't know (don't have any I2S hardware).

CONFIG_SND_SUNXI_SOC_I2S_INTERFACE=y - OK

i2s_used = 1 - OK

I wanted to know how to make a compilation of a particular file sndi2s.c directly on the Lime2.

Link to post
Share on other sites

I wanted to know how to make a compilation of a particular file sndi2s.c directly on the Lime2.

 

Well, if you use legacy image you have this driver already included and you don't have to do absolutely anything, except fix script.bin Unless you want to have it as a module, but this will give you just additional work without any benefit. Do you by any chance want to transfer this module to mainline kernel?

Link to post
Share on other sites

Well, if you use legacy image you have this driver already included and you don't have to do absolutely anything, except fix script.bin Unless you want to have it as a module, but this will give you just additional work without any benefit. Do you by any chance want to transfer this module to mainline kernel?

I have a custom designed board for external clocking.

I want make changes into I2S driver for my board.

And yes, after that I would make port a I2S driver to mainline kernel.

Link to post
Share on other sites

If you want to port driver, then approach in the first post is correct one. You have to remove all references to sys_config.h (functions for reading script.bin) and replace it with device tree functions (device tree files are replacement for script.bin). Along with that you would have to fix all functions and/or principles which changed during 4 years of kernel development. However, if you want just copy module file from image with legacy kernel to image with mainline kernel, it won't work.

Link to post
Share on other sites

I want make changes into I2S driver for my board.

In this case you probably will need to recompile kernel without built-in I2S to avoid conflicts. In any case if you compile on Armbian with legacy kernel, sys_config.h shouldn't be an issue, but you will need to extend your Makefile to compile all source files, something like this:

obj-m+= sunxi-i2s.o

sunxi-i2s-objs+= sunxi-i2sdma.o sndi2s.o sunxi-sndi2s.o

And yes, after that I would make port a I2S driver to mainline kernel.

You don't have to: https://linux-sunxi.org/Linux_mainlining_effort#Planned_for_4.8

Link to post
Share on other sites

This driver for sun4i A10 SoC, Lime2 A20 SoC.

What is DT bits?

 

 

Please check this commit: https://git.kernel.org/cgit/linux/kernel/git/mripard/linux.git/commit/?h=sunxi/for-next&id=6a706356b4456204fd89ef3fbfc6ed4165cebf37

You can see that I2S driver is compatible with both chips, A10 and A20. DT bits are just things you must put inside device tree file to make driver aware of important things. This exactly what is done in aforementioned commit.

Link to post
Share on other sites

This driver for sun4i A10 SoC, Lime2 A20 SoC.

A10 and A20 share most of SoC IP blocks and thus most of the drivers.

 

What is DT bits?

Device Tree. A standart for describing hardware configuratiuon for the kernel, that is used in modern kernel versions instead of Allwinner-specific FEX files. You will need to add generic sections from @jernej's link and activate one of I2S interfaces in board-specific file. You may want to read some official specifications like this and look at current generic (family-specific) and board-specific files for A20 and Lime2.

Link to post
Share on other sites

Guest
This topic is now closed to further replies.
 Share

1 1