User:Mjb/BeagleBone Black

From Offset
< User:Mjb
Revision as of 05:27, 4 May 2018 by Mjb (talk | contribs) (Hardware)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

These are my BeagleBone Black notes. Any questions/comments, email me directly at root (at) skew.org.

See also my FreeBSD on BeagleBone Black notes.

Why BeagleBone Black instead of Raspberry Pi

I run my own FreeBSD server. In 2015 I needed to replace the hardware, which was always running on Intel-based tower or mid-tower PCs before. I thought maybe it would be fun to try to step into the modern age by running it on a Raspberry Pi.

However, I was not impressed by the specs on the initial RPi models; they seemed to be too oriented to robotics, IoT devices, and educational uses. They just did not have enough RAM or CPU speed to handle real-world "production server" loads.

That has changed now that the RPi 3 (2016) and 3+ (2018) models are out, but at the time, the best option for me was going to be a BeagleBone Black, which has just barely enough CPU and RAM for my needs. Also I am a real sucker for the alternative versions of things. So it's FreeBSD instead of Linux, and BeagleBone Black instead of Raspberry Pi.

Hardware

Basic system

In June 2015, I bought:

Total cost was US$130 for all of the above, including shipping. I saved a few bucks by picking up the case from SparkFun's local headquarters.

The BeagleBone Black (BBB) came with a mini-USB to USB cable, and it has Debian Linux installed on its 4GB eMMC embedded flash drive.

I decided to buy an original BBB revision C made by CircuitCo, the Texas, USA-based company which owns the beagleboard.org website. They licensed the BBB design to other manufacturers, so a lot of the boards you can buy are actually made in China by Shenzhen Embest Technology on behalf of element14, a UK-based electronics hacking community. Although I have no qualms with element14 and reviews say these boards are indistinguishable in functionality, I was uncertain whether Embest would use high quality parts or provide the same level of support I expect from CircuitCo. (To be fair, I have no certainty CircuitCo is better.)

Possible upgrades

In 2018, I started looking into the possibility of upgrading the hardware.

Mainboard

BeagleBoard has released some new models, but the BeagleBone Black (still $55) is still the only general-purpose workhorse in the product line. None of the newer models have improved the CPU or RAM.

For future reference, these are the other models:

  • BeagleBone Black Wireless = WiFi replaces the Ethernet port, all else the same.
  • BeagleBone Green = Grove sensor connectors replace HDMI, all else the same.
  • BeagleBone Green Wireless = as above, with WiFi instead of Ethernet.
  • BeagleBone Blue = WiFi board with gobs of robotics-friendly features.

One thing kind of interesting is the BeagleBoard X15, a much more powerful board with 2 dual-core 1.5 GHz CPUs. However, the price of $239, and the lack of any enclosures on the market, make it comparable to the cheaper models of "mini PCs" based on Intel CPUs (the low-end Celeron, slightly better Pentium, or the low-power Core "Y"-series), which for now would be the better option IMHO.

The Raspberry Pi 3B+ ($35), introduced in 2018, seems to be a really great board, but FreeBSD support is not quite where it needs to be yet. I suspect it will be fully supported by the end of the year.

Storage

I am mainly interested in the U3 class micro SD cards with the fastest random write speeds. The best ones will have an A2 rating (these are new/expensive 400 GB cards), second best A1.

Supposedly Samsung cards have some firmware problems which result in slower performance as the card ages. So I think I want to try SanDisk now. Also to avoid counterfeits, it is best to get products sold by Amazon, not fulfilled by Amazon.

These look like my only A1 choices:

I only need about 20 GB, so the 32 GB should be enough, but of course get a bigger one if possible.

Documentation

The BBB comes with no instructions other than a Quick Start guide.

Most third-party tutorials and solutions online were written before the rev. C board was released in mid-2014, and thus they were written for Ångström instead of Debian (e.g. they say to install packages with opkg instead of apt-get). Some of these documents are for earlier boards and refer to hardware issues and workarounds that are no longer applicable.

The clear case

The board just snaps into the clear case from SparkFun. The case is made by SB Components in the UK. So far, I'm pretty happy with it.

That said, the light pipes on the case don't perfectly line up with the LEDs, so they don't work quite as well as they should. You can bend the pipes (carefully) with your finger to get them closer to the right position, but the clear top still refracts the light, making it hard to tell which lights are actually lit. I might paint the top of the case, just around the lights, to see if it helps.

Also, I've read that people are unhappy with this case's micro HDMI port not allowing a typical plug to fit snugly. I haven't tried it yet.

