-
Notifications
You must be signed in to change notification settings - Fork 79
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
Multiple digispark USB #14
Comments
It's not the hardware nor the driver that does the bus enumeration but imho the i2c subsystem of the Linux kernel. And yes, you can simply plug multiple devices into your PC and they'll get individual busses assigned. |
OK, that's good news 👍 If each one is named the same, I won't know if that I2C bus is the one with inputs or the outputs... :-( |
This problem is more sever than I've thought. I've just tested to plug in 2 keys, than unplugged and switched:
Depending which device I've plugged first and what USB order, the BUS# got reordered.
|
Found this, but don't know how to implement it. |
Other possible solution: Add an i2c eeprom to each bus with some unique ID. Then read the IDs from eeprom to know which bus you are talking to. |
I still believe it is easier to modify the name of each firmware.
So, if I find out how to recompile 10x with alternate numbered names, like:
main51.hex My fear is:
|
The driver recognizes the device by USB IDs. Changing the name should not hurt. |
Maybe setting
and trying to detect this in an own UDEV rule is safer. I don't know what UDEV can do with I2C devices, but for others it e.g. can make symlinks with names you want. See: http://hintshop.ludvig.co.nz/show/persistent-names-usb-serial-devices |
Indeed, using udev is the canonical way to solve this kind of issues under Linux.
As you can see, also the USB port is identified, so if you plug the devices always to the same port, you can also identify them, and creating a symlink to the freshly created I2C device accordingly. If the USB port is not predictable, than you can also run an external program from the udev rule to create the desired name for the device (ie. i2cdetect via a bash script to get the available i2c slave addresses on the plugged in i2c bus), and based on the available addresses, you can figure out which bus you are on. See http://www.reactivated.net/writing_udev_rules.html#external-naming. |
You can also distinguish the devices by their position in the physical USB device tree. This information can be gathered from the sysfs or indirectly using tools line usb-devices. |
That's not possible if working remotely. The device HAS TO HAVE a unique name so it can be identified. Like:
That's an other possibility that CAN happen in real life scenarios and needs to be prevented:
A unique identification is needed to set FIXed I2C Bus addresses, so no accidents may happen even if:
A wrong identification of the bus number or device name can cause serious problems. |
Ah, i meant that you can use the
Well, in this scenario either you have to physically make impossible to connect the devices to other USB plugs or/and indeed identify the bus somehow, for example by the available I2C addresses on the bus (if they are different), or as @harbaum suggested, by placing an i2c eeprom to each bus with some unique ID. |
How do I change the I2C bus address of a ATTiny85 Digispark dongle, if I would like to use multiple of them on the same Raspberry Pi4? (Or with a USB HUB.)
I guess I have to re-compile the firmware it again for each one?
Checked both digital.h & main.c files, but did not find any "I2C_BASE_BUS_ADDRESS" or anything similar.
Raspberry Pi4 has 4 I2C buses by default, so this should start from 8+
... or ...
if the BUS address is given by Debian OS, how /where should I change the name or unique identifier of the flashed device so I can distinguish one from the others?
Sorry if my question is wrong, I'm a newbee to this. Trying to drive more than 64 IO pins:
https://community.openhab.org/t/compatible-usb-i2c-adapter-for-rpi4/93690/6
The text was updated successfully, but these errors were encountered: