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

Auto-detect which i2c bus to use #1

Open
alexeightsix opened this issue Nov 25, 2024 · 6 comments
Open

Auto-detect which i2c bus to use #1

alexeightsix opened this issue Nov 25, 2024 · 6 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@alexeightsix
Copy link

After upgrading from Fedora 40 to 41 the script has stopped working.

/home/alex/.cargo/bin/fury-renegade-rgb -b /dev/i2c-7 -2 -4 brightness --value 0
Error:
   0: Input/output error (os error 5)

Location:
   /home/alex/.cargo/registry/src/index.crates.io-6f17d22bba15001f/fury-renegade-rgb-0.1.0/src/fury_commands.rs:103

Backtrace omitted.
Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.

  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BACKTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
                                ⋮ 3 frames hidden ⋮
   4: fury_renegade_rgb::main::ha8668f91e3426857
      at <unknown source file>:<unknown line>
   5: std::sys_common::backtrace::__rust_begin_short_backtrace::h8f9d9e1c84bf02d9
      at <unknown source file>:<unknown line>
   6: std::rt::lang_start::{{closure}}::hfcdb5f4f87b27fed
      at <unknown source file>:<unknown line>
   7: std::rt::lang_start_internal::hcee5ed89fc25829a
      at <unknown source file>:<unknown line>
   8: main<unknown>
      at <unknown source file>:<unknown line>
   9: __libc_start_call_main<unknown>
      at <unknown source file>:<unknown line>
  10: __libc_start_main_alias_1<unknown>
      at <unknown source file>:<unknown line>
  11: _start<unknown>
      at <unknown source file>:<unknown line>

I'm unsure what in the upgrade broke the binary. If you have any ideas let me know.

Thanks

@ARitz-Cracker
Copy link
Owner

These things have always been a little finicky to work with and to this day I have no idea why.

Are ya comfortable with re-building this project but with changing this line to io_err.raw_os_error() == Some(6) || io_err.raw_os_error() == Some(5)?

@ARitz-Cracker ARitz-Cracker added the good first issue Good for newcomers label Nov 25, 2024
@ARitz-Cracker
Copy link
Owner

I also never really looked into how linux determines the order of i2c busses, have you confirmed that the Fedora upgrade didn't move your i2c bus files around?

@alexeightsix
Copy link
Author

alexeightsix commented Nov 25, 2024

The command takes about 10 seconds to execute then crashes:

➜ debug (main) ✗ ./fury-renegade-rgb -b /dev/i2c-7 -2 -4 brightness --value 0
Error:
   0: Input/output error (os error 5)

Location:
   src/fury_commands.rs:103

  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BACKTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
                                ⋮ 5 frames hidden ⋮
   6: <core::result::Result<T,F> as core::ops::try_trait::FromResidual<core::result::Result<core::convert::Infallible,E>>>::from_residual::hb71983b731e368a3
      at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/core/src/result.rs:1989
   7: fury_renegade_rgb::fury_commands::MultiRamController::write_to_all::hf0535fe8f7b3305e
      at /home/alex/tmp/fury-renegade-rgb/src/fury_commands.rs:103
   8: fury_renegade_rgb::fury_commands::MultiRamController::start_command::hf1e3f191d35e1e47
      at /home/alex/tmp/fury-renegade-rgb/src/fury_commands.rs:109
   9: fury_renegade_rgb::fury_commands::MultiRamController::set_brightness_percent::h43e29eed24fe03fe
      at /home/alex/tmp/fury-renegade-rgb/src/fury_commands.rs:158
  10: fury_renegade_rgb::main::hd23474b23c897a06
      at /home/alex/tmp/fury-renegade-rgb/src/main.rs:159
  11: core::ops::function::FnOnce::call_once::hcfe86e0d77531b74
      at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/core/src/ops/function.rs:250
                                ⋮ 16 frames hidden ⋮

Run with COLORBT_SHOW_HIDDEN=1 environment variable to disable frame filtering.
Run with RUST_BACKTRACE=full to include source snippets.

I can always roll back the OS update and let you know of the issue still happens to be sure.

@alexeightsix
Copy link
Author

alexeightsix commented Nov 25, 2024

I also never really looked into how linux determines the order of i2c busses, have you confirmed that the Fedora upgrade didn't move your i2c bus files around?

Not yet, I can dig into this and get back to you.

They seem to be in the same place

➜ /dev ls | grep i2c
i2c-0
i2c-1
i2c-2
i2c-3
i2c-4
i2c-5
i2c-6
i2c-7
i2c-8
i2c-9

@alexeightsix
Copy link
Author

alexeightsix commented Dec 2, 2024

Small Update for anyone interested

It randomly started working again yesterday. The only changes I made (unintentionally) was unplugging my USB Mic (Blue Yeti) from my USB Switch/Hub directly into the Motherboards USB. I also unplugged my ethernet cable from a switch directly into the motherboard as well.

I can try plugging the mic/ethernet (not sure why ethernet would affect this though) if somebody is interested.

➜ kickstart (master) ✗ sudo /home/alex/.cargo/bin/fury-renegade-rgb -b /dev/i2c-7 -2 -4 brightness --value 0
➜ kickstart (master) ✗ echo $?
0

Thanks

@ARitz-Cracker
Copy link
Owner

Hey, being pinged on your comment reminded me that I did some additional research on this, basically:

  • /dev/i2c-* can indeed be non-deterministic in some circumstances circumstances. Since you're on a rolling release distro related to RHEL, subtle changes to the way your system handles enumerating PnP devices wouldn't surprise me, especially since stuff like hot swappable PCIe devices are a common thing in enterprise environments and systemd has been a consistent trend of just doing whatever and expecting applications to cope or ask it what the hell it's thinking.
  • Since /dev/i2c-1 works on my machine, I looked for it in the /sys folder.
  • After doing ls -l /sys/class/i2c-dev/i2c-1/device, I noticed an interesting symlink device -> ../../0000:00:14.0, wich corresponds to the following entry on lspci...
00:14.0 SMBus: Advanced Micro Devices, Inc. [AMD] FCH SMBus Controller (rev 71)
        Subsystem: ASUSTeK Computer Inc. FCH SMBus Controller
        Flags: 66MHz, medium devsel, IOMMU group 11
        Kernel driver in use: piix4_smbus
        Kernel modules: i2c_piix4, sp5100_tco

...on my R9 7950X3D + ROG STRIX X670E-E GAMING WIFI. Which... provides 3 i2c busses, and on my system the RAM RGB controller is connected to the first one it provides.

At the very least, this should help in determining what i2c device you should use if it ever moves around again. I don't have time in the foreseeable future to know what the "proper" way of finding the correct i2c device is unfortunately. (Asking systemd via dbus? How should I probe the bus for the RAM w/o risking wiping your BIOS settings?) So I'll leave this issue open for now.

@ARitz-Cracker ARitz-Cracker added the help wanted Extra attention is needed label Dec 2, 2024
@ARitz-Cracker ARitz-Cracker changed the title Broken after OS update Auto-detect which i2c bus to use Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants