This is a mixed software/hardware question, it applies to general Linux, but I am here because I use openwrt
I am going to develop custom interface device, and must decide how to connect it to the processor module and how it will be seen in the operating system (and thus how it will be programmed). The device will be based on the MCU, therefore any standard interface may be considered. Speed must not be an issue, as well as amount of data is not significant (let's say 100 kb/s).
I can not find the info on how operating system enumerates the devices.
Let's take I2C. You can scan it to identify is there anyone out there, but there seems to be no standard identification command (to read manufacturer and device id). So how OS is going to know who actually is out there? And if various device drivers are to poll for specific device peculiarities, how is it ensured some wrong command designated for another type of device does not make a harm?
Or let's take SPI. How system knows it is SD-card connected, and not some other device? Any generic identification command? If we compare SD-card and W5500, these are totally different devices, and I see no way to have common identification except trying to speak their own language (protocol).
Thus the question in general, what would be the correct way to proceed with interface selection, so that further programming would not appear to require manually operating GPIO pins, but work through general driver?
PS. I asked a question recently, which now helps me a lot - in addition to USB being disabled in originally supplied .dtb file, I see that external I2C is also disabled as well as external SPI. So nothing is going to work out of the box
Update: with my previous developments (not related to Linux/openwrt) I usually know what device is where. So here I am more concerted with two things:
-
how to find the device I need - are device files fixed from boot to boot (and if something else is added fro hardware side), and if not we run into the problem of finding the device (see my question above) as to be identified my device must say something onto the bus into the operating system.
-
will my device be attempted to be scanned by other drivers/applications, which could potentially lead to device screwing up?