Error After Running 'make' Command on Raspberry Pi 3 Model B

58 views Asked by At

I encountered an issue while running a program on my Raspberry Pi 3 Model B. Every time I execute the make command, I encounter the following error:

make -c /lib/modules/6.1.21-v7+/build M=/home/project modules 
make[1]: *** /lib/modules/6.1.21-v7+/build: No such file or directory. Stop 
make: *** [Makefile:4: all] Error 2

I've tried troubleshooting by checking my dependencies and ensuring proper configurations, but the error persists. Any insights or suggestions would be greatly appreciated. Thank you!

Makefile:

obj-m += program1.o

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

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

program1.c:

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/input.h>

static struct input_handler *old_handler;

static int block_mouse_event(struct input_handler *handler, void *data, struct input_event *event)
{
    // Intercept mouse input events and do nothing, i.e., discard the events
    return 0;
}

static struct input_handler {
    void (*event)(struct input_handler *, void *, struct input_event *);
    const char *name;
    const struct input_device_id *id_table;
};

static struct input_handler block_handler = {
    .event = block_mouse_event,
    .name = "block_mouse_handler",
    .id_table = (void *)0,
};

static int mouse_block_init(void)
{
    printk("Mouse block module initialized\n");

    // Register the handler
    old_handler = input_get_handler("mouse0");
    input_register_handler(&block_handler);

    return 0;
}

static int mouse_block_exit(void)
{
    printk("Mouse block module removed\n");

    // Unregister the handler
    input_unregister_handler(&block_handler);
    input_put_handler(old_handler);
}

module_init(mouse_block_init);
module_exit(mouse_block_exit);

//MODULE_LICENSE("GPL");[enter image description here](https://i.stack.imgur.com/72dAb.jpg)

I want to modify mouse click actions through this program.

0

There are 0 answers