How to send IPMI commands over I2C? - linux-device-driver

I am looking into trying to run ipmitool over I2C and was wondering if this is supported. I have a raspberry Pi connected via I2C to another device that has a BMC. I have the character device /dev/i2c-1 which I can use to write I2C commands to but I am hoping to be able to send IPMI commands instead, such as with ipmitool.
If I connect the Pi and other system both to the same network, I can still send commands over ipmitool's lanplus interface but that is not what I want to do. I would like to see if sending them over I2C is possible.
Most commands I run with ipmitool seem to attempt to open the file /dev/ipmi-N which doesn't exist on my raspberry pi. I checked the driver support in the kernel for getting that (https://www.kernel.org/doc/html/latest/driver-api/ipmi.html) and made sure that my kernel has ipmi_msghandler, ipmi_devintf, and ipmi_ssif compiled into it. But still no luck. I suspect the issue is that I haven't correctly configured the ipmi_ssif driver on the kernel command line. Am I on the right path with this? I determined the i2c address with i2cdetect -y 1 and it shows up as 0x10. Dumping the file cat /sys/class/i2c-adapter/i2c-1/name shows me that my adapter is bcm2835. This led me to try to add ipmb_ssif.addr=0x10 ipmi_ssif.adapter=bcm2835 ipmi_ssif.dbg=1,2,4,8 ipmi_ssif.dbg_probe=1 to the kernel command line. However, I didn't specify anything for ipmi_ssif.slave_addrs, ipmi_ssif.tryacpi, or ipmi_ssif.trydmi which admittedly could be my problem. I don't know if it could also be just something with the raspberry Pi maybe not having some support for this or something. Any ideas?
I also tried the driver ipmi_si, although the Pi doesn't seem to have the hardware support for this. I suspect that's trying to access a BMC locally instead of trying to go over I2C. Since the ipmi_ssif talks about going over an SMBus that seemed like the one that I wanted.
I did also looked through some of the other interfaces that ipmitool supports and went down a bit of a rabbit hole with the ipmb-dev-int driver (https://www.kernel.org/doc/html/latest/driver-api/ipmb.html) since that also looked promising and originally mistook it for imb interface. But it doesn't look like ipmitool has that as an interface. But perhaps there is another one there that might be a better option for what I am trying to do. Maybe the free interface for working with freeipmi?
Any ideas would be greatly appreciated!

I posted a similar question to the folks who maintain ipmitool https://github.com/ipmitool/ipmitool/discussions/296 and one of the maintainers there helped me out by pointing me to another ipmb driver https://github.com/Mellanox/ipmb-host that looks like I might be able to use in combination with the OpenIPMI interface.

Related

Connecting two PC's via RS485 (USB to RS485 converter)

I'm trying to establish Modbus RTU connection (for learning purposes) between two PC's (Win10). I'm using two USB to RS485 converters (D- connected together and D+ also connected together). This converters are connected to USB2.0 ports.
USB to RS485 converter
So I'm using "Modbus Poll" and "Modbus Slave" from "modbus tools".
First computer act as slave and has the following settings:
Slave configuration
Slave definition
Second computer act as master and has following settings:
Master configuration
Master definition
And my problem is, everytime i get "Timeout error":
Timeout error
So, what I'm doing wrong? I'm pretty sure converters are not damaged, because Win10 detecs them.
After all I just want to send simple value to another computer (via Modbus RTU) :)
Thanks
Well, this is not a real answer but I can provide some debugging suggestions.
In the past, I had problems with that RS-485 hardware you're using. It didn't work and I'm not sure why. The one I have uses a strange logic to drive DE pin of the MAX485. If I remember correctly, it inverts the TX line coming from CH340G using a NAND gate and feeds it to DE pin. I'm not sure if it was the problem, but I don't think it's a good design.
You may need pull-up and pull-down resistors on RS-485 lines to prevent it from floating when no driver is driving the bus. Some converters include them internally. Also, you may need 120 ohm termination resistors on both ends.
Instead of working with RS-485, you can simply use TTL logic for testing purposes. Use two USB-TTL converters, connect TX to RX (cross connection).
When debugging communication buses (USART, SPI, I2C etc.) always use logic analyzers. Even the cheapest one saves hours of debugging time.
you need to install proper drivers. I used following link which includes a how to video as well as download link for the drivers . Also disable RTS as its 2 wire RS485 so RTS cant be used.

Adress external Hardware directly without driver?

