error happened when using command "make modules"

Hi guys, I want to run ADXL372 accelerometer on Jetson TX2 with SPI protocal. However when I tried to use iio subsystem, I found that there was no adxl372 driver in “/usr/src/kernel/kernel-4.4/drivers/iio/accel”. In that case, I download the adxl372.c ,adxl372.h,adxl372_spi.c ,adxl372_i2c.c from https://github.com/analogdevicesinc/no-OS/blob/master/drivers. Then I changed the Kconfig,and also “make menuconfig”.

At last, when I “make modules”, there were some errors showing on the terminal:

root@tegra-ubuntu:/usr/src/kernel/kernel-4.4# make modules
scripts/kconfig/conf --silentoldconfig Kconfig
CHK include/config/kernel.release
CHK include/generated/uapi/linux/version.h
CHK include/generated/utsrelease.h
make[1]: ‘include/generated/mach-types.h’ is up to date.
CHK include/generated/bounds.h
CHK include/generated/timeconst.h
CHK include/generated/asm-offsets.h
CALL scripts/checksyscalls.sh
CC [M] drivers/iio/buffer/industrialio-triggered-buffer.o
CC [M] drivers/iio/buffer/kfifo_buf.o
DTC drivers/misc/mods/mods.dtb
DTB drivers/misc/mods/mods.dtb.S
AS [M] drivers/misc/mods/mods.dtb.o
LD [M] drivers/misc/mods/mods.o
rm drivers/misc/mods/mods.dtb drivers/misc/mods/mods.dtb.S
Building modules, stage 2.
MODPOST 146 modules
WARNING: could not open drivers/misc/mods/mods.dtb.S: No such file or directory
ERROR: “iio_buffer_put” [drivers/iio/buffer/kfifo_buf.ko] undefined!
ERROR: “iio_buffer_init” [drivers/iio/buffer/kfifo_buf.ko] undefined!
ERROR: “iio_triggered_buffer_predisable” [drivers/iio/buffer/industrialio-triggered-buffer.ko] undefined!
ERROR: “iio_triggered_buffer_postenable” [drivers/iio/buffer/industrialio-triggered-buffer.ko] undefined!
ERROR: “iio_dealloc_pollfunc” [drivers/iio/buffer/industrialio-triggered-buffer.ko] undefined!
ERROR: “iio_alloc_pollfunc” [drivers/iio/buffer/industrialio-triggered-buffer.ko] undefined!
ERROR: “iio_buffer_get” [drivers/iio/buffer/industrialio-triggered-buffer.ko] undefined!
scripts/Makefile.modpost:91: recipe for target ‘__modpost’ failed
make[1]: *** [__modpost] Error 1
Makefile:1130: recipe for target ‘modules’ failed
make: *** [modules] Error 2

Can anybody help?

Are you sure tegra_defconfig has “CONFIG_IIO_KFIFO_BUF” enabled?

Sorry, I am very new to tx2, so how to do “CONFIG_IIO_KFIFO_BUF” ? Is there any links for me?

This is not related to TX2 itself but more to linux kernel. What kernel would build is enabled in tegra_defconfig. It will decide whether the driver is built into kernel or built as a module. If you don’t define driver A inside defconfig, driver A would not be built.

It looks like your driver lacking of some dependencies which are also not enabled on tegra either.
You will need to manually enable it.

I just checked the whole kernel driver to find out where is “kfifo_buf.ko” being built and notice “CONFIG_IIO_KFIFO_BUF” seems necessary for it.

I have found the “CONFIG_IIO_KFIFO_BUF” which in this path "root@tegra-ubuntu:/usr/src/kernel/kernel-4.4/arch/arm64/configs#"

The “CONFIG_IIO_KFIFO_BUF” is in the file “tegra18_android_defconfig

Here is inside:

CONFIG_IIO=y
CONFIG_IIO_BUFFER=y
CONFIG_IIO_KFIFO_BUF=y
CONFIG_IIO_TRIGGER=y

That file is for android build. The correct file for you is tegra18_defconfig.

There is only one command about iio which is “CONFIG_IIO=y” in tegra18_deconfig and the same in tegra21_deconfig

Yes… that is why you have compilation error.

LOL…so I need manually add these commands to tegra18_deconfig ???

CONFIG_IIO_BUFFER=y
CONFIG_IIO_KFIFO_BUF=y
CONFIG_IIO_TRIGGER=y

Yes, that is what I was talking about in #4.
It could be either “=y” or “=m”. Depends on your usecase.

But I am not sure if these are enough. If you still have other error, the way to resolve is similar.