You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Need a way to detect BrickPi and PiStorms on Raspberry Pi #412
This came up in a conversation with @ddemidov in ev3dev/ev3dev-lang@ac9a629#commitcomment-13858910. We want to be able to use the same image file for both BrickPi and PiStorms. Users will have to select which one is attached by changing a setting in config.txt. PiStorms will be easy to detect since is uses a I2C/NXT connection. Basically, it will be automatically detected and everything should "just work". The BrickPi on the other hand uses a tty line discipline. This is attached by a systemd service. So, we need something that can trigger the systemd service rather than the user having to manually enable or disable it. Right now, the presence of the brickpi LED devices is the only thing we have to go off of. It seems like there should be a better way to do this, but I haven't come up with anything yet. Just throwing this out there in case there are any device tree experts listening that may have a better idea.
BrickPi: The file /sys/class/tty/ttyAMA0/device/of_node/brickpi,status exists and contains okay. (Yes, that is a comma and it is part of the file name.)
Can we introduce a system shell script (ev3dev_platform?) that would return ev3/brickpi/pistorms based on this? The script could be universally used by all the bindings.
Can we introduce a more general form of this platform detection? I know that in some cases, the DKMS drivers are all that a user will have, but for the rest of the platforms, we actually have control of the image on the SD card, and therefore we control the kernel.
Can we not just add a known string to /proc/cpuinfo or create our own /proc/ev3devor/sys/class/ev3dev/platform` that has the version string?
Can we introduce a system shell script (ev3dev_platform?) that would return ev3/brickpi/pistorms based on this? The script could be universally used by all the bindings.
Yes, we can do this.
Can we introduce a more general form of this platform detection?
No, we can't. If users are using DKMS drivers, then they just don't have a specific platform. You will never get EV3 LEDs or BrickPi LEDs or PiStorms LEDs using DKMS. These are defined by the board configuration file in the kernel in the case of EV3 and in device-tree overlays in the case of Raspberry Pi. And in fact, your question has made me realize that my proposed detection for the PiStorms is really too general as it is and needs to be revised.
Can we not just add a known string to /proc/cpuinfo
This is exactly what has been done in the case of the EV3. But on Raspberry Pi, this can only tell us which model of Raspberry Pi we have. It cannot tell if we have a BrickPi or a PiStorms or neither.
or create our own /proc/ev3devor/sys/class/ev3dev/platform` that has the version string?
This is exactly what I have done in the case of the BrickPi. The file /sys/class/tty/ttyAMA0/device/of_node/brickpi,status only exists when the BrickPi overlay is enabled. I'm thinking I should do the same for PiStorms. However it doesn't use the tty. It uses i2c and spi. The i2c can be one of 2 devices depending on which Pi model you have which was the reason for the ?, but perhaps we can attach a custom attribute to the spi instead.
Can we introduce a system shell script (ev3dev_platform?) that would return ev3/brickpi/pistorms based on this? The script could be universally used by all the bindings.
However, as @rhempel mentioned, people can be using ev3dev on non-ev3dev platforms, so depending on an external tool is probably not the best idea.
In the case of the EV3, obviously yes. In the case of Raspberry Pi, no. However, on the Raspberry Pi in order to have the full "platform" for BrickPi or PiStorms, you have to have the device-tree overlays (which is sort of like a custom kernel).
Sooo - can we put a virtual "thing" in the device tree that forces a kernel module to be required, and all that kernel module does is create a node somewhere in /sys that lets us identify the hardware?
I guess what you are getting at is we should have one single place to look for all platforms? That is probably not be possible with device tree without a custom kernel.
Well, after thinking about it some more, of course we could do that because we would have the driver in our DKMS package. So, the only problem I see with that is what happens when someone puts their PiStorms on their BrickPi and both overlays try to create the same device node.
I like this. I think we won't loose any functionality this way except for led grouping. I guess there is no generic way to tell that some leds form a group that may be combined to control color? Of course we could put all possible groupings into specification, and only use those that do exist on the current platform.
devicename can contain : characters, so when parsing you need to search for the last two :s. For leds that can be controlled by ev3dev, the function will be ev3dev. All other leds should be ignored. Led groups will have the same devicename but a different color.
For BrickPi and PiStorms the group names can be directly mapped to device names (brickpi1/brickpi2 and pistroms:BA/pistorms:BB). For ev3 its not so obvious: each led gets unique device name. We could strip device names of trailing digits (and get ev3-left/ev3-right groups for ev3), but that would also break grouping for brickpi.
RIght now the blockly blocks on roberta are quite statically modeled to work for the ev3. We can probably do things to have more dynamic led blocks easilly.
@dlech on ev3dev, could we drop the numbers? So that we have ev3-{left,right}:{red,green}:ev3dev. To an app that reads like left and right led with r/g controls. The facts that it is two separate leds instead one combined is an impl detail.
I agree with @ddemidov and @ensonic - the LED number is an implementation detail.
Now if the group of LEDs on the left side of the board were arranged in a line (think bars of reception or battery indicator) then an index number would be reasonable.
Let's think about how to specify LED groups in spec.json in a general way and use the spec to generate platform specific code.
Actually, even if we don't autogenerate the code, thinking about the LED groups in the spec will probably help us come up with a better naming scheme.
Yes. I'm thinking ev3:{left,right}:{red,green}:ev3dev (colon after the ev3 instead of dash) to make it more like the pistorms.
And the more I'm thinking about this, detecting each component individually makes more sense than trying to define an entire platform from a single property. Not only are there nuances between each platform, there are already nuances within each platform (e.g. color screen on EV3 and BrickPi/BrickPi+). And BrickPi and PiStorms have frimware that can be upgraded, so it is possible there could be even more differences and we would have to look at firmware version too. I gets very complex very quickly. I think just looking at each subsystem individually is going to work better in the long run.
Buttons: /sys/class/input/input*/name. It will tell you the "platform
It says EV3 buttons and EV3 speaker beep on EV3. Is there a way to know actual buttons supported on the system, or should we keep a database of platform keys?
In/Out ports.
If I do cat /sys/class/lego-port/*/port_name on EV3, I get
in1
in2
in3
in4
outA
outB
outC
outD
Is lego-port class supported on all platforms, or just ev3?
Is there a way to know actual buttons supported on the system
Yes, /sys/class/input/input0/capabilities/key returns a bitmask of the keys that are present. the EVIOCGBIT(ev,len) ioctl does the same thing.
or should we keep a database of platform keys?
If you want the keys available via introspection while developing on a host computer, then probably yes.
Is lego-port class supported on all platforms, or just ev3?
The lego-port class is on on all platforms. Additionally, if you have any kind of sensor multiplexer, you will have additional ports, like in1:i2c8:mux2, etc. On BrickPi (for now) the port names are the same (in1, outA), but on PiStorms, they are pistorms:BAS1, pistorms:BAM1.
For your information, I've just received a brand new PiStorms, and the RGB LED on the left side (bank B) is not here any more on the new version of the board (black PCB).
I firstly suspected my board to be damaged, since not being able to activate it using the provided Python lib, but the support team answered me with this information after asking them.
Activity
dlech commentedon Nov 4, 2015
OK. Recommended way to know if you are running on...
EV3: The file
/proc/cpuinfocontains the stringLEGO MINDSTORMS EV3 Programmable Brick.BrickPi: The file
/sys/class/tty/ttyAMA0/device/of_node/brickpi,statusexists and containsokay. (Yes, that is a comma and it is part of the file name.)PiStorms: The directory
/sys/bus/i2c/drivers/pistormsexists and contains the symlink (directory)?-001a(and?-001b).Add custom device-tree property check to udev rule.
ddemidov commentedon Nov 4, 2015
Can we introduce a system shell script (
ev3dev_platform?) that would returnev3/brickpi/pistormsbased on this? The script could be universally used by all the bindings.rhempel commentedon Nov 4, 2015
Can we introduce a more general form of this platform detection? I know that in some cases, the DKMS drivers are all that a user will have, but for the rest of the platforms, we actually have control of the image on the SD card, and therefore we control the kernel.
Can we not just add a known string to
/proc/cpuinfoor create our own /proc/ev3devor/sys/class/ev3dev/platform` that has the version string?dlech commentedon Nov 4, 2015
Yes, we can do this.
No, we can't. If users are using DKMS drivers, then they just don't have a specific platform. You will never get EV3 LEDs or BrickPi LEDs or PiStorms LEDs using DKMS. These are defined by the board configuration file in the kernel in the case of EV3 and in device-tree overlays in the case of Raspberry Pi. And in fact, your question has made me realize that my proposed detection for the PiStorms is really too general as it is and needs to be revised.
This is exactly what has been done in the case of the EV3. But on Raspberry Pi, this can only tell us which model of Raspberry Pi we have. It cannot tell if we have a BrickPi or a PiStorms or neither.
This is exactly what I have done in the case of the BrickPi. The file
/sys/class/tty/ttyAMA0/device/of_node/brickpi,statusonly exists when the BrickPi overlay is enabled. I'm thinking I should do the same for PiStorms. However it doesn't use the tty. It uses i2c and spi. The i2c can be one of 2 devices depending on which Pi model you have which was the reason for the?, but perhaps we can attach a custom attribute to the spi instead.dlech commentedon Nov 4, 2015
However, as @rhempel mentioned, people can be using ev3dev on non-ev3dev platforms, so depending on an external tool is probably not the best idea.
rhempel commentedon Nov 4, 2015
Does each supported platform need a custom kernel?
dlech commentedon Nov 4, 2015
In the case of the EV3, obviously yes. In the case of Raspberry Pi, no. However, on the Raspberry Pi in order to have the full "platform" for BrickPi or PiStorms, you have to have the device-tree overlays (which is sort of like a custom kernel).
rhempel commentedon Nov 4, 2015
Sooo - can we put a virtual "thing" in the device tree that forces a kernel module to be required, and all that kernel module does is create a node somewhere in
/systhat lets us identify the hardware?dlech commentedon Nov 4, 2015
I guess what you are getting at is we should have one single place to look for all platforms? That is probably not be possible with device tree without a custom kernel.
dlech commentedon Nov 5, 2015
Well, after thinking about it some more, of course we could do that because we would have the driver in our DKMS package. So, the only problem I see with that is what happens when someone puts their PiStorms on their BrickPi and both overlays try to create the same device node.
7 remaining items
ddemidov commentedon Nov 6, 2015
I like this. I think we won't loose any functionality this way except for led grouping. I guess there is no generic way to tell that some leds form a group that may be combined to control color? Of course we could put all possible groupings into specification, and only use those that do exist on the current platform.
dlech commentedon Nov 6, 2015
Actually, you can tell led groupings. The standard format for led names is
devicename:color:function(comes from https://www.kernel.org/doc/Documentation/leds/leds-class.txt).devicenamecan contain:characters, so when parsing you need to search for the last two:s. For leds that can be controlled by ev3dev, thefunctionwill beev3dev. All other leds should be ignored. Led groups will have the samedevicenamebut a differentcolor.ddemidov commentedon Nov 6, 2015
These are led names I know about:
EV3:
BrickPi:
PiStorms:
For BrickPi and PiStorms the group names can be directly mapped to device names (
brickpi1/brickpi2andpistroms:BA/pistorms:BB). For ev3 its not so obvious: each led gets unique device name. We could strip device names of trailing digits (and getev3-left/ev3-rightgroups for ev3), but that would also break grouping for brickpi.Is it possible to rename leds on ev3 to be
?
ensonic commentedon Nov 6, 2015
RIght now the blockly blocks on roberta are quite statically modeled to work for the ev3. We can probably do things to have more dynamic led blocks easilly.
@dlech on ev3dev, could we drop the numbers? So that we have ev3-{left,right}:{red,green}:ev3dev. To an app that reads like left and right led with r/g controls. The facts that it is two separate leds instead one combined is an impl detail.
rhempel commentedon Nov 6, 2015
I agree with @ddemidov and @ensonic - the LED number is an implementation detail.
Now if the group of LEDs on the left side of the board were arranged in a line (think bars of reception or battery indicator) then an index number would be reasonable.
Let's think about how to specify LED groups in
spec.jsonin a general way and use the spec to generate platform specific code.Actually, even if we don't autogenerate the code, thinking about the LED groups in the spec will probably help us come up with a better naming scheme.
dlech commentedon Nov 6, 2015
Yes. I'm thinking
ev3:{left,right}:{red,green}:ev3dev(colon after theev3instead of dash) to make it more like the pistorms.And the more I'm thinking about this, detecting each component individually makes more sense than trying to define an entire platform from a single property. Not only are there nuances between each platform, there are already nuances within each platform (e.g. color screen on EV3 and BrickPi/BrickPi+). And BrickPi and PiStorms have frimware that can be upgraded, so it is possible there could be even more differences and we would have to look at firmware version too. I gets very complex very quickly. I think just looking at each subsystem individually is going to work better in the long run.
Rename EV3 LEDs.
ddemidov commentedon Nov 6, 2015
It says
EV3 buttonsandEV3 speaker beepon EV3. Is there a way to know actual buttons supported on the system, or should we keep a database of platform keys?If I do
cat /sys/class/lego-port/*/port_nameon EV3, I getIs lego-port class supported on all platforms, or just ev3?
dlech commentedon Nov 6, 2015
Yes,
/sys/class/input/input0/capabilities/keyreturns a bitmask of the keys that are present. theEVIOCGBIT(ev,len)ioctl does the same thing.If you want the keys available via introspection while developing on a host computer, then probably yes.
The lego-port class is on on all platforms. Additionally, if you have any kind of sensor multiplexer, you will have additional ports, like
in1:i2c8:mux2, etc. On BrickPi (for now) the port names are the same (in1,outA), but on PiStorms, they arepistorms:BAS1,pistorms:BAM1.dlech commentedon Nov 9, 2015
Fix released in kernel cycle 8 (
*-8-ev3dev-*).EricPobot commentedon Dec 4, 2015
For your information, I've just received a brand new PiStorms, and the RGB LED on the left side (bank B) is not here any more on the new version of the board (black PCB).
I firstly suspected my board to be damaged, since not being able to activate it using the provided Python lib, but the support team answered me with this information after asking them.
dlech commentedon Dec 4, 2015
please open a new issue for this.
EricPobot commentedon Dec 4, 2015
I was just giving this as an info, since this thread seemed to talk about board identification. It was not an issue in my mind.