BeagleBone

Get nRF24L01+ Radios Working on BeagleBone Black

Published by:

I have some projects that I’m planning with Raspberry Pi, Arduino, and BeagleBone Black. I’ve heard good things about the nRF24L01+ radios and they’re very inexpensive (I paid $6 for a set on Amazon), so I thought I’d give them a try. There’s no official documentation, however, and I found that while there were several resources online, many were inaccurate or had partial information for newcomers. While I have boards with stock operating systems, I didn’t know how to get the SPI bus working, how to wire them, or how to use the code, and each of those things were in a different place. This made things far more complex than they needed to be. My intent here is to provide a simple ‘jumpstart’ for someone wanting to just get it working as a starting point.

I actually have one Raspberry Pi and one BeagleBone Black, and am communicating between them. There’s not a lot of utility to this in the real world, as many other connectivity options are available and easy (e.g. ethernet, wifi), but it’s also easier than programming an Arduino, if you just want to do some testing on the platforms.

Equipment Prerequisites:

BeagleBone Black (rev B) with standard Debian image as of 5/2014 from BeagleBoard.org
nRF24L01+ Radio

1. Wire up equipment

Screen Shot 2014-06-01 at 3.50.18 PM

 

 

beaglebone connectors:

beagleboneblack-pins

2. Enable SPI on the BeagleBone Black. Note that the libraries are coded to use SPI1, and to do this we need to disable the onboard HDMI pins. Go into “/boot/uboot/uEnv.txt”, add the following line to the end (all one line!):


optargs=quiet drm.debug=7 capemgr.disable_partno=BB-BONELT-HDMI,BB-BONELT-HDMIN capemgr.enable_partno=BB-SPIDEV1

Then shut down and restart the BBB. You should now see something like the following when you look at devices:


# ls /dev/spi*
/dev/spidev1.0 /dev/spidev1.1

3. Get the code. Do a “git clone https://github.com/mlsorensen/RF24.git”

4. Compile the code

cd RF24/librf24-bbb/librf24/
make
make install

5. Run examples

cd examples
make
./pingtest

 

You should now have some output that looks like this:


RF24/examples/pingpair/
ROLE: Ping out
STATUS = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1 = 0xf0f0f0f0e1 0xf0f0f0f0d2
RX_ADDR_P2-5 = 0xc3 0xc4 0xc5 0xc6
TX_ADDR = 0xf0f0f0f0e1
RX_PW_P0-6 = 0x20 0x20 0x00 0x00 0x00 0x00
EN_AA = 0x00
EN_RXADDR = 0x03
RF_CH = 0x4c
RF_SETUP = 0x07
CONFIG = 0x0f
DYNPD/FEATURE = 0x00 0x00
Data Rate = 1MBPS
Model = nRF24L01+
CRC Length = 16 bits
PA Power = PA_HIGH
Now sending 153...ok...Failed, response timed out.

If you see strange repetitions in the hex values, it might mean your pins are mis-wired, or that your SPI device is missing. If you do see the above, you’re ready to set up another node. If you do a second BeagleBone Black or Raspberry Pi, follow this but run ./pongtest for the receiver. Once you have two sides working you should see successful pings like this:
Screen Shot 2014-06-01 at 4.02.05 PM

For developers, you should now have a /usr/local/lib/RF24.h that you can include in your code and a library at /usr/local/lib/librf24.so. For documentation, refer to http://maniacbug.github.io/RF24/

Raspberry Pi

Get nRF24L01+ 2.4GHz Radios Working on Raspberry Pi

Published by:

I have some projects that I’m planning with Raspberry Pi, Arduino, and BeagleBone Black. I’ve heard good things about the nRF24L01+ radios and they’re very inexpensive (I paid $6 for a set on Amazon), so I thought I’d give them a try. There’s no official documentation, however, and I found that while there were several resources online, many were inaccurate or had partial information for newcomers. While I have boards with stock operating systems, I didn’t know how to get the SPI bus working, how to wire them, or how to use the code, and each of those things were in a different place. This made things far more complex than they needed to be. My intent here is to provide a simple ‘jumpstart’ for someone wanting to just get it working as a starting point.

I actually have one Raspberry Pi and one BeagleBone Black, and am communicating between them. There’s not a lot of utility to this in the real world, as many other connectivity options are available and easy (e.g. ethernet, wifi), but it’s also easier than programming an Arduino, if you just want to do some testing on the platforms.

Equipment Prerequisites:

Raspberry Pi rev 2 (512MB), running stock Raspbian (Installed from NOOBS 1.3.7, I believe)
nRF24L01+ Radio

1. Wire up equipment
raspberry pi to nRF24L01+

