<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>GigaMegaBlog &#187; Gadgets</title>
	<atom:link href="http://www.gigamegablog.com/category/gadgets/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.gigamegablog.com</link>
	<description>Powered by GigaMegaWatts</description>
	<lastBuildDate>Sun, 05 Feb 2012 16:39:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Beaglebone Linux 101: Configuring Angstrom Linux</title>
		<link>http://www.gigamegablog.com/2012/01/29/beaglebone-linux-101-configuring-angstrom-linux/</link>
		<comments>http://www.gigamegablog.com/2012/01/29/beaglebone-linux-101-configuring-angstrom-linux/#comments</comments>
		<pubDate>Mon, 30 Jan 2012 00:01:46 +0000</pubDate>
		<dc:creator>dwatts</dc:creator>
				<category><![CDATA[Gadgets]]></category>
		<category><![CDATA[Beagleboard]]></category>
		<category><![CDATA[Beaglebone]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.gigamegablog.com/?p=1126</guid>
		<description><![CDATA[My previous two articles about the Beaglebone (here and  here) focused on using it as a development platform for handling Arduino-like tasks: interacting with digital, analog and serial devices. In this article I&#8217;m going to cover the basics of using &#8230; <a href="http://www.gigamegablog.com/2012/01/29/beaglebone-linux-101-configuring-angstrom-linux/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>My previous two articles about the <a href="http://beagleboard.org/bone">Beaglebone</a> (<a href="http://www.gigamegablog.com/2012/01/05/beaglebone-coding-101-blinking-an-led/">here </a>and  <a href="http://www.gigamegablog.com/2012/01/22/beaglebone-coding-101-using-the-serial-and-analog-pins/">here</a>) focused on using it as a development platform for handling Arduino-like tasks: interacting with digital, analog and serial devices.</p>
<p>In this article I&#8217;m going to cover the basics of using the Beaglebone in a different but complementary role: as a network-connected Linux computer.</p>
<p>If you&#8217;re not already familiar with Linux you might be tempted to ignore this aspect of the Beaglebone &#8212; once you&#8217;ve figured out how to copy programs onto the Beaglebone and run them,  you&#8217;re good to go.  However,  by doing some basic Linux configuration you can open up a lot of extra functionality, such as editing files on the Beaglebone directly from your desktop PC, or making the Beaglebone command line more user friendly.</p>
<p>I&#8217;m going to focus on the <a href="http://www.angstrom-distribution.org/">Angstrom Linux</a> distribution that is included in the microSD card packaged with each Beaglebone. Angstrom is not as widely used as other flavours of Linux, like Ubuntu or Fedora. This can be a frustrating to newcomers, since you&#8217;re less likely to figure out how to do things by Googling for the answer. However, Angstrom is well suited to a memory and storage-constrained platform like the Beaglebone, being bloat-free and able to squeeze out more performance from the ARM processor.</p>
<p>I should also mention off the top that I&#8217;m not going to show you how to run a spreadsheet, browser or any other GUI applications on the Beaglebone. That <em>is</em> possible, even without a cape that has a video port (by using VNC), but I think you&#8217;re likely to be disappointed. The Beaglebone&#8217;s memory and CPU constraints will cause a GUI system to be annoyingly slugglish . Think of it more as an Arduino on steroids, not a poor man&#8217;s PC.</p>
<h2>Configuring a terminal on Windows</h2>
<p>(Sorry Mac and Linux users &#8211; the first couple of sections are Windows-centric.)</p>
<p>Whether you connect to the Beaglebone via USB or over the network using SSH, the best terminal software to use on Windows is PuTTY.</p>
<p>You might be scared off after a glimpse of <a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/">PuTTY&#8217;s plain Jane website</a> – it looks like a relic from the early days of the Internet. Trust me, though: PuTTY is the way to go. Unlike other Windows terminal programs, it &#8220;gets&#8221; Linux. It may not be the best all-around terminal program, but it’s the best Windows client for a Linux server.</p>
<p>PuTTY is bristling with options, but for the most part the default settings are fine.  When the Beaglebone is connected via USB, select Serial, fill in the COM port ID, and change the Speed to 115200.  When connecting over the network, select SSH and fill in the IP address.  You should also fill in a  name in the Saved Sessions textbox and click Save.</p>
<p><a href="http://www.gigamegablog.com/wp-content/uploads/2012/01/1-28-2012-9-55-51-PM.jpg"><img class="aligncenter size-full wp-image-1134" title="" src="http://www.gigamegablog.com/wp-content/uploads/2012/01/1-28-2012-9-55-51-PM.jpg" alt="" width="461" height="446" /></a></p>
<p>With the default settings, you&#8217;ll find that some keys don&#8217;t work as expected.  For example, neither Home nor End will work when editing the command line.  To fix this, under Connection &#8211;&gt; Data, change the Terminal-type from the default of xterm to linux.</p>
<p>While you are in this window, you can also fill in a default username for logins. (Which, come to think of it, must be &#8220;root&#8221;, since you haven&#8217;t read the &#8220;Creating a user&#8221; section yet).</p>
<p><a href="http://www.gigamegablog.com/wp-content/uploads/2012/01/1-28-2012-9-38-11-PM.jpg"><img class="aligncenter size-full wp-image-1133" title="" src="http://www.gigamegablog.com/wp-content/uploads/2012/01/1-28-2012-9-38-11-PM.jpg" alt="" width="461" height="445" /></a></p>
<p>One other less-than-obvious thing about PuTTY is the way it handles copy-and-paste: Ctrl-C and Ctrl-V won&#8217;t work.  Instead, any text you highlight on the terminal is automatically copied to the Windows clipboard, and Shift-Insert is the shortcut for Paste.</p>
<h2>Transferring and editing files from Windows</h2>
<p>The other important piece of software you should install on Windows is something to  transfer files to the Beaglebone. If you aren&#8217;t yet comfortable with using Linux command line editors, then this tool is vital, since you are going to need to edit some files below.</p>
<p>For this, you&#8217;ll need to access the Beaglebone over the network (i.e. not a COM port), and use a Windows program called <a href="http://winscp.net/eng/index.php">WinSCP</a>.  The only default setting you&#8217;ll have to change is the File Protocol: the Angstrom demo image&#8217;s SSH server, Dropbear, doesn&#8217;t support SFTP.</p>
<p><a href="http://www.gigamegablog.com/wp-content/uploads/2012/01/1-28-2012-9-42-46-PM.jpg"><img class="aligncenter size-full wp-image-1132" title="" src="http://www.gigamegablog.com/wp-content/uploads/2012/01/1-28-2012-9-42-46-PM.jpg" alt="" width="519" height="369" /></a></p>
<p>You can use WinSCP to transfer files back and forth between Windows and the Beaglebone but, more importantly, you can also use it to edit files directly on the Beaglebone, safely from the comfort of your Windows desktop.</p>
<p>I know, I know, eventually you&#8217;ll want to cut the Windows apronstrings and learn to Esc-Alt-whatever in a command line editor. But having GUI training wheels will save you a lot of frustration as you get started</p>
<p><a href="http://www.gigamegablog.com/wp-content/uploads/2012/01/1-28-2012-9-51-46-PM.jpg"><img class="aligncenter size-full wp-image-1131" title="" src="http://www.gigamegablog.com/wp-content/uploads/2012/01/1-28-2012-9-51-46-PM.jpg" alt="" width="993" height="503" /></a></p>
<h2>Creating a user</h2>
<p>Angstrom Linux initially contains just a root user. I suspect a lot of people like it that way – root is God, so why bother running as a mere mortal instead? I would actually agree: since you&#8217;re almost certainly using it as a single user development platform, go crazy, have fun, be root.</p>
<p>However, if your Beaglebone is going to be accessible from a network, and especially if it&#8217;s going to be accessible over the Internet, disabling the root login is a wise security precaution: having to guess the user-ID makes the Beaglebone much harder to crack.</p>
<p>(Needless to say, if you aren’t going to disable root logins, then for-the-love-of-God give the root user-ID a password!)</p>
<p>My own approach is to login with my user-ID, then switch to root when needed (generally about 10 seconds after logging in, admittedly).</p>
<p>To create a new user-ID, johndoe:</p>
<pre><span style="color: #222222;"><span style="font-family: Courier, monospace;"><span style="font-size: small;">beaglebone:~#</span></span></span><span style="color: #222222;"><span style="font-family: Courier, monospace;"><span style="font-size: small;">useradd johndoe</span></span></span>
<span style="color: #222222;"><span style="font-family: Courier, monospace;"><span style="font-size: small;">beaglebone:~# passwd johndoe</span></span></span>
<span style="color: #222222;"><span style="font-family: Courier, monospace;"><span style="font-size: small;">Enter new UNIX password:</span></span></span>
<span style="color: #222222;"><span style="font-family: Courier, monospace;"><span style="font-size: small;">Retype new UNIX password:</span></span></span>
<span style="color: #222222;"><span style="font-family: Courier, monospace;"><span style="font-size: small;">passwd: password updated successfully</span></span></span></pre>
<p>To give the root user a password:</p>
<pre><span style="color: #222222;"><span style="font-family: Courier, monospace;"><span style="font-size: small;">beaglebone:~# passwd</span></span></span>
<span style="color: #222222;"><span style="font-family: Courier, monospace;"><span style="font-size: small;">Enter new UNIX password:</span></span></span>
<span style="color: #222222;"><span style="font-family: Courier, monospace;"><span style="font-size: small;">Retype new UNIX password:</span></span></span>
<span style="color: #222222;"><span style="font-family: Courier, monospace;"><span style="font-size: small;">passwd: password updated successfully</span></span></span></pre>
<h2>Switching to root</h2>
<p>So you&#8217;ve logged in as an ordinary user, and have quickly discovered that you need to be root to actually do anything, including pretty much all of the steps below. To switch to root</p>
<pre>beaglebone:~$ su</pre>
<p>The password you enter is the root password, not the user&#8217;s. This ain&#8217;t Ubuntu, son.</p>
<h2>Disabling root login</h2>
<p>This step is optional, especially if your Beaglebone isn&#8217;t accessible from the Internet.  In fact, if you&#8217;re using WinSCP to edit system files then <em>don&#8217;t</em> disable the root login &#8211; you can&#8217;t switch to root from within WinSCP.</p>
<p>If you still want to do it, you can disable root login by specifying the &#8220;-w&#8221; command line parm when running the SSH server, <a href="http://matt.ucc.asn.au/dropbear/dropbear.html">Dropbear</a>.</p>
<p>Ordinarily, Dropbear configuration is done by setting options in file /etc/default/dropbear.  This used to work in Angstrom.  However, they&#8217;ve recently switched to launching Dropbear in a way that doesn&#8217;t use any configuration file.</p>
<p>As far as I know, the only way to change the dropbear configuration now is to edit the ExecStart line in a well-hidden file: /lib/systemd/system/dropbear@.service:</p>
<pre>beaglebone:/lib/systemd/system$ cat dropbear@.service
[Unit]
Description=SSH Per-Connection Server
Requires=dropbearkey.service
After=syslog.target dropbearkey.service
[Service]
ExecStart=-/usr/sbin/dropbear -i -r /etc/dropbear/dropbear_rsa_host_key -p 22<strong><span style="color: #000000;"> -w</span></strong>
ExecReload=/bin/kill -HUP $MAINPID
StandardInput=socket</pre>
<p>Note the &#8220;-w&#8221; at the end of the ExecStart line &#8211; I added that to disable the root login.</p>
<p>To restart Dropbear, you still reference the old (but ultimately unused) init.d script:</p>
<pre>/etc/init.d/dropbear restart</pre>
<h2>Changing the host name</h2>
<p>This is purely optional, unless you have multiple Beaglebones, but it&#8217;s an easy way to personalize things:</p>
<p>Edit /etc/hostname and change <em>beaglebone</em> to your new host name.</p>
<p>Then, edit /etc/hosts and make the same change there. Leave the rest of the file as is: it should look something like this when are done, with <em>yourhostname</em> being replaced with – yeah, you got it:</p>
<pre>cat /etc/hosts
127.0.0.1 localhost.localdomain localhost
127.0.0.1 yourhostname</pre>
<p>Your command line prompt won&#8217;t display your shiny new device name until you reboot:</p>
<pre>shutdown –r now</pre>
<h2>Using a static IP address</h2>
<p>This step is also optional, if you have a DHCP server and don&#8217;t mind using its choice of IP address. Unlike the Beagleboard XM, the Ethernet adapter on the Beaglebone always uses the same MAC address, which means that the IP address assigned by the DHCP server won&#8217;t change each time you boot.</p>
<p>Setting a static IP  address requires editing <em>/etc/network/interfaces</em>.  The default version of this file in the Angstrom demo image looks like this:</p>
<pre>beaglebone:~$ cat /etc/network/interfaces
# /etc/network/interfaces -- configuration file for ifup(8), ifdown(8)
# The loopback interface
auto lo
iface lo inet loopback
# Wireless interfaces
iface wlan0 inet dhcp
wireless_mode managed
wireless_essid any
wpa-driver wext
wpa-conf /etc/wpa_supplicant.conf
iface atml0 inet dhcp
# Wired or wireless interfaces
auto eth0
<strong>iface eth0 inet dhcp</strong>
iface eth1 inet dhcp
# Ethernet/RNDIS gadget (g_ether)
# ... or on host side, usbnet and random hwaddr
iface usb0 inet static
address 192.168.7.2
netmask 255.255.255.0
network 192.168.7.0
gateway 192.168.7.1
# Bluetooth networking
iface bnep0 inet dhcp</pre>
<p>You need to replace the &#8220;iface eth0 inet dhcp&#8221; line with hard-coded settings for your IP address, gateway, and DNS servers. (Oh, and you might want to do it while connected to the Beaglebone via the USB cable, rather than Ethernet, in case you mess things up).</p>
<p>Comment out the &#8221;iface eth0 inet dhcp&#8221; line and add new lines with the correct IP addresses in the address, gateway, and dns-nameservers address (don&#8217;t just copy mine &#8211; that&#8217;s cheating):</p>
<pre>#iface eth0 inet dhcp
iface eth0 inet static
<strong>address 192.168.1.2</strong>
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
<strong>gateway 192.168.1.1</strong>
<strong>dns-nameservers 192.168.1.1</strong></pre>
<p>To test your settings, cross your fingers and enter:</p>
<pre>/etc/init.d/networking restart</pre>
<p>Then check to see that you have the new IP address:</p>
<pre>ifconfig eth0</pre>
<p>and gateway…</p>
<pre>netstat –nr</pre>
<p>and DNS server:</p>
<pre> 
cat/etc/resolv.conf</pre>
<p>Ha, were you worried? Me neither!</p>
<h2>Setting the time zone</h2>
<p>You probably noticed shortly after connecting your Beaglebone to the Internet that it  automatically figured out the date and time, sort of: everything except the time zone.</p>
<p>The demo image includes a &#8220;cron&#8221; job that uses NTP to get the correct date and time. You can see this by entering:</p>
<pre>crontab -l
30 * * * * /usr/bin/ntpdate -b -s -u pool.ntp.org</pre>
<p>Every 30 minutes, it will run the ntpdate command to update the system date and time.</p>
<p>The system determines the time zone using a file called /etc/localtime. Don&#8217;t try editing this file – instead, you point it at the correct time zone under /usr/share/zoneinfo. To see what&#8217;s available:</p>
<pre> ls -lr /usr/share/zoneinfo/</pre>
<p>These files in the zoneinfo directory are installed by package tzdata.</p>
<p>Don&#8217;t feel bad if they don&#8217;t include your town – they missed mine too. However, you should be able to find your time zone, or another city in it. For me, I set the timezone by entering:</p>
<pre>rm /etc/localtime
ln -s /usr/share/zoneinfo/America/New_York /etc/localtime</pre>
<p>Note that &#8220;ln -s&#8221; creates a pointer to an existing file &#8211; make sure you get the parms in the right order.</p>
<p>Reboot to update the system time.</p>
<h2>Updating packages</h2>
<p>If you haven&#8217;t updated the Linux packages on your Beaglebone before, and you&#8217;re using one of the early Angstrom images (the original 11-16-11 image, or the 12-26-11 image) you&#8217;re in for a treat. A movie, perhaps, or dinner, or a long romantic walk on the moonlight. As long as it takes an hour or two, cause the first package update is sloooooow.</p>
<p>I don&#8217;t know why, but there has been a steady stream of package updates released since the Beaglebone came out. Usually, Angstrom is a &#8220;sleepier&#8221; distribution – just the occasional bug fix or security update. I&#8217;m guessing that package development for the Beaglebone is more active because the platform is new, and package updates will become less frequent over time.</p>
<p>The basics of updating packages is to remember 2 commands:</p>
<pre>Opkg update
Opkg upgrade</pre>
<p>The first updates your local copy of the list of available packages, and the second does the updating. It&#8217;s all automated – you shouldn&#8217;t see any prompts, so no need to stand around watching it go&#8230; and go &#8230;.</p>
<p>.. phew, done! After the first batch of updates, it&#8217;s a good idea to reboot.</p>
<p>After awhile, the &#8220;opkg upgrade&#8221; will begin to mutter complaints when it&#8217;s done – stuff like:</p>
<pre>Collected errors:
* check_data_file_clashes: Package shadow wants to install file /etc/login.defs
But that file is already provided by package * shadow-sysroot
* check_data_file_clashes: Package shadow wants to install file /etc/login.defs
But that file is already provided by package * shadow-sysroot</pre>
<p>Yada yada yada.  Whatever.</p>
<p>Honestly, you generally don&#8217;t have to do anything to fix the errors – as other packages get updated, the problems get fixed. If they don&#8217;t, there is always Google.</p>
<h2>Installing packages</h2>
<p>The demo image comes with a lot of software, but there are thousands of other packages available. To see everything that is out there, you can enter:</p>
<pre>opkg list</pre>
<p>That&#8217;s a lot of packages! If you have an idea of what you are looking for, use grep to filter the results:</p>
<pre>Opkg list | grep "python"</pre>
<p>To install the package</p>
<pre>Opkg install &lt;packagename&gt;</pre>
<p>If you can&#8217;t find what you want that way, try the online <a href="http://www.angstrom-distribution.org/repo/">Angstrom package browser</a>. It has a more convenient interface, and it&#8217;s possible that the package you&#8217;re looking for isn&#8217;t listed by opkg but can be found on the web site (in the dreaded &#8220;unstable&#8221; branch &#8211; scary!).</p>
<p>For example, my preferred command line editor is <a href="http://www.gnu.org/software/emacs/">Emacs</a>, but that doesn&#8217;t appear in the output of &#8220;opkg list&#8221;.  It is, however, <a href=" http://www.angstrom-distribution.org/repo/?pkgname=emacs">listed in the package browser</a>.</p>
<p>The &#8220;available versions&#8221; section lists 2 options:</p>
<p><a href="http://www.gigamegablog.com/wp-content/uploads/2012/01/1-29-2012-3-33-26-PM.jpg"><img class="aligncenter size-full wp-image-1139" title="" src="http://www.gigamegablog.com/wp-content/uploads/2012/01/1-29-2012-3-33-26-PM.jpg" alt="" width="847" height="351" /></a></p>
<p>The Beaglebone is compatible with armv7a packages, so when that platform is available you should select it.  (Packages compiled for earlier versions of ARM processors will generally also run on the Beaglebone, but more slowly)</p>
<p>You can just click on the link to download it, and copy the package over via WinSCP, or use wget to download it directly to the Beaglebone:</p>
<pre> wget <a href="http://www.angstrom-distribution.org/feeds/unstable/ipk/glibc/armv7a/base/emacs_22.3-r1.6_armv7a.ipk">http://www.angstrom-distribution.org/feeds/unstable/ipk/glibc/armv7a/base/emacs_22.3-r1.6_armv7a.ipk</a></pre>
<p>To install it, just specify the filename instead of the package name:</p>
<pre>opkg install emacs_22.3-r1.6_armv7a.ipk</pre>
<p>You&#8217;ll likely find that it complains about a missing dependency file, liblockfile:</p>
<pre>Installing emacs (22.3-r1.6) to root...
Collected errors:
 * satisfy_dependencies_for: Cannot satisfy the following dependencies for emacs:
 * liblockfile (&gt;= 1.06) *
 * opkg_install_cmd: Cannot install package emacs.</pre>
<p>Yada yada yada.  Actually, this one we can fix.</p>
<p>The package browser web page for emacs, above, lists liblockfile as a dependency.  You can click on the link to <a href=" http://www.angstrom-distribution.org/repo/?pkgname=liblockfile">open up the liblockfile page </a>and download it from there, or enter the following to download the dependency and install both packages:</p>
<pre>wget http://www.angstrom-distribution.org/feeds/2011.03/ipk/glibc/armv7a/base/liblockfile_1.06-r1.6_armv7a.ipk
opkg install liblockfile_1.06-r1.6_armv7a.ipk emacs_22.3-r1.6_armv7a.ipk</pre>
<h2>Other useful opkg commands</h2>
<p>To remove a package</p>
<pre><span style="color: #222222;"><span style="font-family: Courier, monospace;"><span style="font-size: small;">opkg remove &lt;packagename&gt;</span></span></span></pre>
<p>To rip a package from the grasp of a protesting opkg (generally because you intend to replace the package with one that provides the same files):</p>
<pre lang="en-US"><span style="color: #222222;"><span style="font-family: Courier, monospace;"><span style="font-size: small;">opkg remove &lt;packagename&gt; --force-removal-of-dependent-packages</span></span></span></pre>
<p>To get more information about a package:</p>
<pre lang="en-US"><span style="color: #222222;"><span style="font-family: Courier, monospace;"><span style="font-size: small;">opkg info packagename</span></span></span></pre>
<p>To get a list of files that are installed by the package</p>
<pre lang="en-US"><span style="color: #222222;"><span style="font-family: Courier, monospace;"><span style="font-size: small;">opkg files packagename</span></span></span></pre>
<p lang="fr-CA">(Which only works after you&#8217;ve already installed the package - so much for look before you leap!)</p>
<h2>Automating package updates</h2>
<p>There are some people, who we&#8217;ll call &#8220;sissies&#8221;, who would argue that automating package updates is dangerous and irresponsible, since the updates might fail and you don&#8217;t want to leave your system in an unstable state.</p>
<p>Others, who we&#8217;ll call &#8220;real men&#8221;, think that the package update process is reliable enough that it rarely requires manual intervention. And, besides, you can always check the logs to detect any problems. It&#8217;s not like you&#8217;re going to forget to check the logs, right?</p>
<p>Personally, I&#8217;m a sissy. I&#8217;m also forgetful, so I&#8217;ve automated opkg anyway. Needless to say, I rarely bother to look at the output logs. (I know what I&#8217;ll find.. &#8220;Collected errors: yada yada yada&#8221;. Whatever.)</p>
<p>If you&#8217;re a real man, you can add a line to the crontab to automatically update your system.</p>
<p><em>[2/2/12: the following script was updated to add error handling]</em></p>
<p>First, create a script to run.  I use the following:</p>
<pre>
#!/bin/sh
# runopkg.sh
# Update packages and append output to log file
/usr/bin/opkg update
# opkg update returns 0 if OK, 1 if error
if [ $? = 0 ]; then
    /usr/bin/opkg upgrade &#038;>> /var/log/opkgupgrade.log
    echo "opkg complete rc $?  $(date)" >> /var/log/opkgupgrade.log
else
    echo "ERROR: opkg update returned $?" >> /var/log/opkgupgrade.log
fi
</pre>
<p>You can download this file from my site:</p>
<pre>beaglebone:~# wget http://www.gigamegablog.com/docs/runopkg.sh</pre>
<p>&#8230;make it executable&#8230;</p>
<pre>beaglebone:~# chmod u+x runopkg.sh</pre>
<p>&#8230;then add this script to the list of scheduled cron tasks:</p>
<pre>beaglebone:~# crontab -e
30 * * * * /usr/bin/ntpdate -b -s -u pool.ntp.org
33 3 * * * /home/root/runopkg.sh</pre>
<p>By default, the &#8220;crontab -e&#8221; command invokes the vi editor, which you&#8217;ll either love or hate.  Probably hate.</p>
<p>If you stored runopkg.sh in a directory other than the root home folder, be sure to enter the correct path in the crontab line.</p>
<p>The example above runs the update process every day at 3:33 am, and appends both the info and error messages to a log file. It checks the return code after running opkg update. Sometimes it fails to connect to one of the repositories, and it is safest not to do an upgrade with an incomplete list of updates.</p>
<h2>Customizing the command line</h2>
<p>Angstrom provides a standard Bash command line shell without any customizations: no <em>.profile</em> or <em>.bashrc</em> file.</p>
<p>Everybody&#8217;s got their own idea of how to make Bash more useful, but here are some common customizations to get you started.</p>
<p>First, create a file named .profile in  your home directory with the following contents:</p>
<pre># ~/.profile: executed by Bourne-compatible login shells.
if [ -f ~/.bashrc ]; then
 . ~/.bashrc
fi
# path set by /etc/profile
# export PATH
mesg n</pre>
<p>If you like, you can download this file directly from my site. Make sure you store it in your home folder .</p>
<pre>beaglebone:~# wget http://www.gigamegablog.com/docs/.profile</pre>
<p>This is an extremely plain .profile which mainly has one purpose: to activate the .bashrc file.</p>
<p>Next, create a file called .bashrc in your home directory with the following contents:</p>
<pre># ~/.bashrc: executed by bash(1) for non-login shells.
export PS1='\h:\w\$ '
umask 022
# You may uncomment the following lines if you want `ls' to be colorized:
export LS_OPTIONS='--color=auto'
# eval `dircolors`
alias ls='ls $LS_OPTIONS'
alias ll='ls $LS_OPTIONS -l'
alias l='ls $LS_OPTIONS -lA'

# Some more alias to avoid making mistakes:
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
# shell options
# autocorrect cd commands
shopt -s cdspell
# disable Ctrl-D to logout
set -o ignoreeof
# extended pattern matching
shopt -s extglob</pre>
<p>This file can be downloaded from my site &#8211; it should be stored in your home folder:</p>
<pre>beaglebone:~# wget http://www.gigamegablog.com/docs/.bashrc</pre>
<p>This does the following:</p>
<ul>
<li>shortens the command prompt to just your hostname and the current directory</li>
<li>changes the default permissions for new files you create so that they are writable by you, and just readable for everyone else</li>
<li>turns on colors for your &#8220;ls&#8221; output</li>
<li>creates a few shortcuts for common ls options (ll is the most useful, I think)</li>
<li>adds the &#8220;-i&#8221; parm to the copy, move and delete commands, which prompts you for confirmation when you are about to delete or overwrite a file</li>
<li>automatically fixes some typos in directory names</li>
<li>prevents Ctrl-D from dropping your session</li>
<li>enables <a href="http://www.gnu.org/software/bash/manual/bashref.html#Pattern-Matching">extra wildcards for matching files and directories</a></li>
</ul>
<p>By the way, when switching from a regular user to root using the su command, you need to include a hyphen to ensure that the root .profile and .bashrc are used:</p>
<pre>su -</pre>
<h2>Windows networking</h2>
<p>By now, you&#8217;re hopefully starting to look upon your Beaglebone with respect and admiration. You are also probably sick of WinSCP and/or command line editors. Why not welcome your Beaglebone into your Windows network and give it equal standing to your other PCs?</p>
<p>For this, you&#8217;ll need to install Samba.</p>
<pre>opkg install samba</pre>
<p>The correct configuration of Samba is actually quite complicated, or so I would assume since there is an <a href="http://oreilly.com/openbook/samba/book/index.html">entire book on the topic</a> . I haven’t actually read it, so instead I installed a browser-based configuration utility named Swat:</p>
<pre>opkg install xinetd swat</pre>
<p>The <span style="font-family: Georgia, serif; color: #333333;">xinetd utility is the standard way of invoking Swat and many other services that are accessed over the network.  It doesn&#8217;t start the service until it is accessed, which is quite helpful on a memory constrained platform like the Beaglebone.</span></p>
<p lang="en-US">The services are configured by entries in /etc/xinetd.conf or files in /etc/xinet.d, but unfortunately the Swat package currently doesn&#8217;t update either.  So, create a file at <em>/etc/xinetd.d/swat</em>, and paste the following into it:</p>
<pre lang="en-US">service swat
{
   disable = no
   port = 901
   socket_type = stream
   wait = no
   # only_from = localhost
   user = root
   server = /usr/sbin/swat
   log_on_failure += USERID
}</pre>
<p lang="en-US">Note that this configuration uses a port number of 901, allows access to other PCs on the network, and specifies that root is allowed to login.</p>
<p lang="en-US"><span style="color: #333333;"><span style="font-family: Georgia, serif;">After changing the xinetd.conf file, you need to restart xinetd:</span></span></p>
<pre lang="en-US"><span style="color: #222222;"><span style="font-family: Courier, monospace;"><span style="font-size: small;">/etc/init.d/xinetd restart</span></span></span></pre>
<p lang="en-US"><span style="color: #333333;"><span style="font-family: Georgia, serif;">You should now be able to open the following address in a browser on another PC: <em>http://&lt;your-beaglebone-ipaddress&gt;:901</em></span></span></p>
<p lang="en-US"><span style="color: #333333;"><span style="font-family: Georgia, serif;">Login as root at the prompt.</span></span></p>
<p lang="en-US"><span style="color: #333333;"><span style="font-family: Georgia, serif;">The first thing you&#8217;ll want to do is add a user to Samba &#8212; Samba doesn&#8217;t automatically use the same user-IDs and passwords as Linux.  Ideally, you should add a user that has the same user-ID as a Linux user and Windows user, and the same password as the Windows user &#8211; you&#8217;ll have fewer problems with permissions that way.</span></span></p>
<p lang="en-US"><span style="color: #333333;"><span style="font-family: Georgia, serif;">Go to the Swat password page and create a user. The interface isn&#8217;t terribly intuitive: fill in the user name and password in the Server Password Management area, then click then &#8220;Add New User&#8221; button.  You&#8217;ll get a subtle confirmation that the user was added, but it doesn&#8217;t display a list of users.</span></span></p>
<p lang="en-US"><img class="aligncenter" src="http://www.gigamegablog.com/wp-content/uploads/2010/12/swat.png" alt="" width="671" height="264" /></p>
<p lang="en-US">Next, click on Shares and add a share for your user&#8217;s home directory.</p>
<p lang="en-US">This step is advisable since, if there isn&#8217;t at least one share that your Windows user-ID is allowed to access, Samba/Windows will keep prompting for your user-ID and password.  If it&#8217;s the first time you are accessing a Samba share, you won&#8217;t know the cause of the problem: the user-ID, the password, or the share.  So, ensure you have access to <em>something</em> by explicitly sharing your user&#8217;s home directory.</p>
<p lang="en-US">The user interface on the Shares page isn&#8217;t very intuitive either: you need to fill in the textbox next to the Create Share button, then click the button</p>
<p lang="en-US"><a href="http://www.gigamegablog.com/wp-content/uploads/2012/01/1-29-2012-5-32-13-PM.jpg"><img class="aligncenter size-full wp-image-1143" title="" src="http://www.gigamegablog.com/wp-content/uploads/2012/01/1-29-2012-5-32-13-PM.jpg" alt="" width="431" height="351" /></a></p>
<p lang="en-US">Note that, by default, new shares are read-only and are <em>not</em> &#8220;available&#8221;. (Grrrr.)  So, you&#8217;ll need to manually change the &#8220;Available&#8221; setting and Read-only setting then click the Commit Changes button.</p>
<p lang="en-US">(When sharing directories other than your home directory, you may want to leave the Read-only setting on.  If your user-ID doesn&#8217;t have write permissions to the underlying Linux directory, don&#8217;t try to make it a writeable share.  It won&#8217;t work.)</p>
<p lang="en-US"><a href="http://www.gigamegablog.com/wp-content/uploads/2012/01/1-29-2012-5-33-34-PM.jpg"><img class="aligncenter size-full wp-image-1142" title="" src="http://www.gigamegablog.com/wp-content/uploads/2012/01/1-29-2012-5-33-34-PM.jpg" alt="" width="608" height="799" /></a></p>
<p lang="en-US"><span style="color: #333333;"><span style="font-family: Georgia, serif;">I’d also suggest you go to the Global page and change the workgroup to whatever your Windows PC uses &#8211; this makes your Beaglebone easily discovered by Windows.</span></span></p>
<p lang="en-US"><span style="color: #333333;"><span style="font-family: Georgia, serif;">After saving your changes you shouldn&#8217;t have to manually restart Samba, since it continually scans for configuration changes.  However, I often find that a restart is necessary to get your changes to be recognized by Windows:</span></span></p>
<pre lang="en-US">/etc/init.d/samba restart</pre>
<p lang="en-US"><span style="color: #333333;"><span style="font-family: Georgia, serif;">Now, Windows Explorer should be able to see your Beaglebone in your network, with some shares underneath. </span></span></p>
<p lang="en-US"><span style="color: #333333;"><span style="font-family: Georgia, serif;">If you are prompted for a user-ID and password, use the one you entered into Swat’s password page.  If Windows prompts for a new user-ID and password when accessing a share or file, remember that the Linux permissions come into play &#8211; try changing the Linux  directory permissions to give write access to non-root users.</span></span></p>
<h2 lang="en-US">Wrapping Up</h2>
<p lang="en-US">There&#8217;s been some debate in the <a href="http://groups.google.com/group/beagleboard">Beagleboard Google Group</a> about whether it makes sense to have a separate group for the Beaglebone.</p>
<p lang="en-US">IMHO, no.  While the Beaglebone is quite different as an electronics hobbyist platform, it&#8217;s almost completely identical to the Beagleboard when it comes to Linux configuration.  All of the steps I covered in this article also apply to the Beagleboard.</p>
<p lang="en-US">So, when looking for Linux tips and solutions, don&#8217;t ignore postings targeted at the Beagleboard.</p>
<p lang="en-US">Furthermore, while Angstrom has its differences from other Linux distributions, the most commonly used software is the same or very similar.  Dropbear is largely the same as <a href="http://www.openssh.com/">OpenSSH</a>, Busybox is largely the same as the <a href="http://www.gnu.org/software/coreutils/">core GNU utilities</a>, and Angstrom Bash is <a href="http://www.gnu.org/software/bash/">Bash</a>.  Don&#8217;t be discouraged by the lack of documentation on Angstrom or some its utilities.  There&#8217;s a wealth of information out there on SSH, GNU and Bash, and you&#8217;ll find that most of it applies to Angstrom.</p>
<p lang="en-US">The stuff that doesn&#8217;t apply? Ignore it.  Wouldn&#8217;t you rather be coding than reading, anyway?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gigamegablog.com/2012/01/29/beaglebone-linux-101-configuring-angstrom-linux/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Beaglebone Coding 101: Using the Serial and Analog Pins</title>
		<link>http://www.gigamegablog.com/2012/01/22/beaglebone-coding-101-using-the-serial-and-analog-pins/</link>
		<comments>http://www.gigamegablog.com/2012/01/22/beaglebone-coding-101-using-the-serial-and-analog-pins/#comments</comments>
		<pubDate>Mon, 23 Jan 2012 02:20:57 +0000</pubDate>
		<dc:creator>dwatts</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Gadgets]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Beagleboard]]></category>
		<category><![CDATA[Beaglebone]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.gigamegablog.com/?p=1094</guid>
		<description><![CDATA[[Updated Jan 25: Correction! There is a 1.8V voltage source on the Beaglebone: Port 9 Pin 32.  Thanks to Koen Kooi for the info.  I've updated the text with this information] This article is my second explaining the fundamentals of &#8230; <a href="http://www.gigamegablog.com/2012/01/22/beaglebone-coding-101-using-the-serial-and-analog-pins/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><span style="color: #0000ff;">[Updated Jan 25: Correction! There is a 1.8V voltage source on the Beaglebone: Port 9 Pin 32.  Thanks to Koen Kooi for the info.  I've updated the text with this information]</span></p>
<p>This article is my second explaining the fundamentals of coding with the <a href="http://beagleboard.org/bone">Beaglebone</a>. In the <a href="http://www.gigamegablog.com/2012/01/05/beaglebone-coding-101-blinking-an-led/">first article</a> I explained some of the mysteries of pin muxing, and gave an example of a very simple usage of a digital pin. This time, I’ll use an analog sensor and serial I/O (just O, actually), to create a time and temperature LCD display.</p>
<p>I have to admit that I’m far from an expert – I’m basically writing about this stuff as I figure it out.</p>
<p>The Beaglebone will hopefully prove to be a ground-breaking product, introducing a lot of electronics hobbyists to embedded Linux programming. Unfortunately, at this point there isn’t much in the way of embedded Linux development tools or tutorials that is geared to newcomers. This should change by the summer of 2012, as <a href="https://github.com/jadonk/bonescript">bonescript</a> expands and more Beaglebone-based projects pop up on blogs and sites like <a href="http://www.instructables.com">Instructables</a>. Until then, it will be one baby step at a time…</p>
<p><a href="http://www.gigamegablog.com/wp-content/uploads/2012/01/HPIM0986.jpg"><img class="aligncenter size-full wp-image-1098" title="" src="http://www.gigamegablog.com/wp-content/uploads/2012/01/HPIM0986.jpg" alt="" width="2304" height="1728" /></a></p>
<h2>Analog Input</h2>
<p>The first rule of analog input with the Beaglebone is:<br />
<span style="text-decoration: underline;"><span style="color: #ff0000; text-decoration: underline;">NOTE: Maximum voltage is 1.8V. Do not exceed this voltage. Voltage dividers</span></span><br />
<span style="text-decoration: underline;"><span style="color: #ff0000; text-decoration: underline;"> should be used for voltages higher than 1.8V.</span></span></p>
<p>So sayeth the Beaglebone System Reference Manual (Emphasis theirs. )</p>
<p>I haven’t experimented with what happens if you go above 1.8V, but since they’ve made the warning red and underlined, I’m pretty sure it would not go well.<br />
This limitation is a problem, since:</p>
<ul>
<li><del>There is no pin on the Beaglebone that provides a 1.8V source</del><br />
<span style="color: #0000ff;">[Correction Jan 25 - as pointed out in the comments, there is a pin that provides 1.8V, Port 9 pin 32 (labelled VDD_ADC in the Beaglebone System Reference Manual).    So you can ignore the stuff about voltage dividers and level converters below if you are using an analog sensor that can operate on 1.8V, like a potentiometer.]</span></li>
<li>Many analog sensors require a minimum voltage greater than 1.8V</li>
</ul>
<p>So, until someone has a better idea, voltage dividers will be an important part of any Beaglebone analog circuit.</p>
<p>The second most important thing to know about the Beaglebone’s analog input is that the software support seems to be a work-in-progress. The approach I’m taken is based on a <a href="http://dominion.thruhere.net/koen/cms/using-the-analog-pins-on-a-beaglebone">brief blog post</a> by one of the maintainers of the Beaglebone Angstrom demo images. His remarks would suggest that they have a better plan that is under development. As far as I know, the approach taken here is an Angstrom kernel modification that won’t work at all on a Ubuntu image with the vanilla Ubuntu kernel.</p>
<p>Back to the issue of 1.8 max voltage. You have a couple of options in your design:</p>
<ul>
<li><span style="color: #0000ff;">Added Jan 25: Use Port 9 Pin 32 as your voltage source, if your analog sensor can work on 1.8V</span></li>
<li>Use a couple of high precision resistors that can knock 3.3V or 5V down to exactly 1.8V</li>
<li>Use a couple of garden variety resistors to knock the voltage below 1.8V, then modify your software to adjust for the difference</li>
</ul>
<p>Being lazy, I’m going with the latter approach. Being very lazy, I’m not even bothering to hook up the resistors – as shown in the screenshot below, I’m using a tiny breakout board to do the work.</p>
<p>Specifically, this is a <a href="http://www.sparkfun.com/products/8745">Sparkfun Logic Level Converter &#8211; BOB-08745</a>. You’ll see this part recommended quite often in Beagleboard/Beaglebone circles, since it is an inexpensive solution that can handle a range of voltages, and supports 2-way conversion (necessary for I2C).</p>
<p>For the purpose of analog input I’m not using the board as intended &#8211; I&#8217;m taking advantage of a semi-documented hack. The RX pins on this board just use a voltage divider: the voltage going into the “HV” pins comes out as half the amount from the LV pins. The circuit for this, taken from the <a href="http://www.sparkfun.com/datasheets/BreakoutBoards/Level-Converter-v10.pdf">BOB-08745 schematic</a>, is shown below.</p>
<p><a href="http://www.gigamegablog.com/wp-content/uploads/2012/01/1-22-2012-6-23-53-PM.jpg"><img class="aligncenter size-full wp-image-1103" title="Voltage divider for analog input" src="http://www.gigamegablog.com/wp-content/uploads/2012/01/1-22-2012-6-23-53-PM.jpg" alt="" width="121" height="192" /></a></p>
<p>If you don’t have a BOB-08745, you can just use a couple of 10K resistors.</p>
<p>Before actually using this type of circuit, measure what voltage you get from the LV end of the voltage divider if the HV end is connected directly to 3.3V. If it isn’t below 1.8V, figure out what’s wrong before you hook it up to the Beaglebone. (Red and underlined, remember?) Don’t worry if the reading isn’t exactly 50% &#8211; we will calibrate the software to handle the variance.</p>
<p>The 2 analog sensors I’m using are a 10K potentiometer and an analog thermistor (temperature sensor), the <a href="http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en027103">Microchip MCP9700A</a>.</p>
<p><a href="http://www.gigamegablog.com/wp-content/uploads/2012/01/Circuit.jpg"><img class="aligncenter size-full wp-image-1104" title="" src="http://www.gigamegablog.com/wp-content/uploads/2012/01/Circuit.jpg" alt="" width="2304" height="1728" /></a></p>
<p>As you can see from the photos, the connections are:</p>
<p>- Potentiometer and MCP9700A:</p>
<ul>
<li>Input pin to 3.3V (which connects to pins 3 or 4 of Port 9 on the Beaglebone),</li>
<li>Ground pin to ground (connects to pins 1 or 2 of Port 9 of the Beaglebone),</li>
<li>Output pin to one of the RXI pins on the Sparkfun level converter (or to the HV pin on the voltage divider circuit)</li>
<li><span style="color: #0000ff;">Added Jan 25: An alternative for the potentiometer is to connect the input pin to Port 9 Pin 32 (VDD_ADC)., and the output pin directly to the Beaglebone AIN0 pin (pin 39 on Port 9)</span></li>
</ul>
<p>- Sparkfun level converter:</p>
<ul>
<li>HV to 3.3V</li>
<li>HV GND and LV GND to Ground</li>
<li>LV RXO for the potentiometer to the Beaglebone AIN0 pin (pin 39 on Port 9, or the outside pin of the 4th row from the “bottom” &#8211; the end opposite the Ethernet port)</li>
<li>LV RXO for the MCP9700A to the Beaglebone AIN1 pin (pin 40 on Port 9, or the inside pin of the 4th row)</li>
</ul>
<p>Note that the LV pin on the level converter isn’t used, since we are just interested in the voltage divider.</p>
<p>The definitive guide to the Beaglebone pin connections is the System Reference Manual. For this project we are just using Port 9, so you can refer to the table below:</p>
<p><a href="http://www.gigamegablog.com/wp-content/uploads/2012/01/1-22-2012-3-38-57-PM.jpg"><img class="aligncenter size-full wp-image-1102" title="" src="http://www.gigamegablog.com/wp-content/uploads/2012/01/1-22-2012-3-38-57-PM.jpg" alt="" width="782" height="801" /></a></p>
<h2>Testing Analog Input</h2>
<p>Remember all that stuff about pin muxing from the first article? You can forget about it for analog in.</p>
<p>As you can see by looking at Table 12 of the Beaglebone System Reference Manual (part of which is shown below), the mux table for all of the analog in pins (AIN1 to AIN6) is empty: the pins can only be used for analog in.</p>
<p><a href="http://www.gigamegablog.com/wp-content/uploads/2012/01/1-22-2012-7-09-16-PM.jpg"><img class="aligncenter size-full wp-image-1105" title="" src="http://www.gigamegablog.com/wp-content/uploads/2012/01/1-22-2012-7-09-16-PM.jpg" alt="" width="768" height="215" /></a></p>
<p>There actually are entries for these pins in the file system, <em>/sys/kernel/debug/omap_mux</em>, but they have the correct setting by default, and as far as I can tell the Mode setting has no effect on the pins. (The Python code I wrote sets them anyway, but that’s admittedly more out of ignorance than caution.)</p>
<p>So, we can proceed directly to using the pins.</p>
<p>Let’s start with the potentiometer on analog 0 (pin 39 of Port 9). To get the current reading from the pot, enter the following (yes, it’s ain1 for analog 0 – go figure):</p>
<pre>root@beaglebone:~# cat /sys/devices/platform/tsc/ain1
 1807</pre>
<p>A number should be displayed. Turn the pot all the way up and repeat. You’ll see the maximum value.</p>
<p>For me, it’s 3779. Or 3775. Or 3776. It drifts around a little. Go figure.</p>
<p>The analog input pins on the Beaglebone are 12-bit, so the maximum possible value is 4096. This represents a value of 1.8V. At 3779, it’s reading 3779/4096 * 1.8V, or 1.66V, which is about what you would expect with a 10K/10K voltage divider with 3.3V input.</p>
<p>Now, check the MCP7200A thermometer on analog 1 (again, the analog index is off by 1, so it&#8217;s ain2):</p>
<pre>root@beaglebone:~# cat /sys/devices/platform/tsc/ain2
 826</pre>
<p>You should get a relatively low value: if it’s above 1000, either you are in hell or your thermistor isn&#8217;t hooked up correctly.</p>
<p>The formula for converting this reading to a temperature is:</p>
<p>(milliVolts – 500) / 10</p>
<p>The 826 reading I got is 826/4096 * 1.8V, or 362 mV.</p>
<p>Is it cold in here, or is it just me?</p>
<p>It’s just me. The voltage divider knocked the reading from the MCP7200A down by about half, or the actual reading is 362 * 2, or 724 mV. The temperature reading is therefore (724 – 500) / 10, or 22.4. (No, <em>that</em> isn&#8217;t cold, it’s just metric).</p>
<p>Actually, neither the MCP9700A nor this approach is very accurate. The <a href="http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en027103">MCP7200A’s datasheet</a> says it&#8217; typical accuracy is to within 1 degree C . There isn’t anything we can do to improve that, but we can make our calculation more accurate by allowing for slight variances of the resistors in our voltage divider.</p>
<p>To see what effect the voltage divider is having, temporarily hook the input to 3.3V instead of the MCP9700A’s output pin. Then check the value of /sys/devices/platform/tsc/ain2 again.</p>
<p>And again. And again.</p>
<p>I get 3765. And 3762. And 3759.</p>
<p>Given that each 10mV is a degree, that jumping about is a real problem. We’ll plug the average (call it 3762) into the code, then average a bunch of readings to get the temperature, approximately.</p>
<h2>Serial I/O</h2>
<p>The Beaglebone has 6 serial UARTs. One of those, UART0, is connected to the USB port, but that leaves us with 5 to play with. This is quite a step up from the Arduino’s single UART, or the <a href="http://www.netduino.com" target="_blank">Netduino</a>’s 2 UARTs.</p>
<p>All of these are 3.3V UARTs. This is a problem if you’re communicating with a 5V device, but only when receiving data. Some 3.3 microcontrollers, like the Netduino’s, have “5V tolerant” pins, so they can communicate directly with 5V serial devices. But, for the Beaglebone:</p>
<p><span style="text-decoration: underline;"><span style="color: #ff0000; text-decoration: underline;">NOTE: Do not connect 5V logic level signals to these pins or the board will be</span></span><br />
<span style="text-decoration: underline;"><span style="color: #ff0000; text-decoration: underline;"> damaged.</span></span></p>
<p>So sayeth the Beaglebone System Reference Manual.</p>
<p>I assume this means that connecting an UART RX pin directly to the TX pin of a 5V serial device is a bad idea. I did it for awhile, and my Beaglebone lived to tell the tale, but maybe I got lucky.</p>
<p>Were we receiving data from the Serial LCD, then a level converter would be required, like the Sparkfun BOB-08745 described earlier. (Actually a second level converter would be needed, since we would be going between 3.3Vand 5, not 3.3 and 1.8ish.)</p>
<p>However, it will be serial TX only for this project, and all 5V serial devices that I’ve come across handle 3.3V on the RX pin without problems.</p>
<p>In the demo Angstrom image, the pins are <em>not</em> enabled for UART by default. Yup, time for the black art of pin muxing again.</p>
<p>Working with UART1’s mux mode is relatively straightforward. UART1 is the Mode 0 usage for the pin, and as you may recall from <a href="http://www.gigamegablog.com/2012/01/05/beaglebone-coding-101-blinking-an-led/" target="_blank">my first article</a>, the pin name used in the file system are taken from the Mode 0 usage. To check the current settings:</p>
<pre>root@beaglebone:~# cat /sys/kernel/debug/omap_mux/uart1_rxd
 name: uart1_rxd.(null) (0x44e10980/0x980 = 0x0037), b NA, t NA
 mode: OMAP_PIN_OUTPUT | OMAP_MUX_MODE7
 signals: uart1_rxd | mmc1_sdwp | d_can1_tx | NA | NA | NA | NA | NA

 root@beaglebone:~# cat /sys/kernel/debug/omap_mux/uart1_txd
 name: uart1_txd.(null) (0x44e10984/0x984 = 0x0037), b NA, t NA
 mode: OMAP_PIN_OUTPUT | OMAP_MUX_MODE7
 signals: uart1_txd | mmc2_sdwp | d_can1_rx | NA | NA | NA | NA | NA</pre>
<p>As you can see, both are set to 0&#215;37 by default in the Angstrom demo image. This setting means they are in Mode 7 (as the 2nd line of the output confirms) and that the Receive feature is enabled for both pins.</p>
<p>Let’s briefly take a closer look at the meaning of these mux pins. In my last article I explained the Mode settings, but not the other bits. The full list of the bit settings can be found in Table 9-58 of the AM335x Technical Reference Manual &#8211; you can find a link to it <a href="http://processors.wiki.ti.com/index.php/Device:AM335x:Device_Evaluation">here</a>. I’ll save you the trouble of searching for the table in that 4500-page behemoth:</p>
<p><a href="http://www.gigamegablog.com/wp-content/uploads/2012/01/1-22-2012-7-19-44-PM.jpg"><img class="aligncenter size-full wp-image-1107" title="" src="http://www.gigamegablog.com/wp-content/uploads/2012/01/1-22-2012-7-19-44-PM.jpg" alt="" width="624" height="352" /></a></p>
<p>The 2 UART pins currently have a mux setting of 0&#215;37, or 0011 0111. So:</p>
<ul>
<li>The slow slew rate is selected – this might concern me if I knew what it meant.</li>
<li>The Receiver is enabled – we want that for the RX pin, not so much for the TX pin</li>
<li>The pullup/pulldown is set to pullup – not a concern for serial communication</li>
<li>The pullup/pulldown is enabled</li>
<li>The 3 mode bits are all on, to indicate mode 7</li>
</ul>
<p>We want to set both pins to Mode 0, and we also want the receiver disabled on the TX pin:</p>
<pre>root@beaglebone:~# echo 20 &gt; /sys/kernel/debug/omap_mux/uart1_rxd

 root@beaglebone:~# cat /sys/kernel/debug/omap_mux/uart1_rxd
 name: uart1_rxd.uart1_rxd (0x44e10980/0x980 = 0x0020), b NA, t NA
 mode: OMAP_PIN_OUTPUT | OMAP_MUX_MODE0
 signals: uart1_rxd | mmc1_sdwp | d_can1_tx | NA | NA | NA | NA | NA

 root@beaglebone:~# echo 0 &gt; /sys/kernel/debug/omap_mux/uart1_txd

 root@beaglebone:~# cat /sys/kernel/debug/omap_mux/uart1_txd
 name: uart1_txd.uart1_txd (0x44e10984/0x984 = 0x0000), b NA, t NA
 mode: OMAP_PIN_OUTPUT | OMAP_MUX_MODE0
 signals: uart1_txd | mmc2_sdwp | d_can1_rx | NA | NA | NA | NA | NA</pre>
<p>Having said all that, I’m actually going to use UART2 for this project.</p>
<p>UART2 is a little trickier, since its pins have other names in the file system. Looking at Table 11 of the Beaglebone System Reference Manual, we see that UART2_TXD is pin 21, and UART2_RXD is pin 22. Table 12 (below) tells us that pin 21’s Mode 0 usage (and therefore the name used in the file system) is spi0_d0, and that UART2_RXD is the Mode 1 usage. For Pin 22, it’s spi0_sclk, and we also want to change it to Mode 1.</p>
<p><a href="http://www.gigamegablog.com/wp-content/uploads/2012/01/1-22-2012-7-21-55-PM.jpg"><img class="aligncenter size-full wp-image-1108" title="" src="http://www.gigamegablog.com/wp-content/uploads/2012/01/1-22-2012-7-21-55-PM.jpg" alt="" width="932" height="94" /></a></p>
<p>Here are the commands for checking the current settings, and changing the settings to use UART2:</p>
<pre>root@beaglebone:~# cat /sys/kernel/debug/omap_mux/spi0_d0
 name: spi0_d0.(null) (0x44e10954/0x954 = 0x0037), b NA, t NA
 mode: OMAP_PIN_OUTPUT | OMAP_MUX_MODE7
 signals: spi0_d0 | NA | NA | NA | NA | NA | NA | NA

 root@beaglebone:~# echo 1 &gt; /sys/kernel/debug/omap_mux/spi0_d0

 root@beaglebone:~# cat /sys/kernel/debug/omap_mux/spi0_d0
 name: spi0_d0.(null) (0x44e10954/0x954 = 0x0001), b NA, t NA
 mode: OMAP_PIN_OUTPUT | OMAP_MUX_MODE1
 signals: spi0_d0 | NA | NA | NA | NA | NA | NA | NA

 root@beaglebone:~# cat /sys/kernel/debug/omap_mux/spi0_sclk
 name: spi0_sclk.(null) (0x44e10950/0x950 = 0x0037), b NA, t NA
 mode: OMAP_PIN_OUTPUT | OMAP_MUX_MODE7
 signals: spi0_sclk | NA | NA | NA | NA | NA | NA | NA

 root@beaglebone:~# echo 21 &gt; /sys/kernel/debug/omap_mux/spi0_sclk

 root@beaglebone:~# cat /sys/kernel/debug/omap_mux/spi0_sclk
 name: spi0_sclk.(null) (0x44e10950/0x950 = 0x0021), b NA, t NA
 mode: OMAP_PIN_OUTPUT | OMAP_MUX_MODE1
 signals: spi0_sclk | NA | NA | NA | NA | NA | NA | NA</pre>
<h2>A Python Time and Temperature Display for the Beaglebone</h2>
<p>I’ve written some Python code to try out the analog and serial pins of the Beaglebone. It gets the temperature from the MCP9700A, and uses the potentiometer to set the backlight of the LCD.</p>
<p><a href="http://www.gigamegablog.com/wp-content/uploads/2012/01/HPIM0988.jpg"><img class="aligncenter size-full wp-image-1099" title="" src="http://www.gigamegablog.com/wp-content/uploads/2012/01/HPIM0988.jpg" alt="" width="2304" height="1728" /></a></p>
<p>You can <a href="http://code.google.com/p/gigamega-micro/downloads/detail?name=serdisplay.py">download the Python program from my Google Code project page</a>: it&#8217;s just a single file, serdisplay.py.</p>
<p>From the Beaglebone command line, you can download the Python program as follows:</p>
<pre>root@beaglebone:~# wget http://gigamega-micro.googlecode.com/files/gpiotester.py</pre>
<p>I’ve tested the code with the<a href="http://www.sparkfun.com/products/10097"> Sparkfun Serial Enabled LCD Kit</a>, the <a href="http://www.sparkfun.com/products/258">Sparkfun Serial Enabled Backpack</a>. I’ve also coded support for Matrix Orbital serial LCDs, but haven’t tested that yet.</p>
<p>The code uses one Python library that isn’t included in the Angstrom demo image, python-serial. To install it:</p>
<pre>root@beaglebone:~# opkg install python-serial</pre>
<p>There is no configuration file or command line parameters yet, so any changes to the default settings (the Sparkfun Serial LCD Backpack and a 4-row 20-column LCD) should be made to the code near the top of the program:</p>
<pre># -------------- configurable settings ---------
# settings for UART1
 #DISPLAYPORT = '/dev/ttyO1'
 #RX_MUX = 'uart1_rxd'
 #TX_MUX = 'uart1_txd'
 #MUX_MODE = 0
# settings for UART2
 DISPLAYPORT = '/dev/ttyO2'
 RX_MUX = 'spi0_sclk'
 TX_MUX = 'spi0_d0'
 MUX_MODE = 1
# settings for Serial LCD
 DISPLAY_TYPE = 'SPARKFUN_KIT'
 #DISPLAY_TYPE = 'MATRIX_ORBITAL'
 #DISPLAY_TYPE = 'SPARKFUN'
# settings for analog voltage conversion
 MAX_ANALOG = 3762 # approx 4096 * (1.65/1.8), since voltage divider gives me max of 1.65
 # -- actual values of 3762 based on measurements
# settings for display updates
 TIME_UPDATE_INTERVAL = 1 # every second
 TIME_DISPLAY_ROW = 1
 TEMPERATURE_DISPLAY_ROW = 2
 LCD_NUM_ROWS = 4
 LCD_NUM_COLS = 20
# determines whether debug info is written to the console
 Debug = True
# ---------------------------------------------------------</pre>
<p>Then, just run the program as root:</p>
<pre>root@beaglebone:~# python serdisplay.py</pre>
<p>To stop the program, press Ctrl-Z to put it in the background, then kill the background job:</p>
<pre>root@beaglebone:~# kill %1</pre>
<p>If you want to keep the program running all the time, I’d recommend using the <a href="http://www.gnu.org/software/screen/">GNU Screen</a> utility:</p>
<pre>root@beaglebone:~# screen
&lt;Press enter when prompted&gt;
root@beaglebone:~# python serdisplay.py</pre>
<p>To return to the main command command prompt (leaving the Python program running in the background) press Ctrl-A D.  To go back to the Screen session at any time in the future:</p>
<pre>root@beaglebone:~# screen –r –d</pre>
<p>For troubleshooting, any error messages are written to serdisplay.log in the same directory as serdisplay.py.</p>
<h2>Programmer’s Show And Tell</h2>
<p>Since the focus of this article is the Beaglebone, not Python, I’ll just point out some Beaglebone-specific parts of the code.</p>
<p>The code which initializes the UART for the serial display is:</p>
<pre>DISPLAYPORT = '/dev/ttyO2'
 RX_MUX = 'spi0_sclk'
 TX_MUX = 'spi0_d0'
 MUX_MODE = 1
 BAUDRATE = 9600
 TIMEOUT = 3 # serial port timeout is 3 seconds - only used when reading from display
# MUX settings
 RECEIVE_ENABLE = 32
. . .
open('/sys/kernel/debug/omap_mux/' + RX_MUX, 'wb').write("%X" % (RECEIVE_ENABLE + MUX_MODE))
 # set the TX pin for Mode 0
 open('/sys/kernel/debug/omap_mux/' + TX_MUX, 'wb').write("%X" % MUX_MODE)
 serDisplay = serial.Serial(DISPLAYPORT, BAUDRATE, timeout=TIMEOUT)</pre>
<p>There are Linux character devices assigned to the BeagleBone UARTs: UART1 is /dev/ttyO1, UART2 is /dev/ttyO2, and so on.</p>
<p>From the point of view of the Python program, the Beaglebone’s UART behaves like any other serial port. The code I wrote would work unchanged (aside from the /dev name) when communicating with an XBee, or through a USB-based virtual COM port.</p>
<p>Analog input is a little more finicky. The code which reads the analog value is:</p>
<pre>def readAnalog(pinIndex):
 try:
    # add 1 to pin index to get analog pin sys filename
    reading = open("/sys/devices/platform/tsc/ain" + str(pinIndex + 1), "r").read()

    # sometimes string has trailing nulls - delete them
    val = int(re.sub(r'[^\d]+', '', reading))
    return val
 except:
    log.exception('Error in readAnalog')</pre>
<p>As indicated by the comments, I found that the value read through the file system was sometimes corrupted: it contained nulls, usually after the value, but occasionally imbedded within the value. I’m not sure if this is a Python-specific thing, or other code would also encounter the problem. In Python, you can strip out the null (and any other non-numeric) values using a regular expression:</p>
<pre>val = int(re.sub(r'[^\d]+', '', reading))</pre>
<p>From time to time, the attempt to read the analog value will throw an exception.  So, it&#8217;s best to use a try/except handler like the one above.</p>
<p>One other problem is that the analog value tends to jump around by about 5 points from one reading to the next, even when it should be constant (e.g. from the potentiometer). I adjusted for this by using an average reading for the temperature, and by ignoring potentiometer readings (i.e. LCD brightness settings) that are within 20 of the last setting.</p>
<p>Don’t forget that the analog value is from 0-4096 – 16 times more sensitive than on the Arduino &#8212;  so allow for a greater range of readings.</p>
<h2>Wrapping Up</h2>
<p>Based on my testing of the code in this project, I&#8217;ve found that the Beaglebone’s UARTs are quite reliable and pretty easy to use.  Serial communications should be a relatively easy and trouble-free addition to any Beaglebone project.</p>
<p>Analog in, on the other hand,  has room for improvement.</p>
<p>The approach I used for reading analog input in is good enough for things that don’t require precise accuracy, like the potentiometer or a light meter.  The readings returned by the MCP9700A thermistor are not as stable as they should be.</p>
<p>Fortunately, analog is not the only game in town when it comes to temperature readings, so I plan to experiment with some I2C sensors in the future.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gigamegablog.com/2012/01/22/beaglebone-coding-101-using-the-serial-and-analog-pins/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Beaglebone Coding 101: Blinking an LED</title>
		<link>http://www.gigamegablog.com/2012/01/05/beaglebone-coding-101-blinking-an-led/</link>
		<comments>http://www.gigamegablog.com/2012/01/05/beaglebone-coding-101-blinking-an-led/#comments</comments>
		<pubDate>Thu, 05 Jan 2012 19:49:49 +0000</pubDate>
		<dc:creator>dwatts</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Gadgets]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Beagleboard]]></category>
		<category><![CDATA[Beaglebone]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.gigamegablog.com/?p=1079</guid>
		<description><![CDATA[[Updated Jan 22 - various improvements to the Python sample code at the end of the article] In November, Texas Instruments, Digi-Key and the other members of Beagleboard.org, the Beaglebone.  This is a simpler, more hobbyist-friendly little brother to the &#8230; <a href="http://www.gigamegablog.com/2012/01/05/beaglebone-coding-101-blinking-an-led/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><em>[Updated Jan 22 - various improvements to the Python sample code at the end of the article]</em></p>
<p>In November, <a href="http://www.ti.com">Texas Instruments</a>, <a href="http://www.digikey.com">Digi-Key</a> and the other members of <a href="http://beagleboard.org">Beagleboard.org</a>, the <a href="http://beagleboard.org/bone">Beaglebone</a>.  This is a simpler, more hobbyist-friendly little brother to the <a href="http://beagleboard.org/hardware">Beagleboard</a> (which I&#8217;ve written about in <a href="http://www.gigamegablog.com/tag/beagleboard/">past articles</a>).</p>
<p>Compared to the Beagleboards, the Beaglebone is considerably less expensive ($90), provides access to all of its pins, is pin-compatible with 3.3V sensors and devices (aside from analog in, which is still 1.8V), and provides a more friendly &#8220;out of the box&#8221; experience.  As with the Arduino, the only thing you need to get started is a USB cable.</p>
<p>As a developer, my most pleasant surprise with the Beaglebone was the inclusion of an entry-level IDE and scripting language: the <a href="http://c9.io/">Cloud9 IDE</a> configured to run <a href="http://nodejs.org/">node.js</a> and <a href="https://github.com/jadonk/bonescript">bonescript</a>.</p>
<p>With the Beagleboards, there was no &#8220;out of the box&#8221; IDE.  There were plenty of options for developing with the Beagleboard – Texas Instrument&#8217;s Code Composer Studio, Eclipse, or the command-line GCC tools being the most prominent – but all had a fairly steep learning curve just to do something basic, like blink an LED.</p>
<p>One of the most slippery patches on that learning curve is figuring out how to convince the Linux kernel to let your code access the pins.  It&#8217;s nowhere near as simple as Arduino&#8217;s &#8220;<em>digitalwrite(13, HIGH)</em>&#8221; – or, at least, it wasn&#8217;t until bonescript came along.  Although bonescript is still in its very early stages, there is enough meat on it to give the embedded Linux newbie a friendly introduction to coding.</p>
<h2>The Circuit</h2>
<p>The circuit is your garden-variety LED configuration:</p>
<ul>
<li>an LED</li>
<li>a resistor (680R or thereabouts) connected to the negative pin of the LED</li>
<li>a jumper from the positive pin of the LED to the digital pin</li>
<li>a jumper from the resistor to ground</li>
</ul>
<p>The Beaglebone actually has 65 GPIO pins to choose from, but we&#8217;ll go with the one used by the <em>blinkled.js</em> program that is included with bonescript.  This is Pin 3 on Header 8, referred to by the <a href="http://beagleboard.org/static/BONESRM_latest.pdf">Beaglebone System Reference Manual</a> as  GPIO1_6 on Expansion B, but known to Linux as gpmc_ad6.</p>
<p>Say what?</p>
<p>Well, the &#8220;Pin 3 on Header 8&#8243; part is simple enough. If you look at the Beaglebone, Port 8 is one of the 2 double-rows of female headers,  labeled P8 on the circuit board.  (In the figure below, taken from the System Reference Manual, Port 8 is labeled &#8220;Expansion B).</p>
<div class="img aligncenter size-full wp-image-1083" style="width:598px;">
	<a href="http://www.gigamegablog.com/wp-content/uploads/2012/01/04-01-2012-5-32-10-PM.png"><img src="http://www.gigamegablog.com/wp-content/uploads/2012/01/04-01-2012-5-32-10-PM.png" alt="Beaglebone, showing pin P8_3 and Ground" width="598" height="582" /></a>
	<div>Beaglebone, showing pin P8_3 and Ground</div>
</div>
<p>At either end of the headers you&#8217;ll find the rows marked 1 and 2, and 45 and 46.  So, Pin 3 is the 2<sup>nd</sup> row from the top, left column, as indicated in the figure.</p>
<p>The other names for the pin, along with the locations of the ground pins, can be found in the <a href="http://beagleboard.org/static/BONESRM_latest.pdf">System Reference Manual</a>.  If you look at Table 8 – &#8220;Expansion Header P8 Pinout&#8221; (a portion of which is shown below), you&#8217;ll find the pins labeled with their default usages in the Angstrom Linux demo image (the one that comes packaged with the beaglebone on a microSD card).</p>
<div class="img aligncenter size-full wp-image-1082" style="width:586px;">
	<a href="http://www.gigamegablog.com/wp-content/uploads/2012/01/04-01-2012-7-42-03-PM.png"><img src="http://www.gigamegablog.com/wp-content/uploads/2012/01/04-01-2012-7-42-03-PM.png" alt="Default pin settings in Anstrom Linux" width="586" height="227" /></a>
	<div>Default pin settings in Anstrom Linux</div>
</div>
<p>Clearly, Ground is the top row of Port 8, so that&#8217;s the last bit of information we need to know to hook up the circuit.  But we&#8217;ll need to understand that part about pins having &#8220;default usages&#8221; – more on that later.</p>
<h2>Cloud9 IDE and bonescript</h2>
<p>When you boot up the Beaglebone with the microSD card from the box, the Cloud9 IDE is automatically started.  Once you have an  IP address assigned to the Beaglebone (either through its Ethernet port connection or through USB networking), you can load the Cloud9 IDE on your PC browser at http:&lt;beaglebone address&gt;:3000</p>
<p>(I haven&#8217;t tried to use USB networking myself, but the procedure for doing so is explained in <a href="http://beagleboard.org/static/beaglebone/a3/README.htm">Getting started with your new BeagleBone</a>.)</p>
<p>The Cloud9 IDE interface is pretty intuitive.  You select a source code file in the left pane, edit it in a tab in the right pane, and select Debug or Run from the toolbar to execute the code.</p>
<div class="img aligncenter size-full wp-image-1080" style="width:607px;">
	<a href="http://www.gigamegablog.com/wp-content/uploads/2012/01/04-01-2012-8-43-35-PM.png"><img src="http://www.gigamegablog.com/wp-content/uploads/2012/01/04-01-2012-8-43-35-PM.png" alt="Cloud9 IDE" width="607" height="454" /></a>
	<div>Cloud9 IDE</div>
</div>
<p>If you are coming at this from the Arduino, you will notice 3 significant differences from the Arduino IDE:</p>
<ul>
<li>You don&#8217;t upload your code to the board.  The Beaglebone is more like a PC than an Arduino – the code is stored on its file system, and you just run it.</li>
<li>You can debug your code.  Not Arduino&#8217;s form of debugging – print statements to the console (though you can do that too) &#8212; but real debugging, as in breakpoints, watch variables, step-by-step execution.</li>
<li>The coding language is Javascript, not C.  Specifically, it&#8217;s <a href="http://nodejs.org/">node.js</a>, which is Javascript optimized for running on a server, rather than in a browser, by way of some extra libraries.  The &#8220;server&#8221; in this case is the little old Beaglebone.  As you might imagine, node.js is not the fastest environment for running code on the Beaglebone, but for LED blinking and many other types of prototyping, it&#8217;s fast enough.</li>
</ul>
<p>Despite the differences, Arduino coders should find the transition to Cloud9 and bonescript to be quite easy.  The blinkled.js code looks very much like Arduino code.  That&#8217;s no coincidence: the README for the bonescript project, which you can find on its github page <a href="https://github.com/jadonk/bonescript">here</a>,  says that the goal is &#8220;to have something that provides most of the Arduino functions and is generally usable by Summer 2012&#8243;.</p>
<pre><strong>var</strong> ledPin <strong>=</strong> bone.P8_3;
<strong>var</strong> ledPin2 <strong>=</strong> bone.USR3;

setup <strong>=</strong> <strong>function</strong>() {
    pinMode(ledPin, OUTPUT);
    pinMode(ledPin2, OUTPUT);
};

loop <strong>=</strong> <strong>function</strong>() {
    digitalWrite(ledPin, HIGH);
    digitalWrite(ledPin2, HIGH);
    delay(1000);
    digitalWrite(ledPin, LOW);
    digitalWrite(ledPin2, LOW);
    delay(1000);
};</pre>
<p>This code from blinkled.js does the following:</p>
<ul>
<li>defines 2 pins, P8_3 (Port 8, pin 3) and USR3 (which is one of the built-in LEDS on the board, next to the Ethernet port)</li>
<li>sets these pins for Output</li>
<li>loops, turning these 2 LEDs on and off, once per second, ad infinitum</li>
</ul>
<p>If you&#8217;ve attached an LED to pin 3, and you run blinkled.js in Cloud9, you should find it blinking happily away. (There is a dropdown button next to the Run and Debug toolbar icons in Cloud9 to let you choose the file).</p>
<p>It&#8217;s that simple.</p>
<p>I lie.</p>
<p>There is actually considerable complexity behind the code which creates those 2 pin objects, <em>bone.P8_3</em> and <em>bone.USR3</em>.  The complicated code is in one of the 2 &#8220;library&#8221; files in the bonescript folder, <em>index.js</em>.</p>
<h2>Pins and Muxing</h2>
<p>Before we dive into the index.js code, let&#8217;s return to the <a href="http://beagleboard.org/static/BONESRM_latest.pdf">Beaglebone System Reference Manual</a>.  As you&#8217;ll recall, I earlier referred to the &#8220;default usage&#8221; on Port 8 Pin 3.  It has other usages, and the process of telling the board how you want to use that pin is called muxing (short for multiplexing).</p>
<p>The available usages of the pin, and all of the others on the Port 8, are listed in Tables 9 (the first part of which is shown below) and 10 of the System Reference Manual.  Each pin can have up to 8 uses, &#8220;mux mode&#8221; 0 through 7.  The default setting in the Angstrom Image is generally, but not always, mode 7.  Table 8 is the definitive guide to Angstrom&#8217;s default mux setting for each pin.</p>
<div class="img aligncenter size-full wp-image-1081" style="width:724px;">
	<a href="http://www.gigamegablog.com/wp-content/uploads/2012/01/04-01-2012-8-06-20-PM.png"><img src="http://www.gigamegablog.com/wp-content/uploads/2012/01/04-01-2012-8-06-20-PM.png" alt="Pin Mux settings from the System Reference Manual" width="724" height="228" /></a>
	<div>Pin Mux settings from the System Reference Manual</div>
</div>
<p>(Incidentally, other Linux distributions for the Beaglebone, such as Ubuntu, will have their own default mux settings.  The board doesn&#8217;t control the mux settings, the software does.  The developers of the Angstrom Linux image on the SD card selected their defaults to be the most commonly used ones by hobbyists, providing a good out-of-the-box experience.)</p>
<p>If you Google &#8220;Beagleboard mux&#8221;, you&#8217;ll find lots of pages explaining the various ways in which you can change the mux setting.  Many of them refer to U-Boot configuration and kernel modules, which are complicated and, fortunately, no longer necessary.  There has been a lot of work done recently at making the mux settings accessible to &#8220;userland&#8221; code by way of the Linux file system.  If you (or your code) wants to read or change the mux setting, it just needs to read or write to a file.</p>
<p>Great.  So which file?</p>
<p>This information used to be hard to come by, scattering amongst various forum and blog posts, or hidden inside code in U-Boot or the linux kernel.  However, if you&#8217;re learning to code with the Beaglebone, I think the best way to learn the mux file system is to look at how bonescript handles it.</p>
<h2>Muxing the bonescript way</h2>
<p>So, back to the Cloud9 IDE.  This time, open up the index.js file in the bonescript directory.  (Note that this part of bonescript is in active development and is likely to change by the time you read this, but the underlying file system will still be the same)</p>
<p>A little ways into the code (line 39 in the current release, bonescript 1.0-r10), you&#8217;ll find the following:</p>
<pre><strong>var</strong> gpio0 <strong>=</strong> 0;
<strong>var</strong> gpio1 <strong>=</strong> gpio0<strong>+</strong>32;
<strong>var</strong> gpio2 <strong>=</strong> gpio1<strong>+</strong>32;
<strong>var</strong> gpio3 <strong>=</strong> gpio2<strong>+</strong>32;

bone <strong>=</strong> exports.bone <strong>=</strong>
{
    P8_1<strong>:</strong> { name<strong>:</strong> "DGND" },
    P8_2<strong>:</strong> { name<strong>:</strong> "DGND" },
    P8_3<strong>:</strong> { name<strong>:</strong> "GPIO1_6", gpio<strong>:</strong> gpio1<strong>+</strong>6, mux<strong>:</strong> "gpmc_ad6" },
    P8_4<strong>:</strong> { name<strong>:</strong> "GPIO1_7", gpio<strong>:</strong> gpio1<strong>+</strong>7, mux<strong>:</strong> "gpmc_ad7" },
    P8_5<strong>:</strong> { name<strong>:</strong> "GPIO1_2", gpio<strong>:</strong> gpio1<strong>+</strong>2, mux<strong>:</strong> "gpmc_ad2" },
    P8_6<strong>:</strong> { name<strong>:</strong> "GPIO1_3", gpio<strong>:</strong> gpio1<strong>+</strong>3, mux<strong>:</strong> "gpmc_ad3" },
    P8_7<strong>:</strong> { name<strong>:</strong> "TIMER4", gpio<strong>:</strong> gpio2<strong>+</strong>2, mux<strong>:</strong> "gpmc_advn_ale" },
    P8_8<strong>:</strong> { name<strong>:</strong> "TIMER7", gpio<strong>:</strong> gpio2<strong>+</strong>3, mux<strong>:</strong> "gpmc_oen_ren" },
. . .
    USR0<strong>:</strong> { name<strong>:</strong> "USR0", gpio<strong>:</strong> gpio1<strong>+</strong>21, led<strong>:</strong> "usr0", mux<strong>:</strong> "gpmc_a5" },
    USR1<strong>:</strong> { name<strong>:</strong> "USR1", gpio<strong>:</strong> gpio1<strong>+</strong>22, led<strong>:</strong> "usr1", mux<strong>:</strong> "gpmc_a6" },
    USR2<strong>:</strong> { name<strong>:</strong> "USR2", gpio<strong>:</strong> gpio1<strong>+</strong>23, led<strong>:</strong> "usr2", mux<strong>:</strong> "gpmc_a7" },
    USR3<strong>:</strong> { name<strong>:</strong> "USR3", gpio<strong>:</strong> gpio1<strong>+</strong>24, led<strong>:</strong> "usr3", mux<strong>:</strong> "gpmc_a8" }</pre>
<p>This table contains 3 important pieces of information:</p>
<ol>
<li>the label that bonescript uses to identify the pins (P8_1, P8_2, etc)</li>
<li>the GPIO pin number (P8_3 is <em>gpio1+6</em>, or 38)</li>
<li>the mux label (P8_3 is <em>gpmc_ad6</em>)</li>
</ol>
<p>The GPIO pin number tells you the directory name you will use to read from or write to the pin.  The mux label tells you the filename you will use to read or write the mux setting.</p>
<p>Let&#8217;s start with the mux setting.  This is handled by some code just below the exports.bone table:</p>
<pre>if(pin.mux) {
 try {
    var muxfile = fs.openSync(
      "/sys/kernel/debug/omap_mux/" + pin.mux, "w"
      );
    fs.writeSync(muxfile, "7", null);
 } catch(ex3) {
    console.log("" + ex3);
    console.log("Unable to configure pinmux for: " + pin.name +
      " (" + pin.mux + ")");
. . .</pre>
<p>There is more to the error handling, but the important part is the reference to &#8220;<em>/sys/kernel/debug/omap_mux/</em>&#8221; + pin.mux.  This is the file used to read and write the mux setting.  In the case of Port 8 Pin 3, the full path is <em>/sys/kernel/debug/omap_mux/gpmc_ad6</em>.</p>
<p>This is the part that is newcomers to pin muxing often trip over: if you want to set a pin to be a GPIO pin, your code needs to reference a filename that appears to be intended for a different usage of the pin (gpmc_ad6).  The mux filename isn&#8217;t taken from its intended usage, it&#8217;s taken from its mode 0 usage.  The mode 0 usage for Port 8 Pin 3 is gpmc_ad6 – we know this from the table in the bonescript code, but the definitive reference for the Beaglebone pin mux modes are Tables 9 and 11 of the <a href="http://beagleboard.org/static/BONESRM_latest.pdf">Beaglebone System Reference Manual</a>.</p>
<p>Having opened the file (<em>fs.openSync</em>), the bonescript code writes a 7 to it (<em>fs.writeSync</em>).  This, as you probably guessed, sets the mux mode to 7, the GPIO mode for that pin.  The process of setting mux modes isn&#8217;t quite as simple as &#8220;write the  mode to a file&#8221;:  the mux mode setting also affects other aspects of the pin, such as whether it can be used for input.  The bonescript code shown above is actually correct only for setting pins to be GPIO Output pins.  The bonescript project will soon support other mux mode settings.</p>
<h2>Blinking LEDs the bonescript way</h2>
<p>Having set the pin to be in digital output mode, the next task is to set it high or low.  You&#8217;ll recall that this was handled in blinkled.js by calling a function called digitalWrite, same as the Arduino does.</p>
<p>The source code for digitalWrite can be found further down in index.js:</p>
<pre>digitalWrite <strong>=</strong> exports.digitalWrite <strong>=</strong> <strong>function</strong>(pin, value)
{
    fs.writeFileSync(gpio[pin.gpio].path, "" <strong>+</strong> value);
};</pre>
<p>OK, so it&#8217;s writing a value to a file, either HIGH (defined as 1) or LOW (0).  But which file?</p>
<p>The code to set that &#8220;path&#8221; property also in index.js, just below where the pin mux setting was done:</p>
<pre>try {
    try {
        fs.writeFileSync("/sys/class/gpio/export", "" + n);
    } catch(ex2) {
        // TODO: If the file is already exported, can we know who did
        // did it so that we aren't opening it twice?  In general, this
        // shouldn't be an error until we have some better resource
        // management.
        //console.log(ex2);
        //console.log("Unable to export gpio: " + n);
    }
    fs.writeFileSync("/sys/class/gpio/gpio" + n + "/direction",
        mode);
    gpio[n].path = "/sys/class/gpio/gpio" + n + "/value";
    return(true);
} catch(ex) {
    // Perhaps we couldn't open it because it was allocated as an LED
    if(pin.led) {
        fs.writeFileSync(
            "/sys/class/leds/beaglebone::" + pin.led + "/trigger",
            "gpio");
        if(mode == OUTPUT) {
            gpio[n].path =
                "/sys/class/leds/beaglebone::" + pin.led +
                "/brightness";
        } else {
            gpio[n].path =
                "/sys/class/leds/beaglebone::" + pin.led +
                "/gpio";
        }
        return(true);
    }
}</pre>
<p>The first thing it does is try to write to a file named &#8220;export&#8221;, specifically , &#8220;/sys/class/gpio/export&#8221;.  The value written is the GPIO pin number, which you&#8217;ll recall was specified in the table earlier in index.js.  For Port 8 Pin 3, it was defined as gpio1+6, or 38.</p>
<p>The export file is a funky weird-ass file: when you write a pin number to it, it (well, the kernel process which monitors that file) creates a directory and a bunch of files that provide interfaces for accessing the pin.  The directory is created at <em>/sys/class/gpio/export/gpioNN</em>. In the case of Port 8 Pin 3, that&#8217;s <em>/sys/class/gpio/export/gpio38</em>.</p>
<p>For the purpose of using a GPIO pin, the two most important files in the <em>gpioNN</em> directory are named <em>direction</em> and <em>value</em>.</p>
<p>The <em>direction</em> file determines whether the pin is going to be used for reading or writing.  As mentioned earlier, you can&#8217;t use a pin for reading without setting flipping a bit in the mux mode setting, so our only choice at this point is output.   The bonescript code writes the value &#8220;out&#8221; to the <em>direction</em> file (i.e. to <em>/sys/class/gpio/export/gpio38/direction</em>).</p>
<p>The code then saves the path to the <em>value</em> file (i.e. <em>/sys/class/gpio/export/gpio38/)</em> in the pin&#8217;s <em>path</em> property.  This, then, explains what the code in the digitalWrite function is doing:</p>
<pre>fs.writeFileSync(gpio[pin.gpio].path, "" <strong>+</strong> value);</pre>
<p>It writes a 1 to the value file (i.e. /sys/class/gpio/export/gpio38/value) to set the pin high (and the turn the LED on) and a 0 to set it low (and the LED off).</p>
<p>But wait, there&#8217;s more!</p>
<p>The bonescript code shown above also has an error handler.</p>
<p>Writing to the export file also tells the kernel that you intend to use that pin.  If the pin is already being used by something more important than your dinky userland application (i.e. the kernel or one of its pals), it will helpfully toss an error at you.</p>
<p>Generally, when your attempt to export a pin fails, you have no option but to go away and sulk.  Something is using that pin, and it might be a hardware driver that won&#8217;t be giving it up any time soon (such as the SD card socket, or an LCD).  There are ways of tracking down what&#8217;s using it, but I won&#8217;t cover them in this post.</p>
<p>One possibility is that the GPIO pin is being used by one of the built-in &#8220;user LEDs&#8221;, USR0 – USR3.  As you can see from the final entries in the bonescript mux table, those LEDs are connected to GPIOs 53-56.  So, the bonescript code checks to see if you&#8217;re trying to write to those GPIOs – if so, it assumes you want to access the user LEDs, and redirects you to their address.</p>
<p>These user LEDs are accessed through a different part of the file system than the GPIOs – technically, they are part of the Beaglebone board, not part of the CPU.  So, they are accessed through the <em>/sys/class/leds/beaglebone</em> directory, not <em>/sys/class/gpio</em>.</p>
<p>The Beagleboard (the &#8216;bone&#8217;s big brother) also has user LEDs, and they are accessed in basically the same way there, so you can find a good explanation of how to write to them in some of the articles written for the Beagleboard.  The command line interface is explained in <a href="http://elinux.org/EBC_Exercise_02_Flashing_an_LED">this article on eLinux</a>.  For C language code that interfaces to the user LEDs, see <a href="http://www.lvr.com/code/led_control.c">this sample</a> from Jan Axelson&#8217;s <a href="http://www.amazon.com/USB-Embedded-Hosts-Developers-Guide/dp/1931448248/ref=ntt_at_ep_dpt_3">USB Embedded Hosts: The Developer&#8217;s Guide</a>.  (This, by the way, is one of the few books currently available that specifically covers Beagleboard programming).</p>
<h2>Blinking LEDs the Python Way</h2>
<p>The directories and paths used by the bonescript code can also be used from other programming languages: pretty much anything that runs on Linux can read and write from the file system.</p>
<p>Here is my own humble contribution, a snippet of Python code which blinks the USR2, USR3 and Port 8 Pin 3 ten times.  It has the advantage of distilling the bonescript code down to the bare bones needed to access that particular pin.</p>
<p><em>[Updated Jan 22 - added support for User LEDs 2 and 3, handle case where pin already exported, and simplified  the file I/O syntax:]</em></p>
<pre class="brush: python; title: ; notranslate">
import time

# put Port 8 Pin 3 into mode 7 (GPIO)
open('/sys/kernel/debug/omap_mux/gpmc_ad6', 'wb').write(&quot;%X&quot; % 7)

try:
   # check to see if the pin is already exported
   open('/sys/class/gpio/gpio38/direction').read()
except:
   # it isn't, so export it
   print(&quot;exporting GPIO 38&quot;)
   open('/sys/class/gpio/export', 'w').write('38')

# set Port 8 Pin 3 for output
open('/sys/class/gpio/gpio38/direction', 'w').write('out')
# we will assume that USR1 and USR 2 are already configured as LEDs

for i in range(10):
   # turn on USR1 and external LED
   open('/sys/class/gpio/gpio38/value', 'w').write(&quot;1&quot;)
   open(&quot;/sys/devices/platform/leds-gpio/leds/beaglebone::usr1/brightness&quot;, 'w').write(&quot;1&quot;)
   # turn off USR2
   open(&quot;/sys/devices/platform/leds-gpio/leds/beaglebone::usr2/brightness&quot;, 'w').write(&quot;0&quot;)

   time.sleep(1)

   # turn off USR1 and external LED
   open('/sys/class/gpio/gpio38/value', 'w').write(&quot;0&quot;)
   open(&quot;/sys/devices/platform/leds-gpio/leds/beaglebone::usr1/brightness&quot;, 'w').write(&quot;0&quot;)
   # turn on USR2
   open(&quot;/sys/devices/platform/leds-gpio/leds/beaglebone::usr2/brightness&quot;, 'w').write(&quot;1&quot;)

   time.sleep(1)

# cleanup - remove GPIO38 folder from file system
open('/sys/class/gpio/unexport', 'w').write('38')
</pre>
<p> The Python code also demonstrates something that the bonescript code doesn&#8217;t handle.  To be a nice little userland app and clean up after yourself, you can write the GPIO pin number to /sys/class/gpio/unexport.  This doesn&#8217;t &#8220;release&#8221; the GPIO to other apps – you never had it locked for your exclusive use in the first place – so unexport&#8217;ing is just a convention to make the gpio file system is a little more manageable.</p>
<p>Since python is already installed on the Angstrom image, you can download the file and run it as follows:</p>
<pre>wget http://gigamega-micro.googlecode.com/files/gpiotester.py
python gpiotester.py</pre>
<h2>Wrapping Up</h2>
<p>If you think that&#8217;s a lot of work in order to blink an LED, you should have tried it a few years ago, when the Beagleboard was first released.</p>
<p>Back in the day, to do anything with a GPIO pin you pretty much had to be an embedded Linux guru, or beg for crumbs of knowledge from the guru&#8217;s table.  (Oh, and good luck getting your LED to light up on 1.8V.  You kids have it easy these days!)</p>
<p>The Beaglebone arrives at a time when the embedded Linux device market is growing by leaps and bounds, both in terms or hardware and development tools.  As a hobbyist (or a budding professional), this is a good time to hop on board the platform.</p>
<p>Incidentally, while the Beaglebone platform is geared for hobbyists and prototypers, the chip it uses is very much targeted at professionals.  The Texas Instruments Sitara AM3359 is a descendent of (and largely code compatible with) the storied OMAP chip family, which powers a lot of consumer gadgets: many of Nokia&#8217;s high-end smartphones like the E90, Motorola&#8217;s Droid line of Android smartphones, the Nook Color and the Kindle Fire.</p>
<p>If you can get to a root command line on one of those devices, you can probably set a GPIO high and low using the same code as above (and if you&#8217;re lucky, cause an inglorious crash).  How cool is that?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gigamegablog.com/2012/01/05/beaglebone-coding-101-blinking-an-led/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>A Pachube Google Gadget: Size Matters</title>
		<link>http://www.gigamegablog.com/2011/11/05/a-pachube-google-gadget-size-matters/</link>
		<comments>http://www.gigamegablog.com/2011/11/05/a-pachube-google-gadget-size-matters/#comments</comments>
		<pubDate>Sat, 05 Nov 2011 22:34:14 +0000</pubDate>
		<dc:creator>dwatts</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Gadgets]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Pachube]]></category>

		<guid isPermaLink="false">http://gigamegatech.com/?p=1034</guid>
		<description><![CDATA[As described in past articles, I use the Pachube online Database/Internet-Of-Things-Thingee to log data from Tweet-A-Watt and various other sensors. (It&#8217;s pronounced &#8220;Patch-bay&#8221;, apparently, but that won&#8217;t stop me from my thinking &#8220;Pa-Chew-Bee&#8221; every time I see the word. Feel &#8230; <a href="http://www.gigamegablog.com/2011/11/05/a-pachube-google-gadget-size-matters/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>As described in <a href="http://gigamegablog.com/2011/03/10/tweet-a-watt-beyond-the-twitter/">past </a><a href="http://gigamegablog.com/2011/10/29/fez-xbee-sensor-hat-trick/">articles</a>, I use the <a href="http://www.pachube.com">Pachube</a> online Database/Internet-Of-Things-Thingee to log data from <a href="http://www.ladyada.net/make/tweetawatt/">Tweet-A-Watt</a> and various other sensors. (It&#8217;s pronounced &#8220;Patch-bay&#8221;, apparently, but that won&#8217;t stop me from my thinking &#8220;Pa-Chew-Bee&#8221; every time I see the word. Feel free to join me.)</p>
<p><a href="http://www.pachube.com"><img class="aligncenter size-full wp-image-1043" title="PachubeLogo" src="http://www.gigamegablog.com/wp-content/uploads/2011/11/PachubeLogo.png" alt="" width="238" height="80" /></a></p>
<p>I like Pachube &#8212; it&#8217;s reliable, well-designed, well-documented, and very much open to hobbyists.  They <a href="http://blog.pachube.com/2011/01/bringing-down-barriers-pachube-service.html">recently did away with paid plans</a> and made all aspects of the site and service free, so I’d encourage you to give them a try. If you need help at getting your data into Pachube, see their <a href="http://api.pachube.com/quickstart/">Quick Start guide</a> and <a href="http://community.pachube.com/tutorials">Tutorials</a>. My article on <a href="http://gigamegablog.com/2011/03/10/tweet-a-watt-beyond-the-twitter/">connecting Tweet-A-Watt to Pachube</a> also contains some tips on getting started, and my article on the <a href="http://gigamegablog.com/2011/10/29/fez-xbee-sensor-hat-trick/">FEZ XBee Sensor</a> shows an easy way to post data to Pachube from Python.</p>
<p>Pachube&#8217;s site provides a page for each of your feeds, showing a graph of the last 24 hours of readings from each of your datastreams. That&#8217;s good if you remember to go look at it, but I&#8217;d prefer that my graphs come to me, via a gadget on my iGoogle home page.</p>
<p><a href="http://www.google.com/ig/directory?type=gadgets&amp;url=apps.pachube.com/google_gadget/gadget.xml">Pachube released a Google Gadget</a> some time ago, and I&#8217;ve been using it for some time. It works well, but there are a few extra features that I really wanted:<br />
- larger graphs, and the ability to resize the gadget container to see them<br />
- a time axis in local time, rather than UTC<br />
- the ability the set the timespan: 12 hours, 1 week, 1 month, etc.<br />
- a Maximized view that shows the graphs in humongous GigaMegaSize</p>
<p>So, I&#8217;ve created a Google Gadget which adds these features, plus a few more.</p>
<p>You can <a href="http://www.google.com/ig/directory?url=www.gigamegablog.com/gadgets/gm-pachube.xml">grab the gadget from the Google Gadgets directory</a>.</p>
<h1>Settings</h1>
<p>Here is a description of the various options available on the Edit Settings dialog.</p>
<p><a href="http://www.gigamegablog.com/wp-content/uploads/2011/11/GadgetSettings.png"><img class="aligncenter size-full wp-image-1039" title="GadgetSettings" src="http://www.gigamegablog.com/wp-content/uploads/2011/11/GadgetSettings.png" alt="" width="334" height="401" /></a></p>
<p><strong>Feed #</strong>: Numeric Pachube Feed ID</p>
<p><strong>Datastreams</strong>: To graph all datastreams in the feed, leave this field blank. Otherwise, enter the datastream ID and click the Add button. For example, to add the 2 datastreams below&#8230;</p>
<p><a href="http://www.gigamegablog.com/wp-content/uploads/2011/11/Datastreams.png"><img class="aligncenter size-full wp-image-1037" title="Datastreams" src="http://www.gigamegablog.com/wp-content/uploads/2011/11/Datastreams.png" alt="" width="638" height="197" /></a></p>
<p>&#8230;type Cactus, click Add, type CatGrass, click Add. The field should then look like this:</p>
<p><a href="http://www.gigamegablog.com/wp-content/uploads/2011/11/DatastreamsInputBox.png"><img class="aligncenter size-full wp-image-1038" title="DatastreamsInputBox" src="http://www.gigamegablog.com/wp-content/uploads/2011/11/DatastreamsInputBox.png" alt="" width="309" height="91" /></a></p>
<p><strong>Time Span, Time Span Units</strong> – This determines what period of time will be graphed. As shown in the screenshot, the default is 24 hours. Time Span Units can be set to hours, days, weeks or months.</p>
<p><strong>Show Status</strong>. If true, each graph will be preceded by a line of text giving the Datastream ID, the last reading and the date and time it was received, as shown in this screenshot.</p>
<p><a href="http://www.gigamegablog.com/wp-content/uploads/2011/11/GraphsDetailed.png"><img class="aligncenter size-full wp-image-1040" title="GraphsDetailed" src="http://www.gigamegablog.com/wp-content/uploads/2011/11/GraphsDetailed.png" alt="" width="290" height="217" /></a></p>
<p><strong>Detailed Grid</strong>. If true, vertical and horizontal grid lines will be displayed, as in the 2 graphs above. If false, only a vertical grid separating each time span unit is displayed, as in the following (GigaMegaSized) graph.</p>
<p><a href="http://www.gigamegablog.com/wp-content/uploads/2011/11/GraphWithoutStatus.png"><img class="aligncenter size-full wp-image-1041" title="GraphWithoutStatus" src="http://www.gigamegablog.com/wp-content/uploads/2011/11/GraphWithoutStatus.png" alt="" width="573" height="296" /></a></p>
<p><strong>Axis Labels</strong>: If true, numeric labels are added to the vertical and horizontal axis indicating the range of values. Note that, depending on the time span, these labels tend to overlap in a smaller graph (and I don&#8217;t have any control over the format of the labels). If false, the only labels are the minimum and maximum value of the vertical axis.</p>
<p><strong>Graph Width and Graph Height:</strong> Determines the size of each graph, in pixels. When the gadget is maximized, both sizes are automatically doubled. These values are required, and are initially set to a width of 280 and a height of 100.</p>
<p><strong>Gadget Height:</strong> Determines the height of the overall gadget, in pixels. If not specified, a default of 200 is used. (The gadget width can&#8217;t be set by the code, and varies depending on the browser type and the resolution of the monitor.)</p>
<p><strong>Time zone:</strong> Your local time zone. The default is UTC (aka Greenwich Mean Time). This setting affects the timestamp in the Status field, as well as the labels on the horizontal axis of the grid. The rather eclectic collection of names in the dropdown lists was Pachube’s idea, not mine. (Look <a href="http://api.pachube.com/#time-zones">here</a> if you don’t believe me!)</p>
<h1>Wrapping Up</h1>
<p>I&#8217;d welcome any bug reports or feature requests.</p>
<p>iGoogle’s Gadget framework does a lot of caching sleight-of-hand, so if you find that a change of settings doesn’t appear in the gadget, try refreshing the page. As for features , there are some things I can’t add because they aren’t supported by Pachube’s API yet (multiple datastreams in a graph, for example), but otherwise I’m open to suggestions.</p>
<p>For developers, I plan to write an article in the near future explaining the gadget&#8217;s use of the Pachube API.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gigamegablog.com/2011/11/05/a-pachube-google-gadget-size-matters/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>BeagleBoard XM and Ubuntu 11.04 – The Big Dog Still Has a Burr in its Paw</title>
		<link>http://www.gigamegablog.com/2011/08/20/beagleboard-xm-and-ubuntu-11-04-%e2%80%93-the-big-dog-still-has-a-burr-in-its-paw/</link>
		<comments>http://www.gigamegablog.com/2011/08/20/beagleboard-xm-and-ubuntu-11-04-%e2%80%93-the-big-dog-still-has-a-burr-in-its-paw/#comments</comments>
		<pubDate>Sat, 20 Aug 2011 15:07:21 +0000</pubDate>
		<dc:creator>dwatts</dc:creator>
				<category><![CDATA[Gadgets]]></category>
		<category><![CDATA[Beagleboard]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://gigamegatech.com/?p=958</guid>
		<description><![CDATA[As I wrote back in December, I switched from running Ubuntu 10.10 to Angstrom on my Beagleboard XM because I was unhappy with Ubuntu&#8217;s speed.  Some of Ubuntu&#8217;s code isn&#8217;t ready for the XM&#8217;s 1 gigahertz processor, so the processor &#8230; <a href="http://www.gigamegablog.com/2011/08/20/beagleboard-xm-and-ubuntu-11-04-%e2%80%93-the-big-dog-still-has-a-burr-in-its-paw/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>As I wrote <a href="http://gigamegablog.com/2010/12/09/beagleboard-xm-and-angstrom-getting-the-big-dog-to-run-at-full-speed/">back in December</a>, I switched from running <a href="http://www.ubuntu.com/">Ubuntu </a>10.10 to <a href="http://www.angstrom-distribution.org/">Angstrom</a> on my <a href="http://beagleboard.org/hardware-xM">Beagleboard XM</a> because I was unhappy with Ubuntu&#8217;s speed.  Some of Ubuntu&#8217;s code isn&#8217;t ready for the XM&#8217;s 1 gigahertz processor, so the processor is automatically throttled back to 800 Mhz during Ubuntu&#8217;s bootup.  To make matters worse, Ubuntu&#8217;s code is compiled with cross-platform compatibility in mind, and therefore lacks some optimizations that would take advantage of the XM&#8217;s more advanced OMAP processor.</p>
<p style="text-align: center;"><a href="http://www.beagleboard.org"><img class="aligncenter size-full wp-image-467" src="http://www.gigamegablog.comhttp://www.gigamegablog.com/wp-content/uploads/2010/12/beagle-hd-logo.gif" alt="" width="301" height="53" /></a></p>
<p>I&#8217;ve been pretty happy with Angstrom – it has proven to be fast, stable and low maintenance.  When Ubuntu&#8217;s Natty Narwal release arrived in April, I didn’t jump at the chance to try it.  However, when I finally got around to checking it out, something in the <a href="https://wiki.ubuntu.com/ARM/NattyReleaseNotes">release notes</a> caught my eye:</p>
<p><em>OMAP3 CPUs don&#8217;t run at full speed by default. While we set the required mpurate cmdline parameter on our images, the values for the different OMAP3 CPUs are not always correct, to work around this you can edit the cmdline in /boot/boot.script and call &#8220;sudo flash-kernel&#8221;, the change will take effect on next reboot. This should only affect BeagleXM users</em></p>
<p>Ah, now you tell me!  It was all a misunderstanding – just a typo in the boot parameters.  Ubuntu baby, here I come. Nice knowing ya, Angstrom.</p>
<p>Alas, it was not to be.  Ubuntu 11.04 is no faster on the XM than Ubuntu 10.10 was.  The release notes actually refer to the fact that, by default, the processor is now throttled back to 600 Mhz (!), but you can change the boot parameters to lift it back to 800 Mhz.</p>
<p>However, Ubuntu does have some nice new features that Angstrom lacks, and I came across a couple of not-so-nice &#8220;features&#8221; that might trip up others who try out Ubuntu on the Beagleboard XM.  So, here&#8217;s the full story of getting Ubuntu 11.04 up and <del>running</del> loping.</p>
<h2>Preparing the Boot Image</h2>
<p>One of the new features in Ubuntu 11.04 is that the <a href="https://wiki.ubuntu.com/ARM/OMAP">official images from Canonical Inc</a>. include a version intended for &#8220;headless&#8221; configurations: where you intend to use the Beagleboard as a server with no monitor or keyboard.</p>
<p>Unlike other Linux images for the Beagleboard, Canonical&#8217;s images automatically run an installation program the first time you boot.  In Ubuntu 10.10 and earlier this install program required a physically connected monitor: now there is a text version that can be run in a serial terminal program like <a href="http://www.winputty.com/">WinPutty</a>.</p>
<p>An alternative (and the method I used when installing earlier Ubuntu releases) is <a href="http://elinux.org/BeagleBoardUbuntu#Demo_Image">Robert Nelson&#8217;s preconfigured &#8220;demo&#8221; Ubuntu image</a>.</p>
<p>A short digression… If I was going to install Ubuntu 11.04 again, I would actually go with Robert Nelson&#8217;s version over Canonical&#8217;s.  He updates the image quite often (and it now sports the shiny new version 3.0 Linux kernel – still no 1 Ghz support <img src='http://www.gigamegablog.com/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' />   ).  Canonical&#8217;s image is now a few months out of date, and the first time you update the packages to their latest version you&#8217;ll get 100s of megabytes of data that take hours (no exaggeration) to install.</p>
<p>If you decide to use Robert Nelson&#8217;s image, then you can skip ahead to the &#8220;Getting on the Network&#8221; section.</p>
<p><a href="https://wiki.ubuntu.com/ARM/OMAPHeadlessInstall">Canonical&#8217;s instructions</a> for downloading their image and copying it to the microSD card are a little confusing, since you get directed to a download page that includes builds for all the processors they support.</p>
<p>The correct file for the Beagleboard (both XM and earlier) is this one: <a href="http://cdimage.ubuntu.com/releases/11.04/release/ubuntu-11.04-preinstalled-headless-armel+omap.img.gz">http://cdimage.ubuntu.com/releases/11.04/release/ubuntu-11.04-preinstalled-headless-armel+omap.img.gz</a>.  It&#8217;s a 204M file.</p>
<p>You&#8217;ll also need to download the updated kernel for the XM from  <a href="http://people.canonical.com/~tobin/natty/beagleXM-natty.tgz">http://people.canonical.com/~tobin/natty/beagleXM-natty.tgz</a></p>
<p>Windows users will probably need to find a way to use Linux in order to configure the microSD card. <a href="https://wiki.ubuntu.com/ARM/OmapNetbook"> Canonical&#8217;s  install instructions</a> for their oddly-named &#8221;Netbook&#8221; image – the one you would use if you have a monitor, mouse and keyboard connected to your Beagleboard – mentions that a Windows package like <a href="https://launchpad.net/win32-image-writer">Image Writer</a>  can be used to write the .img file to the microSD card.  True enough,  but then you&#8217;ll have to figure out how to mount the ext3 partition on the card to transfer over the kernel patch.  Personally, I used <a href="http://www.vmware.com/products/player/">VMPlayer</a> running the PC version of Ubuntu.</p>
<p>As usual, you&#8217;ll need to know what the device name of your card is before you start.  Generally, the best method is to run &#8220;dmesg&#8221; immediately after connecting the microSD card to the PC – the messages at the end of the output will identify the device name.  In my case, it was /dev/sde.</p>
<p>To copy the Ubuntu download to the microSD card:</p>
<pre>dwatts@ubuntu:~$ sudo umount /dev/sde?
dwatts@ubuntu:~$ gunzip -c ubuntu-11.04-preinstalled-headless-armel+omap.img.gz
 | sudo dd bs=4M of=/dev/sde
0+48794 records in
0+48794 records out
1675173888 bytes (1.7 GB) copied, 310.701 s, 5.4 MB/s
dwatts@ubuntu:/mnt/hgfs/download/Beagleboard$ sync</pre>
<p>You&#8217;ll also need to install the updated kernel for the XM, as described at the bottom of the <a href="https://wiki.ubuntu.com/ARM/OMAPHeadlessInstall">install instructions</a>.</p>
<p>The quickest way to mount the 2 partitions on the microSD card is to remove the card are reconnect it, Ubuntu &#8211; and most other OSes &#8212; will automatically mount them.  Otherwise:</p>
<pre>dwatts@ubuntu: sudo mkdir /media/boot
dwatts@ubuntu: sudo mkdir /media/ubuntu
dwatts@ubuntu: sudo mount –t vfat /dev/sde1 /media/boot
dwatts@ubuntu: sudo mount /dev/sde2 /media/ubuntu</pre>
<p>Then extract and copy over the 2 files.  Note that the 2<sup>nd</sup> file should be copied as root</p>
<pre>dwatts@ubuntu: tar -zxf beagleXM-natty.tgz
dwatts@ubuntu: cp uImage /media/boot
dwatts@ubuntu: sudo cp vmlinuz-2.6.38-8-omap /media/ubuntu/boot
dwatts@ubuntu: sync
dwatts@ubuntu: sudo umount /dev/sde?</pre>
<h2>Booting Ubuntu</h2>
<p>As mentioned earlier, the first boot will automatically launch an install program.  You can&#8217;t bypass it, and you can&#8217;t connect to the Beagleboard over a network until the installer completes.  So, if you don&#8217;t have a monitor physically connected to the Beagleboard, you&#8217;ll need to connect a PC to its serial port.</p>
<p>A USB-serial adapter should work well.  Mine is a generic brand that, when inserted into Windows, loads the common <a href="http://www.prolific.com.tw/eng/downloads.asp?id=31">&#8220;Prolific&#8221; driver</a>.</p>
<p>I used <a href="http://www.winputty.com/">WinPutty</a> as the serial terminal.</p>
<p>The serial settings are 115200 bps, N-8-1 with no Flow Control.  In order for the pseudo-graphics in the Canonical installer to appear correctly, you&#8217;ll need to change the character set from the default of Latin-1 to UTF8, as shown below:</p>
<p style="text-align: center;"><a href="http://www.gigamegablog.com/wp-content/uploads/2011/08/2011-08-17-20-41-39.jpg"><img class="aligncenter size-full wp-image-975" title="WinPutty character set for Ubuntu installer" src="http://www.gigamegablog.com/wp-content/uploads/2011/08/2011-08-17-20-41-39.jpg" alt="" width="451" height="439" /></a></p>
<p>In its full glory, the install program looks like this.  The lovely magenta background is, as far as I know, a design choice, not a bug:</p>
<p style="text-align: center;"><a href="http://www.gigamegablog.com/wp-content/uploads/2011/08/20-08-2011-11-17-28-AM.jpg"><img class="aligncenter size-full wp-image-980" title="Ubuntu's character-based installer. Purdy, ain't it?" src="http://www.gigamegablog.com/wp-content/uploads/2011/08/20-08-2011-11-17-28-AM.jpg" alt="" width="831" height="469" /></a></p>
<p>The installer lets you enter the a machine name, as well as your user-ID and password.  Beyond that, I selected the default on most menus.</p>
<p>In the screen that allows you to select software, shown above, I selected Basic Ubuntu Server, OpenSSH Server and Samba File Server.  Don&#8217;t go crazy with your software selections.  At this point your XM&#8217;s processor has been throttled down to an extra slow 600Mhz, so you don&#8217;t want to give the installer any more work than necessary.</p>
<h2>Fixing the Processor Speed</h2>
<p>After the install program runs and the Beagleboard XM is rebooted, the first thing you&#8217;ll want to do is fix the processor speed.  If you look at the processor info, you&#8217;ll see</p>
<pre>dwatts@bigdog:~$ cat /proc/cpuinfo
Processor        : ARMv7 Processor rev 2 (v7l)
BogoMIPS       : 471.61
Features          : swp half thumb fastmult vfp edsp neon vfpv3
CPU implementer      : 0x41
CPU architecture: 7
CPU variant    : 0x3
CPU part         : 0xc08
CPU revision   : 2
Hardware       : OMAP3 Beagle Board
Revision          : 0020
Serial              : 0000000000000000</pre>
<p>The BogoMIPS rating, a crude performance benchmark, is actually slightly lower than I get with an original (non-XM) Beagleboard.</p>
<p>To fix this you&#8217;ll need to change the mpurate setting from 1000 to 800 in /boot/boot.script, as marked in bold below.</p>
<pre>fatload mmc 0:1 0x80000000 uImage
fatload mmc 0:1 0x81600000 uInitrd
setenv bootargs ro elevator=noop vram=12M omapfb.mode=dvi:1280x720MR-16@60 _
  mpurate=<strong>800</strong> root=UUID=25210e81-e728-4a73-96ff-06df5c29216f fixrtc _
  quiet splash console=ttyO2,115200n8
bootm 0x80000000 0x81600000</pre>
<p>The not-terribly-user-friendly vi editor is good enough for this.  Just :</p>
<ul>
<li>launch vi (sudo vi /boot/boot.script)</li>
<li>cursor down to the beginning of the &#8220;1000&#8243; after &#8220;mpurate=&#8221;</li>
<li>press x twice to erase the 1 and the 0</li>
<li>press I once to enter insert mode</li>
<li>type 8</li>
<li>press Esc</li>
<li>Enter w</li>
<li>Enter q</li>
</ul>
<p>Crude, but effective.  If you mess up, you can exit vi at any time without saving by pressing Esc and entering q!.</p>
<p>After updating the file, enter</p>
<pre>dwatts@bigdog:~$ sudo flash-kernel
dwatts@bigdog:~$ sudo shutdown –r now</pre>
<p>After rebooting, the BogoMIPs score should be about 630, which is the same as with Ubuntu 10.10.</p>
<p>Unfortunately, based on this <a href="http://groups.google.com/group/beagleboard/browse_thread/thread/14796c8db9f69c77#">post by Robert Nelson in Beagleboard Google Groups</a>, it isn&#8217;t clear when (or if) Ubuntu is going to be able to run at 1 Ghz.</p>
<h2>Getting on the Network</h2>
<p>The default network configuration needs to handle the Beagleboard XM&#8217;s non-standard Ethernet device name of usb0.  The /etc/network/interfaces file should contain the 2 lines marked in bold below:</p>
<pre>dwatts@bigdog:~ cat :/etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
<strong>auto usb0</strong>
<strong>iface usb0 inet dhcp </strong></pre>
<p><strong> </strong>If they aren&#8217;t there, you&#8217;ll need to add them.  If you were traumatized by using the vi editor earlier, another approach to editing the file is :</p>
<pre>dwatts@bigdog:~ sudo –i
root@bigdog:~# echo auto usb0 &gt;&gt; /etc/network interfaces
root@bigdog:~# echo iface usb0 inet dhcp &gt;&gt;/etc/network interfaces</pre>
<p>Then activate the Ethernet port:</p>
<pre>root@bigdog:~# ifup usb0</pre>
<p>The Beagleboard XM&#8217;s Ethernet adapter uses a dynamic MAC address, so if you are using DHCP to assign the IP address (as the above configuration will do), the IP address will change each time it&#8217;s rebooted.  This can be rather frustrating if your Beagleboard is going to be used as a server.  You can change this by using the same settings as explained in <a href="http://gigamegablog.com/2010/12/26/beagleboard-xm-angstrom-next-steps-assigning-a-static-ip/">my blog post about Angstrom</a>– the interface file in Ubuntu has the same format as in Angstrom.  (A more advanced solution to the problem, which I haven&#8217;t tried, is to patch the kernel so that the same MAC address is used each time: <a href="http://www.electronsonradio.com/2011/07/angstrom-on-the-beagleboard-fixing-your-mac-address/">see this post on the Electrons on Radio blog</a>).</p>
<h2>Updating Ubuntu</h2>
<p>Now you get an opportunity to fully and completely appreciate how slowly the Ubuntu package updater runs on the Beagleboard XM.  You&#8217;ll need to download and install a few month&#8217;s (or more) worth of Ubuntu updates.</p>
<pre>root@bigdog:~# aptitude update
root@bigdog:~#: aptidude upgrade</pre>
<p>Unless you&#8217;re practicing to be a Buddhist monk, you&#8217;ll probably not want to sit and watch aptitude crawl along for the next couple of hours.</p>
<p>Speed issues aside, Ubuntu&#8217;s package installer software works the same on the Beagleboard as it does on a full PC.  Here are some of the more useful options (though you might end up using Webmin rather than the command line for this &#8212; see the Webmin section below):</p>
<p>To list the packages that are currently installed:</p>
<pre>root@bigdog:~#: dpkg --get-selections</pre>
<p>To find a package based on text in its name or description:</p>
<pre>root@bigdog:~#:  aptitude search &lt;text&gt;</pre>
<p>To get more info on a specific package</p>
<pre>root@bigdog:~#:  aptitude show &lt;packagename&gt;</pre>
<h2>Updating the Date and Time</h2>
<p>If you enter the  &#8221;date&#8221; command you&#8217;ll likely find that the date is correct, but the time is off by a few hours or more.  Ubuntu has already installed the NTP software needed to automatically set the time, but it needs to know where you live:</p>
<p>To display the current timezone:</p>
<pre>root@bigdog:~#:  cat /etc/timezone
America/North_Dakota/Center</pre>
<p>To change the timezone</p>
<pre>root@bigdog:~#: dpkg-reconfigure tzdata</pre>
<p>You&#8217;ll then see a pop-up dialog to guide you through the process.</p>
<p style="text-align: center;"><a href="http://www.gigamegablog.com/wp-content/uploads/2011/08/2011-08-17-19-04-37.jpg"><img class="aligncenter size-full wp-image-971" title="Timezone configuration dialog" src="http://www.gigamegablog.com/wp-content/uploads/2011/08/2011-08-17-19-04-37.jpg" alt="" width="636" height="300" /></a></p>
<h2>WebMin</h2>
<p>After going through the indignity of manually hobbling your processor, then watching it take a couple of hours to slog through the software updates,  you might be wondering why any sane person would choose Ubuntu over Angstrom.  Here&#8217;s why: <a href="http://webmin.com/">Webmin</a>!</p>
<p>WebMin is the tops.  It&#8217;s the thing.  All the girls get up when it sings (yeah).</p>
<p>And Angstrom doesn’t have it.</p>
<p>Installing WebMin isn&#8217;t as easy as &#8220;aptitude install webmin&#8221;, but trust me: it&#8217;s worth it.  Full instructions are here: <a href="http://www.webmin.com/deb.html">http://www.webmin.com/deb.html</a>, but you should need just 2 or 3 commands:</p>
<pre>root@bigdog:~#: wget <a href="http://www.webmin.com/download/deb/webmin-current.deb">http://www.webmin.com/download/deb/webmin-current.deb</a>
root@bigdog:~#: dpkg –install webmin-current.deb</pre>
<p>Unless you&#8217;ve installed a bunch of Perl-specific packages, you&#8217;ll get a bunch of errors due to missing dependencies.  It looks messy, but it&#8217;s actually quite simple to fix:</p>
<pre>root@bigdog:~#: aptitude install perl libnet-ssleay-perl openssl _
  libauthen-pam-perl libpam-runtime libio-pty-perl apt-show-versions python</pre>
<p>Don&#8217;t worry if not all of those packages are missing.  Ubuntu&#8217;s updater might be slow, but it&#8217;s no dummy.  Not only will it sort out what&#8217;s needed, but it will automatically install webmin for you once all of the missing packages are there.</p>
<p>Once it&#8217;s installed, you can load Webmin in a brower from any PC at:</p>
<p><a href="https://%3Cipaddress%3E:10000/">https://&lt;ipaddress&gt;:10000</a></p>
<p>Note that Webmin will want to use secure protocol (https) by default, and your browser will mutter about missing security certificates as a result.  You can turn off the requirement for a secure connection within Webmin later.</p>
<p>Ordinarily, you should be able to login to Webmin using your own user-ID.  I couldn&#8217;t – no idea why, but something went wrong.  I had to login as root.</p>
<p>Wait, what? Login as root?  Impossible, you say!  Ubuntu won&#8217;t allow it.</p>
<p>Bah, Ubuntu and what army?  You just have to set a root password manually first:</p>
<pre>root@bigdog:~# passwd root
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully</pre>
<p>If you want to prevent Webmin from requiring an https connection, click the Webmin link in the upper left of the main Webmin menu, then Webmin Configuration, then SSL Encryption.  &#8220;Change the Enable SSL if available&#8221; setting to No:</p>
<p><a href="http://www.gigamegablog.com/wp-content/uploads/2011/08/2011-08-17-17-18-52.jpg"><img class="aligncenter size-large wp-image-961" title="Turning off https for Webmin" src="http://www.gigamegablog.com/wp-content/uploads/2011/08/2011-08-17-17-18-52-1024x510.jpg" alt="" width="640" height="318" /></a></p>
<p>Among the many Linux system administration tasks that Webmin makes a lot easier are:</p>
<p>1. Updating Ubuntu packages.  (Easier, but sadly not faster.)</p>
<p style="text-align: center;"><a href="http://www.gigamegablog.com/wp-content/uploads/2011/08/2011-08-17-17-22-53.jpg"><img class="aligncenter size-large wp-image-962" title="Webmin Package Updater" src="http://www.gigamegablog.com/wp-content/uploads/2011/08/2011-08-17-17-22-53-1024x459.jpg" alt="" width="640" height="286" /></a></p>
<p>2. Viewing System Logs</p>
<p><a href="http://www.gigamegablog.com/wp-content/uploads/2011/08/2011-08-17-17-25-41.jpg"><img class="aligncenter size-large wp-image-963" title="Webmin System Log Viewer" src="http://www.gigamegablog.com/wp-content/uploads/2011/08/2011-08-17-17-25-41-1024x457.jpg" alt="" width="640" height="285" /></a></p>
<p>3. Reading documentation and help files for packages.  Note that Webmin goes beyond man pages and puts together a list of all the documentation installed with the package.</p>
<p><a href="http://www.gigamegablog.com/wp-content/uploads/2011/08/2011-08-17-17-29-08.jpg"><img class="aligncenter size-large wp-image-964" title="Webmin Documentation Viewer" src="http://www.gigamegablog.com/wp-content/uploads/2011/08/2011-08-17-17-29-08-1024x546.jpg" alt="" width="640" height="341" /></a></p>
<p>4. Mounting drives, include shared folders on Windows PCs (after you&#8217;ve installed Samba and configured, as described below).  It will also handle updating fstab so that the drive is automatically mounted when the system is booted.</p>
<p><a href="http://www.gigamegablog.com/wp-content/uploads/2011/08/2011-08-17-17-31-48.jpg"><img class="aligncenter size-large wp-image-965" title="Mounting a drive with Webmin" src="http://www.gigamegablog.com/wp-content/uploads/2011/08/2011-08-17-17-31-48-1024x449.jpg" alt="" width="640" height="280" /></a></p>
<p>5. File management. Tucked away under the &#8220;Others&#8221; section of the left-hand menu is a Java-based File Manager.</p>
<p><a href="http://www.gigamegablog.com/wp-content/uploads/2011/08/2011-08-17-19-17-10.jpg"><img class="aligncenter size-large wp-image-972" title="Webmin File Explorer" src="http://www.gigamegablog.com/wp-content/uploads/2011/08/2011-08-17-19-17-10-1024x386.jpg" alt="" width="640" height="241" /></a></p>
<p>6. Software configuration.  The Servers menu in the lefthand pane contains custom modules for configuration some common software packages, such as SSH and Samba.</p>
<h2>SSH</h2>
<p>If you selected OpenSSH from the Ubuntu installer&#8217;s software menu, then the SSH is already up and running.  Otherwise, you can install it with:</p>
<pre>root@bigdog~#: aptitude install openssh-server</pre>
<p>Alternatively, you can use Webmin to locate and install a package, using the &#8220;Software Packages&#8221; menu:</p>
<p><a href="http://www.gigamegablog.com/wp-content/uploads/2011/08/20-08-2011-11-57-29-AM.jpg"><img class="aligncenter size-full wp-image-984" title="Using Webmin to install SSH" src="http://www.gigamegablog.com/wp-content/uploads/2011/08/20-08-2011-11-57-29-AM.jpg" alt="" width="878" height="405" /></a></p>
<p>The default settings will allow you to login using your Ubuntu user-ID and password.  The SSH server also supports file transfer using an SCP package like <a href="http://winscp.net/eng/index.php">WinSCP</a>.</p>
<p>If you intend to access your Beagleboard through the Internet, then you&#8217;ll probably want to replace password authentication with public key authentication.  To enable this:</p>
<p>1. Upload your public key to a file named ~/.ssh/authenticated_keys – you&#8217;ll probably have to create the ~/.ssh folder first.  You can use WinSCP to copy the file over, or WebMin&#8217;s file manager, which includes Edit and Upload functions.</p>
<p>2. Test that you can now login using your public key, rather than entering a password.  In WinPutty, you specify the location of your private key here:</p>
<p><a href="http://www.gigamegablog.com/wp-content/uploads/2011/08/2011-08-17-19-23-07.jpg"><img class="aligncenter size-full wp-image-973" title="WinPutty private key configuration" src="http://www.gigamegablog.com/wp-content/uploads/2011/08/2011-08-17-19-23-07.jpg" alt="" width="450" height="440" /></a></p>
<p>3. In Webmin, select Servers in the lefthand pane, then select SSH Server. Set “Allow authentication by password” to No.  While you are there, set “Allow login by root” to No as a security precaution.  Return to the main SSH Server menu and click the Apply Changes button, which will restart the SSH server.</p>
<p style="text-align: center;"><a href="http://www.gigamegablog.com/wp-content/uploads/2011/08/2011-08-17-17-51-04.jpg"><img class="aligncenter size-full wp-image-966" title="Using Webmin to configure SSH" src="http://www.gigamegablog.com/wp-content/uploads/2011/08/2011-08-17-17-51-04.jpg" alt="" width="1015" height="548" /></a></p>
<p>Incidentally, the SSH server&#8217;s default configuration will allow client-to-server port forwarding.  This allows you to access the web server and WebMin from a remote PC after connecting through SSH.  For example, the following settings in WinPutty allow you to connect with SSH and then securely access Webmin through a browser as <a href="http://localhost:10000/">http://localhost:10000</a>.</p>
<p><a href="http://www.gigamegablog.com/wp-content/uploads/2011/08/2011-08-17-19-54-02.jpg"><img class="aligncenter size-full wp-image-974" title="WinPutty settings for port forwarding" src="http://www.gigamegablog.com/wp-content/uploads/2011/08/2011-08-17-19-54-02.jpg" alt="" width="449" height="442" /></a></p>
<h2>Samba</h2>
<p>If you didn&#8217;t select &#8220;Samba File Server&#8221; from the Ubuntu installer&#8217;s  software menu, then you can install it using Webmin or by running</p>
<pre>root@bigdog:~# aptitude install samba</pre>
<p>Users are automatically added as Samba users, but their passwords aren’t.</p>
<p>You can configure Samba through Webmin  by selecting Samba Windows File Sharing under the Servers menu.  You need to click on “Edit Samba Users and Passwords”, then select “New password” and type in your password.  This is the password that Windows PCs will need to supply in order to access your Samba shares.</p>
<p><a href="http://www.gigamegablog.com/wp-content/uploads/2011/08/2011-08-17-18-04-04.jpg"><img class="aligncenter size-full wp-image-970" title="Setting Samba user password in Webmin" src="http://www.gigamegablog.com/wp-content/uploads/2011/08/2011-08-17-18-04-04.jpg" alt="" width="777" height="382" /></a></p>
<p>To share a folder, click on “Create a new file share”.  Fill in the “Share name” and “Directory to share”.  If the directory already exists, set “Automatically create directory” to No.</p>
<p>By default, shares are read only.  To change that, click on the share name at the top of the window, then click on Security And Access Control.  Change “Writeable” to yes.</p>
<p><a href="http://www.gigamegablog.com/wp-content/uploads/2011/08/20-08-2011-12-10-40-PM.jpg"><img class="aligncenter size-large wp-image-986" title="Making a Samba shared directory writeable using Webmn" src="http://www.gigamegablog.com/wp-content/uploads/2011/08/20-08-2011-12-10-40-PM-1024x478.jpg" alt="" width="640" height="298" /></a></p>
<p>At the bottom of the window is a button to restart Samba and apply changes right away, but generally changes are automatically loaded by Samba without restarting.</p>
<h1>Wrapping Up</h1>
<p>Aside from Webmin, Ubuntu offers a few other advantages over Angstrom that you might want to consider:</p>
<ul>
<li>Its VNC server is much easier to configure than Angstrom&#8217;s.</li>
<li>If you are running VNC, or physically connected with a monitor, keyboard and mouse, Ubuntu offers some shiny new window managers that aren&#8217;t available on Angstrom, such as<a href="http://www.gnome.org/"> GNOME 3</a>  and Ubuntu&#8217;s own Unity2D desktop.</li>
<li>The <a href="http://www.google.com/chrome/">Google Chrome browser</a> (with support for extensions) and <a href="http://www.arduino.cc/">Arduino IDE </a>(running on Java) are among the applications that Ubuntu offers, and which aren&#8217;t available as packages for Angstrom.</li>
</ul>
<p>However, if you try running software like GNOME 3 and Chrome, you&#8217;ll find that they just serve to emphasize Ubuntu&#8217;s biggest weakness: they are just too slow to be usable for most tasks.</p>
<p>Ubuntu is, in my opinion, a solid choice for the Beagleboard XM when used as a server.  Background processes like Samba, the CUPS print server, and lighttpd web server run well &#8211; I haven&#8217;t noticed any response time annoyances there.  When combined with Webmin (which is also quite fast), it&#8217;s a relatively user friendly way to learn the basics of Linux system administration.</p>
<p>But, when you have the need for speed, <a href="http://www.angstrom-distribution.org/">Angstrom</a> is still way ahead of the pack.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gigamegablog.com/2011/08/20/beagleboard-xm-and-ubuntu-11-04-%e2%80%93-the-big-dog-still-has-a-burr-in-its-paw/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Nimbits Gadget: Minding the Data Store</title>
		<link>http://www.gigamegablog.com/2011/05/21/a-nimbits-gadget-minding-the-data-store/</link>
		<comments>http://www.gigamegablog.com/2011/05/21/a-nimbits-gadget-minding-the-data-store/#comments</comments>
		<pubDate>Sat, 21 May 2011 21:43:39 +0000</pubDate>
		<dc:creator>dwatts</dc:creator>
				<category><![CDATA[Gadgets]]></category>
		<category><![CDATA[Electronics]]></category>
		<category><![CDATA[nimbits]]></category>
		<category><![CDATA[Tweet-A-Watt]]></category>

		<guid isPermaLink="false">http://gigamegatech.com/?p=850</guid>
		<description><![CDATA[Updated June 4: I&#8217;ve corrected a couple of things, as marked in blue. Also, developers might be interested in my follow-up blog entry A Nimbits Gadget: Programmer&#8217;s Show And Tell Updated Dec 3/11: I fixed a broken feature: autoscaling of &#8230; <a href="http://www.gigamegablog.com/2011/05/21/a-nimbits-gadget-minding-the-data-store/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><span style="color: #3366ff;"><em>Updated June 4: I&#8217;ve corrected a couple of things, as marked in blue. Also, developers might be interested in my follow-up blog entry <a href="http://www.gigamegablog.com/?p=871/">A Nimbits Gadget: Programmer&#8217;s Show And Tell</a></em></span></p>
<p><em>Updated Dec 3/11: I fixed a broken feature: autoscaling of the Y axis was no longer working, resulting in values above 100 being cut-off.  </em></p>
<p><em>Updated Dec 14/11: I&#8217;ve added a couple of new settings: Graph Width and Gadget Height.  For details, see the &#8220;Settings&#8221; section below.</em></p>
<p>As mentioned in <a href="http://gigamegablog.com/2011/03/10/tweet-a-watt-beyond-the-twitter/" target="_blank">my post</a> about the data-logging service <a href="http://www.pachube.com" target="_blank">Pachube</a>, I found the best way to monitor my datastreams was with the <a href="http://www.google.com/ig/directory?url=apps.pachube.com/google_gadget/gadget.xml" target="_blank">Pachube Google Gadget</a>.  Stick it on your<a href="http://www.google.com/ig" target="_blank"> iGoogle </a>page, and it allows you to quickly and conveniently keep an eye on your data without having to go out of your way to find it.</p>
<p>When <a href="http://gigamegablog.com/2011/03/28/tweet-a-watt-beyond-the-twitter-part-deux/" target="_blank">I started logging data </a>to the open source <a href="http://www.nimbits.com/" target="_blank">Nimbits</a> system, the first thing I went looking for was some equally convenient way to keep tabs on my Nimbits data. While Nimbits offers a lot of built-in methods for monitoring your data, such as e-mail, Google Talk, and Twitter, I decided that nothing worked as well for me as that Gadget. So, I decided to write a <a href="http://www.google.com/ig/directory?type=gadgets&amp;url=www.gigamegablog.com/gadgets/nimbits.xml">Nimbits Gadget</a>.</p>
<p>The Gadget displays up to 3 line graphs, with each line graph containing as many Data Points (i.e. datastreams) as you like. You can optionally include a Status line showing the last data point received.</p>
<p>You can grab the gadget from <a href="http://www.google.com/ig/directory?type=gadgets&amp;url=www.gigamegablog.com/gadgets/nimbits.xml">its Google Directory page</a>.</p>
<p style="text-align: left;"><a href="http://www.gigamegablog.com/wp-content/uploads/2011/05/Nimbits-Gadget.png"><img class="aligncenter size-full wp-image-854" src="http://www.gigamegablog.com/wp-content/uploads/2011/05/Nimbits-Gadget.png" alt="" width="362" height="250" /></a><br />
In this post I’ll describe the settings for the Gadget, and in the next post I’ll write a bit about the Gadget code and the underlying Nimbits API.</p>
<h2>What You’ll Need</h2>
<p>If you’ve never used Nimbits before, you’ll need to start posting data to it before the Gadget will do you any good. The Gadget is display-only – it won’t help you get data into the system. The process of creating and configuring a Nimbits account and adding Data Points to it was described in <a href="http://gigamegablog.com/2011/03/28/tweet-a-watt-beyond-the-twitter-part-deux/" target="_blank">an earlier post</a>.</p>
<p><strong>One major caveat</strong>: the Data Points that the Gadget displays must be <strong>Public</strong>. Admittedly, this is just to keep the coding relatively simple. Private data points require authentication, something which can be tricky from a Javascript application like a Gadget, though I expect (hope?) that this will be streamlined somewhat by the shared Googly underpinnings of Nimbits and the gadget. If it works, I’ll add authentication in a future update of the code.</p>
<h2>Settings</h2>
<p>The settings dialog, shown below, is longer than the average gadget’s. Not to brag, or anything.</p>
<p><a href="http://www.gigamegablog.com/wp-content/uploads/2011/05/14-12-2011-6-48-02-PM.jpg"><img class="aligncenter size-full wp-image-1070" title="" src="http://www.gigamegablog.com/wp-content/uploads/2011/05/14-12-2011-6-48-02-PM.jpg" alt="" width="327" height="516" /></a></p>
<p>&nbsp;</p>
<p style="text-align: center;">
<p>Most of the options are there so that you can tinker with the gadget appearance and features to see what suits you best. The defaults should work fine, but there are a few settings which you’ll need to supply. Let’s start with those.</p>
<h3>Required Settings</h3>
<h4>Server</h4>
<p>If you are using the public Nimbits server, then leave this at the default, app.nimbits.com. If you’ve installed your own copy of the Nimbits code on the Google App Engine, then fill in the name of that GAE instance (usually your-app-name.appspot.com)</p>
<h4>Data Points</h4>
<p><a href="http://www.gigamegablog.com/wp-content/uploads/2011/05/Nimbits-Data-Points.png"><img class="alignright size-full wp-image-853" src="http://www.gigamegablog.com/wp-content/uploads/2011/05/Nimbits-Data-Points.png" alt="" width="179" height="131" /></a>In Nimbits, a Data Point is the unique name assigned to a specific datastream. For example, in the screenshot to the right there are 2 Data Points, Home Meter and Plant Light. (Power Usage is a category – the Gadget only works with Data Points, not Categories).</p>
<p>Enter the name of a Data Point in the textbox then click the Add button. You’ll then see it listed below the textbox.</p>
<p>To add a second Data Point to the same graph, enter its name in the textbox then click the Add button. (You have to add them one at a time, rather than typing them in all at once).</p>
<p>To display a Data Point in a separate graph, click the “Display Graph 2?” checkbox to turn it on. Fill in the name of the Data Point in its textbox then click the Add button.</p>
<p>The following screenshot shows 2 Data Points added to the 1st graph, and 1 Data Point in the second graph.</p>
<p><a href="http://www.gigamegablog.com/wp-content/uploads/2011/05/14-12-2011-6-49-16-PM.jpg"><img class="aligncenter size-full wp-image-1069" title="" src="http://www.gigamegablog.com/wp-content/uploads/2011/05/14-12-2011-6-49-16-PM.jpg" alt="" width="331" height="535" /></a></p>
<p style="text-align: center;">
<p>To remove a Data Point from a graph, click the “X” next to the Data Point name. To remove a graph entirely, turn off its checkbox. (OK, here’s the thing: You can’t remove a graph by removing all of its Data Points – Google’s idea, not mine. The gadget “list” interface pretends to remove them, then adds back the last item when you’re not looking. Apparently, that is not evil.)</p>
<h4>Your Email Address</h4>
<p>This field is mandatory when using the public Nimbits server (i.e. when the Server fields is app.nimbits.com). That’s how Nimbits figures out which Data Points belong to you.<br />
<del datetime="2011-06-04T18:08:53+00:00">The field is optional if you’ve <a href="https://code.google.com/p/nimbits-server/wiki/NimbitsServerInstalling">setup your own Nimbits server using the Google App Engine</a>.</del></p>
<p><span style="color: #3366ff;"><br />
<em>Update June 4: Actually, the e-mail address is optional when using your own Nimbits server only if you&#8217;re authenticated with the backend Google App Engine. Since I&#8217;m not sure what triggers that authentication, you should just go ahead and fill in your e-mail address.</em></span></p>
<h4>Graph Height</h4>
<p>This determine the height, in pixels, of the graph. The default of 200 will only allow one full graph to fit. A size of 80 will allow 2 graphs with Status lines to fit.</p>
<h4>Graph Width   [Added: Dec 14 2011]</h4>
<p>This determines the width, in pixels, of each graph.  The default of 310 pixels fits snugly in the gadget container on my desktop PC, but the optimal width will vary depending on the browser and device you&#8217;re using.</p>
<h4>Gadget Height   [Added: Dec 14 2011]</h4>
<p>This determines the height, in pixels, of the gadget container.  The default setting is 240 pixels, which is big enough for a couple of graphs and status lines.</p>
<h3>Other Settings</h3>
<h4>Time Span</h4>
<p>The amount of data displayed on the graph is specified in the Time Span field. You can enter it either as hour or as # of readings. In either case, you’ll get the most recent data: that is, the most recent x hours of data, or the most recent x readings.</p>
<p>By default, this is set to display the last 24 hours of data.</p>
<h4>Legend</h4>
<p>This option determines whether a list of the Data Points and their colours are displayed at the top of the graph. This option is particularly useful if you have multiple Data Points in a graph. Turning the legend off frees up more vertical space for the data in the graph.</p>
<h4>Grid Style</h4>
<p>This option determines the grid lines displayed on the graph: None, Vertical, Horizontal or Both. You can have any number of grid lines you like, as long as that number is 10.</p>
<h4>Show Status</h4>
<p>This option determines whether a status line is displayed above each graph, giving the name of the first Data Point and the date and time of the last reading. The status is particularly useful to identify that your data stream has stopped working, since the line graph won’t make that outage apparent. (Integrating downtime into the graph is definitely a top priority for future updates of the gadget.)</p>
<p>The downside to displaying the status is that it slows down the refresh time of the gadget, and (ahem) the code doesn’t always work. See the Troubleshooting section below if the Status line displays something other than a status.</p>
<h2>Troubleshooting</h2>
<h4>Blank or missing graphs</h4>
<p>When something goes wrong, you generally end up with a blank graph rather than an error message. That’s kind of by design: if there is no data matching the settings, the Nimbits API will dutifully provide an empty set of data to Google Charts, which will dutifully display it.</p>
<p>If the graphs are missing entirely, then the gadget likely couldn’t find a Nimbits server, so check your Server setting.</p>
<p>If blank graphs are displayed, try turning on the Legend and Status options in the settings – they may give an indication of what went wrong.</p>
<p>If the legend is labeled “Doesn’t exist”, then the Data Point might not have been correctly entered in the settings.</p>
<h4>Status line errors</h4>
<p>The Status might be set to one of the following errors:</p>
<ul>
<li><strong>The requested URL /service/currentvalue was not found on this server.</strong> Check the server name in the settings. This error means the server exists, but Nimbits isn’t running on it.</li>
<li><strong>Could not identify user</strong>. Check the email address field in the settings.</li>
<li><strong>Status unknown</strong> or <strong>Undefined</strong>. Unfortunately, there seem to be a variety of causes to this one. The problem isn’t with the settings – it’s likely something I can fix in the code. So, don’t blame yourself, blame me. Fixing this is a priority for future versions of the gadget.</li>
</ul>
<h4>Slow updates</h4>
<p>If the Gadget takes too long to update itself, try turning off the Status option in the settings, and/or putting multiple Data Points on the same graph. Each graph and each status field require an extra call to the Nimbits server. Three data points on one graph take much less time to appear than 3 graphs.</p>
<h4>Data isn’t updated often enough</h4>
<p>Chill, dude! Updates to the graphs and status will only appear every 5 minutes, no matter how much you click the browser Refresh button. This is by design. Google caches the data used by the gadgets, and I’ve set the cache length for 5 minutes.</p>
<p>If you don’t manually refresh the browser page, iGoogle will update all of the gadgets just once per hour.</p>
<h4>Some graphs don’t fit</h4>
<p>I left the Gadget height at its default, and there is no way for the user to increase the size of a gadget in iGoogle. You can fit more graphs in the space by reducing the Graph Height in the Settings dialog. The default of 200 will fit just one graph; a Graph Height of 80 should fit two graphs with their status fields.</p>
<p><a href="http://www.gigamegablog.com/wp-content/uploads/2011/05/Supersize-Me.png"><img class="aligncenter size-full wp-image-857" title="Supersize-Me" src="http://www.gigamegablog.com/wp-content/uploads/2011/05/Supersize-Me.png" alt="" width="369" height="257" /></a> You can see an expanded view of all graphs by clicking Maximize control button on the titlebar, or by selecting the Nimbits gadget in the list on the left of the iGoogle screen.</p>
<h2>Wrapping Up</h2>
<p>If you have any problems, or requests for features in future versions of the gadget, please leave a comment below.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gigamegablog.com/2011/05/21/a-nimbits-gadget-minding-the-data-store/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Beagleboard XM / Angstrom Next Steps: NTP Time Daemon and Cron</title>
		<link>http://www.gigamegablog.com/2011/01/03/beagleboard-xm-angstrom-next-steps-ntp-time-daemon-and-cron/</link>
		<comments>http://www.gigamegablog.com/2011/01/03/beagleboard-xm-angstrom-next-steps-ntp-time-daemon-and-cron/#comments</comments>
		<pubDate>Mon, 03 Jan 2011 23:34:08 +0000</pubDate>
		<dc:creator>dwatts</dc:creator>
				<category><![CDATA[Gadgets]]></category>
		<category><![CDATA[Beagleboard]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://gigamegatech.com/?p=597</guid>
		<description><![CDATA[At about 8 am on January 1st, I was awakened by the beep-beep-beep of an unhappy UPS system.  The power had gone off, and it stayed off for about half an hour. Mercifully (this being 8 am on January 1), &#8230; <a href="http://www.gigamegablog.com/2011/01/03/beagleboard-xm-angstrom-next-steps-ntp-time-daemon-and-cron/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>At about 8 am on January 1st, I was awakened by the beep-beep-beep of an unhappy UPS system.  The power had gone off, and it stayed off for about half an hour. Mercifully (this being 8 am on January 1), my UPS bleated for only about 15 minutes before going to sleep, as did I soon afterwards.</p>
<p>At about 8:30, my Beagleboard was rebooted and promptly resumed its role as <a href="http://www.ladyada.net/make/tweetawatt/">Tweet-A-Watt</a> server.  You&#8217;ll have to take my word for that, since it abandoned its role as Tweet-A-Watt <em>Twitterer</em>.  I didn&#8217;t notice this latter fact until earlier today.  So, if you read my <a href="http://gigamegablog.com/2010/12/09/beagleboard-xm-and-angstrom-getting-the-big-dog-to-run-at-full-speed/">Beagleboard XM And Angstrom &#8211; Getting the Big Dog to Run At Full Speed<br />
</a> post sometime between Jan 1 and Jan 3, you might have wondered if the Big Dog had, indeed, begun to fight with Angstrom.  But, rest assured, the failure was mine, not the Beagleboard&#8217;s or Angstrom&#8217;s.</p>
<div class="img alignright size-medium wp-image-602" style="width:300px;">
	<a href="http://www.gigamegablog.com/wp-content/uploads/2011/01/the_persistence_of_memory_1931_salvador_dali.jpg"><img src="/wp-content/uploads/2011/01/the_persistence_of_memory_1931_salvador_dali-300x225.jpg" alt="Hello, Dali" width="300" height="225" /></a>
	<div>Hello, Dali</div>
</div>What I had failed to do was configure an <a href="http://en.wikipedia.org/wiki/Network_Time_Protocol">NTP daemon</a>, so that it would automatically get the correct date and time in just such an event.  Oddly, it ended up being about 6 days off &#8211; when I checked it earlier today the system date was December 28th.  This led to a &#8220;date out of range&#8221; error from the Twitter API when it attempted to tweet.</p>
<p>There is a <a href="http://mechomaniac.com/BeagleboardTimezones">post on the Mechomaniac blog</a> which explains the process of configuring your timezone and installing the NTP package.  After following those instructions, you can enter <em>ntpdate pool.ntp.org</em>, and your system date and time should be set correctly.  (If the time is off, you probably didn&#8217;t set the timezone correctly &#8211; as stated in that blog entry, the <em>/etc/timezone</em> file used by some Linux distros seems to be ignored by Angstrom.)</p>
<p>Although I didn&#8217;t include the NTP configuration in my initial article about setting up Angstrom the Beagleboard XM, I actually had done it.  I also took the next logical step, which is to configure ntpdate to be automatically run periodically, so that your system date is updated after, say, a power outage.</p>
<p>Or, so I thought.</p>
<p>What I did was</p>
<pre class="brush: bash; title: ; notranslate">
opkg install cron
</pre>
<p><em>[Update Aug 13: Oh, hai!  Dan from the Future, here.  Sorry to interrupt your reading, but I just installed a new Angstrom image generated with <a href="http://narcissus.angstrom-distribution.org/">Narcissus</a>, and I found that the ntpdate entry was placed in the correct crontabs file after installing cron: /var/cron/tabs/root. So, if you're configuring NTP using an up-to-date cron package, then you're probably done!  However, I'm sure you'll want to continuing reading, to see what madcap adventures Dan from the Past got himself into this time...]</em></p>
<p>Period.  The next step should have been to configure cron to run ntpdate.  However, when I checked to see how cron was configured, I noticed that a folder named <em>/etc/cron/crontabs</em> existed, and in there was a file named root that contained:</p>
<pre class="brush: bash; title: ; notranslate">
30 * * * *    /usr/bin/ntpdate -s -u pool.ntp.org
</pre>
<p>And, furthermore, the cron package automatically added a file to etc/init.d so that cron was automatically started when the system booted.</p>
<p>Hey yeah! That was easy, especially by Angstrom standards.  Surprisingly easy.  Suspiciously easy.  Hmmm.</p>
<p>On January 1 I belatedly learned that it isn&#8217;t quite that easy.  The problem is that <em>/etc/cron/crontabs</em> isn&#8217;t where the configuration tables for cron are stored, at least not in the world of Angstrom.  They are in <em>/var/cron/tabs</em>.  One way to configure cron to run ntpdate is to copy the file from <em>/etc/cron/crontabs</em> to here.  Then, restart the cron daemon</p>
<pre class="brush: bash; title: ; notranslate">
cp /etc/cron/crontabs/root /var/cron/tabs/
/etc/init.d/cron restart
</pre>
<p>In the interests of Linux orthodoxy, I should mention that this isn&#8217;t the &#8220;proper&#8221; way.  The proper way is to make use of two crontab commands.</p>
<p>To see what is currently configured (for root &#8211; for another user&#8217;s crontab, replace &#8220;root&#8221; in the following commands with the user-ID):</p>
<pre class="brush: bash; title: ; notranslate">
crontab -u root -l
</pre>
<p>If you are already root (which you should be for the purpose of configuring ntpdate), you can leave out the user name:</p>
<pre class="brush: bash; title: ; notranslate">
crontab -l
</pre>
<p>To change what is configured</p>
<pre class="brush: bash; title: ; notranslate">
crontab -e
</pre>
<p>This last one will launch <a href="http://www.cs.colostate.edu/helpdocs/vi.html">vi</a> so that you can edit the file.</p>
<p>Oops, maybe I should have mentioned that earlier.  If you are now staring dumbfounded at the world&#8217;s most user-hostile editor, press the Esc key, enter <em>:quit!</em> and take a deep breath. Then, copy the root file from the crontabs folder, as specified earlier.  Should you need to change the contents of this file, you can just edit the &#8220;<em>root</em>&#8221; file using your preferred editor, then copy the resulting file into <em>/var/cron/tabs</em>.  If you go this route, you&#8217;ll need to manually restart cron afterwards, whereas changes made with <em>crontab -e</em> are automatically detected by cron.</p>
<p>Actually, its possible to configure crontab to use another editor &#8212; Google it if you&#8217;re interested.</p>
<p>The above crontab line will run ntpdate at the 30th minute of every hour (i.e. 12:30, 1:30).  That&#8217;s probably fine, but if you want to stand out from the crowd you can change it to something less common like <em>13 * *</em> etc, or change ntp.pool.org to your favorite neighbourhood NTP server.</p>
<p>Not working?  Not sure that it&#8217;s working, and anal retentive? By default cron will log its results to /etc/cron/log, in a format like this</p>
<pre class="brush: bash; title: ; notranslate">
root (01/03-17:03:00-1237) CMD (-s -u pool.ntp.org )
root (01/03-17:03:00-1236) MAIL (mailed 27 bytes of output but got status 0x0001)

root (01/03-17:08:00-1259) CMD (/usr/bin/ntpdate -s -u pool.ntp.org )
</pre>
<p>The &#8220;MAIL&#8221; entry is how it handles errors &#8211; presumably you have to configure mail on your Linux box in order for that error message to actually go somewhere.  It wouldn&#8217;t matter much in the case of this ntpdate command, since the &#8220;-s&#8221; tells it to log its output to syslog.  And syslog is another thing that works differently in Angstrom (and doesn&#8217;t work at all by default).  Sigh. We won&#8217;t go there.</p>
<p>If you want to know what went wrong when ntpdate goes wrong, you&#8217;ll have to change the crontab entry to something like the following:</p>
<pre class="brush: bash; title: ; notranslate">
13 * * * *  /usr/bin/ntpdate -u pool.ntp.org ›› /home/root/ntpdatelog.txt
</pre>
<p>This will append the results of the <em>ntpdate </em>command to a text file.</p>
<p>Oh, and a belated Happy New Year from my Beagleboard!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gigamegablog.com/2011/01/03/beagleboard-xm-angstrom-next-steps-ntp-time-daemon-and-cron/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Beagleboard XM / Angstrom Next Steps: Assigning a Static IP</title>
		<link>http://www.gigamegablog.com/2010/12/26/beagleboard-xm-angstrom-next-steps-assigning-a-static-ip/</link>
		<comments>http://www.gigamegablog.com/2010/12/26/beagleboard-xm-angstrom-next-steps-assigning-a-static-ip/#comments</comments>
		<pubDate>Sun, 26 Dec 2010 17:00:01 +0000</pubDate>
		<dc:creator>dwatts</dc:creator>
				<category><![CDATA[Gadgets]]></category>
		<category><![CDATA[Beagleboard]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://gigamegatech.com/?p=526</guid>
		<description><![CDATA[A few weeks ago I wrote about configuring a Beagleboard XM to run Angstrom Linux. At the time I was somewhat dubious about whether Angstrom would prove to be a stable platform. So far, so good. My Beagleboard XM has &#8230; <a href="http://www.gigamegablog.com/2010/12/26/beagleboard-xm-angstrom-next-steps-assigning-a-static-ip/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>A few weeks ago <a href="http://gigamegablog.com/2010/12/09/beagleboard-xm-and-angstrom-getting-the-big-dog-to-run-at-full-speed/">I wrote about configuring a Beagleboard XM to run Angstrom Linux</a>.  </p>
<p>At the time I was somewhat dubious about whether Angstrom would prove to be a stable platform.  So far, so good.  My Beagleboard XM has been faithfully working 24/7, receiving <a href="http://www.ladyada.net/make/tweetawatt/">Tweet-A-Watt</a> data via XBee and posting <a href="http://twitter.com/gigamegabot">power usage updates to Twitter</a>.</p>
<p>Over that time, I&#8217;ve made a few tweaks to the initial configuration and have begun to give the new dog some new responsibilities.</p>
<p>The first of the tweaks is to have it use a static IP address rather than using one assigned by the router&#8217;s DHCP service.  </p>
<p>This tweak is necessary because the XM&#8217;s Ethernet port is not a dedicated piece of hardware with a &#8220;burnt-in&#8221; Ethernet MAC address.  Instead, it makes use of the same USB hub chipset&#8217;s ability to handle Ethernet communications.  (The chipset is an <a href="http://www.smsc.com/index.php?tid=300&#038;pid=135">SMSC LAN9514</a>).  Saving and restoring the MAC address is the responsibility of the software, and the Linux driver used for this chipset doesn&#8217;t support this feature currently.</p>
<p>The end result is that the DHCP server thinks the Beagleboard XM is a new PC every time it is rebooted, and assigns it a new IP address.  This is a major nuisance if you are using the XM as a headless server.  After each reboot you have to hunt down the XM over the network by checking the DHCP logs, or by physically connecting to its serial port.</p>
<p>One solution to the problem is to manually assign a MAC address by changing the XM&#8217;s boot parameters, as described in Max Galemin&#8217;s blog post <a href="http://maxgalemin.blogspot.com/2010/11/patch-for-fixing-random-mac-address-on.html">here</a>.  </p>
<p>Another solution is to manually assign the IP address, instead.  This is somewhat easier to configure, and it allows you to choose an easy-to-remember address.  One downside to this approach is that <a href="http://lifehacker.com/348197/access-your-computer-anytime-and-save-energy-with-wake+on+lan">Wake-On-Lan</a> support won&#8217;t work, since you need to configure a MAC address for the &#8220;magic packet&#8221;.  I went with a static IP, but if you can&#8217;t let sleeping dogs lie (nyuck nyuck nyuck) then go with the static MAC instead.</p>
<p>The process of configuring a static IP address is the same in Angstrom as in most Linux distros. The only catch is that the device name is <em>/dev/usb0</em>, rather than the <em>/dev/eth0</em> used on most PCs. </p>
<p>1. Switch to root, backup /etc/network/interfaces, then edit it:</p>
<pre class="brush: bash; title: ; notranslate">
user@beagleboard ~  su -
Password:
root@beagleboard:~# cd /etc/network
root@beagleboard:/etc/network# mkdir back122610
root@beagleboard:/etc/network# cp interfaces back122610/
</pre>
<p>2.  You&#8217;ll need to know the IP address of your gateway and your DNS server.  If you aren&#8217;t sure, you can see what the XM is currently using (as assigned by the DHCP server) by running a couple of commands:</p>
<pre class="brush: bash; title: ; notranslate">
root@beagleboard:/etc/network# netstat -nr
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 usb0
0.0.0.0         192.168.1.1     0.0.0.0         UG        0 0          0 usb0

root@beagleboard:/etc/network# cat /etc/resolv.conf
search lan
nameserver 111.222.333.444
</pre>
<p>Your gateway address is displayeded in the 2nd row of output from <em>netstat -nr</em> (192.168.1.1 in the above example).  Your DNS is displayed in the 2nd line of <em>/etc/resolv.conf </em>(111.222.333.444). </p>
<p>3. Edit the interfaces file (e.g. vi interfaces).  Comment out the line that says &#8220;iface usb0 inet dhcp&#8221; and replace it with the following lines, specifying your own IP addresses. In the following example, I&#8217;m assigning the XM address 192.168.1.2.  The gateway (my router) is address 192.168.1.1.  Since my router is configured as a DNS server, my DNS server address is also 192.168.1.1.  </p>
<pre class="brush: bash; title: ; notranslate">
# Ethernet/RNDIS gadget (g_ether) or LAN9514
auto usb0
# iface usb0 inet dhcp
iface usb0 inet static
      address 192.168.1.2
      netmask 255.255.255.0
      network 192.168.1.0
      broadcast 192.168.1.255
      gateway 192.168.1.1
      dns-nameservers 192.168.1.1
</pre>
<p>4. If you are connected from a remote PC, reboot. Otherwise, if you are connected to the Beagleboard&#8217;s serial console or with a keyboard and LCD, you can just start and stop the network interface:</p>
<pre class="brush: bash; title: ; notranslate">
root@beagleboard:/etc/network# shutdown -r now
</pre>
<p>&#8230;or&#8230;</p>
<pre class="brush: bash; title: ; notranslate">
root@beagleboard:/etc/network# ifdown usb0
root@beagleboard:/etc/network# ifup usb0
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.gigamegablog.com/2010/12/26/beagleboard-xm-angstrom-next-steps-assigning-a-static-ip/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Beagleboard XM and Angstrom &#8211; Getting the Big Dog to Run At Full Speed</title>
		<link>http://www.gigamegablog.com/2010/12/09/beagleboard-xm-and-angstrom-getting-the-big-dog-to-run-at-full-speed/</link>
		<comments>http://www.gigamegablog.com/2010/12/09/beagleboard-xm-and-angstrom-getting-the-big-dog-to-run-at-full-speed/#comments</comments>
		<pubDate>Thu, 09 Dec 2010 23:03:53 +0000</pubDate>
		<dc:creator>dwatts</dc:creator>
				<category><![CDATA[Gadgets]]></category>
		<category><![CDATA[Beagleboard]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://gigamegatech.com/?p=456</guid>
		<description><![CDATA[When I received a Beagleboard XM low-power computer a few weeks ago, I promptly installed Ubuntu Maverick 10.10 on it. I&#8217;ve found Ubuntu&#8217;s build for Beagleboard&#8216;s ARM-based processors to be remarkably stable on my previous generation Beagleboard C4, so this &#8230; <a href="http://www.gigamegablog.com/2010/12/09/beagleboard-xm-and-angstrom-getting-the-big-dog-to-run-at-full-speed/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>When I received a <a href="http://beagleboard.org/hardware-xM">Beagleboard XM</a> low-power computer a few weeks ago, I promptly installed <a href="http://www.ubuntu.com">Ubuntu</a> Maverick 10.10 on it. I&#8217;ve found <a href="http://elinux.org/BeagleBoardUbuntu">Ubuntu&#8217;s build for Beagleboard</a>&#8216;s ARM-based processors to be remarkably stable on my previous generation Beagleboard C4, so this seemed to be a safe bet. On the XM, Ubuntu seems remarkably solid, but remarkably slow.</p>
<p><a href="http://beagleboard.org/hardware-xM"><img class="alignright size-full wp-image-467" title="beagle-hd-logo" src="http://www.gigamegablog.com/wp-content/uploads/2010/12/beagle-hd-logo.gif" alt="" width="301" height="53" /></a>I noticed some early signs of trouble on the initial boot: an ominous &#8220;&#8221;Kernel is not ready for 1Ghz limiting to 800Mhz&#8221; message, and a Windows-like leisurely boot time. My first impressions were confirmed by running the <a href="http://hardinfo.berlios.de/">HardInfo</a> benchmarks. Every one of them except BogoMIPs was lower on the XM than the C4 by 10-20%. BogoMIPs was a disappointment too, at just over 600. On the Angstrom demo build that is bundled with the XM, the BogoMIPs benchmark was close to 1000.</p>
<p>I tried installing Ubuntu 10.04 on the XM, but the HardInfo benchmarks were just as slow. A <a href="http://www.google.com/search?q=google+beagleboard+xm+ubuntu+slow">Google search</a> confirms that others have run into the same problem with the XM, and as of now (early December 2010) there doesn&#8217;t seem to be a workaround. It would appear that Ubuntu isn&#8217;t yet optimized for the XM&#8217;s faster DM3730 processor.</p>
<p>Performance aside, Ubuntu 10.10 ran well on the XM. But it broke my heart to see the old C4 running rings around the new pup. So goodbye Ubuntu, hello Ångström, at least for now.</p>
<p><a href="http://www.angstrom-distribution.org/">Angstrom</a> (sorry, I&#8217;m not going to type in those umlauts again) is a Linux distribution that seems to be designed for speed and not comfort. As the name suggests, its roots are as a relatively tiny OS that can run on portable devices that are slower and more memory constrained than the XM, such as <a href="http://openpandora.org/">Pandora handheld gaming console</a> and the <a href="http://www.linuxfordevices.com/c/a/Linux-For-Devices-Articles/Device-Profile-Sharps-Zaurus-SL5500-Linux-PDA/">Sharp Zaurus</a>. The XM lets Angstrom stretch its legs, and it responds with blazing speed!<br />
<a href="http://www.openpandora.org/"><img class="alignright size-full wp-image-473" title="Pandora game console" src="http://www.gigamegablog.com/wp-content/uploads/2010/12/openpandora.jpg" alt="" width="372" height="91" /></a><br />
Unfortunately, it&#8217;s also much trickier than Ubuntu to configure. Angstrom&#8217;s default installation doesn&#8217;t include a lot of the packages that are included in every Ubuntu install (and most other distros too). Many of the packages available for Angstrom have generic or misleading names, so it can be hard to track down the one you want. There isn&#8217;t a lot of end user documentation for Angstrom, and the user base is much smaller than Ubuntu&#8217;s, so Googling won&#8217;t always find you the answer either.</p>
<p>Here&#8217;s a step-by-step description of how I got Angstrom up and running. To take optimal advantage of Beagleboard&#8217;s ultra low power design, my goal was a &#8220;headless&#8221; application server (i.e. no monitor and therefore no GUI).</p>
<p>1. Angstrom&#8217;s has an online image builder named <a href="http://narcissus.angstrom-distribution.org/">Narcissus</a>. While its pretty easy to generate an image, it isn&#8217;t obvious how to boot the image on your Beagleboard. The best instructions that I found were in <a href="http://treyweaver.blogspot.com/2010/10/installing-angstrom-on-beagleboard-xm.html">this article on Trey Weaver&#8217;s blog</a>. The only thing that I did differently than what it describes is the command to extract files from the Angstrom image file. Since Narcissus is (currently) using a default image format of gzip (i.e. the downloaded image file ends with .gz), the command to extract the boot files has slightly different parms:</p>
<pre>
tar --wildcards -xzvf [your-download-file] ./boot/*
</pre>
<p>Similarly, the command to extract the root filesystem is:</p>
<pre>
sudo tar -xvz -C /media/Angstrom -f [your-download-file]
</pre>
<p>2. The Beagleboard XM has a built-in serial port, and the default Angstrom build supports it, so you can initially login by connecting a PC to the serial port (a USB-to-serial adapter works fine) and running a terminal program. (Settings are 115200 bps, N-8-1 no flow control.) On Windows, <a href="http://www.winputty.com/">WinPutty</a> works well &#8211; on a Linux PC, <a href="http://alioth.debian.org/projects/minicom/">minicom</a> is, I think, the best bet.</p>
<p>However, you may run into an irritating problem with the display and keyboard input being garbled. I&#8217;ve had that problem when I&#8217;ve installed Angstrom on both my Beagleboards, and I&#8217;m not aware of any workaround.</p>
<p>Fortunately, the garbled terminal only occurs when connecting through the Beagleboard&#8217;s serial port, so you&#8217;ll want to switch to some other type of connection as soon as possible.</p>
<p><em>[Update: It turns out that the garbling occurred only when using a PCI Serial Port card.  I switched to a USB-Serial converter (which uses the common Prolific chipset), and WinPutty works flawlessly.]</em></p>
<p>Since I wasn&#8217;t interested in hooking the Beagleboard up to a monitor and keyboard, I switched to using SSH to bring up a command line connection from another PC. Here is another area where Angstrom is easier to use than Ubuntu &#8211; Angstrom activates the Ethernet port by default, and includes an SSH server named <a href="http://matt.ucc.asn.au/dropbear/dropbear.html">Dropbear</a> by default, so you may be able to connect by SSH on your very first boot, bypassing the serial port entirely.</p>
<p>In any case, the default user-ID is root, and it has no password.</p>
<p>3. To set a password, use the passwd command. I&#8217;d suggest you do so even if you aren&#8217;t at all concerned about security, since some utilities will expect a password.</p>
<pre>passwd
</pre>
<p>Angstrom makes some suggestions about the length and types of characters in your password, but it doesn&#8217;t enforce them.</p>
<p>4. You might want to add a regular user account too. The command for that is useradd</p>
<pre>
useradd youruserid
</pre>
<p>You need to assign a password to this user-ID before it can be used to login:</p>
<pre>passwd youruserid</pre>
<p>5. If the only Linux distro you&#8217;ve used before is Ubuntu, you might be puzzled about the command used to run root commands when logged in as another user. &#8220;sudo&#8221; isn&#8217;t installed in Angstrom by default. Configuring sudo in Angstrom is surprisingly difficult, so you might want to stick to running as root, or get used to switching from a user account to root by entering:</p>
<pre>
su -
</pre>
<p>Enter the root password when prompted, not the user password à la Ubuntu.</p>
<p>6. The command to install packages in <a href="http://wiki.openmoko.org/wiki/Opkg">opkg</a> (which, like pretty much every other command I list, must be run as root). Entering &#8220;opkg &#8211;help&#8221; will tell you all you need to know, but here are some commonly used commands:<br />
To bring your installed packages up-to-date</p>
<pre>
opkg update
opkg upgrade
</pre>
<p>To install a package:</p>
<pre>
opkg install packagename
</pre>
<p>To remove a package:</p>
<pre>
opkg remove packagename
</pre>
<p>If the removal of a package fails due to a long list of dependent packages (and you are sure you don&#8217;t want to keep any of them!):</p>
<pre>
opkg remove packagename --force-removal-of-dependent-packages
</pre>
<p>Unlike Ubuntu&#8217;s aptitude, opkg doesn&#8217;t automagically remove conflicting packages for you. So, when an install fails due to conflicts, you need to either remove them manually, or (as a last resort) grit your teeth, cross your fingers, and enter:</p>
<pre>
opkg install packagename --force-overwrite
</pre>
<p>To list the files in an installed package:</p>
<pre>
opkg files packagename
</pre>
<p>If you want to install something and are trying to figure out its packagename, you can get a list of packages whose name includes a search term:</p>
<pre>
opkg list | grep "whatever"
</pre>
<p>To get a description of a package:</p>
<pre>
opkg info packagename
</pre>
<p>A better way of finding a package is to use the <a href="http://www.angstrom-distribution.org/repo/">package browser on Angstrom&#8217;s web site</a>. Better, but frankly not great, since Angstrom tends to use different package names from other distros, and the package descriptions are usually vague.</p>
<p>To get a list of packages already installed:</p>
<pre>
opkg list_installed
</pre>
<p>7. As with most Linux distros, the default text editor is &#8220;vi&#8221;. Lots of alternatives are available, but the one I use is emacs:</p>
<pre>
opkg install emacs
</pre>
<p>8. You&#8217;ll need an editor to change the hostname to something other than the default of &#8220;beagleboard&#8221;. The 2 files you&#8217;ll need to edit are /etc/hostname and /etc/hosts. For example, to change your hostname to bigdog, the contents should be:</p>
<pre>
youruserid@bigdog:/etc$ cat hostname
bigdog
youruserid@bigdog:/etc$ cat hosts
127.0.0.1       localhost.localdomain           localhost
127.0.0.1       bigdog
</pre>
<p>9. <em>[Update: This step may no longer be necessary - I noticed that the Angstrom 11.03 Narcissus image uses bash as the default user shell]</em> By now, you&#8217;ve probably noticed that the shell is missing some features that you&#8217;re used to, like color coding. Strangely, one of the things that Angstrom doesn&#8217;t install by default is the nearly-universal bash shell. To install it:</p>
<pre>
opkg install bash
</pre>
<p>After installing it, you need to make it the default for your user-ID (though you can run it temporarily by just entering &#8220;bash&#8221;). The command for doing this is</p>
<pre>
chsh /bin/bash
</pre>
<p>Since you have to be root to do this, if you want to change a non-root user to the bash shell, enter</p>
<pre>
chsh /bin/bash youruserid
</pre>
<p>10. You&#8217;ll probably want to make some folders on the Beagleboard accessible over the network. In my case, I primarily use Windows PCs, so I needed to install <a href="http://www.samba.org/">Samba</a>. Since configuring samba can be tedious using its command line tools, I also installed the browser-based samba configuration tool, <a href="http://www.samba.org/samba/docs/man/Samba-HOWTO-Collection/SWAT.html">SWAT</a>:</p>
<pre>
opkg install xinetd
opkg install samba swat
</pre>
<p>xinetd is the standard way of invoking SWAT (and other port-based utilities). You&#8217;ll probably have to manually edit the SWAT settings in the xinetd configuration file &#8212; the following settings will allow access from any PC:</p>
<pre>
The updated /etc/xinetd.conf file should look like this:

# Simple configuration file for xinetd
#
# Some defaults, and include /etc/xinetd.d/

defaults
{

}

service swat
{
   disable = no
   port    = 901
   socket_type = stream
   wait    = no
#       only_from = localhost
   user = root
   server = /usr/sbin/swat
   log_on_failure += USERID
}
includedir /etc/xinetd.d
</pre>
<p>After changing the xinetd.conf file, you need to restart xinetd:</p>
<pre>
/etc/init.d/xinetd restart
</pre>
<p>You should now be able to open the following address in a browser on another PC: http:&lt;ipaddress&gt;901</p>
<p>Login as root at the prompt.</p>
<p>By default, the home folders are shared &#8211; if you created a non-root user-ID then the defaults may be fine. However, you&#8217;ll need to go to the SWAT password page and enter the user-ID and password that you login to Windows. Click the &#8220;Add New User&#8221; button when you&#8217;re done &#8212; it may be old to you, but it&#8217;s new to SWAT:</p>
<p><a href="http://www.samba.org/samba/docs/man/Samba-HOWTO-Collection/SWAT.html"><img class="aligncenter size-full wp-image-471" title="SWAT - Server Password Management" src="http://www.gigamegablog.com/wp-content/uploads/2010/12/swat.png" alt="" width="671" height="264" /></a></p>
<p>I&#8217;d also suggest you go to the Global page and change the workgroup to whatever your Windows PC uses, and enter something meaningful in the &#8220;netbios name&#8221; field.</p>
<p>After saving your changes you don&#8217;t need to restart Samba &#8211; it applies your changes automatically.</p>
<p>If you go to a Windows PC, you should now be able to see your Beagleboard in your network, with some shares underneath. If you are prompted for a user-ID and password, use the one you entered into SWAT&#8217;s password page.</p>
<p>11. One of the things I want to use my XM for is as a <a href="http://www.ladyada.net/make/tweetawatt/">Tweet-A-Watt</a> server. It&#8217;s a good match: software to monitor electricity usage running on an ultra low-power platform. This requires adding a couple of things to Angstrom: <a href="http://www.python.org">Python</a>, and access to an <a href="http://www.digi.com/products/wireless/point-multipoint/xbee-series1-module.jsp#overview">XBee</a> connected to a USB drive. Both of these turned out to be somewhat trickier than they are on Ubuntu.</p>
<p><a href="http://www.python.org"><img class="alignright size-full wp-image-479" title="Python" src="http://www.gigamegablog.com/wp-content/uploads/2010/12/python_logo.jpg" alt="" width="111" height="151" /></a>12. The main package for Python is named python-core. However, Angstrom&#8217;s idea of a &#8220;core&#8221; lacks a lot of python libraries that are standard on pretty much any other Python installation. After playing hide-and-seek with various packages, I gave in and installed the full set of libraries, packaged as python-modules. I also included pyserial for access to the XBee</p>
<pre>
opkg install python python-modules python-pyserial
</pre>
<p>At this point, you can install the Python setuptools package, which includes the easy_install command. easy_install allows you to install many other python libraries that don&#8217;t (seem to) have Angstrom packages. In my case, I needed <a href="https://github.com/joshthecoder/tweepy">Tweepy</a>, which can be used to provide Twitter access to tweetawatt (I wrote <a href="http://gigamegablog.com/2010/09/22/surviving-the-twitter-oauthcalypse-with-tweet-a-watt/">an earlier post</a> about that):</p>
<pre>
opkg install python-setuptools
easy_install tweepy
</pre>
<p>13. Unlike Ubuntu for Beagleboard, Angstrom doesn&#8217;t include support for serial port USB devices in the kernel. If you plug in a USB serial I/O device like an XBee or <a href="http://www.arduino.cc">Arduino</a>, it will be recognized, but no port (e.g. /dev/ttyUSB0) will be assigned to it.</p>
<p>(On the other hand, USB storage devices are supported by default in the Angstrom kernel. And, unlike Ubuntu on the Beagleboard, some drives are automatically mounted, so after plugging in a USB drive you should be able to immediately access it under /media/sda. Kewl.)</p>
<p>To install support for USB serial I/O devices:</p>
<pre>
opkg install kernel-module-ftdi-sio
</pre>
<p>You can temporarily load the kernel module to confirm that it works by entering</p>
<pre>
/opt/bin/depmod -a
/opt/bin/modprobe ftdi-sio
</pre>
<p>If you plug in an XBee, it should now be assigned a port. (Probably /dev/ttyUSB0, but you can enter dmesg and look at the bottom of the output to confirm this).</p>
<p>To automatically load the kernel module at bootup:</p>
<pre>
echo usbserial > /etc/modutils/usbserial
echo ftdi_sio > /etc/modutils/ftdi_sio
update-modules
</pre>
<p>this will update the /etc/modules file.</p>
<p><a href="http://www.angstrom-distribution.org"><img class="alignleft size-full wp-image-475" title="Angstrom Linux" src="http://www.gigamegablog.com/wp-content/uploads/2010/12/angstrom1.jpg" alt="" width="208" height="243" /></a><br />
Phew. In the unlikely even that you read this far before actually trying to get Angstrom working, you might be wondering if it is worth all the effort. The process of setting up the same configuration in Ubuntu is simpler and much better documented.</p>
<p>While its somewhat rewarding to use long-neglected command line skills (and learn a few new ones), I&#8217;d frankly have to admit that I&#8217;ll probably change back to Ubuntu when (if?) its performance on the XM is comparable to Angstrom&#8217;s. There are some packages that don&#8217;t seem to exist yet in Angstrom, and I don&#8217;t have the time/skillz to port them over. (Most notably, I would love to have Python&#8217;s Matlib package, and a browser administration tool along the lines of WebMin. Oddly, the standard Linux help command, man, is currently not available for the Beagleboard).</p>
<p>One other concern: Ubuntu is rock solid on my older Beagleboard, and Angstrom&#8217;s stability is, for me, unproven. However, Tweet-a-Watt is now up and running on my XM &#8211; if it&#8217;s still posting updates to <a href="http://www.twitter.com/gigamegabot">www.twitter.com/gigamegabot</a> when you read this, then maybe tiny Angstrom and the Big Dog really are a match.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gigamegablog.com/2010/12/09/beagleboard-xm-and-angstrom-getting-the-big-dog-to-run-at-full-speed/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>The iPhone and the clipboard: an uneasy alliance</title>
		<link>http://www.gigamegablog.com/2010/06/07/the-iphone-and-the-clipboard-an-uneasy-alliance/</link>
		<comments>http://www.gigamegablog.com/2010/06/07/the-iphone-and-the-clipboard-an-uneasy-alliance/#comments</comments>
		<pubDate>Mon, 07 Jun 2010 23:23:22 +0000</pubDate>
		<dc:creator>dwatts</dc:creator>
				<category><![CDATA[Gadgets]]></category>
		<category><![CDATA[Software Tools]]></category>
		<category><![CDATA[eBooks]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://gigamegatech.com/?p=407</guid>
		<description><![CDATA[I recently spent some time as a guest of the Ontario judicial system. No, not as a prisoner, something much more unpleasant: jury duty. Recommended Reading This is the second time in five years that I&#8217;ve &#8220;done my duty&#8221;, and &#8230; <a href="http://www.gigamegablog.com/2010/06/07/the-iphone-and-the-clipboard-an-uneasy-alliance/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I recently spent some time as a guest of the Ontario judicial system.  No, not as a prisoner, something much more unpleasant: jury duty.</p>
<div class="img    alignleft" style="width:216px;">
	<img src="http://www.gigamegablog.com/wp-content/uploads/2010/06/get_out_of_jury_duty.jpg" alt="Recommended Reading" width="216" height="297" />
	<div>Recommended Reading</div>
</div>
<p>This is the second time in five years that I&#8217;ve &#8220;done my duty&#8221;, and in both instances the week consisted of 99% waiting around and 1% being rejected out-of-hand by defense counsel.  I am, of course, crushed by the repeated rejections, but I managed to get some benefit from the other 99% of my week by reading a software development e-book.</p>
<p>When I went through this five years ago, I did my reading on a <a href="http://reviews.cnet.com/pdas/dell-axim-x51/4505-3127_7-31503979.html#cnetReview">Dell Axim</a> running Windows Mobile 5.0.  You laugh, but let me tell you that one thing it did really well was copy and paste.  You selected the text with the stylus (stop laughing), used a button to toggle to Word and pasted the text in.  A task so simple even Windows Mobile could handle it.</p>
<p>Five years later, I&#8217;m using an iPhone. In technical terms, the iPhone is a Porsche and the Axim a Yugo.  But when it comes to copy and paste, the Porsche is a freaking nightmare to drive.</p>
<p>The problem isn&#8217;t so much with the iPhone as with its apps.  Very few of e-readers allow you to copy text into the clipboard.  It&#8217;s bizarre! Do they think we don&#8217;t want that feature (we&#8217;re too dumb), or do they not trust us to use it responsibly (we&#8217;re too dishonest)? Either way, it&#8217;s insulting.</p>
<p>However, it&#8217;s not all doom and gloom.  There are two very, very good apps that do support the clipboard, and a growing number of e-books that are compatible with them.</p>
<p><strong> </strong></p>
<div class="img  alignright" style="width:90px;">
	<a href="http://www.lexcycle.com/"><img src="http://www.gigamegablog.com/wp-content/uploads/2010/06/stanza.jpg" alt="Stanza - march to a different drummer" width="90" height="90" /></a>
	<div>Stanza - march to a different drummer</div>
</div>
<p><strong>Stanza</strong>.   <a href="http://www.lexcycle.com/">Stanza</a> supports a long list of e-book formats, but unfortunately you are unlikely to encounter most of them when buying e-books.  The 3 exceptions are:</p>
<ol>
<li>eReader &#8211; This is a &#8220;secure&#8221; (piracy-protected) format that is used by Fictionwise and Books on Board for most of their books, and by Barnes and Noble for many of them.</li>
<p></p>
<li>ePub &#8211; The ePub format supported by Stanza is not &#8220;secure&#8221;, which unfortunately makes it harder to find (we&#8217;re dishonest, remember).  However, if you&#8217;re a computer geek then you&#8217;re in luck: O&#8217;Reilly and Microsoft Press offer ePub editions of almost all of their publications.</li>
<p></p>
<li>PDF &#8211; Support for PDF format documents was added to Stanza last week.  Unfortunately, its copy support is pretty inconsistent, often copying gibberish to the clipboard.</li>
</ol>
<div class="img  alignright" style="width:96px;">
	<a href="http://www.goodiware.com/goodreader.html"><img src="http://www.gigamegablog.com/wp-content/uploads/2010/06/gr-icon-96.jpg" alt="GoodReader - not bad!" width="96" height="143" /></a>
	<div>GoodReader - not bad!</div>
</div>
<p><strong>GoodReader</strong>.  <a href="http://www.goodiware.com/goodreader.html">GoodReader </a>supports just one format, PDF, but that&#8217;s still the most commonly used format for technical publications.  I&#8217;ve <a href="http://gigamegablog.com/2009/07/22/pdfs-authorized-copying-prohibited/">raved about this app before</a>, and I&#8217;ve grown more and more impressed with it over time.  They added clipboard support a couple of releases ago, and while its not the most convenient implementation (you can only copy a full page of text, not selected text), it is fast and reliable, just like the rest of GoodReader.  I&#8217;ve yet to find a PDF that GoodReader couldn&#8217;t handle &#8212; amazingly, it loads 100 meg monsters faster than my desktop PC.</p>
<p>Once you&#8217;ve filled the iPhone&#8217;s clipboard, your options for pasting text are much better.</p>
<p>You might find that the built-in Notes app is good enough for this task.  I use <a href="http://tapbots.com/software/pastebot/">Pastebot</a> &#8211; a lot of people rave about its advanced formatting features and automatic synchronization (Mac only), but I like the fact that it automatically saves the clipboard contents when you open the app.  If you need to format the text after you paste it (change fonts, italics, etc.), you should consider <a href="http://www.dataviz.com/products/documentstogo/iphone/index.html?device_id=577">Documents To Go</a>.  I&#8217;m really impressed with how quickly it manages to bring you back to your last spot in a document without multitasking &#8212; the app is ready to paste a couple of seconds after you click the launcher (on an iPhone 3GS).</p>
<p>The new iOS 4 will make the copy-and-paste process somewhat smoother with its support for multitasking and fast app switching: it might even be able to compete with Windows Mobile 5!</p>
<p>One last piece of good news: O&#8217;Reilly (and associated publisher, Microsoft Press) continue to make most of their books available as very inexpensive iPhone apps, generally $5 or $6.  That&#8217;s the full book, pictures and all.</p>
<p>If you&#8217;ve bought one of these apps, you were probably disappointed to find that clipboard support was disabled.  This seems to be related to the underlying version of Stanza (which their apps bundle with the e-book). For some reason Stanza quietly disabled clipboard support in an update to their app last year, then quietly re-enabled it in the next update.  Hmm.</p>
<p>While O&#8217;Reilly continues to use the clipboard-disabled version of Stanza, it is easy enough to do the upgrade yourself. Just follow the process described in <a href="http://gigamegablog.com/2009/09/14/epub-crawl-pulling-a-book-out-of-an-app/">my earlier post</a> to extract the ePub from the O&#8217;Reilly / Microsoft Press book app, then import the ePub into Stanza using their <a href="http://www.lexcycle.com/download">desktop app</a> or a URL link.</p>
<p>I&#8217;m pretty sure that O&#8217;Reilly is OK with you doing so &#8212; as mentioned in my earlier post, it was O&#8217;Reilly themselves who originally documented the process.  If not, maybe I&#8217;ll get yet another opportunity to read e-books as a guest of the Ontario judicial system!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gigamegablog.com/2010/06/07/the-iphone-and-the-clipboard-an-uneasy-alliance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

