Warning: modules_install: missing 'System.map' file. Skipping depmod

user11875340 picture user11875340 · Aug 16, 2019 · Viewed 18.1k times · Source

I am trying to insert a kernel module using depmod and modprobe utilities in-order to resolve any dependencies. When I build the module it throws "Warning: modules_install: missing 'System.map' file. Skipping depmod."

And later when I try to execute modprobe it throws an error saying "modprobe: FATAL: Module i2c_eeprom_client.ko not found in directory /lib/modules/4.19.58-v7+"

Below is the make file I am using:

obj-m += i2c_eeprom_client.o
KDIR = /lib/modules/$(shell uname -r)/build

all:
    make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
    make -C $(KDIR) M=$(PWD) modules_install

clean:
    make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean

And below is the output of build:

make -C /lib/modules/4.19.58-v7+/build M=/home/pi/work/eeprom modules
make[1]: Entering directory '/usr/src/linux-headers-4.19.58-v7+'
  Building modules, stage 2.   
  MODPOST 1 modules
make[1]: Leaving directory '/usr/src/linux-headers-4.19.58-v7+'
make -C /lib/modules/4.19.58-v7+/build M=/home/pi/work/eeprom 
modules_install  
make[1]: Entering directory '/usr/src/linux-headers-4.19.58-v7+'
  INSTALL /home/pi/work/eeprom/i2c_eeprom_client.ko
  DEPMOD  4.19.58-v7+
Warning: modules_install: missing 'System.map' file. Skipping depmod.
make[1]: Leaving directory '/usr/src/linux-headers-4.19.58-v7+'

How can i fix this problem ? Please help

Platform : Raspberry PI 3b+, Raspbian - linux 4.19.58-v7+

Answer

Ian Abbott picture Ian Abbott · Aug 16, 2019

You can run depmod after the modules_install step. Also, it is better practice to separate the installation from the building to avoid having to build with root privileges:

obj-m += i2c_eeprom_client.o

# Default to running kernel's build directory if KDIR not set externally
KDIR ?= "/lib/modules/$(shell uname -r)/build"

all:
    $(MAKE) -C "$(KDIR)" M="$(CURDIR)" modules

install:
    $(MAKE) -C "$(KDIR)" M="$(CURDIR)" modules_install
    depmod -A

clean:
    $(MAKE) -C "$(KDIR)" M="$(CURDIR)" clean

Invoke as:

$ make
$ make install