Compare commits
1 commit
main
...
main-usb-d
Author | SHA1 | Date | |
---|---|---|---|
98f33b1246 |
4 changed files with 96 additions and 0 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
# Ignore other compiled files and directories
|
# Ignore other compiled files and directories
|
||||||
*.o
|
*.o
|
||||||
|
*.o.d
|
||||||
*.mod
|
*.mod
|
||||||
*.symvers
|
*.symvers
|
||||||
*.order
|
*.order
|
||||||
|
|
7
10_lnp_usb_driver/Makefile
Normal file
7
10_lnp_usb_driver/Makefile
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
obj-m += test_module.o
|
||||||
|
|
||||||
|
all:
|
||||||
|
make -C $(LINUX_MODULES_FOLDER)/build M=$(PWD) modules
|
||||||
|
|
||||||
|
clean:
|
||||||
|
make -C $(LINUX_MODULES_FOLDER)/build M=$(PWD) clean
|
35
10_lnp_usb_driver/bind.sh
Executable file
35
10_lnp_usb_driver/bind.sh
Executable file
|
@ -0,0 +1,35 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Définir les détails du périphérique USB et des pilotes
|
||||||
|
VENDOR_ID="1b1c"
|
||||||
|
DEVICE_ID="0c0b"
|
||||||
|
NEW_DRIVER="lightning-node-pro"
|
||||||
|
|
||||||
|
# Vérifier les identifiants avec lsusb
|
||||||
|
echo "Vérifiez que le périphérique est listé avec les identifiants corrects :"
|
||||||
|
lsusb | grep "${VENDOR_ID}:${DEVICE_ID}"
|
||||||
|
|
||||||
|
# Trouver le chemin du périphérique USB
|
||||||
|
USB_DEVICE_PATH=$(find /sys/bus/usb/devices/*/ -type f -name 'idVendor' -execdir sh -c 'grep -q '"$VENDOR_ID"' idVendor && grep -q '"$DEVICE_ID"' idProduct && pwd' \; | head -n 1)
|
||||||
|
|
||||||
|
if [ -z "$USB_DEVICE_PATH" ]; then
|
||||||
|
echo "Périphérique USB non trouvé"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Chemin du périphérique USB : $USB_DEVICE_PATH"
|
||||||
|
|
||||||
|
# Extraire l'identifiant du périphérique (par exemple, 1-10)
|
||||||
|
DEVICE_IDENTIFIER=$(basename "$USB_DEVICE_PATH")
|
||||||
|
|
||||||
|
echo "Identifiant du périphérique : $DEVICE_IDENTIFIER"
|
||||||
|
|
||||||
|
# Délier le périphérique USB du pilote actuel
|
||||||
|
echo "Délier le périphérique USB du pilote actuel..."
|
||||||
|
echo -n "$DEVICE_IDENTIFIER" | sudo tee "/sys/bus/usb/devices/$DEVICE_IDENTIFIER/driver/unbind" > /dev/null
|
||||||
|
|
||||||
|
# Lier le périphérique USB au nouveau pilote
|
||||||
|
echo "Lier le périphérique USB au nouveau pilote..."
|
||||||
|
echo -n "$DEVICE_IDENTIFIER" | sudo tee "/sys/bus/usb/drivers/${NEW_DRIVER}/bind" > /dev/null
|
||||||
|
|
||||||
|
echo "Périphérique USB lié avec succès au nouveau pilote"
|
53
10_lnp_usb_driver/test_module.c
Normal file
53
10_lnp_usb_driver/test_module.c
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
#include <linux/init.h>
|
||||||
|
#include <linux/usb.h>
|
||||||
|
#include <linux/module.h>
|
||||||
|
|
||||||
|
#define USB_VENDOR_ID_CORSAIR 0x1b1c
|
||||||
|
#define USB_DEVICE_ID_LIGHTNING_NODE_PRO 0x0c0b
|
||||||
|
|
||||||
|
static int lnp_driver_probe(struct usb_interface *interface,
|
||||||
|
const struct usb_device_id *id)
|
||||||
|
{
|
||||||
|
pr_info("Détection USB pour Lightning Node Pro\n");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct usb_device_id lnp_driver_table[] = {
|
||||||
|
{ USB_DEVICE(USB_VENDOR_ID_CORSAIR, USB_DEVICE_ID_LIGHTNING_NODE_PRO) },
|
||||||
|
{} /* Entrée de terminaison */
|
||||||
|
};
|
||||||
|
MODULE_DEVICE_TABLE(usb, lnp_driver_table);
|
||||||
|
|
||||||
|
static struct usb_driver lnp_driver = {
|
||||||
|
.name = "lightning-node-pro",
|
||||||
|
.id_table = lnp_driver_table,
|
||||||
|
.probe = lnp_driver_probe,
|
||||||
|
};
|
||||||
|
|
||||||
|
static int __init lnp_usb_driver_init(void)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = usb_register(&lnp_driver);
|
||||||
|
if (ret < 0) {
|
||||||
|
pr_err("lnp_usb_driver: Impossible d'enregistrer le pilote pour %s. Code d'erreur: %d\n",
|
||||||
|
lnp_driver.name, ret);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void __exit lnp_usb_driver_exit(void)
|
||||||
|
{
|
||||||
|
usb_deregister(&lnp_driver);
|
||||||
|
}
|
||||||
|
|
||||||
|
module_init(lnp_usb_driver_init);
|
||||||
|
module_exit(lnp_usb_driver_exit);
|
||||||
|
|
||||||
|
MODULE_LICENSE("GPL");
|
||||||
|
MODULE_AUTHOR("Florian RICHER <florian.richer@protonmail.com>");
|
||||||
|
MODULE_DESCRIPTION("Un module noyau pour utiliser le Lightning Node Pro LED");
|
||||||
|
MODULE_VERSION("1.0");
|
Loading…
Add table
Reference in a new issue