Finished up RPiBMC post, added a number of images - still WIP

This commit is contained in:
Joshua Boniface 2017-03-17 13:42:50 -04:00
parent 095b5d1d6d
commit 6c68084cf4
10 changed files with 18 additions and 10 deletions

View File

@ -15,8 +15,9 @@ IPMI BMCs are pretty ubiquitous in the datacenter and enterprise computing, beca
If you don't know what it is, the Rapberry Pi is a small single-board computer, featuring an ARM SOC, Ethernet, USB, video, audio, and most importantly, GPIO, powered by MicroUSB and running the Debian distribution '[Raspbian](https://www.raspberrypi.org/downloads/raspbian/)'. The GPIO pins allow, with a simple utility or Python library, one to control or read information from various devices, including a serial console interface. These features make the Raspberry Pi a perfect fit for a BMC, and really not that far from the "real" BMCs found in most server-grade motherboards.
(Pictured: A Raspberry Pi)
[Picture - RPi]
(Pictured: A Raspberry Pi 1 model B)
![Raspberry Pi](/images/rpibmc/rpi-1b.jpg)
## The hardware
@ -38,7 +39,8 @@ The most common way to do this is to use a USB to Serial adapter, but like the o
This method does require a special chip, as you can see in the first link above. Luckily, the converter chips can be had for about $1.50 for 5 on eBay from the right Chinese sellers. And with the tiny little board and some small jumpers, we can connect the chip not to the rear DB9 port, but directly to the motherboard COM2 header; no messy crossover cables or USB to serial adapters! The resulting device is `/dev/ttyAMA0` in Raspbian and works flawlessly with your terminal emulator of choice; I'm using screen to allow persistence and clean disconnection without terminating the serial session (more on that later!)
(Pictured: the MAX3232 signal converter board)
[Picture - MAX3232 board]
![MAX3232 Serial boards](/images/rpibmc/max3232-boards.jpg)
### GPIO to rule them all
@ -48,15 +50,19 @@ The Raspberry Pi's GPIO pins provide a nice simple method for interfacing with t
The power and reset switches are a little more complex. While you can direct the GPIO directly to the switch headers, this will not work as you would expect, and could in fact risk blowing out your motherboard by sending 3.3V into the switch headers. The solution is to use a transistor: connect the gate pin of the transistor to your GPIO pin, and the anode and cathode pins to the switch header. The result is an electrically controlled switch, which turns on when the GPIO is set high, and turns off again when the GPIO is set low. You can now safely control the power and reset switches with your Raspberry Pi.
(Pictured: the wiring layout for a first-generation model-B Raspberry Pi BMC)
[Picture - wiring diagram]
(Pictured: the wiring layout for a first-generation model-B Raspberry Pi BMC and the breadboad [sans serial])
![GPIO pinout](/images/rpibmc/rpi-1b-gpio.png)
![My wiring diagram](/images/rpibmc/wiring-diagram-sans-serial.jpg)
### Cabling it up
The actual cabling is a little more complex. Mainly because, even with a BMC-managed system, you sometimes want to press the physical power button, or see the system is on via the chassis power LED. This is easily done by using a combination of female-female and male-male jumper cables. Insert a male-male into top side of a female-female cable at one end, and voila! A male-ended lead for the chassis switch or LED, and a female-ended lead for connecting to your resistor/transistor/Raspberry Pi as you wish. Some electrical tape to keep everything snug and secure, and we have the perfect DIY out-of-band management solution!
To keep everything neat, I used a through-hole solderable breadboard to mount all the components and keep everything neat. Header pins let us interface directly between the motherboard, Raspberry Pi, and the chassis buttons and LEDs using female-female jumper cables, again keeping everything nice and neat and easy to understand. The required components include two transitiors, two resistors, and a couple jumper wires. The transitors let us control the power and reset switches with a GPIO pin, while the resistors keep us from frying the LEDs (and the Raspberry Pi).
(Pictured: the cabling of the Raspberry Pi BMC)
[Picture - the cabling]
![My wiring diagram](/images/rpibmc/finished-product.jpg)
## The software
@ -67,7 +73,8 @@ The software side started out as a basic Raspbian system, however I wanted to ma
The actual software doing the heavy lifting is a combination of `screen`, to view the host system serial console, and the `gpio` utility by WiringPi (Debian package `wiringpi`). The `screen` session is configured to start automatically at BMC boot to ensure all serial output is captured and stored for later analysis - a major problem with the (few) SSH-based BMCs I've tried! The `gpio` program makes writing and reading the GPIO pins simple and easy, returning 0 or 1 for the low/high states and easily writing states. By writing the BMB shell in `bash`, I was able to get all the flexibility I wanted without any programming overhead; the whole thing is under 200 lines.
(Pictured: an example session with `bmc.sh`)
![Shell example](/images/bmcshell.png)
![Shell example](/images/rpibmc/bmcshell-sample.png)
For example, here is the `powersw` function, which manages the power button for the `powersw` and `kill` commands. By introducing a delay, we can even simulate a power-button force-off event for the `kill` task and avoid messing with the raw power:
@ -103,7 +110,7 @@ readpower() {
}
```
The entire code of the BMC "shell" can be found on my [GitHub](https://github.com/joshuaboniface), and is called via a small hack to the `/etc/passwd` file for the `bmc` user, starting by default and terminating the SSH session on exit; to set this when creating a new user, simply pass `useradd` the `-S /path/to/bmc.sh` flag instead:
The entire code of the BMC "shell" can be found on my [GitHub](https://github.com/joshuaboniface/rpibmc), and is called via a small hack to the `/etc/passwd` file for the `bmc` user, starting by default and terminating the SSH session on exit; to set this when creating a new user, simply pass `useradd` the `-S /path/to/bmc.sh` flag instead:
```
bmc:x:0:0:bmc:/home/bmc:/bin/bmc.sh
@ -119,6 +126,7 @@ Finally we're able to set the host system's name (for display when logging in) v
I hope you've found this post interesting and useful - if you have some IPMI-less systems you want to manage remotely, I definitely recommend you try it out. So far my testing has been extremely positive; for under $30 (if you can find the Raspberry Pi for the right price), you can build youself out-of-band BMC management for any motherboard you can find. And the remote management makes even the most irritating host messups ("Oh broke my udev network rules, again!?") trivial to recover from. A small price to pay for the peace of mind of being able to manage your system from almost anywhere, even a cruise ship!
(Pictured: what you might have to do without a Raspberry Pi BMC!)
[Picture - texting my dad to reboot ceph2 from a cruise ship]
![Txt from a ship](/images/rpibmc/txt-from-a-ship.png)
If you have any questions or comments, shoot me an e-mail!

Binary file not shown.

Before

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 93 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 687 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 551 KiB