警告:modules_install:缺少 'System.map' 文件。跳过 depmod

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

我正在尝试使用 depmodmodprobe 实用程序插入内核模块以解决任何依赖关系。当我构建模块时,它会抛出“警告:modules_install:缺少 'System.map' 文件。跳过 depmod。

稍后,当我尝试执行 modprobe 时,它会抛出一条错误消息 "modprobe: FATAL: Module i2c_eeprom_client.ko not found in directory /lib/modules/4.19.58-v7+"

下面是我正在使用的 make 文件:

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

下面是构建的输出:

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+'

我该如何解决这个问题?请帮忙

平台:Raspberry PI3b+,Raspbian-linux4.19.58-v7+

您可以在 modules_install 步骤之后 运行 depmod。此外,更好的做法是将安装与构建分开,以避免必须使用 root 权限构建:

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

调用为:

$ make
$ make install