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

Need to install dev rules after every startup #69

Closed
tothbar opened this issue Nov 4, 2024 · 19 comments · Fixed by #72
Closed

Need to install dev rules after every startup #69

tothbar opened this issue Nov 4, 2024 · 19 comments · Fixed by #72
Assignees
Milestone

Comments

@tothbar
Copy link

tothbar commented Nov 4, 2024

Hi, I'm using raspberry pi5 with a fresh install of rasbian arm64. For some reason I need to install the dev rules after every time I reboot the system. Do u know any solutions for this?

@szszoke
Copy link
Contributor

szszoke commented Nov 5, 2024

Can you post the output of the install script and can you check that the installed files are still there after reboot?

@tothbar
Copy link
Author

tothbar commented Nov 5, 2024

make[1]: Entering directory '/home/tothbar/overwitch/udev' make[1]: Nothing to be done for 'install-exec-am'. /usr/bin/mkdir -p '/lib/udev/hwdb.d' /usr/bin/install -c -m 644 20-usb-elektron.hwdb '/lib/udev/hwdb.d' /usr/bin/mkdir -p '/lib/udev/rules.d' /usr/bin/install -c -m 644 20-usb-elektron.rules '/lib/udev/rules.d' make install-data-hook make[2]: Entering directory '/home/tothbar/overwitch/udev' make[2]: Leaving directory '/home/tothbar/overwitch/udev' make[1]: Leaving directory '/home/tothbar/overwitch/udev'

after it I can see the the 20-usb-elektron-rules file, and also after reboot.
Then I found out that the problem is that the Digitakt was plugged in before I booted the raspberry pi. If I replugged it in, it worked flawlessly, otherwise this is the error message I got:

$ overwitch-cli -d Digitakt ERROR:engine.c:750:ow_engine_init_from_bus_address: Error while opening device: LIBUSB_ERROR_ACCESS ERROR:jclient.c:302:jclient_init: Overwitch error: can't find a matching device

so I guess I found the problem, sorry for taking your time. But if there would be a way to make the system recognize the device if it's plugged in before it started, that would make things even more stable.

thanks, Barnabás

@dagargo
Copy link
Owner

dagargo commented Nov 5, 2024

That's a known problem with devices in Overbridge mode. At least, it happens to me every time I reboot my computer.

As you've said replugging the USB cable solves it. Changing the USB mode in the devices works too.

@tothbar
Copy link
Author

tothbar commented Nov 5, 2024

Thanks for your help guys!

@tothbar tothbar closed this as completed Nov 5, 2024
@szszoke
Copy link
Contributor

szszoke commented Nov 5, 2024

I wonder if it would be enough to reset the USB ports.

Can you try to follow the answer from the post below and report back if it solved the issue?

https://unix.stackexchange.com/questions/234581/disconnect-and-reconnect-usb-port-via-cli#243457

If it works, maybe this could be automated?

@dagargo dagargo reopened this Nov 5, 2024
@dagargo
Copy link
Owner

dagargo commented Nov 5, 2024

I'll try to take a look at this because resetting the device manually is annoying.

@dagargo dagargo self-assigned this Nov 5, 2024
@dagargo dagargo added this to the 2.0 milestone Nov 5, 2024
@tothbar
Copy link
Author

tothbar commented Nov 5, 2024

okey, then I won't try now

@dagargo
Copy link
Owner

dagargo commented Nov 6, 2024

I've noticed that the issue is that the udev rules are not applied at boot. At least not correctly.

The error LIBUSB_ERROR_ACCESS means access denied (insufficient permissions).

$ overwitch-cli
ERROR:engine.c:757:ow_engine_init_from_bus_address: Error while opening device: LIBUSB_ERROR_ACCESS
ERROR:jclient.c:302:jclient_init: Overwitch error: can't find a matching device

Changing the permission manually fixes it. Digitakt is device 006 attached to bus 003.

$ ls -la /dev/bus/usb/003/007
crw-rw-r-- 1 root root 189, 262 nov  6 23:28 /dev/bus/usb/003/007

$ sudo chmod 666 /dev/bus/usb/003/006

So the issue is outside the Overwitch code. But it might be on the udev rules definition though.

@tothbar, could you confirm that this solves your issue? At least we'll know where to look next.