2. Enable SPI on the Raspberry Pi. Go into “/etc/modprobe.d/raspi-blacklist.conf”, and comment out the line “blacklist spi-bcm2708”, then reboot. You should now see something like the following when you look at devices:


# ls /dev/spi*
/dev/spidev0.0 /dev/spidev0.1

3. Get the code. Do a “git clone https://github.com/mlsorensen/RF24.git”

4. Compile the code

cd RF24/librf24-rpi/librf24/
make
make install

5. Run examples

cd examples
make
./pingtest

 

You should now have some output that looks like this:


RF24/examples/pingpair/
ROLE: Ping out
SPI device = /dev/spidev0.0
SPI speed = 8000000
CE GPIO = 25
STATUS = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1 = 0xf0f0f0f0e1 0xf0f0f0f0d2
RX_ADDR_P2-5 = 0xe2 0xe3 0xe4 0xe5
TX_ADDR = 0xf0f0f0f0e1
RX_PW_P0-6 = 0x20 0x20 0x20 0x20 0x20 0x20
EN_AA = 0x00
EN_RXADDR = 0x3f
RF_CH = 0x4c
RF_SETUP = 0x07
CONFIG = 0x0f
DYNPD/FEATURE = 0x00 0x04
Data Rate = 1MBPS
Model = nRF24L01+
CRC Length = 16 bits
PA Power = PA_MAX
Now sending 1498841111...ok...Failed, response timed out.
Now sending 1498842326...ok...Failed, response timed out.

If you see strange repetitions in the hex values, it might mean your pins are mis-wired, or that your SPI device is missing. If you do see the above, you’re ready to set up another node. If you do a second Raspberry Pi, follow this but run ./pongtest for the receiver. Once you have two sides working you should see successful pings like this:
Screen Shot 2014-06-01 at 4.02.05 PM

For developers, you should now have a /usr/local/lib/RF24.h that you can include in your code and a library at /usr/local/lib/librf24.so. For documentation, refer to http://maniacbug.github.io/RF24/

Virtualization

CloudStack vs OpenStack! Who will win?

Published by:

I’ve been spending a lot of time working on cloud solutions recently, and have run across this question countless times.  Some are worried about betting on the wrong horse, others already have a stake in it or are linked somehow to those who do, and some simply want to know which is best.  After having gotten to know both solutions, I think this is a short-sighted question, but I’d like to talk a little bit about them before explaining why. If you feel you already know the two well, then skip these sections for the tl;dr version.

CloudStack is the older of the two, and is undoubtedly more mature as of this writing.  It is a full stack solution, the download you get provides management, storage, host agent, EC2 API compatibility, and everything you need to manage a cloud infrastructure. From a development standpoint, there is a CloudStack API for remote control, as well as the ability to develop plugins to modify or add functionality to cloudstack.

It supports KVM, Xen, VMware, and Oracle VM. It has support for bridging, VLAN managementand direct network management, as well as recently added support for Nicira STT and plain GRE isolation for networking(both through openvswitch bridging). For VM disk storage, it allows NFS, Cluster LVM, Rados Block Device(Ceph), local storage, or any other storage that can be mounted as a ‘shared filesystem’, such as GFS or OCFS2. For backups, ISO images, VM templates, snapshots and such, there is a ‘secondary storage’, which is primarily NFS or OpenStack’s Swift object store.

It recently underwent a licensing change and is now under the Apache Foundation, and with that change, some of the components now need to be downloaded separately, such as VMware plugins and other components that aren’t license compatible. The developers are currently working to make that migration, and in the future you may see ‘oss’ and ‘non-oss’ builds for download or be directed in the documentation to fetch a specific package to include a particular functionality.  It of course has the backing of Citrix, is used by large companies like SoftLayer and GoDaddy down to small businesses.

OpenStack started out as a project whose main contributors were NASA and Rackspace. It is younger, but has recently had a lot of news buzz, and is even referred to by some as ‘the media darling’, if an open source project could be described as such. It is a more modular approach. It’s a group of services; the storage service, compute service, network service, and a web dashboard. As such, the installation and management is a bit more complicated, as each service is set up and configured independently, but it’s also a potential bonus in that each service can be swapped out independently with various solutions. Each service also has its own API and could be deployed independently or incorporated into a separate project.

It supports xapi and libvirt based virtualizations solutions, meaning Xen, KVM, LXC, and VMware to the extent in which libvirt is capable. The current networking service has support for linux bridging and VLAN isolation, and a new service called Quantum is in the works which will support SDN based openvswitch isolation like Nicira.  For VM volume storage, it relies largely on iSCSI, and the storage service has the capability of managing many iSCSI targets, as well as Ceph, local and NFS support for VM volumes. There is also an object storage service called Swift, which can be used for generic data storage, and is even run and sold as a separate service by some.

OpenStack is largely backed and used by RackSpace. It recently lost NASA support, but has more than made up for that in good publicity. It has yet to gain a wide install base as of this writing, though there are many contributors and people playing with it if the mailing lists and blogs are any indication.

So back to the original question: Who is going to win?  My prediction is that neither will “win”; this simply isn’t a one-winner game.  Who won between Xen and VMware? Who won between RedHat and Ubuntu?  For all of the posturing that some might do, and the holy war attitudes that grow up around technologies, in the end there is usually room for more than one product. CloudStack seems to be maintaining the lead at the moment, and tomorrow maybe OpenStack will get ahead, there may even be a 70/30 split, but the companies involved and the scale of the market indicate that there will be active development and support for both platforms. This has been evidenced to me in just the past few months, where I’ve seen companies scrambling to provide support for their stuff in both platforms. Companies like Brocade, Nicira/VMware, Netapp, are actively supporting and developing code for both platforms in hopes of driving cloud customers to use their products.

Even if it were a one-winner contest, depending on your size you may be able to influence the race. If you see a tug-of-war in process, with ten men on either side, and you’ve got a team of five behind you, do you need to stop to consider which team you should support in order to back the winner?  Some individuals I’ve heard asking this question should really be asking “which technology do I want to help win?” instead of thinking that they’re an inactive bystander in the equation.

In all of the back and forth, and daily news about who is building what with the backing of which companies, one thing is certain. Cloud infrastructure as a service is going to be a hit.

Stuff

Korean 27″ Displays

Published by:

I recently purchased two new 27″ displays from a Korean Ebayer. You can read all about them here and here.  Basically they’re the same panels that are in the nice Apple displays, but they didn’t quite make the cut for one reason or another, so they got sent to obscure Korean manufacturers who sell them in monitors for 1/4 the price.

I purchased Sunday afternoon for $319 each, shipping included, and 48 hours later they arrived. They both look remarkably good, I really had to hunt to find any discernible defect. One has two tiny stuck pixels and the other I *think* is just a hair dimmer than the other, which seemed to go away via brightness adjustment.

Really, though, this post is about how I got them to play nicely with the Nvidia TwinView on my Ubuntu desktop. You see, with the nouveau driver that is loaded by default, one worked fine, but to get the full acceleration and TwinView, I had to install the nvidia module, and for some reason it didn’t want to properly retrieve the monitor’s EDID. The result was a flickering 640 x 480 display; not pretty.

In troubleshooting, I noticed that ‘xrandr –prop’ would get the EDID nicely, but tools like get-edid from the read-edid package would return 128 bits worth of ‘1’s and complain of a corrupt EDID. X seemed to pick up the proper one when running the nouveau driver, and not when running the nvidia driver.

So I fired up a hex editor and pasted the EDID as reported via xrandr, all 128 bytes, and added a custom EDID file to my xorg.conf so the nvidia driver would work with the dual displays.

You can add the following to the screen section of /etc/X11/xorg.conf, just under metamodes or wherever you prefer.

Option “CustomEDID” “DFP:/etc/X11/shimian-edid.bin”

Note you can also do semicolon delimited for multiple displays (or so I’ve read):

Option “CustomEDID” “DFP-0:/etc/X11/shimian-edid.bin; DFP-1:/etc/X11/catleap.bin”

I’m including the QH270 EDID .bin file here, in case anyone is desperately looking for it or having a hard time creating one. It should be similar or even work as a drop-in replacement for the Catleap Q270, aside from the Achieva models.

Stuff

New Linux Device Mapper Snapshot Performance

Published by:

Here’s a quick weigh-in on the new experimental device-mapper thin provisioning (and improved snapshots) that exists in linux kernel 3.2. I recently compiled a kernel and tested it, and it looks rather promising. I would expect this to become stable more quickly than, say, btrfs (which obviously has different design goals but could also be used as a means of snapshotting files/vm disks). With any luck, LVM will be fitted for support relatively soon.

These are quick and dirty, sequential write test was with ‘dd if=/dev/zero of=testfile bs=1M count=16000 conv=fdatasync’, and results are in MB/s.  Random IO test was done with fio:
[global]
ioengine=libaio
iodepth=4
invalidate=1
direct=1
thread
ramp_time=20
time_based
runtime=300

[8RandomReadWriters]
rw=randrw
numjobs=8
blocksize=4k
size=512M

 

At any rate, it looks like we’re well on our way to high performance LVM snapshots that work well  (finally!).