Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more hard-coded usbvid/pid to udev rules #1876

Merged
merged 1 commit into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions src/developer_opts.c
Original file line number Diff line number Diff line change
Expand Up @@ -1577,22 +1577,42 @@ void dev_output_pgm_defs(char *pgmidcp) {
}
}

for(LNODEID pidn=lfirst(pgm->usbpid); pidn; pidn=lnext(pidn))
udr = add_udev(udr, &ui, usbvid, *(int *) ldata(pidn), ishid, ids);
for(LNODEID pidn=lfirst(pgm->usbpid); pidn; pidn=lnext(pidn)) {
int pid = *(int *) ldata(pidn);
udr = add_udev(udr, &ui, usbvid, pid, ishid, ids);

// Piggy back PIC Snap devices that can be switched to AVR mode
if(usbvid == USB_VENDOR_ATMEL && pid >= 0x217f && pid <= 0x2181) {
udr = add_udev(udr, &ui, USB_VENDOR_MICROCHIP, USB_DEVICE_SNAP_PIC_MODE, ishid, ids);
udr = add_udev(udr, &ui, USB_VENDOR_MICROCHIP, USB_DEVICE_SNAP_PIC_MODE_BL, ishid, ids);
}
// Piggy back PIC pickit4 devices that can be switched to AVR ones
if(usbvid == USB_VENDOR_ATMEL && pid >= 0x2177 && pid <= 0x2179) {
udr = add_udev(udr, &ui, USB_VENDOR_MICROCHIP, USB_DEVICE_PICKIT4_PIC_MODE, ishid, ids);
udr = add_udev(udr, &ui, USB_VENDOR_MICROCHIP, USB_DEVICE_PICKIT4_PIC_MODE_BL, ishid, ids);
}
// Piggy back old usbasp when new one is seen
if(usbvid == USBASP_SHARED_VID && pid == USBASP_SHARED_PID)
udr = add_udev(udr, &ui, USBASP_OLD_VID, USBASP_OLD_PID, ishid, ids);
}
}

if(raw)
dev_pgm_raw(pgm);
}

int reboot = 0;
for(Dev_udev *u = udr; !reboot && u-udr < ui; u++)
reboot |= u->ishid;

if(udev && ui) {
int all = str_eq(pgmidcp, "*");
const char *var = all? "": str_asciiname((char *) str_ccprintf("-%s", pgmidcp));
dev_info("1. Examine the suggested udev rule%s below; to install run:\n\n", str_plural(ui + udr[0].ishid));
dev_info("%s -c \"%s/u\" | tail -n +%d | sudo tee /etc/udev/rules.d/55-%s%s.rules\n",
progname, pgmidcp, all? 9: 11, progname, var);
dev_info("sudo chmod 0644 /etc/udev/rules.d/55-%s%s.rules\n\n", progname, var);
dev_info("2. Unplug any AVRDUDE USB programmers and plug them in again\n");
dev_info("2. %s\n", reboot? "Reboot your computer": "Unplug any AVRDUDE USB programmers and plug them in again");
dev_info("3. Enjoy user access to the USB programmer(s)\n\n");
if(!all)
dev_info("Note: To install all udev rules known to AVRDUDE follow: %s -c \"*/u\" | more\n\n",
Expand Down
3 changes: 2 additions & 1 deletion src/jtag3.c
Original file line number Diff line number Diff line change
Expand Up @@ -1743,6 +1743,7 @@ int jtag3_open_common(PROGRAMMER *pgm, const char *port, int mode_switch) {
}
if(pic_mode >= 0) {
msg_error("\n");
cx->usb_access_error = 0;
pmsg_error("%s in %s mode detected\n",
pgmstr, pinfo.usbinfo.pid == bl_pid? "bootloader": "PIC");
if(mode_switch == PK4_SNAP_MODE_AVR) {
Expand All @@ -1757,7 +1758,7 @@ int jtag3_open_common(PROGRAMMER *pgm, const char *port, int mode_switch) {
imsg_error("run %s again to continue the session\n\n", progname);
} else {
pmsg_error("to switch into AVR mode try\n");
imsg_error("$ %s -c%s -p%s -P%s -x mode=avr\n", progname, pgmid, partdesc, port);
imsg_error("$ %s -c %s -p %s -P %s -x mode=avr\n", progname, pgmid, partdesc, port);
}
serial_close(&pgm->fd);
return LIBAVRDUDE_EXIT;;
Expand Down
1 change: 1 addition & 0 deletions src/usbasp.c
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,7 @@ static int usbasp_open(PROGRAMMER *pgm, const char *port) {
/* check if device with old VID/PID is available */
if(usbOpenDevice(pgm, &PDATA(pgm)->usbhandle, USBASP_OLD_VID, "www.fischl.de",
USBASP_OLD_PID, "USBasp", port) == 0) {
cx->usb_access_error = 0;
/* found USBasp with old IDs */
pmsg_error("found USB device USBasp with old VID/PID; please update firmware of USBasp\n");
return 0;
Expand Down
Loading