Is it possible to access external hardware without using a driver, i.e. not having the driver abstraction layer in between program and external device?
Can you use a device by implementing your own driver-like controlling/handling directly in your program code?
I'm trying to understand a program that implements a Modbus protocol and some very specific Modbus configurations. Now I don't know how exactly it communicates with the Modbus devices.
It looks to me that this is very similar to what a driver does.
But can it even communicate DIRECTLY with the device without having a driver installed?
Yes, there are several micro-kernel OS's that always configure this way -- drivers are entirely implemented outside of the kernel.
The first thing you likely need is to get access to the device's registers; typically performed with mmap(), you may need to dig around a bit to find the right settings for cacheability, etc...
Second problem is interrupts. Unless you are running something like QNX, you won't have a way to have interrupts signal your program directly. You will probably have to turn them off and poll the device periodically.
If you are using linux and need io ports (inb, outb, etc...) man ioperm for more information.

What is the minimum hardware requirements for a CAN bus simulation?

I am making a research about CAN bus, and I need to see how it works. Is there a way to simulate simple CAN bus instructions? What hardware I must have for this purpose?
P.S: I am very new to topic.
To simulate can instructions you don't need any hardware. You can use socketcan under Linux and setup a virtual can-interface.
After you have setup the virtual can-interface vcan0, to try first things install can-utils:
sudo apt install can-utils
Then listen on the virtual can interface vcan0 by executing
candump vcan0
On another terminal send for example a can frame (with identifier 123) with 3 bytes of data 0x123456 to the interface vcan0 via
cansend vcan0 123#123456
You should also see the sent can-frame on the other terminal, where you executed candump vcan0.
In case you really want to "talk" to a real CAN-network you need hardware. One good and cost-effective way, would be to use a Raspberry Pi with a CAN-extension shield. Also there you can use socketcan + can-utils.

Is there any better option that PI4J to write/read from UART in raspbian?

i'm looking for a better way for UART I/O in my raspberryPI in the linux side where i'm using Java.
now i'm using PI4J (wiringPI) but i'm facing few problems, i noticed many missing messages.
Also it's limited to 57600 baud rate and i wish to use higher.
So i was wondering if there is another well tested way to communicate.
In the other side i run c on cc2530 which run perfectly.
My main problem is in the java side where some messages get lost.
Thanks
I'm not sure of the exact Zigbee module you're working with, but this summary of the CC2530 says that it supports UART and SPI. Perhaps you can check the documentation for the module you're using and see if SPI might be a better alternative. Depending on the 2530's capability, SPI can be much faster than 57600.
Ok Found the JSerialComm which give what i needed.

Receive BLE beacon with Raspberry Pi

I am looking for a tutorial on how to receive an iBeacon signal with a Raspberry PI.
What I am trying to do is monitor a zone of our warehouse. Once a beacon that advertises specific information enters that zone the rasperry Pi should send a REST request to a webservice.
I've found this: Can RaspberryPi with BLE Dongle detect iBeacons? but it does not quite answer my question. Does anyone know of a good tutorial how to implement something like the above?
(the easier the better, I am not exactly a programming whiz ... :-) )
Cheers,
Vitus
My company is working on tools to make doing this easier, but we do not have a tutorial available yet. We are the ones who posted the information you referenced: Can RaspberryPi with BLE Dongle detect iBeacons?
If you want to call a ReST service when an iBeacon is detected, you can use it with the detection script we provided. As the detection script runs, it writes out the identifiers of any iBeacons it sees. What you would need to do is write a separate program that reads in the output of this script, looks for identifiers that it cares about, then calls the ReST service when it sees them.
Connecting two programs by taking the standard output of one and reading it with another is a very common programming technique on Linux. You would run our program with ibeacon_scan -b and it would output the information below:
2F234454-CF6D-4A0F-ADF2-F4911BA9FFA6 1 6 -59
E2C56DB5-DFFB-48D2-B060-D0F5A71096E0 6 9 -55
74278BDA-B644-4520-8F0C-720EAF059935 0 73 -50
You would then read this information in with your second program line by line, parsing out the three part identifier from each line. And then call your ReST Service if the identifiers match the iBeacon you are looking for.
The specifics of how you do this depend on what programming language you want to use. You could do it in C, Ruby, Perl, Java or any other language supported by the Raspberry Pi. If you have a client library for your ReST service, you probably want to build this program in whatever language that client library uses.
Full disclosure: I am Chief Engineer for Radius Networks.