<?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>logIt &#187; ARM Linux</title>
	<atom:link href="https://lakm.us/logit/category/arm-linux/feed/" rel="self" type="application/rss+xml" />
	<link>https://lakm.us/logit</link>
	<description>Log Around The Clock</description>
	<lastBuildDate>Sat, 06 Jun 2015 14:17:37 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Mobile WiFi NAS on Raspberry Pi with TrueCrypt</title>
		<link>https://lakm.us/logit/2014/06/mobile-wifi-nas-raspberry-pi-truecrypt/</link>
		<comments>https://lakm.us/logit/2014/06/mobile-wifi-nas-raspberry-pi-truecrypt/#comments</comments>
		<pubDate>Sun, 01 Jun 2014 04:23:18 +0000</pubDate>
		<dc:creator>Arif</dc:creator>
				<category><![CDATA[ARM Linux]]></category>
		<category><![CDATA[General Linux]]></category>
		<category><![CDATA[application]]></category>
		<category><![CDATA[ARMv6]]></category>
		<category><![CDATA[file system]]></category>
		<category><![CDATA[fuse]]></category>
		<category><![CDATA[Raspberry Pi]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://lakm.us/logit/?p=778</guid>
		<description><![CDATA[Mobile NAS sounds like an idea worth waiting for to run on my mini Raspberry Pi Model A. Unfortunately, it only took me a while, before abandoning it. I&#8217;ve waited since writing about Raspberry Pi USB problem, that is to finally cut the backfeeding power line from the el cheapo powered USB hub. There comes [...]]]></description>
				<content:encoded><![CDATA[<p>Mobile <a href="http://en.wikipedia.org/wiki/Network-attached_storage" target="_blank">NAS</a> sounds like an idea worth waiting for to run on my mini <a href="http://www.raspberrypi.org/tag/model-a/" target="_blank">Raspberry Pi Model A</a>. Unfortunately, it only took me a while, before abandoning it. I&#8217;ve waited since <a href="../../../2013/03/raspberry-pi-common-usb-problems/" title="Raspberry Pi Common USB Problems" target="_blank">writing about Raspberry Pi USB problem</a>, that is to <a href="https://flic.kr/p/kqopvk" title="Cutting backfeed from el cheapo USB hub to make friend with dual rating power bank &#038; Raspberry Pi" target="_blank">finally cut the backfeeding power line from the <em>el cheapo</em> powered USB hub</a>. There comes new problem afterward, my &#8220;big storage&#8221; ―a <a href="http://www.seagate.com/external-hard-drives/portable-hard-drives/standard/backup-plus/" title="Backup Plus Slim Portable Drive" target="_blank">Seagate® Backup Plus Slim Portable Drive</a>, shipped with no bulky power supply line― can&#8217;t be mounted. Silence soon follows rotating motor sound a while after plugging-in. I&#8217;ve tried both <a href="http://en.wikipedia.org/wiki/Ext3" target="_blank">ext3</a> and <a href="http://en.wikipedia.org/wiki/NTFS-3G" target="_blank">NTFS (using ntfs-3g)</a> without luck. Later, as benchmark whether it is USB power in question, I try to connect the same set of <em>el cheapo</em> USB hub plus external power to laptop, and it works, leaving me stranded with other issue (is it USB 3.0? 256MB of the Model A? Anything?). I must say that it isn&#8217;t completely not-working as the USB hub set can mount with <a href="http://www.ebay.co.uk/itm/Ritmo-R-Driver-III-USB-2-0-to-sata-Ide-cable-/221221820375" title="R-Driver III USB 2.0 to sata / Ide cable" target="_blank">USB to IDE converter</a> and my old internal hard disk (noting that there shouldn&#8217;t be similar power issue this way). If only it weren&#8217;t for the AC power adapter and large size, this is Mobile NAS; beats me.</p>
<div class="wp-caption aligncenter" style="width: 460px"><img alt="Mobile NAS [Raspberry Pi hack] by aqila_rifti, on Flickr" src="https://farm6.staticflickr.com/5193/14317107955_73226c6432_n.jpg" title="Mobile NAS [Raspberry Pi hack] by aqila_rifti, on Flickr" width="320" height="320" /><p class="wp-caption-text">Battery power bank, WiFi USB stick, and thumb drive</p></div>
<p>I then turn away to motor-less small storage, a <a href="http://www.sandisk.com/products/usb/drives/cruzer-switch/" title="Sandisk Cruzer CZ52 " target="_blank">32 Gigs USB thumb drive</a> so I can move on to other concern: on-the-fly encryption. Hence, I follow <a href="http://kenfallon.com/truecrypt-on-a-respberry-pi-no-gui/" target="_blank">instructions to install True Crypt on Raspberry Pi</a>. After unpacking of <code>wxWidgets-2.8.12.tar.gz</code> and <code>TrueCrypt 7.1a Source.tar.gz</code> in place, putting header files from <code>pkcs-11-cryptoki2.20</code>, and then install <code>libfuse-dev</code>, the following <code>make</code> will require long time:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">PKCS11_INC</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>truecrypt<span style="color: #000000; font-weight: bold;">/</span>pkcs<span style="color: #000000; font-weight: bold;">/</span>
&nbsp;
$ <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #007800;">NOGUI</span>=<span style="color: #000000;">1</span> <span style="color: #007800;">WX_ROOT</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>wxWidgets wxbuild
Configuring wxWidgets library...
Building wxWidgets library...
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>wxWidgets<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>common<span style="color: #000000; font-weight: bold;">/</span>string.cpp:<span style="color: #000000;">84</span>:<span style="color: #000000;">39</span>: warning: ‘wxEmptyString’ initialized and declared ‘extern’ <span style="color: #7a0874; font-weight: bold;">&#91;</span>enabled by default<span style="color: #7a0874; font-weight: bold;">&#93;</span></pre></div></div>

<p><span id="more-778"></span></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #007800;">NOGUI</span>=<span style="color: #000000;">1</span> <span style="color: #007800;">WX_ROOT</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>wxWidgets wxbuild
Compiling Buffer.cpp
Compiling Exception.cpp
Compiling Event.cpp
...
..<span style="color: #000000; font-weight: bold;">/</span>Crypto<span style="color: #000000; font-weight: bold;">/</span>Aeskey.c:<span style="color: #000000;">527</span>:<span style="color: #000000;">25</span>: warning: operation on ‘ss<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">7</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>’ may be undefined <span style="color: #7a0874; font-weight: bold;">&#91;</span>-Wsequence-point<span style="color: #7a0874; font-weight: bold;">&#93;</span>
..<span style="color: #000000; font-weight: bold;">/</span>Crypto<span style="color: #000000; font-weight: bold;">/</span>Aeskey.c:<span style="color: #000000;">527</span>:<span style="color: #000000;">25</span>: warning: operation on ‘ss<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">7</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>’ may be undefined <span style="color: #7a0874; font-weight: bold;">&#91;</span>-Wsequence-point<span style="color: #7a0874; font-weight: bold;">&#93;</span>
..<span style="color: #000000; font-weight: bold;">/</span>Crypto<span style="color: #000000; font-weight: bold;">/</span>Aeskey.c:<span style="color: #000000;">527</span>:<span style="color: #000000;">25</span>: warning: operation on ‘ss<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">7</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>’ may be undefined <span style="color: #7a0874; font-weight: bold;">&#91;</span>-Wsequence-point<span style="color: #7a0874; font-weight: bold;">&#93;</span>
...
Converting Language.xml
Compiling Resources.cpp
Linking truecrypt</pre></div></div>

<p>I created the TrueCrypt volume separately via its desktop GUI with <code>ext3</code> file system to then mount it in Pi to a configured <a href="http://en.wikipedia.org/wiki/Samba_(software)" target="_blank">Samba share</a>. As pointed out in <a href="http://raspberrywebserver.com/serveradmin/share-your-raspberry-pis-files-and-folders-across-a-network.html" target="_blank">a post</a>, the following changes are added to <code>smb.conf</code></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">...
wins support = <span style="color: #c20cb9; font-weight: bold;">yes</span>
...
<span style="color: #7a0874; font-weight: bold;">&#91;</span>pitruecrypt<span style="color: #7a0874; font-weight: bold;">&#93;</span>
   <span style="color: #007800;">comment</span>= Pi Truecrypt Volume
   <span style="color: #007800;">path</span>=<span style="color: #000000; font-weight: bold;">&lt;</span>the <span style="color: #c20cb9; font-weight: bold;">mount</span> path of the USB thumb drive TrueCrypt volume<span style="color: #000000; font-weight: bold;">&gt;</span>
   <span style="color: #007800;">browseable</span>=Yes
   <span style="color: #007800;">writeable</span>=Yes
   only <span style="color: #007800;">guest</span>=no
   create <span style="color: #007800;">mask</span>=0777
   directory <span style="color: #007800;">mask</span>=0777
   <span style="color: #007800;">public</span>=no</pre></div></div>

<p>and then user-password are entered via interactive command.</p>
<p>For mobility, I already had the Pi as WiFi access point using <code><a href="hostap.epitest.fi/hostapd/" target="_blank">hostapd</a></code> (check <a href="http://sirlagz.net/2012/08/09/how-to-use-the-raspberry-pi-as-a-wireless-access-pointrouter-part-1/" target="_blank">these steps</a>) and <a href="http://www.amazon.com/HAME-10400mAh-Double-Indicators-Capacity/dp/B00B5OFC5I" target="_blank">power bank</a>, so it&#8217;s now matter of performance. In the case of <code><a href="http://www.samba.org/rsync/" target="_blank">rsync</a></code>, initial sync of some 1,500 items totaling in 1 Gig size elapses in approximately the same 12 minutes of time compared to one bulk file of the same size. Of course, over the next incremental sync, it only takes less than a minute for the thousand items to just update slight differences.</p>
<h3>Security</h3>
<p>Back to security, there surely risk by opening Samba share to mounted TrueCrypt volume. But, for me it would be practically manageable (cross my finger). There is more concern to the fate of <a href="http://truecrypt.sourceforge.net/" target="_blank">TrueCrypt</a> after it is being closed in such a weird way, given that <a href="https://opencryptoaudit.org/reports/iSec_Final_Open_Crypto_Audit_Project_TrueCrypt_Security_Assessment.pdf" target="_blank">last audit</a> finds nothing severe. Anyway, I found brute force tool, but no critical attack exists currently, unless e.g. it stays powered on and mounted, the person gain physical access. Beats me again.</p>
]]></content:encoded>
			<wfw:commentRss>https://lakm.us/logit/2014/06/mobile-wifi-nas-raspberry-pi-truecrypt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Any m-by-n Matrix Keypad for Raspberry Pi</title>
		<link>https://lakm.us/logit/2014/02/any-m-x-n-matrix-keypad-raspberry-pi/</link>
		<comments>https://lakm.us/logit/2014/02/any-m-x-n-matrix-keypad-raspberry-pi/#comments</comments>
		<pubDate>Sat, 08 Feb 2014 18:30:57 +0000</pubDate>
		<dc:creator>Arif</dc:creator>
				<category><![CDATA[ARM Linux]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[application]]></category>
		<category><![CDATA[GPIO]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[Raspberry Pi]]></category>

		<guid isPermaLink="false">http://lakm.us/logit/?p=746</guid>
		<description><![CDATA[What about instantiating any m x n matrix keypad by a Python class? Raspberry Pi takes me to learn how to build a Python class for the first time while expanding my initial WiringPi-based matrix keypad into a derivative work. A matrix keypad instance is defined by: Actual GPIO pins used forming the row and [...]]]></description>
				<content:encoded><![CDATA[<p>What about instantiating any m x n matrix keypad by a <a href="http://docs.python.org/2/tutorial/classes.html" title="Python Classes" target="_blank">Python class</a>? <a href="http://www.raspberrypi.org/" target="_blank">Raspberry Pi</a> takes me to learn how to build a Python class for the first time while expanding my initial <a href="../../2013/03/raspberry-pi-membrane-matrix-keypad-gpio-input-2/" title="Raspberry Pi: Membrane (Matrix) Keypad as GPIO Input" target="_blank">WiringPi-based matrix keypad</a> into a derivative work.</p>
<p>A matrix keypad instance is defined by:</p>
<ol>
<li>Actual GPIO pins used forming the row and column of the m x n matrix</li>
<li>Individual character in-use as symbol for each button</li>
</ol>
<p>Hence, I instantiate and call method like</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">...
<span style="color: black;">QPad</span>  = matrixQPi<span style="color: black;">&#40;</span>keyPad=keyPad,row=row,col=col<span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">print</span> QPad.<span style="color: black;">scanQ</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>to print the character being pressed. Some examples pushed to <a href="https://github.com/bandono/matrixQPi/tree/v2.0" title="Github: matrixQPi v2.0" target="_blank">my github</a> explains how the above <code>keyPad</code>, <code>row</code>, and <code>col</code> are defined to scan-read pressed button of 2&#215;2, 2&#215;3, and 4&#215;3 matrix keypads <time datetime="2014-02-23">(or have it 3&#215;4 matrix keypads in other words)</time>.</p>
<div class="wp-caption aligncenter" style="width: 460px"><img alt="Illustration of any m-by-n matrix: 4x3, 2x2, and 2x3 keypad with different button symbols &#038; GPIO combinations" src="../../../../images/any-mxn-matrix-keypad-raspberry-pi.png" title="Illustration of any m-by-n matrix: 4x3, 2x2, and 2x3 keypad with different button symbols &#038; GPIO combinations" width="368" height="264" /><p class="wp-caption-text">Illustration of any m-by-n matrix: 4x3, 2x2, and 2x3 keypad with different button symbols &#038; GPIO combinations</p></div>
<p>I used deprecated <a href="https://github.com/WiringPi/WiringPi-Python" title="WiringPi-Python" target="_blank">Wiring-Pi Python</a> (they already moved to <a href="https://github.com/WiringPi/WiringPi2-Python" title="WiringPi2-Python" target="_blank">2.x version</a>) without problem. However, you&#8217;ll fail building from latest commit and must use combination of older commits as described by my updated part of <a href="../../2013/03/raspberry-pi-gpio-input-button-basics-1/" title="Raspberry Pi GPIO Input Button Basics" target="_blank">an old-post</a>. By the way, there&#8217;s I/O expander support for <a href="https://github.com/WiringPi/WiringPi2-Python" title="WiringPi2-Python" target="_blank">WiringPi2-Python</a> which is good, considering:</p>
<blockquote><p>GPIO is expensive and for the sake of a keypad, you should not spend all.</p></blockquote>
<p>(A friend told me that once)</p>
]]></content:encoded>
			<wfw:commentRss>https://lakm.us/logit/2014/02/any-m-x-n-matrix-keypad-raspberry-pi/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Duplicate/Restore ARM Linux Image to MMC/SD Card (BeagleBoard and DevKit ARM)</title>
		<link>https://lakm.us/logit/2013/03/duplicate-restore-arm-linux-image-mmc-sd-card-beagleboard-devkit-board/</link>
		<comments>https://lakm.us/logit/2013/03/duplicate-restore-arm-linux-image-mmc-sd-card-beagleboard-devkit-board/#comments</comments>
		<pubDate>Mon, 25 Mar 2013 10:02:45 +0000</pubDate>
		<dc:creator>Arif</dc:creator>
				<category><![CDATA[ARM Linux]]></category>
		<category><![CDATA[ARMv7]]></category>
		<category><![CDATA[backup/restore]]></category>
		<category><![CDATA[BeagleBoard]]></category>
		<category><![CDATA[DevKit8500D]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[rootfs]]></category>

		<guid isPermaLink="false">http://lakm.us/logit/?p=530</guid>
		<description><![CDATA[By booting from MMC/SD card, you can bring up your BeagleBoard-xM or DevKit8500D (both are ARMv7). It is the only way for the xM (microSD card to be exact), while with DevKit, you have the option to flash it to the board for NAND-boot once you&#8217;re sure that it works with SD card. eLinux wiki [...]]]></description>
				<content:encoded><![CDATA[<p>By booting from MMC/SD card, you can bring up your <a href="http://beagleboard.org/hardware-xM" target="_blank">BeagleBoard-xM</a> or <a href="http://www.armkits.com/product/devkit8500d.asp" target="_blank">DevKit8500D</a> (both are <a href="http://en.wikipedia.org/wiki/ARM_Cortex-A8" target="_blank">ARMv7</a>). It is the only way for the xM (microSD card to be exact), while with DevKit, you have the option to flash it to the board for NAND-boot once you&#8217;re sure that it works with SD card. <a href="http://elinux.org" target="_blank">eLinux wiki</a> has some sections about the card setup e.g. <a href="http://elinux.org/BeagleBoardDebian" target="_blank">Debian setup</a>, how to <a href="http://elinux.org/BeagleBoard#U-Boot_booting" target="_blank">start from U-boot prompt</a>, etc.</p>
<p>In the Debian example, the wiki introduced <a href="http://elinux.org/BeagleBoardDebian#Debian_NetInstall" target="_blank">NetInstall</a>. Later I find out the <code>mk_mmc.sh</code> script shown there to be useful for (1) duplicating and (2) restoring working Linux backup to new or corrupted MMC/SD card. I break down that <a href="https://github.com/RobertCNelson/netinstall/blob/bd32dd39732ccf33bfec8895c809f0d4fa79c95c/mk_mmc.sh" title="mk_mmc.sh (tree bd32dd3973)" target="_blank">Robert C. Nelson&#8217;s <code>mk_mmc.sh</code> script at GitHub</a> to small routines for setting up the card.</p>
<div class="wp-caption aligncenter" style="width: 460px"><img alt="typical-sd-card-partition-arm-linux-board.png" src="../../../../images/typical-sd-card-partition-arm-linux-board.png" title="Typical boot-rootfs partitions of SD card to boot ARM-Linux boards" width="334" height="131" /><p class="wp-caption-text">Typical boot-rootfs partitions of SD card to boot ARM-Linux boards</p></div>
<p>It&#8217;s an elegant script automating the process of preparing SD card for embedded Linux, but requires large downloading on the run (mostly root file system and then <a href="http://www.denx.de/wiki/U-Boot" title="Das U-Boot" target="_blank">U-Boot</a> binaries and loader config). Duplicating/restoring means we already have those and probably only need to do elementary process rather than full card preparation. Below are some processes that can be repeatedly used.</p>
<p><span id="more-530"></span><a id="Checking.Version" href="#Checking.Version" rel="bookmark" title="Checking Tool Versions"><br />
<h4>Checking Tool Versions</h4>
<p></a></p>
<p>The tools to work with are common in Linux distribution (I used Ubuntu) and require <code>root</code> privilege. The script checked for <code>fdisk</code> and <code>parted</code> installed. My versions are</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ fdisk <span style="color: #660033;">-v</span>
fdisk <span style="color: #7a0874; font-weight: bold;">&#40;</span>util-linux-ng 2.17.2<span style="color: #7a0874; font-weight: bold;">&#41;</span>
$ parted <span style="color: #660033;">-v</span>
parted <span style="color: #7a0874; font-weight: bold;">&#40;</span>GNU parted<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000;">2.2</span></pre></div></div>

<p>Originally <code>mk_mmc.sh</code> will exit If &#8220;<code>GNU Fdisk</code>&#8221; found instead. Also for the above <code>parted</code> version, &#8220;<code>--align cylinder</code>&#8221; argument will be used.</p>
<p><a id="Creating.Partitions" href="#Creating.Partitions" rel="bookmark" title="Creating Two Partitions"><br />
<h4>Creating Two Partitions</h4>
<p></a></p>
<p>Setting up two partitions which are the boot image (<code>FAT 16</code>) and root file system (<code>ext4</code>). The SD card plugged in through USB card reader found as <code>/dev/sdb</code> in this example (<strong>we&#8217;re formatting be sure of this!</strong>). If you plug MMC card to laptop slot, it may be found as <code>/dev/mmcblk0</code>. </p>
<ol>
<li>Format card into a single disk</li>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ parted <span style="color: #660033;">--script</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sdb mklabel msdos
$ fdisk <span style="color: #660033;">-l</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sdb</pre></div></div>

<li>Create the boot partition (allocating 64MB)</li>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ fdisk <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sdb <span style="color: #cc0000; font-style: italic;">&lt;&lt; END
n
p
1
1
+64M
t
e
p
w
END</span></pre></div></div>

<p>then make sure it&#8217;s done.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">sync</span></pre></div></div>

<li>Flag it as <code>boot</code></li>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ parted <span style="color: #660033;">--script</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sdb <span style="color: #000000; font-weight: bold;">set</span> <span style="color: #000000;">1</span> boot on</pre></div></div>

<li>Create the root file system by first determining space left after the first partition</li>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #007800;">END_BOOT</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">LC_ALL</span>=C parted <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sdb unit mb print <span style="color: #c20cb9; font-weight: bold;">free</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> primary <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $3}'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">cut</span> <span style="color: #660033;">-d</span> <span style="color: #ff0000;">&quot;M&quot;</span> -f1<span style="color: #7a0874; font-weight: bold;">&#41;</span>
$ <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$END_BOOT</span> 
<span style="color: #000000;">69.7</span>
$ <span style="color: #007800;">END_DEVICE</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">LC_ALL</span>=C parted <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sdb unit mb print <span style="color: #c20cb9; font-weight: bold;">free</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> Free <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tail</span> <span style="color: #660033;">-n</span> <span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $2}'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">cut</span> <span style="color: #660033;">-d</span> <span style="color: #ff0000;">&quot;M&quot;</span> -f1<span style="color: #7a0874; font-weight: bold;">&#41;</span>
$ <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$END_DEVICE</span> 
<span style="color: #000000;">3951</span></pre></div></div>

<p>In this case 4GB SD card is used and the above calculation will stretch space left from 69.7 to 3951 of as <code>rootfs</code> partition.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ parted <span style="color: #660033;">--script</span> <span style="color: #660033;">--align</span> cylinder <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sdb mkpart primary ext4 <span style="color: #007800;">$END_BOOT</span> <span style="color: #007800;">$END_DEVICE</span></pre></div></div>

<li>Format <code>boot</code> and <code>rootfs</code> according to each file system type with those naming also. They&#8217;re already accessible as <code>/dev/sdb1</code> and <code>/dev/sdb2</code> (previously didn&#8217;t exist) or relevant <code>/dev/mmcblk0p(some index)</code>.</li>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ mkfs.vfat <span style="color: #660033;">-F</span> <span style="color: #000000;">16</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sdb1 <span style="color: #660033;">-n</span> boot
$ mkfs.ext4 <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sdb2 <span style="color: #660033;">-L</span> rootfs</pre></div></div>

<li>Finally we have something like the output of <code>parted</code> below</li>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #007800;">LC_ALL</span>=C parted <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sdb unit mb print <span style="color: #c20cb9; font-weight: bold;">free</span> 
Model: HUAWEI MMC Storage <span style="color: #7a0874; font-weight: bold;">&#40;</span>scsi<span style="color: #7a0874; font-weight: bold;">&#41;</span>
Disk <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sdb: 4023MB
Sector <span style="color: #c20cb9; font-weight: bold;">size</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>logical<span style="color: #000000; font-weight: bold;">/</span>physical<span style="color: #7a0874; font-weight: bold;">&#41;</span>: 512B<span style="color: #000000; font-weight: bold;">/</span>512B
Partition Table: msdos
&nbsp;
Number  Start   End     Size    Type     File system  Flags
 <span style="color: #000000;">1</span>      0.03MB  70.9MB  70.8MB  primary  fat16        boot, lba
        70.9MB  4023MB  3953MB           Free Space</pre></div></div>

<p><em>(yes I used Huawei modem as the microSD card reader)</em>
</ol>
<p><a id="Restoring.Linux" href="#Restoring.Linux" rel="bookmark" title="Restoring Linux"><br />
<h4>Restoring Linux</h4>
<p></a></p>
<p>For the <code>boot</code> partition content we can simply copy-paste the backup files, while for <code>rootfs</code> normally compressed file (preserving path information) is used for backup. Restore this by mounting <code>rootfs</code> and then unpacking the file (again <code>/dev/sdb2</code> in this case).</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>host<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ <span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>media<span style="color: #000000; font-weight: bold;">/</span>rootfs
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>host<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ <span style="color: #c20cb9; font-weight: bold;">mount</span> <span style="color: #660033;">-t</span> ext4 <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sdb2 <span style="color: #000000; font-weight: bold;">/</span>media<span style="color: #000000; font-weight: bold;">/</span>rootfs
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>host<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ pv armel-rootfs-201110131018.tar <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">--numeric-owner</span> <span style="color: #660033;">--preserve-permissions</span> <span style="color: #660033;">-xf</span> - <span style="color: #660033;">-C</span> <span style="color: #000000; font-weight: bold;">/</span>media<span style="color: #000000; font-weight: bold;">/</span>rootfs</pre></div></div>

<p>Below is an example of how to backup <code>rootfs</code> from the mounted SD card (<code>/media/rootfs</code>).</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>host<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>media<span style="color: #000000; font-weight: bold;">/</span>rootfs
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>host<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ <span style="color: #000000; font-weight: bold;">/</span>media<span style="color: #000000; font-weight: bold;">/</span>rootfs<span style="color: #666666; font-style: italic;"># tar --numeric-owner --preserve-permissions -cvf /home/arif/Documents/arm-linux/ubuntu/rootstock-rootfs/armel-rootfs-201202141421.tar ./*</span></pre></div></div>

<p>(Check <a href="../../../2011/10/running-ubuntu-on-devkit8500d-natty-kernel-and-lucid-rootfs/" title="Running Ubuntu on DevKit8500D (Natty Kernel and Lucid RootFS)" target="_blank">my other post related to creating <code>rootfs</code></a>)</p>
<p><a id="Creating.Swap" href="#Creating.Swap" rel="bookmark" title="Creating Swap"><br />
<h4>Creating Swap</h4>
<p></a></p>
<p><code>mk_mmc.sh</code> also offers optional <code>swap</code> creation. It is a &#8220;file&#8221; inside <code>rootfs</code> partition created by</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>host<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ <span style="color: #c20cb9; font-weight: bold;">dd</span> <span style="color: #007800;"><span style="color: #000000; font-weight: bold;">if</span></span>=<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>zero <span style="color: #007800;">of</span>=<span style="color: #000000; font-weight: bold;">/</span>media<span style="color: #000000; font-weight: bold;">/</span>rootfs<span style="color: #000000; font-weight: bold;">/</span>SWAP.swap <span style="color: #007800;">bs</span>=1M <span style="color: #007800;">count</span>=<span style="color: #000000;">250</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>host<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ mkswap <span style="color: #000000; font-weight: bold;">/</span>media<span style="color: #000000; font-weight: bold;">/</span>rootfs<span style="color: #000000; font-weight: bold;">/</span>SWAP.swap</pre></div></div>

<p>(the above will create 262MB swap inside <code>rootfs</code> SD card currently mounted to <code>/media/rootfs</code> of the laptop)</p>
<p>It will be mounted as <code>swap</code> by the ARM-Linux board via <code>fstab</code> setting configured below.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>host<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;/SWAP.swap  none  swap  sw  0 0&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>media<span style="color: #000000; font-weight: bold;">/</span>rootfs<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>fstab</pre></div></div>

<p>Synchronize and safely remove the card</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>host<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ <span style="color: #c20cb9; font-weight: bold;">sync</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>host<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ <span style="color: #c20cb9; font-weight: bold;">umount</span> <span style="color: #000000; font-weight: bold;">/</span>media<span style="color: #000000; font-weight: bold;">/</span>rootfs</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>https://lakm.us/logit/2013/03/duplicate-restore-arm-linux-image-mmc-sd-card-beagleboard-devkit-board/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Modem usb_modeswitch in Raspberry Pi</title>
		<link>https://lakm.us/logit/2013/03/modem-usb_modeswitch-raspberry-pi/</link>
		<comments>https://lakm.us/logit/2013/03/modem-usb_modeswitch-raspberry-pi/#comments</comments>
		<pubDate>Mon, 25 Mar 2013 03:35:30 +0000</pubDate>
		<dc:creator>Arif</dc:creator>
				<category><![CDATA[ARM Linux]]></category>
		<category><![CDATA[ARMv6]]></category>
		<category><![CDATA[comparison]]></category>
		<category><![CDATA[modem]]></category>
		<category><![CDATA[Raspberry Pi]]></category>
		<category><![CDATA[USB]]></category>

		<guid isPermaLink="false">http://lakm.us/logit/?p=571</guid>
		<description><![CDATA[USB modem these days are plug-and-play as CD-ROM first allowing driver and internet dialer application installations and then as modem afterwards. This Windows-behavior is handled by USB_ModeSwitch in Linux. Likely three years ago we did eject and other driver attachment by writing udev rules. Now it&#8217;s almost automatically attached as modem after insertion and people [...]]]></description>
				<content:encoded><![CDATA[<p>USB modem these days are plug-and-play as CD-ROM first allowing driver and internet dialer application installations and then as modem afterwards. This Windows-behavior is handled by <a href="http://www.draisberghof.de/usb_modeswitch/" target="_blank">USB_ModeSwitch</a> in Linux. Likely three years ago we did eject and other driver attachment by <a href="http://www.reactivated.net/writing_udev_rules.html" target="_blank">writing <code>udev</code> rules</a>.</p>
<p>Now it&#8217;s almost automatically attached as modem after insertion and people have been contributing to list of device-and-target device after mode-switching (find it as <code>/usr/share/usb_modeswitch/configPack.tar.gz</code>). At least for <a href="http://www.raspberrypi.org/" target="_blank">Raspberry Pi (RPi)</a>, I have one device list from August 2012 when playing around with <a href="http://xbian.org/" target="_blank">XBian 0.8.3</a> and one from May 2012 in when using <a href="http://www.raspbian.org/" target="_blank">Raspbian Wheezy (2012-08-16)</a>.</p>
<div class="wp-caption aligncenter" style="width: 460px"><img alt="old-huawei-e220-newer-e153-raspberry-pi-compatibility.jpg" src="../../../../images/old-huawei-e220-newer-e153-raspberry-pi-compatibility.jpg" title="Huawei E220 requires no mode-switch" width="310" height="380" /><p class="wp-caption-text">Huawei E220 requires no mode-switch from vendor-product ID 12d1:1003 to function as modem</p></div>
<p>There is still wrapper for udev in <code>/lib/udev/rules.d/40-usb_modeswitch.rule</code> and my Huawei E153 HSDPA stick recognized and switched successfully as shown:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">usb_modeswitch: switching device 12d1:<span style="color: #000000;">1446</span> on 001<span style="color: #000000; font-weight: bold;">/</span>005
...
logger: usb_modeswitch: switched to 12d1:14ac on 001<span style="color: #000000; font-weight: bold;">/</span>006</pre></div></div>

<p><span id="more-571"></span>But I didn&#8217;t get there in the first place. Because of USB power problem (<a href="../../../2013/03/raspberry-pi-common-usb-problems/" title="Raspberry Pi Common USB Problems" target="_blank">detailed in previous post</a>), I used to plug USB devices before powering up so that I could use <a href="http://htc-linux.org/wiki/index.php?title=File:Usb-y-power-cable.jpg" title="File:Usb-y-power-cable.jpg" target="_blank">Y-cable injected by separate power source</a> without powered USB-hub. It turned out that if I had plugged the USB before powering up the RPi the mode-switching didn&#8217;t occur.</p>
<p>The HSDPA USB modem used is <a href="http://www.huaweidevice.co.id/webmain/main/product/detail/35/huawei-e153" target="_blank">Huawei E153</a> appearing in <code>lsusb</code> with vendor-product ID <code>12d1:1446</code>. Using aforementioned <a href="http://xbian.org/" target="_blank">XBian</a> and target device <code>12d1:140c</code> (suggested in <a href="http://www.santinoli.com/open/e1692-howto.html" target="_blank">Santinoli&#8217;s post</a>), I arbitrarily succeeded to switch to modem and dial internet with <code>pppd</code>.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ usb_modeswitch <span style="color: #660033;">-v</span> 12d1 <span style="color: #660033;">-p</span> <span style="color: #000000;">1446</span> <span style="color: #660033;">-P</span> 140c</pre></div></div>

<p>(I placed Santinoli&#8217;s config in <code>/etc/usb_modeswitch.conf</code>)<br />
This wasn&#8217;t stable however (also note that XBian consumed CPU above 50% for <a href="http://xbmc.org/" title="XBMC" target="_blank"><code>xbmc</code></a>).</p>
<p>Later I find out that it will automatically switch to <code>12d1:14ac</code> instead when plugged in after RPi is up. However, since it also won&#8217;t switch if plugged before power-up, I also try to mode-switch manually using config file found inside <code>/usr/share/usb_modeswitch/configPack.tar.gz</code> archive named <code>12d1:1446</code>.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ usb_modeswitch <span style="color: #660033;">-v</span> 12d1 <span style="color: #660033;">-p</span> <span style="color: #000000;">1446</span> <span style="color: #660033;">-c</span> 12d1\:<span style="color: #000000;">1446</span></pre></div></div>

<p>It doesn&#8217;t seem to work. Modification to something close to my previous config also fails. Hence, consistent result only occurs if the stick is plugged in after RPi up. Then I decide to use USB-hub (also <a href="../../../2013/03/raspberry-pi-common-usb-problems/" title="Raspberry Pi Common USB Problems" target="_blank">detailed in previous post</a>) to tackle power issue (it will reboot anyway if you plug in without adequate powering). However, after successful mode-switch what&#8217;s being reported in <a href="http://elinux.org/RPi_VerifiedPeripherals">eLinux Wiki</a> often happens: it slows down, try <code>lsub</code> command for example.</p>
<p>Currently I give up the idea of using that modem and choose older <a href="http://en.wikipedia.org/wiki/Huawei_E220" target="_blank">Huawei E220</a>:</p>
<ol>
<li>No <code>usb_modeswitch</code>. <a href="../../../2012/01/compile-usb-serial-modem-using-option-c-ubuntu-on-beagleboard-xm/" title="Compile USB Serial Modem Using option.c (Ubuntu on Beagleboard xM)" target="_blank">Driver attached directly by the kernel as <code>option.ko</code> device</a> (this device has been on the list for long)</li>
<li>Stable. No slowing down</li>
</ol>
<p>The E153 modem itself has been implemented to stream video using the <a href="http://en.wikipedia.org/wiki/ARM_Cortex-A8" target="_blank">higher ARM type</a> <a href="http://beagleboard.org/hardware-xm" target="_blank">BeagleBoard-xM</a> without significant stability issue (check <a href="https://www.youtube.com/watch?v=yFZoFsqAdS8" title="Zoom IP Camera Streaming &#038; Control on BeagleBoard (Over HSDPA Network)" target="_blank">my YouTube demo</a>). It mode-switched when powering up Ubuntu on the Beagle.</p>
]]></content:encoded>
			<wfw:commentRss>https://lakm.us/logit/2013/03/modem-usb_modeswitch-raspberry-pi/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Raspberry Pi Common USB Problems</title>
		<link>https://lakm.us/logit/2013/03/raspberry-pi-common-usb-problems/</link>
		<comments>https://lakm.us/logit/2013/03/raspberry-pi-common-usb-problems/#comments</comments>
		<pubDate>Sun, 24 Mar 2013 08:02:29 +0000</pubDate>
		<dc:creator>Arif</dc:creator>
				<category><![CDATA[ARM Linux]]></category>
		<category><![CDATA[ARMv6]]></category>
		<category><![CDATA[ARMv7]]></category>
		<category><![CDATA[BeagleBoard]]></category>
		<category><![CDATA[comparison]]></category>
		<category><![CDATA[Raspberry Pi]]></category>
		<category><![CDATA[USB]]></category>

		<guid isPermaLink="false">http://lakm.us/logit/?p=556</guid>
		<description><![CDATA[USB problem is the first thing to arise with Raspberry Pi when plugging-in peripherals. This isn&#8217;t exclusive though, learning that my Linux laptop also has it and the higher ARM architecture, BeagleBoard-xM, also experiences the same issue sometime. But with Raspberry Pi (RPi) in]]></description>
				<content:encoded><![CDATA[<p><a href="http://en.wikipedia.org/wiki/Universal_Serial_Bus" title="Universal Serial Bus" target="_blank">USB</a> problem is the first thing to arise with <a href="http://www.raspberrypi.org/" title="www.raspberrypi.org" target="_blank">Raspberry Pi</a> when plugging-in peripherals. This isn&#8217;t exclusive though, learning that my Linux laptop also has it and the higher ARM architecture, <a href="http://beagleboard.org/hardware-xm">BeagleBoard-xM</a>, also experiences the same issue sometime. But with Raspberry Pi (RPi) in <a href="http://www.pcworld.com/article/156494/superspeed_usb.html" title="""Over 6 billion products are in the market, and over 2 billion ship a year now"" target="_blank">the universe of many viable USB device options</a>, you&#8217;ll definitely need to double its popular credit card-sized form to have powered USB-hub docked next to it, although Y-cable with separate power assistant injecting the USB device directly is sometime adequate.</p>
<div class="wp-caption aligncenter" style="width: 460px"><a href="http://www.flickr.com/photos/aqila_rifti/8580224756/" title="y-cable . #Pi USB power-hog? buggy? by aqila_rifti, on Flickr"><img src="http://farm9.staticflickr.com/8244/8580224756_00de511912_n.jpg" width="310" height="310" alt="y-cable . #Pi USB power-hog? buggy?"></a><p class="wp-caption-text">Y-cable for USB modem stick &#038; various current rating-AC power adapters for smartphone/tablet to go with Raspberry Pi</p></div>
<p><a href="http://elinux.org/RPi_VerifiedPeripherals" title="RPi Verified Peripherals" target="_blank">eLinux Wiki lists</a> market available USB-hubs reported to work. A decent brand (that will cost you) qualifies:</p>
<ul>
<li>Doesn&#8217;t leak power back to RPi via USB port (check this by unplugging the main power, then check the red LED indicator) as this will interfere with the <code>reboot</code> command (physical state vs software).</li>
<li>Provides charging from one of its port for RPi, meaning no separate source for <a href="http://www.raspberrypi.org/archives/260" title="Power supply confirmed as 5V micro USB" target="_blank">the exclusive 700 mA requirement</a>. A single AC power adapter with high current rating will fit all (check <a href="http://www.ianrolfe.com/raspberry-pi/keys-to-getting-the-pi-working/" title="Keys to getting the Pi working" target="_blank">single power connectivity sketch in this blog post</a>)</li>
</ul>
<p><span id="more-556"></span>An ugly situation when I plugged in WiFi stick and modem looks like:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">kernel: <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000;">1836.871640</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> smsc95xx <span style="color: #000000;">1</span>-<span style="color: #000000;">1.1</span>:<span style="color: #000000;">1.0</span>: eth0: Failed to <span style="color: #c20cb9; font-weight: bold;">read</span> register index 0x00000118
...
kernel: <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000;">1803.780601</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> phy0 -<span style="color: #000000; font-weight: bold;">&gt;</span> rt2x00usb_vendor_request: Error - Vendor Request 0x07 failed <span style="color: #000000; font-weight: bold;">for</span> offset 0x101c with error -110.</pre></div></div>

<p>tail of the above <code>syslog</code> is saying error with the (1) ethernet (<a href="http://www.raspberrypi.org/faqs" target="_blank">this is actually also a USB 2.0</a> but not appearing in <code>lsusb</code> command) and (2) the WiFi stick used (in this case with <a href="http://www.mediatek.com/_en/01_products/04_pro.php?sn=1007">RT5370 chipset</a>). Then, of course (3) doing things with the just plugged modem you&#8217;ll expect more instability.</p>
<p>I mentioned <a href="http://beagleboard.org/hardware-xm">BeagleBoard-xM</a> which also came with similar USB ethernet on-board. Unfortunately, Beagle was more stable when my case was to have it stream a zoom-camera input to internet (check <a href="https://www.youtube.com/watch?v=yFZoFsqAdS8" title="Zoom IP Camera Streaming &#038; Control on BeagleBoard (Over HSDPA Network)" target="_blank">my YouTube demo</a>). The camera decoder and modem were both USB plugged without Y-cable or additional power supply. As a standalone system, part of the design was to <code>reboot</code> under trouble detected by the software. Again, OS command <code>reboot</code> is not achievable consistently with the RPi when power backfeeds through USB port.</p>
<p>(PS: Note that previous comparison solely points out what to expect when dealing with USB among other considerations e.g. price, different ARM, etc. which are entirely different.)</p>
<p>As an absolute requirement for me, I found a powered USB-hub available in Indonesian market as <strong>7 ports XTec Go</strong>. Yes, it leaks power back as confirmed by the vendor-product ID <code>05e3:0608</code> of the chipset listed in <a href="http://elinux.org/RPi_VerifiedPeripherals" title="RPi Verified Peripherals" target="_blank">eLinux Wiki lists</a> with a bunch of different names (judging the picture, <a href="http://uk.shopping.com/Hama-USB2-0-HUB-1-7-M-NETZT-KA/info?sb=1" target="_blank">Hama</a> is closest).</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ lsusb
...
Bus 001 Device 004: ID 05e3:0608 Genesys Logic, Inc. USB-<span style="color: #000000;">2.0</span> <span style="color: #000000;">4</span>-Port HUB
Bus 001 Device 005: ID 05e3:0608 Genesys Logic, Inc. USB-<span style="color: #000000;">2.0</span> <span style="color: #000000;">4</span>-Port HUB
...</pre></div></div>

<div class="wp-caption aligncenter" style="width: 460px"><a href="http://www.flickr.com/photos/aqila_rifti/8581522699/" title="old HSDPA Huawei modem requiring no usb_modeswitch. Cheap USB hub Genesys chipset. WiFi stick. #Pi by aqila_rifti, on Flickr"><img src="http://farm9.staticflickr.com/8510/8581522699_b1bfcdf05f_n.jpg" width="300" height="300" alt="old HSDPA Huawei modem requiring no usb_modeswitch. Cheap USB hub Genesys chipset. WiFi stick. #Pi"></a><p class="wp-caption-text">Three Musketeers: powered USB-hub (Genesys chipset), Huawei E220 HSDPA modem, and TL-WN727N WiFi stick</p></div>
<p>My el cheapo USB-hub, HDSPA modem, and WiFi stick are the matchmaking of brands shown in the above image. It achieves long uptime like 6 hours serving internet when RPi used as router. I still use separate AC power adapter on the go with me: regular 700 mA that comes with smartphone will do for the RPi, while for the USB-hub, I have 2A rating from tablet charger. However, I&#8217;ve also plugged separate 500 mA charger for the hub without problem and/or excessive heat (you need to touch the supply sometime to feel any nasty heat as some of them might have been low quality build that could blow up. Yes it did). My plan with mobility is to have power bank with dual USB charging output (<a href="http://www.amazon.com/HAME-10400mAh-Double-Indicators-Capacity/dp/B00B5OFC5I" title="HAME MP1 10400mAh Power Bank Double USB Output 5V/1A &#038; 5V/2.1A 4 LED Indicators Show Power Level Full Capacity" target="_blank">this Hame has 1A and 2.1A</a>) when no AC source nears.</p>
<p>Have I tested other USB modem stick? Check <a href="../../../2013/03/modem-usb_modeswitch-raspberry-pi/" title="Modem usb_modeswitch in Raspberry Pi" target="_blank">my other post related to <code>usb_modeswitch</code></a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://lakm.us/logit/2013/03/raspberry-pi-common-usb-problems/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Raspberry Pi: Membrane (Matrix) Keypad as GPIO Input</title>
		<link>https://lakm.us/logit/2013/03/raspberry-pi-membrane-matrix-keypad-gpio-input-2/</link>
		<comments>https://lakm.us/logit/2013/03/raspberry-pi-membrane-matrix-keypad-gpio-input-2/#comments</comments>
		<pubDate>Wed, 13 Mar 2013 08:55:13 +0000</pubDate>
		<dc:creator>Arif</dc:creator>
				<category><![CDATA[ARM Linux]]></category>
		<category><![CDATA[ARMv6]]></category>
		<category><![CDATA[embedded system]]></category>
		<category><![CDATA[GPIO]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[Raspberry Pi]]></category>
		<category><![CDATA[shell script]]></category>

		<guid isPermaLink="false">http://lakm.us/logit/?p=533</guid>
		<description><![CDATA[Membrane matrix keypad using GPIO as Raspberry Pi input has been my goal since WiringPi deployed in the first place. To begin with, GPIO hacking was initially started with some important basics (see previous post). Without external system (other interfacing chip), the 3&#215;4 membrane keypad reserved all seven GPIO pins plus one pin used for [...]]]></description>
				<content:encoded><![CDATA[<p>Membrane matrix keypad using GPIO as <a href="http://www.raspberrypi.org" target="_blank">Raspberry Pi</a> input has been my goal since <em><a href="https://projects.drogon.net/raspberry-pi/wiringpi/" target="_blank">WiringPi</a></em> deployed in the first place. To begin with, GPIO hacking was initially started with some important basics (see <a href="./2013/03/raspberry-pi-gpio-input-button-basics-1/" target="_blank">previous post</a>). Without external system (other interfacing chip), the <a href="http://www.adafruit.com/products/419" title="Similar product from Adafruit: Membrane Matrix Keypad 3x4" target="_blank">3&#215;4 membrane keypa</a>d reserved all seven GPIO pins plus one pin used for LED indicating successful reading of pressed key.</p>
<p><time datetime="2014-02-09"><br />
<blockquote style="background-color:lightyellow;"><strong><em>Updated:</em></strong> for those who fail to build using <a href="https://github.com/WiringPi/WiringPi-Python" title="WiringPi-Python" target="_blank">deprecated WiringPi-Python</a>, check <a href="../../2013/03/raspberry-pi-gpio-input-button-basics-1/" title="Raspberry Pi GPIO Input Button Basics" target="_blank">this updated post</a> to know which commit that build without error. There is now also <a href="../../2014/02/any-m-x-n-matrix-keypad-raspberry-pi/" title="Any m-by-n Matrix Keypad for Raspberry Pi" target="_blank">a Python class for matrix keypad</a>.</p></blockquote>
<p></time></p>
<p>My idea of having the keypad is to make alternative input available under no keyboard presence nor shell access. List of things I can think of for instances, pressed key &#8220;0&#8243; will make the Raspberry Pi (RPi) dial GPRS to a specific ISP and act as router to the USB WiFi stick, pressed key &#8220;7&#8243; will convert it to a router that will bridge the ethernet to WiFi, etc. In short, those key readings will invoke subsequent scripts to run inside RPi.</p>
<p>The physical connection schematic drawings and code are gitified (visit <a href="https://github.com/bandono/matrixQPi/tree/v1.2" title="gitHub: matrixQPi v1.2" target="_blank">v1.2 of the project on gitHub</a>). A nice animated image on how the buttons connect pins forming a matrix can be found in <a href="http://www.hackyourmind.org/blog/rpi-hw-interfacing-the-raspberry-pi-with-matrix-keypad/" target="_blank">hackyourmind.org</a>.</p>
<div class="wp-caption aligncenter" style="width: 460px"><a href="http://www.flickr.com/photos/aqila_rifti/8541074196/" title="Raspberry #Pi membrane (matrix) keypad. Longer hours with the circuitry in fear of bricking it. The code took half day of work instead by aqila_rifti, on Flickr"><img src="http://farm9.staticflickr.com/8375/8541074196_a22dccbd2a.jpg" width="310" height="310" alt="Raspberry #Pi membrane (matrix) keypad. Longer hours with the circuitry in fear of bricking it. The code took half day of work instead"></a> <p class="wp-caption-text">Matrix keypad: alternative quick input for Raspberry Pi to start certain command</p></div>
<p>Some remarks over what the code does:<br />
<span id="more-533"></span></p>
<ul>
<li>It only read one pressed key at a time.</li>
<li>It uses no interrupt. To read input it must wait and scan (this waiting experience is by far negligible to human sense).</li>
<li>Debouncing doesn&#8217;t seem necessary as <em>WiringPi</em> already provided this by software (I suppose <a href="https://github.com/WiringPi/WiringPi/blob/master/examples/wfi.c" title="WiringPi: wfi.c" target="_blank">this timing method on their gitHub</a> deals with debounce).</li>
</ul>
<p>How it works? <a href="http://www.raspberrypi.org/phpBB3/viewtopic.php?t=30376&#038;p=291617" title="RPi Forum: Membrane Keypad Circuit Help" target="_blank">RPi forum thread</a> gives a general idea that applies in my case:</p>
<ol>
<li>Divide the 3&#215;4 matrix as columns and rows. 4 GPIO pins as rows are pulled-up with 10k resistors and initialized as input.</li>
<li>Other 3 GPIO pins as columns are initialized as output low.</li>
<li>First loop will scan for one pressed key being read as one of the rows pulled-low</li>
<li>After the loop breaks, all columns are set as input, then the row pin found in the loop is set as output-high</li>
<li>Second loop will scan for column being pulled-high by that row pin. Between both loops, it is assumed that the key press is still in effect. In reality, normal human act of pressing this key elapses long enough for the software to run the scans in two loops.</li>
<li>Bingo! The code reads row-column combination of the pressed key.</li>
</ol>
<p>Example of the code&#8217;s output by calling from shell:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #c20cb9; font-weight: bold;">true</span>; <span style="color: #000000; font-weight: bold;">do</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>matrixQPi.py -i; <span style="color: #000000; font-weight: bold;">done</span>
<span style="color: #000000;">3</span>
<span style="color: #000000;">6</span>
<span style="color: #000000;">9</span>
<span style="color: #000000;">8</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #000000; font-weight: bold;">*</span></pre></div></div>

<p>(In the above example <code>^C</code> will throw Python <code>KeyboardInterrupt</code> messages before  breaking the <code>bash</code> loop)</p>
]]></content:encoded>
			<wfw:commentRss>https://lakm.us/logit/2013/03/raspberry-pi-membrane-matrix-keypad-gpio-input-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Raspberry Pi GPIO Input Button Basics</title>
		<link>https://lakm.us/logit/2013/03/raspberry-pi-gpio-input-button-basics-1/</link>
		<comments>https://lakm.us/logit/2013/03/raspberry-pi-gpio-input-button-basics-1/#comments</comments>
		<pubDate>Mon, 11 Mar 2013 02:57:58 +0000</pubDate>
		<dc:creator>Arif</dc:creator>
				<category><![CDATA[ARM Linux]]></category>
		<category><![CDATA[ARMv6]]></category>
		<category><![CDATA[embedded system]]></category>
		<category><![CDATA[GPIO]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[Raspberry Pi]]></category>

		<guid isPermaLink="false">http://lakm.us/logit/?p=500</guid>
		<description><![CDATA[When you start hacking Raspberry Pi&#8217;s GPIO, first thing to keep in mind is the +3.3V CMOS logic level voltage despite the 5V supply. Secondly, read references about current limiting resistors (eLinux Wiki has a section there). What to avoid then? Try not to physically short the GPIO pin to ground when it is programmed [...]]]></description>
				<content:encoded><![CDATA[<p>When you start hacking Raspberry Pi&#8217;s GPIO, first thing to keep in mind is the +3.3V CMOS logic level voltage despite the 5V supply. Secondly, read references about current limiting resistors (eLinux Wiki has <a href="http://elinux.org/RPi_Tutorial_EGHS:Switch_Input" title="RPi_Tutorial_EGHS:Switch_Input" target="_blank">a section there</a>). What to avoid then? Try not to <strong>physically</strong> short the GPIO pin to ground when it is <strong>programmed</strong> as the opposite output-high.</p>
<p>GPIO pin logic state (meaning voltage) are both programmable and driven by physical-connection. I choose <em><a href="https://projects.drogon.net/raspberry-pi/wiringpi/" title="WiringPi" target="_blank">wiringPi</a></em> for practical reasons: availability of its <a href="https://github.com/WiringPi/WiringPi-Python" title="WiringPi-Python" target="_blank">Python wrapper</a> and its simple syntax (glancing it at first sight). <strong>WiringPi</strong> has an option of using its own pin numbering to address it in the code instead of the original GPIO numbering (there are board revisions to watch for in some cases of usage, not mine). Every pin can be initialized as input or output.</p>
<p><time datetime="2014-02-08"><br />
<blockquote style="background-color:lightyellow;"><strong><em>Updated:</em></strong> <a href="https://github.com/WiringPi/WiringPi-Python" title="WiringPi-Python" target="_blank">Wiring-Pi Python</a> is deprecated and moving to <a href="https://github.com/WiringPi/WiringPi2-Python" title="WiringPi2-Python" target="_blank">2.x version</a> that supports I/O expander. However, you can still find this combination of commits that will work and build without error message:</p>
<p>- main module: <a href="https://github.com/WiringPi/WiringPi-Python/tree/9c77bde53fb5fa6283268b4a529e47048f8a379d">WiringPi-Python@9c77bde</a><br />
- submodule: <a href="https://github.com/WiringPi/WiringPi/tree/89bbe97856407979fa75c4c793fabf4db839a0ee">WiringPi@89bbe97</a></p>
<p>(Check how to build on my <a href="https://github.com/bandono/matrixQPi/tree/v2.0" title="matrixQP v2.0" target="_blank">README</a>)</p></blockquote>
<p></time></p>
<p>Using an <a href="http://overseas.sanwa-meter.co.jp/items/detail.php?id=85" title="Sanwa Multimeter: DIY KIT-8D" target="_blank">analog multitester</a>, here are behavioral findings:</p>
<ul>
<li>GPIO pin voltage swings to high logic after reboot (the meter&#8217;s needle is rocking for a second or so). It is in low voltage afterward until being programmed or physically pulled-up.</li>
<li>Two pins, wiringPi pin 8 and 9, remain in high logic voltage after reboot. They are SDA0 and SCL0 to be used as an I²C, however they can be used to read button as well. (<a href="http://elinux.org/RPi_Low-level_peripherals" title="RPi low-level peripherals" target="_blank">eLinux Wiki</a>: &#8220;there are 1.8 k pulls up resistors on the board for these pins&#8221;)</li>
<li>I did short the high logic to ground accidentally, it invoked reboot. (I don&#8217;t know how many times or how long of this will brick the Raspberry Pi)</li>
</ul>
<p>Prior to trying the push-button switch, I didn&#8217;t have proper circuitry and working with wires as probes, prone to accident that was. I found an advice to insulate the +5V pin voltage so I could worry less.</p>
<div class="wp-caption aligncenter" style="width: 460px"><br />
<a href="http://www.flickr.com/photos/aqila_rifti/8440986498/" title="Raspbery Pi: Getting Started with GPIO Hack by aqila_rifti, on Flickr"><img src="http://farm9.staticflickr.com/8230/8440986498_5acd920148.jpg" width="300" height="300" alt="Raspbery Pi: Getting Started with GPIO Hack"></a><p class="wp-caption-text">Insulate the +5V pin of Raspberry Pi</p></div>
<p>A 10k pull-up resistor and a button are enough to test the following. Go to interactive Python shell and run line by line until the button push is read as low logic (GPIO7 in this example):</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;"># python</span>
Python 2.7.3rc2 <span style="color: black;">&#40;</span>default, May  <span style="color: #ff4500;">6</span> <span style="color: #ff4500;">2012</span>, <span style="color: #ff4500;">20</span>:02:<span style="color: #ff4500;">25</span><span style="color: black;">&#41;</span> 
<span style="color: black;">&#91;</span>GCC 4.6.3<span style="color: black;">&#93;</span> on linux2
Type <span style="color: #483d8b;">&quot;help&quot;</span>, <span style="color: #483d8b;">&quot;copyright&quot;</span>, <span style="color: #483d8b;">&quot;credits&quot;</span> <span style="color: #ff7700;font-weight:bold;">or</span> <span style="color: #483d8b;">&quot;license&quot;</span> <span style="color: #ff7700;font-weight:bold;">for</span> more information.
<span style="color: #66cc66;">&gt;&gt;&gt;</span> <span style="color: #ff7700;font-weight:bold;">import</span> wiringpi
<span style="color: #66cc66;">&gt;&gt;&gt;</span> <span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">time</span>
<span style="color: #66cc66;">&gt;&gt;&gt;</span> INPUT=<span style="color: #ff4500;">0</span>
<span style="color: #66cc66;">&gt;&gt;&gt;</span> OUTPUT=<span style="color: #ff4500;">1</span>
<span style="color: #66cc66;">&gt;&gt;&gt;</span> HIGH=<span style="color: #ff4500;">1</span>
<span style="color: #66cc66;">&gt;&gt;&gt;</span> LOW=<span style="color: #ff4500;">0</span>
<span style="color: #66cc66;">&gt;&gt;&gt;</span> SETUP=wiringpi.<span style="color: black;">wiringPiSetup</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
<span style="color: #66cc66;">&gt;&gt;&gt;</span> <span style="color: #ff7700;font-weight:bold;">print</span> SETUP
<span style="color: #ff4500;">0</span>
<span style="color: #66cc66;">&gt;&gt;&gt;</span> wiringpi.<span style="color: black;">pinMode</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">7</span>,INPUT<span style="color: black;">&#41;</span>
<span style="color: #66cc66;">&gt;&gt;&gt;</span> RESULT=wiringpi.<span style="color: black;">digitalRead</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">7</span><span style="color: black;">&#41;</span>
<span style="color: #66cc66;">&gt;&gt;&gt;</span> <span style="color: #ff7700;font-weight:bold;">print</span> RESULT
<span style="color: #ff4500;">1</span>
<span style="color: #66cc66;">&gt;&gt;&gt;</span> RESULT=wiringpi.<span style="color: black;">digitalRead</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">7</span><span style="color: black;">&#41;</span>
<span style="color: #66cc66;">&gt;&gt;&gt;</span> <span style="color: #ff7700;font-weight:bold;">print</span> RESULT
<span style="color: #ff4500;">1</span>
<span style="color: #66cc66;">&gt;&gt;&gt;</span> RESULT=wiringpi.<span style="color: black;">digitalRead</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">7</span><span style="color: black;">&#41;</span>
<span style="color: #66cc66;">&gt;&gt;&gt;</span> <span style="color: #ff7700;font-weight:bold;">print</span> RESULT
<span style="color: #ff4500;">0</span>
<span style="color: #66cc66;">&gt;&gt;&gt;</span></pre></div></div>

<p>These basics convince me to go ahead with my goal of having a <a href="http://www.adafruit.com/products/419" title="Adafruit: Membrane Matrix Keypad 3x4" target="_blank">membrane (matrix) keypad</a> as input for Raspberry Pi to run some script (see <a href="../../../2013/03/raspberry-pi-membrane-matrix-keypad-gpio-input-2/" title="Raspberry Pi: Membrane (Matrix) Keypad as GPIO Input" target="_blank">next post</a>).</p>
<p>(Check also <a href="./2013/03/raspberry-pi-common-usb-problems/" title="Raspberry Pi Common USB Problems" target="_blank">RPi common USB problems post</a>)</p>
]]></content:encoded>
			<wfw:commentRss>https://lakm.us/logit/2013/03/raspberry-pi-gpio-input-button-basics-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cross-Compiling for Ubuntu ARM by ffmpeg Example</title>
		<link>https://lakm.us/logit/2012/11/cross-compiling-ubuntu-arm-ffmpeg/</link>
		<comments>https://lakm.us/logit/2012/11/cross-compiling-ubuntu-arm-ffmpeg/#comments</comments>
		<pubDate>Mon, 05 Nov 2012 10:02:03 +0000</pubDate>
		<dc:creator>Arif</dc:creator>
				<category><![CDATA[ARM Linux]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[ARMv7]]></category>
		<category><![CDATA[BeagleBoard]]></category>
		<category><![CDATA[compile]]></category>
		<category><![CDATA[ffmpeg]]></category>
		<category><![CDATA[make-install]]></category>

		<guid isPermaLink="false">http://lakm.us/logit/?p=409</guid>
		<description><![CDATA[This has been a delayed post since I only figure out how to solve configure error just now. It wasn&#8217;t really necessary to cross-compile last year because compiling ffmpeg directly on the ARM-board finished overnight (despite the low CPU). Anyway, in this post I&#8217;m still using the board to easily retrieve package dependencies from Ubuntu [...]]]></description>
				<content:encoded><![CDATA[<p>This has been a delayed post since I only figure out how to solve <code>configure</code> error just now. It wasn&#8217;t really necessary to cross-compile last year because compiling <code><a href="https://ffmpeg.org/" title="FFMPEG" target="_blank">ffmpeg</a></code> directly on the ARM-board finished overnight (despite the low CPU). Anyway, in this post I&#8217;m still using the board to easily retrieve package dependencies from Ubuntu ARM repository. Toolchain used is <code>arm-linux-gnueabi-gcc-</code>. The following steps will apply in general:</p>
<ol>
<li> download source file (that is <code>ffmpeg</code> in this example)</li>
<li>retrieve development library/build dependecies</li>
<li>place header files and dependency libraries into toolchain path</li>
<li><code>configure</code> with toolchain</li>
<li><code>make</code> and create <code>.deb</code> installer package with <code>checkinstall</code></li>
</ol>
<div class="wp-caption aligncenter" style="width: 460px"><img alt="cross-compile-desktop-and-arm-board-illustration.png" src="../../../../images/cross-compile-desktop-and-arm-board-illustration.png" title="cross-compile: what&#039;s done on desktop &#038; what&#039;s done on ARM-board" width="350" height="207" /><p class="wp-caption-text">cross-compile: Illustration of what&#039;s done on ARM-board and what&#039;s  done on desktop</p></div>
<p>Prior to anything, install <a href="http://www.linaro.org/" title="Linaro" target="_blank">Linaro</a> toolchain by adding their repo first:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> add-apt-repository ppa:linaro-maintainers<span style="color: #000000; font-weight: bold;">/</span>toolchain
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> gcc-arm-linux-gnueabi</pre></div></div>

<p>A complete guide on how to compile ffmpeg can be found in their <a href="https://ffmpeg.org/trac/ffmpeg/wiki/UbuntuCompilationGuideLucid" title="Compile FFmpeg on Ubuntu Lucid Lynx 10.04 LTS" target="_blank">wiki</a>. It applies generally. So, I&#8217;ll just skip to following <code>configure</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>ubuntu-desktop<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ .<span style="color: #000000; font-weight: bold;">/</span>configure <span style="color: #660033;">--cross-prefix</span>=arm-linux-gnueabi- <span style="color: #660033;">--enable-cross-compile</span> <span style="color: #660033;">--target-os</span>=linux <span style="color: #660033;">--arch</span>=arm  <span style="color: #660033;">--cpu</span>=cortex-a8 <span style="color: #660033;">--extra-cflags</span>=<span style="color: #ff0000;">'-march=armv7-a -mfpu=neon -mfloat-abi=softfp'</span> <span style="color: #660033;">--enable-libtheora</span></pre></div></div>

<p><span id="more-409"></span></p>
<p>As an example, the above configure requires <a href="http://www.theora.org/downloads/" title="Theora" target="_blank">Theora</a> libraries. <code><a href="http://packages.ubuntu.com/lucid/libtheora-dev" title="http://packages.ubuntu.com/oneiric/libtheora-dev" target="_blank">libtheora-dev</a></code> itself requires <code>libogg-dev</code>. Use <code>apt-get</code> on the board to get them from Ubuntu ARM repository. Get the <code>.deb</code> files from <code>/var/cache/apt/archives/</code> of the ARM-board to your desktop and extract them as <code>root</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>ubuntu-desktop<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ <span style="color: #c20cb9; font-weight: bold;">dpkg</span> <span style="color: #660033;">-x</span> libogg-dev_1.2.2~dfsg-1ubuntu1_armel.deb <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>cross-compile
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>ubuntu-desktop<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ <span style="color: #c20cb9; font-weight: bold;">dpkg</span> <span style="color: #660033;">-x</span> libtheora-dev_1.1.1+dfsg.1-<span style="color: #000000;">3</span>_armel.deb <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>cross-compile</pre></div></div>

<p>The above <code>/usr/local/cross-compile</code> is just a temporary directory. The toolchain needs header files and dependency libraries to be placed inside <code>/usr/arm-linux-gnueabi/include/</code> and <code>/usr/arm-linux-gnueabi/lib/</code> consecutively. In my case I created the following link for header&#8217;s <code>include</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>ubuntu-desktop<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>arm-linux-gnueabi<span style="color: #000000; font-weight: bold;">/</span>include
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>ubuntu-desktop<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ <span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>cross-compile<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>theora
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>ubuntu-desktop<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ <span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>cross-compile<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>ogg</pre></div></div>

<p>and copied these from <code>/usr/local/cross-compile/usr/lib</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">libogg.a
libogg.so
libtheora.a
libtheoradec.a
libtheoradec.la
libtheoradec.so
libtheoraenc.a
libtheoraenc.la
libtheoraenc.so
libtheora.la
libtheora.so</pre></div></div>

<p>After successful <code>configure</code>, run <code>make</code> (this will take some time), and then pack the whole working directory to the ARM-board. Instead of doing <code>make install</code> in the ARM-board, use <code>checkinstall</code> to install and create the <code>.deb</code> package. This way we can make use of <code>dpkg</code> to uninstall or re-install in the manner of package manager.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>beagleboard<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> checkinstall <span style="color: #660033;">--pkgname</span>=<span style="color: #c20cb9; font-weight: bold;">ffmpeg</span> <span style="color: #660033;">--pkgversion</span>=<span style="color: #ff0000;">&quot;5:<span style="color: #007800;">$(./version.sh)</span>&quot;</span> \
     <span style="color: #660033;">--backup</span>=no <span style="color: #660033;">--deldoc</span>=<span style="color: #c20cb9; font-weight: bold;">yes</span> <span style="color: #660033;">--default</span></pre></div></div>

<p>Please mind that even if we put &#8220;<code>--install=no</code>&#8220;, the above <code>checkinstall</code> will overwrite all <code>ffmpeg</code> binaries in <code>/usr/local/bin/</code>. This is the reason why I move the process to the ARM-board: to keep other running version on my desktop stays as it is.</p>
<p>Check the test of streaming from our cross-compiled <code>ffmpeg</code> in previous <a href="./2012/11/simple-ffmpeg-udp-video-streaming-from-beagleboard-running-ubuntu" title="Simple FFMPEG UDP Video Streaming" target="_blank">post</a>.</p>
<h1>A Little History</h1>
<p>When first attempt to <code>configure</code> exited with <code>ERROR: libtheora not found</code>, I found the following test failed in the output log:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">$ arm<span style="color: #339933;">-</span>linux<span style="color: #339933;">-</span>gnueabi<span style="color: #339933;">-</span>gcc <span style="color: #339933;">-</span>D_ISOC99_SOURCE <span style="color: #339933;">-</span>D_FILE_OFFSET_BITS<span style="color: #339933;">=</span><span style="color: #0000dd;">64</span> <span style="color: #339933;">-</span>D_LARGEFILE_SOURCE <span style="color: #339933;">-</span>D_POSIX_C_SOURCE<span style="color: #339933;">=</span><span style="color: #0000dd;">200112</span> <span style="color: #339933;">-</span>D_XOPEN_SOURCE<span style="color: #339933;">=</span><span style="color: #0000dd;">600</span> <span style="color: #339933;">-</span>march<span style="color: #339933;">=</span>armv7<span style="color: #339933;">-</span>a <span style="color: #339933;">-</span>mfpu<span style="color: #339933;">=</span>neon <span style="color: #339933;">-</span>mfloat<span style="color: #339933;">-</span>abi<span style="color: #339933;">=</span>softfp <span style="color: #339933;">-</span>mcpu<span style="color: #339933;">=</span>cortex<span style="color: #339933;">-</span>a8 <span style="color: #339933;">-</span>std<span style="color: #339933;">=</span>c99 <span style="color: #339933;">-</span>fomit<span style="color: #339933;">-</span>frame<span style="color: #339933;">-</span>pointer <span style="color: #339933;">-</span>marm <span style="color: #339933;">-</span>pthread <span style="color: #339933;">-</span>E <span style="color: #339933;">-</span>o <span style="color: #339933;">/</span>tmp<span style="color: #339933;">/</span>ffconf.<span style="color: #202020;">UdYctJgq</span>.<span style="color: #202020;">o</span> <span style="color: #339933;">/</span>tmp<span style="color: #339933;">/</span>ffconf.<span style="color: #202020;">mwXpf9Tl</span>.<span style="color: #202020;">c</span>
...
<span style="color: #339933;">/</span>usr<span style="color: #339933;">/</span>lib<span style="color: #339933;">/</span>gcc<span style="color: #339933;">/</span>arm<span style="color: #339933;">-</span>linux<span style="color: #339933;">-</span>gnueabi<span style="color: #339933;">/</span>4.6.1<span style="color: #339933;">/</span>..<span style="color: #339933;">/</span>..<span style="color: #339933;">/</span>..<span style="color: #339933;">/</span>..<span style="color: #339933;">/</span>arm<span style="color: #339933;">-</span>linux<span style="color: #339933;">-</span>gnueabi<span style="color: #339933;">/</span>bin<span style="color: #339933;">/</span>ld<span style="color: #339933;">:</span> cannot find <span style="color: #339933;">-</span>ltheoraenc
<span style="color: #339933;">/</span>usr<span style="color: #339933;">/</span>lib<span style="color: #339933;">/</span>gcc<span style="color: #339933;">/</span>arm<span style="color: #339933;">-</span>linux<span style="color: #339933;">-</span>gnueabi<span style="color: #339933;">/</span>4.6.1<span style="color: #339933;">/</span>..<span style="color: #339933;">/</span>..<span style="color: #339933;">/</span>..<span style="color: #339933;">/</span>..<span style="color: #339933;">/</span>arm<span style="color: #339933;">-</span>linux<span style="color: #339933;">-</span>gnueabi<span style="color: #339933;">/</span>bin<span style="color: #339933;">/</span>ld<span style="color: #339933;">:</span> cannot find <span style="color: #339933;">-</span>ltheoradec
<span style="color: #339933;">/</span>usr<span style="color: #339933;">/</span>lib<span style="color: #339933;">/</span>gcc<span style="color: #339933;">/</span>arm<span style="color: #339933;">-</span>linux<span style="color: #339933;">-</span>gnueabi<span style="color: #339933;">/</span>4.6.1<span style="color: #339933;">/</span>..<span style="color: #339933;">/</span>..<span style="color: #339933;">/</span>..<span style="color: #339933;">/</span>..<span style="color: #339933;">/</span>arm<span style="color: #339933;">-</span>linux<span style="color: #339933;">-</span>gnueabi<span style="color: #339933;">/</span>bin<span style="color: #339933;">/</span>ld<span style="color: #339933;">:</span> cannot find <span style="color: #339933;">-</span>logg</pre></div></div>

<p>What was inside the above temporary file (<code>/tmp/ffconf.mwXpf9Tl.c</code>):</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#include &lt;theora/theoraenc.h&gt;</span>
<span style="color: #993333;">int</span> x<span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>You can run that test to check whether all dependencies are met.</p>
]]></content:encoded>
			<wfw:commentRss>https://lakm.us/logit/2012/11/cross-compiling-ubuntu-arm-ffmpeg/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Simple ffmpeg UDP Video Streaming (from BeagleBoard running Ubuntu)</title>
		<link>https://lakm.us/logit/2012/11/simple-ffmpeg-udp-video-streaming-from-beagleboard-running-ubuntu/</link>
		<comments>https://lakm.us/logit/2012/11/simple-ffmpeg-udp-video-streaming-from-beagleboard-running-ubuntu/#comments</comments>
		<pubDate>Mon, 05 Nov 2012 09:04:49 +0000</pubDate>
		<dc:creator>Arif</dc:creator>
				<category><![CDATA[ARM Linux]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[ARMv7]]></category>
		<category><![CDATA[BeagleBoard]]></category>
		<category><![CDATA[ffmpeg]]></category>
		<category><![CDATA[streaming]]></category>
		<category><![CDATA[VLC]]></category>

		<guid isPermaLink="false">http://lakm.us/logit/?p=406</guid>
		<description><![CDATA[I really mean simple, this is a one command line UDP stream from the BeagleBoard (running Ubuntu ARM) to my desktop (IP address 192.168.1.19 in this example), the source video is an FLV file inside the ARM-board: $ ffmpeg -i UNIQLO_MIXPLAY.flv -v 0 -vcodec mpeg4 -f mpegts udp:192.168.1.19:1234 Although it&#8217;s a break-dance video, it plays [...]]]></description>
				<content:encoded><![CDATA[<p>I really mean simple, this is a one command line UDP stream from the BeagleBoard (running Ubuntu ARM) to my desktop (IP address <code>192.168.1.19</code> in this example), the source video is an FLV file inside the ARM-board:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">ffmpeg</span> <span style="color: #660033;">-i</span> UNIQLO_MIXPLAY.flv <span style="color: #660033;">-v</span> <span style="color: #000000;">0</span> <span style="color: #660033;">-vcodec</span> mpeg4 <span style="color: #660033;">-f</span> mpegts udp:192.168.1.19:<span style="color: #000000;">1234</span></pre></div></div>

<div class="wp-caption aligncenter" style="width: 460px"><img alt="ffmpeg-cross-compiled-flv-video-udp-streaming-test.jpg" src="../../../../images/ffmpeg-cross-compiled-flv-video-udp-streaming-test.jpg" title="ffmpeg streaming from BeagleBoard played by VLC on the desktop" width="420" height="365" /><p class="wp-caption-text">ffmpeg streaming from BeagleBoard played by VLC on the desktop</p></div>
<p>Although it&#8217;s a break-dance video, it plays uninterrupted, without any break. </p>
<p>Here is how my desktop see the stream with <a href="http://www.videolan.org/vlc/" title="VLC" target="_blank">VLC player</a>:</p>
<div class="wp-caption aligncenter" style="width: 460px"><img alt="vlc-simple-udp-stream-test.png" src="../../../../images/vlc-simple-udp-stream-test.png" title="VLC setup (on the desktop) to play the UDP stream" width="354" height="100" /><p class="wp-caption-text">VLC setup (on the desktop) to play the UDP stream</p></div>
<p>With less documentation, a more complex setup with integration to <a href="http://www.wowza.com/" title="Wowza" target="_blank">Wowza Media Server</a> is available on my <a href="https://github.com/bandono/zoom-camera-board" title="zoom camera board" target="_blank">github</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://lakm.us/logit/2012/11/simple-ffmpeg-udp-video-streaming-from-beagleboard-running-ubuntu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zabbix Proxy: distributed NMS monitoring via embedded Linux (Ubuntu on BeagleBoard)</title>
		<link>https://lakm.us/logit/2012/07/zabbix-proxy-distributed-nms-monitoring-embedded-linux-ubuntu-beagleboard/</link>
		<comments>https://lakm.us/logit/2012/07/zabbix-proxy-distributed-nms-monitoring-embedded-linux-ubuntu-beagleboard/#comments</comments>
		<pubDate>Thu, 19 Jul 2012 07:26:15 +0000</pubDate>
		<dc:creator>Arif</dc:creator>
				<category><![CDATA[ARM Linux]]></category>
		<category><![CDATA[ARMv7]]></category>
		<category><![CDATA[BeagleBoard]]></category>
		<category><![CDATA[embedded system]]></category>
		<category><![CDATA[OSS]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[snmp]]></category>
		<category><![CDATA[Zabbix]]></category>

		<guid isPermaLink="false">http://lakm.us/logit/?p=404</guid>
		<description><![CDATA[As already mentioned in previous post&#8217;s introduction, proof of concept on how Zabbix Proxy works under unreliable communication is what this next post about. The idea is to have these scenarios tested: independent SNMP data polling by individual NMS proxy (embedded system) intermittent connection between main/master NMS server with its proxy Of course we&#8217;ll do [...]]]></description>
				<content:encoded><![CDATA[<p>As already mentioned in <a href="./2012/07/compile-zabbix-proxy-ubuntu-arm-beagleboard/" title="Compile Zabbix Proxy in Ubuntu ARM (BeagleBoard)" target="_blank">previous post&#8217;s</a> introduction, proof of concept on how <a href="http://www.zabbix.com/documentation/1.8/manual/processes/zabbix_proxy" title="Zabbix Proxy" target="_blank">Zabbix Proxy</a> works under unreliable communication is what this next post about. The idea is to have these scenarios tested:</p>
<ol>
<li>independent SNMP data polling by individual NMS proxy (embedded system)</li>
<li>intermittent connection between main/master NMS server with its proxy</li>
</ol>
<p>Of course we&#8217;ll do them in implementation context of <a href="http://www.zabbix.com/documentation/1.8/manual/processes/zabbix_server" title="Zabbix Server" target="_blank">Zabbix Server</a> as main/master NMS server and our <a href="http://beagleboard.org/hardware-xM/" target="_blank">BeagleBoard xM</a> as its proxy.</p>
<div class="wp-caption aligncenter" style="width: 460px"><img alt="zabbix-proxy-routine-log-abstract-illustration.jpg" src="../../../../images/zabbix-proxy-routine-log-abstract-illustration.jpg" title="Zabbix Proxy - distributed NMS over embedded Linux" width="380" height="293" /><p class="wp-caption-text">Zabbix Proxy - distributed NMS over embedded Linux</p></div>
<p>In the technical details, I already followed pretty much the same steps showed in <a href="http://www.zabbix.com/wiki/howto/install/debian/zabbix_proxy_on_debian_sqlite" target="_blank">installation wiki</a> (with the exception that I didn&#8217;t put the process into startup <code>init.d</code> script as I would start it manually as needed).</p>
<p>The first test is to make our Ubuntu ARM board accepts configuration done in Zabbix Server web-GUI, retrieves SNMP data to it, and sends collected data to server. Mode passive is chosen so that the server will be the one initiating contact with the board. After enabling a certain SNMP host, i.e. <code>host-aaa</code>, as monitored-by-proxy, the Zabbix Server log will show:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000;">15677</span>:<span style="color: #000000;">20120601</span>:<span style="color: #000000;">022022.960</span> Sending configuration data to proxy <span style="color: #ff0000;">'beaglexm1'</span>. Datalen <span style="color: #000000;">9205</span></pre></div></div>

<p>Our board, &#8216;<code>beaglexm1</code>&#8216;, will start to poll SNMP data from <code>host-xxx</code> to then store it in designated <code>sqlite</code> database.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000;">975</span>:<span style="color: #000000;">20120531</span>:<span style="color: #000000;">212024.098</span> proxy <span style="color: #666666; font-style: italic;">#8 started [poller #5]</span>
<span style="color: #000000;">984</span>:<span style="color: #000000;">20120531</span>:<span style="color: #000000;">212024.128</span> proxy <span style="color: #666666; font-style: italic;">#17 started [discoverer #1]</span>
<span style="color: #000000;">968</span>:<span style="color: #000000;">20120531</span>:<span style="color: #000000;">212025.423</span> Received configuration data from server. Datalen <span style="color: #000000;">9205</span>
<span style="color: #000000;">971</span>:<span style="color: #000000;">20120531</span>:<span style="color: #000000;">212030.388</span> Enabling SNMP host <span style="color: #7a0874; font-weight: bold;">&#91;</span>host-aaa<span style="color: #7a0874; font-weight: bold;">&#93;</span></pre></div></div>

<p>From time to time as configured, our board will also run housekeeping to keep our board database file in small size.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000;">1081</span>:<span style="color: #000000;">20120531</span>:<span style="color: #000000;">224513.922</span> Executing housekeeper
<span style="color: #000000;">1081</span>:<span style="color: #000000;">20120531</span>:<span style="color: #000000;">224514.505</span> Deleted <span style="color: #000000;">4885</span> records from <span style="color: #7a0874; font-weight: bold;">history</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">0.453765</span> seconds<span style="color: #7a0874; font-weight: bold;">&#93;</span></pre></div></div>

<p>Under normal connection, in main Zabbix Server we&#8217;ll start seeing the collected data from <code>host-aaa</code> the same way as when the SNMP data is polled by the server directly. To emulate disruption to the connectivity, I choose to use simple <code>iptables</code> drop packet. This time the server will no longer seeing new data.</p>
<p>After the drop block is released, the server we&#8217;ll start seeing new data as well as data from the period of intermittent connection. It will take some time before all of that being sent to the server.</p>
<p>In general that proves it. I collected 44 OID values from the <code>host-aaa</code> every 30 seconds and in this case BeagleBoard utilization was very low as this wasn&#8217;t a stress test to see its performance. </p>
]]></content:encoded>
			<wfw:commentRss>https://lakm.us/logit/2012/07/zabbix-proxy-distributed-nms-monitoring-embedded-linux-ubuntu-beagleboard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