I just wanted a good-looking clear case with good ventilation, a good fit, and that's not too expensive. Reviews of one popular clear case said that the holes for the connector ports didn't allow for certain cables to plug in. Several other clear cases are on Thingiverse, but they're DIY kits requiring a fair amount of assembly. Adafruit's cases are ugly. I chose the SB Components case because it looks good, doesn't cost too much, and has some ventilation.

I wondered if heat would be a problem. The SB Components case bottom has two rows of very slim ventilation slots, plus two mounting holes that allow for airflow if you don't need to mount the case. The lid has large slots above the FTDI and cape connectors, and some tiny holes you can poke a paperclip through to push the buttons on the board. If you had a cape on it, with the lid on, then probably all of these top slots and holes would be covered and useless for ventilation. The ports on the sides of the case are slightly oversized, allowing for more compatibility with big-ended cables, with a side effect being a little bit more room for air to flow around the ports when no such cables are connected.

I used the info and script at http://godfear.org/beaglebone-black-2/how-to-monitor-beaglebone-black-cpu-temperature/22 to monitor the temperature. The CPU does get warm, but even when maxed out with 100% load with the lid on (and no capes) it only is about 45°C warmer than the air temperature outside the case. The CPU's maximum operating temperature is 90°C, so in this case, it should be fine as long as the air temperature stays below 45°C (113°F). So, keep it out of direct sunlight. If more heat dissipation is needed, you can buy a cheap, stick-on heat sink kit marketed for the Raspberry Pi. ... I don't know how much this will drop the CPU temperature, but I'm guessing it's no more than 5°C (11°F).

Power

The BBB can run on power through the mini USB cable, although I'm told that it can be "flaky" when powered this way.

It's better to use a separate 5V DC power supply like the one I got from Adafruit. It plugs into the barrel connector.

Either way, the BBB turns on and boots as soon as you plug it in.

When powered on, the blue LED next to the power connector will be lit. A nearby row of four more blue LEDs are user-configurable, but by default will indicate power on, and then eMMC access, CPU activity, micro SD card access, and an "I'm alive" heartbeat pattern.

Accessing the BBB directly via attached keyboard, mouse, and monitor

The Quick Start guide that comes with the BBB says you can plug an HDMI monitor into the mini HDMI port, and a mouse and keyboard into the USB host port, and then use the BBB like any other computer; the Debian Linux desktop should appear on the monitor after boot. I have not tried this yet because I don't have a mini-to-standard HDMI cable, nor a spare USB mouse!

The USB host port is the regular-sized USB 2.0 port. Probably you will need to connect a hub to it if you need to hook up multiple devices, and as always, the hub may need to be powered (i.e. the kind that plugs into the wall) if the devices are particularly power-hungry.

Accessing the BBB via the mini USB cable and a Windows PC

The Quick Start guide that comes with the BBB says you can plug the mini side of the included USB cable into the BBB, and the regular-sized side into a Windows PC. If you do this, the board powers on and boots up. It only takes a few seconds to boot into Debian Linux.

Windows should automatically download and install the necessary drivers. After that's done, Windows will recognize a special partition on the BBB's eMMC as an external USB drive. On my PC it was assigned volume (drive letter) H. Of course this will vary depending on what other drives you have and what letters are reserved.

As directed in the Quick Start guide, you can open this newly found drive (in Explorer) and then open START.htm in your browser. JavaScript must be enabled in the browser.

What you get is a web page that's almost identical to the Getting Started tutorial on beagleboard.org.

From there you can download drivers for your Windows PC to add virtual ethernet capability to the USB connection. After installing those drivers, Windows will see the BBB at 192.168.7.2, and the BBB will see the Windows PC at 192.168.7.1. At this point, you can SSH into the Debian OS from the Windows PC (user: root, no password!), and you can access a mini web server running at http://192.168.7.2/.

Also, Windows will see a new network connection which represents the BBB via USB. In order for the BBB to reach the Internet (as long as the USB cable is the only option), you need to tell Windows to share its regular adapter's connection (e.g. Local Area Connection) with the BBB's connection (e.g. Local Area Connection 3), and you need to configure Debian's networking appropriately as well, mainly by running

  • echo "nameserver 8.8.8.8" >> /etc/resolv.conf
  • route add default gw 192.168.7.1

You may also have to kill -USR1 the PID of udhcpd in order to renew the DHCP lease.

Instructions for how to get all of this set up on Windows 7 are in a 2013 blog post by Carl Lance, and there are some important updates in the comments.

I had some trouble with all of this, where I did everything I was supposed to, but it wouldn't work right away, then it was fine after a few minutes. Bizarre!