@dagargo
Copy link
Owner

dagargo commented Nov 8, 2024

Running sudo udevadm trigger forces the execution of the rules and fixes the issue.

Further research seems to indicate that the prefix 20 is to low to be applied correctly at boot and changing it to 91 as suggested here seems to have fixed it.

fix-apply-udev-rules-at-boot branch contains the fix.

@tothbar, take a look at the branch and once you confirm it works it will be merged into master. BTW, don't forget to run make uninstall from the udev directory before pulling the changes so that no old rules are installed.

@szszoke
Copy link
Contributor

szszoke commented Nov 10, 2024

make uninstall doesn't actually seem to remove anything on my system.

@dagargo
Copy link
Owner

dagargo commented Nov 10, 2024

Thanks for reporting this, @szszoke.

Running make uninstall is fixed in master and gtk3-overbridge-cc-midi and deletes the rules as expected.

Also, branch fix-apply-udev-rules-at-boot incorporates the uninstaling code too.

Same situation as before. Don't forget to run make uninstall from the udev directory before pulling the changes of the fix-apply-udev-rules-at-boot. And once it's tested I'll merge it into master.

@szszoke
Copy link
Contributor

szszoke commented Nov 10, 2024

make uninstall in master and fix-apply-udev-rules-at-boot works now. I am rebooting now and report back if there are any permission issues.

@szszoke
Copy link
Contributor

szszoke commented Nov 10, 2024

I could not see permission issues after rebooting just my computer but not my DT2. Overwitch just worked.

@tothbar
Copy link
Author

tothbar commented Nov 15, 2024

got back to the project now. Thanks guys for the fix, it works perfectly.

@tothbar
Copy link
Author

tothbar commented Nov 15, 2024

i made a script now, to lunch overwitch when usb is connected

`#!/bin/bash
sleep 1
sudo -u tothbar /usr/local/bin/overwitch-cli -d Digitone -v >> /var/log/usb-log.txt 2>&1

echo "Digitone-overwitch started" >> /var/log/usb-log.txt

`

created it with sudo nano /usr/local/bin/run_overwitch_dt.sh
also run sudo chmod +x /usr/local/bin/run_overwitch_dt.sh

and made the udev rule with
sudo nano /etc/udev/rules.d/run_overwitch_dt.rules

contains:
ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="1935", ATTR{idProduct}=="0b36", RUN+="/usr/local/bin/run_overwitch_dt.sh"

works perfeclty, its so much more convenient now!

@dagargo dagargo reopened this Nov 16, 2024
@dagargo
Copy link
Owner

dagargo commented Nov 16, 2024

That is really cool.

Would you like to add this to the README.md? I can do it myself too If you're OK with it.

Perhaps we could create a subsection at the end of the Installation section.

https://github.com/dagargo/overwitch?tab=readme-ov-file#installation

@tothbar
Copy link
Author

tothbar commented Nov 16, 2024

Ill! newer did something like this:)

@dagargo
Copy link
Owner

dagargo commented Nov 23, 2024

Inspired by the @tothbar idea, I've just added an option to run overwitch-cli as a service. It uses USB hotplug to be notified when an Elektron device is plugged in.

$ overwitch-cli -s -vv
DEBUG:engine.c:1225:ow_hotplug_loop: Registering USB hotplug callback...
[...]
DEBUG:engine.c:1183:ow_hotplug_callback: USB hotplug: device arrived
DEBUG:main-cli.c:242:hotplug_callback: Starting new jclient for bus 003 and address 009...
DEBUG:main-cli.c:280:hotplug_callback: Pooled jclient 0 available...
[...]

This way, having a systemd unit works and there is no need for service restarts when plugging in devices.

/etc/systemd/user$ cat overwitch.service 
[Unit]
Description=Overwitch service

[Service]
GuessMainPID=true
ExecStart=overwitch-cli -b 8 -s
Restart=on-failure

Obviously, when running the service there is no need for the GUI whatsoever.

@dagargo
Copy link
Owner

dagargo commented Nov 26, 2024

@tothbar, I've just added the documentation to the README.md in d68de3b.

Take a look and, if you want to add something, create a new issue or a PR.

@dagargo dagargo closed this as completed Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants