Sunday, May 5, 2013

Beaglebone Black Experiences

I am just turning my procedures document into something others can read.  I am skipping some of the info I found easily online.


What are you up to?

Where I work, we make equipment that detects nuclear radiation.  Close to that equipment, we have computers that aggregate the information, perform calculations, make decisions, and at some point they might record information in a database or post information for users to observe either on computers or other devices.

Obviously, we are always trying to do more for less. 

I am up to other things at the same time but, basically, I am looking for a small cheap way to get all that done.

The Beaglebone Black ('Bone' for short) is a good place to start.

A bit more about where I am going:

We use C# and the .NET Framework mostly.  I have Unix experience but it is in the distant past.  I really like to dodge using Linux development tools and get the Bone running my C# code.

The way to do that is to get Mono working on the Bone.  Mono is a small CLR and .NET Framework that can run on Linux. 

What is a Beaglebone Black?

A Beaglebone is a ultra-lowcost single board computer: http://beagleboard.org/Products/BeagleBone%20Black

The 'Black' is a recent (2013-05-05) variant with greater power and lower cost.  I jump right into it since you really just need to know if you are not interested in reading any further.

I will keep this simple.


A Little More About the Bone?


If you want to stay with me here ...

Features:
Board:  3.4in x 2.1in (fits in an Altoids tin)
Memory:  512Mb
Disk (well ... not really):  2Gb EMMC and an SD card slot
Microprocessor:  TI AM3359 Sitara ARM Cortex-A8 Microprocessor
Speed:  1GHZ with DC Power (5V) / 500MHZ with USB Power
Ethernet:  10/100 RJ45

Weight:  1.4 oz (39.68 grams)

Connections:
5V Power
USB In
USB Out
Micro HDMI Video Out
RJ45
Micro SD Socket
Numerous general purpose I/O points including serial ports, digital I/O, analog I/O etc. 

The board has three pushbuttons: reset, power and boot.

Where did you get it?

Amazon through Special Computing.  I bought a pair (one for me and one for my son) BeagleBone Black DevKit at a whopping $45.00 each. 

What you get in the box?

Not much but you don't need much.
You get the board and a USB cable to connect it to your computer.
You get a card with almost no info except where to get other info on the web.


Now I am gonna fast forward to doing some things and I will fill in later.


How do you 'Factory Reset' the bone?

See, I munged the thing several times so getting it back to 'as shipped' condition was important.

The 'getting started' site kinda explains the process as 'obtaining the most current Angstrom' distribution: http://beagleboard.org/static/beaglebone/latest/README.htm

However, I ran into a raft of difficult detials:
  • The MD5 Hash check box in the imager dialog MUST be checked.
  • The USER/BOOT switch is on the Black board just above (top side) the SD card coupling.  You hold it down while you power up to make it run from the SD card (which flashes the NAND).
  • Flashing the NAND took ALL of the 45 minutes they said it would and it the LEDs flash like crazy while it is going on.  In particular, USR3 was on a lot but not during normal operation.

Apparently, the SD image with flash the NAND weather or not you push the USER/BOOT button.  I put it in again and rebooted without the U/B button and signed up for another 45 minute reflash.

Mounting a Thumb Drive

  1. Insert the drive (it took a second to blink)
  2. Run dmesg which will give  you a hint what device the drive was loaded
  3. Make a folder to mount it on: mkdir thumb
  4. Mount it: mount /dev/sda thumb
  5. Play
  6. Unmount it: umount /dev/sda

Getting Mono to Work

The Package

Looking for a mono that would go with the Angstrom linux distribution on the Bone, I found:  http://www.angstrom-distribution.org/repo/?pkgname=mono

There are a coupla versions there and I picked:  mono 2.10.8.1-r0 for armv7a (Ångström v2012.05 eglibc armv7a base feed)

Once I had the file in hand,

    mono_2.10.8.1-r0_armv7a.ipk,

I copied it to a thumb drive.

The 'Hello World' App

Now I needed a tiny Windows app to verify my mono would work.

I build a console app with the following source code:


    using System;

    namespace Hello
    {
        class Program
        {            static void Main(string[] args)            {                Console.WriteLine("Hello, Bone!");            }
        }
    }


Not quite sure which .NET version the Mono covered, I built this targeting .NET Framework 2.0.

I ended up with a Hello.exe.  I ran it on Windows to make sure then copied it to the thumb drive.

Putting This On The Bone


I moved the thumb drive to the bone.  Using the procedure above, I mounted it on a directory called thumb.  I installed the mono package:

ipkg install thumb/mono_2.10.8.1-r0_armv7a.ipk



Note: I had completely 'boned' the Bone before (requiring the factory reset procedure) and I believed it had to do the limited free space on the 2Gb drive being bogarted by copy things off the thumb drive.  This time I installed from the thumb drive with better results.

Trying it Out


I copied the Hello.exe program from the thumb drive and ran it


Does not look like much but I did a ton of crap wrong on the way to this so I was pretty glad to see it.

So mono will take a Win app as an argument and run it for you.


Thats it!





2 comments:

  1. Thanks for posting this. It helped me out. On my version of Angstrom, rather than use ipkg, I needed to use opkg.

    ReplyDelete
  2. Thanx, Zane. Make sure to post back your success.

    ReplyDelete