Error message
make: *** /lib/modules/$(uname -r)/build: No such file or directory. Stop.
make: *** [all] Error 2Resolution
This is becuase your recent rpi-update updated the firmware to a version with a "too-new" kernel version, and command apt-get install raspberrypi-kernel-headers installs an older kernel header.
You need to first look into the /lib/modules directory and find which version has the correct, full kernel headers:
cd /lib/modules
find ./ -name buildthen downgrade the firmware to the one with that kernel version with the build directory (in this example, version 5.10.63):
sudo rpi-update 64132d67d3e083076661628203a02d27bf13203cNote that the hash specifies the firmware version, which can be found here at: https://github.com/Hexxeh/rpi-firmware/commits.
If you see deprecated dependencies, e.g.
/home/pi/ucsma/ucsma-raspi-gpio/gpio_timeline.c:31:19: error: field 'time' has incomplete type
struct timespec time;
^~~~
it might not be a good idea to just downgrade the firmware and the kernel (which is possible using the rpi-update COMMIT_HASH command mentioned above). This is becuase although you can downgrade the firmware and the running kernel, it is difficult to find a matching kernel headers to build your modules (raspberrypi-kernel-headers only keeps the most recent headers in the apt repository). Also it would be beneficial to keep this repo compatible with the latest kernel version available on the Raspberry Pi.