I wasn't sure I wanted to make all of these settings stick because I'm not sure I'll always be connected via the USB cable, so for now, I manually run route add default gw 192.168.7.1 only when necessary. It would be nice to figure out if there's a way to make this determination automatic.

Also on the Getting Started tutorial are instructions on how to put a disk image (usually another OS) onto a micro SD card, and then either boot from that card or use it to flash and replace the eMMC.

Accessing the console via the FTDI cable and a Windows PC

You can see the console by running a terminal emulator on a PC and listening to a serial port. The BBB must be connected to a USB port on the PC by way of the FTDI cable. On the BBB, this cable plugs into the 6-pin connector labeled J1. The little arrow embossed on the plastic covering on the 6-wire end of the cable corresponds to the black wire, and the arrow means this end of the connector is supposed to go on the "first" pin. There should be a dot on the board next to this pin. I don't know what happens if you hook it up the wrong way around, but I'm guessing it's not good.

The other end of the FTDI cable plugs into the USB port of a computer. If the computer is running Windows, plugging it in (even with the BBB unpowered) should result in drivers being installed from Windows Update. If that doesn't work, disconnect the cable, get the latest drivers from the FTDI site (which also has drivers for other OSes), and run the Windows setup executable as an Administrator.

The drivers make the cable (plus the serial adapter on the BBB) act like a serial port, which means it gets a COM designation in Windows. After installing the drivers, there may be a delay of up to a minute before you see a notification that a COM port has been added. Wait for the notification before you reattach the cable, so the OS doesn't start a new search for drivers. On my computer the new port was designated COM5, but this can vary; I got COM3 on another computer. Windows may say a reboot is needed after installing the drivers, but this isn't really necessary.

On the Windows PC, you need to install a terminal program with serial port support in order to see the console. My usual SSH client (Bitvise) doesn't allow for non-SSH connections via a serial port, so I chose to use Tera Term instead. I set it up to connect via serial, COM5. Under Setup > General: default port COM5, language UTF-8. Under Setup > Serial port: Port COM5, Baud rate 115200, Data 8 bit. Under Setup > Terminal: locale: english-us, CodePage: 65001. You can also set the font, terminal size, and window title as desired. Save the setup as TERATERM.INI, overwriting the existing one.

Once you have Tera Term (or whatever terminal emulator) listening to the serial port, you can power on the BBB (e.g. by plugging in the power cable), or hit the board's reset button if it's already powered on. As the board boots, the console should show you what it's doing, and eventually will give you a Debian login prompt, where you can type (through the terminal emulator, i.e. on your Windows machine) the default username and password combo, which is shown above the login prompt.

Communication over the serial port is fairly primitive. Unlike communication via SSH or telnet, there's no protocol for the terminal emulator to inform the OS of the terminal type and screen geometry. So after logging in, you probably want to set TERM=xterm-256color at the first command prompt, because Debian's default TERM=linux is not entirely compatible with Tera Term's vt100 implementation, and FreeBSD's default TERM=vt100 does not support color. You'll also need to run stty rows ## cols ## to set the rows and columns to appropriate values (replace ## with the right numbers, of course). (The default terminal type depends on /etc/ttys, which maps your assigned tty to certain terminal characteristics.)

Shutdown

There's a warning saying that bad things will happen if you disconnect the power cable without shutting down first, but it doesn't say how to shut down properly. I also don't know if this only applies to when the device is running on USB power or if it's just for the main cable.

In Debian, the command to completely power down is (as root):

  • shutdown -hP now

In FreeBSD, it's:

  • shutdown -p now

This usually works within a few seconds, but I've seen this not fully shut down the system right away. I don't know why. I disconnected the power after waiting a while, and when I powered it back on, it didn't boot until I hit the reset button.

There's also the power button on the board, right next to the ethernet port. Pressing this should have the same effect as the shutdown command above.

Clock

The on-board clock does not have a battery, so it thinks it's 2014-04-23 at every boot. If you want the date to be right, you have to log in and set it—or, ideally, fetch the current time form an NTP server. To do that, you can either run ntpdate or configure the OS to start an NTP daemon (which acts as client and server) at boot time.

One-time prep for running ntpdate (in Debian Linux):

  • rm /etc/localtime
  • ln -s /usr/share/zoneinfo/America/Denver /etc/localtime
  • echo NTPSERVERS="pool.ntp.org" > /etc/default/ntpdate

For doing this (and a whole lot more) on FreeBSD, see my FreeBSD on BeagleBone Black notes.