The problem
When you execute the rpi-source command you get the error:
Traceback (most recent call last):
File "/usr/bin/rpi-source", line 320, in <module>
kernel = debian_method(debianlog)
File "/usr/bin/rpi-source", line 277, in debian_method
kernel.config = proc_config_gz()
File "/usr/bin/rpi-source", line 201, in proc_config_gz
sh("sudo modprobe configs 2> /dev/null")
File "/usr/bin/rpi-source", line 85, in sh
subprocess.check_call(cmd, shell=True)
File "/usr/lib/python2.7/subprocess.py", line 186, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command 'sudo modprobe configs 2> /dev/null' returned non-zero exit status 1
If you execute the command sudo modprobe configs 2
you will see the following error:
modprobe: ERROR: ../libkmod/libkmod.c:586 kmod_search_moddep() could not open moddep file '/lib/modules/4.9.59-v7+/modules.dep.bin'
modprobe: FATAL: Module configs not found in directory /lib/modules/4.9.59-v7+
This means that you are missing the modules for your current kernel version. Check with uname -a
you current version and verify that directories under /lib/modules.
Solution
The problem is that when you want to use rpi-source it failing since it tries to download the source of a newer kernel than the one installed. First upgrade all your packages to the latest version and also the kernel:
sudo apt update
sudo apt upgrade
# also update to the latest kernel with
sudo rpi-update