Skip to content

Commit

Permalink
Relocate usb_detach to utils (qmk#5121)
Browse files Browse the repository at this point in the history
* Relocate usb_detach to utils

* Relocate usb_detach to utils - fix up files after move
  • Loading branch information
zvecr authored and drashna committed Feb 18, 2019
1 parent 545f95c commit 1a6a2a7
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 105 deletions.
33 changes: 0 additions & 33 deletions keyboards/jj40/tools/usb_detach.c

This file was deleted.

16 changes: 0 additions & 16 deletions keyboards/jj4x4/tools/README.md

This file was deleted.

33 changes: 0 additions & 33 deletions keyboards/jj4x4/tools/usb_detach.c

This file was deleted.

16 changes: 0 additions & 16 deletions keyboards/ymd96/tools/README.md

This file was deleted.

18 changes: 18 additions & 0 deletions util/usb_detach/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# the compiler: gcc for C program, define as g++ for C++
CC = gcc

# compiler flags:
# -g adds debugging information to the executable file
# -Wall turns on most, but not all, compiler warnings
CFLAGS = -g -Wall

# the build target executable:
TARGET = usb_detach

all: $(TARGET)

$(TARGET): $(TARGET).c
$(CC) $(CFLAGS) -o $(TARGET) $(TARGET).c

clean:
$(RM) $(TARGET)
12 changes: 5 additions & 7 deletions keyboards/jj40/tools/README.md → util/usb_detach/readme.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
# JJ40 Tools

## usb_detach.c
# usb_detach

When trying to flash on Linux, you may encounter a "Resource Unavailable" error. This means that Linux's HID driver has taken exclusive control of the keyboard, and the program script can't flash it.
This program can force Linux to give up a device, so that the programming script can reset it.

### To compile:
```
gcc usb_detach.c -o usb_detach
## To compile:
```bash
make clean && make
```

### To run:
## To run:
1. Use `lsusb` to discover the Bus and Device numbers for your keyboard.
2. Run the program: `sudo ./usb_detach /dev/bus/usb/<BUS>/<DEVICE>`.
3. Build and program the firmware as normal.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* Found at https://www.linuxquestions.org/questions/linux-hardware-18/how-to-unclaim-usb-device-558138/#post3406986 */
#include <stdio.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
Expand Down

0 comments on commit 1a6a2a7

Please sign in to comment.