<?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</title>
	<atom:link href="https://lakm.us/logit/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>Nebri Automation for Weather Feed to Twitter</title>
		<link>https://lakm.us/logit/2015/06/nebri-automation-weather-feed-twitter/</link>
		<comments>https://lakm.us/logit/2015/06/nebri-automation-weather-feed-twitter/#comments</comments>
		<pubDate>Tue, 02 Jun 2015 14:13:39 +0000</pubDate>
		<dc:creator>Arif</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[job automation]]></category>
		<category><![CDATA[monitoring]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[socialmedia]]></category>
		<category><![CDATA[wearable]]></category>

		<guid isPermaLink="false">http://lakm.us/logit/?p=842</guid>
		<description><![CDATA[The season was intermittently rainy or dry as I began to take interest in weather. After getting stuck with “If-this-than-that” (IFTTT) for multiple location feeds of weather, I found out that I wasn&#8217;t alone, a geek hit the same wall, yet bringing another automation forgery: Nebri OS, an event-driven development platform based-on writing rules in [...]]]></description>
				<content:encoded><![CDATA[<p>The season was intermittently rainy or dry as I began to take interest in weather. After getting stuck with <a href="https://ifttt.com/" title="IFTTT" target="_blank">“If-this-than-that” (IFTTT)</a> for multiple location feeds of weather, I found out that I wasn&#8217;t alone, a geek hit the same wall, yet bringing another automation forgery: <a href="https://nebrios.com/" title="Nebri: Event-driven development platform" target="_blank">Nebri OS</a>, an event-driven development platform based-on writing rules in <a href="https://www.python.org/" title="Python" target="_blank">Python</a>. Without despise, eventually I still use IFTTT on the other end to send weather alert to my smartwatch <a href="../../../2015/01/commuter-train-trouble-alert-delivered-watch-ifttt/" title="Get Commuter Train Trouble Alert Delivered to Watch by IFTTT" target="_blank">again</a>.</p>
<p>A quick adaptation of <a href="https://nebrios.com/blog/weather-alerts-in-multiple-locations" title="Weather Alerts In Multiple Locations" target="_blank">Nebri&#8217;s straightforward blog post</a> is to first shortlist rain related codes into <a href="https://github.com/bandono/nebri/blob/master/tweet_rain/README.md" title="README.md" target="_blank">15 of them</a> and changing from forecast to latest measurement instead. Bridging Nebri and <a href="http://www.cookoo2.com/" title="COOKOO 2" target="_blank">my smartwatch</a> are <a href="https://twitter.com/" title="Twitter" target="_blank">Twitter</a> and <a href="https://ifttt.com/recipes/296352-bogor-jakarta-rain-weather-alert" title="Bogor-Jakarta rain weather alert " target="_blank">IFTTT recipe</a>–the watch merely mirrored my phone, you don&#8217;t need it actually. Why (again) Twitter? Well, rather than the &#8220;then that&#8221; side–the watch enabler, the &#8220;if this&#8221; side of IFTTT for Twitter recipes is quite powerful given so many tweet filtering options.</p>
<p><div class="wp-caption aligncenter" style="width: 460px"><img alt="Nebri OS workflow from YWeather to Twitter" src="../../../../images/nebrios-event-driven-workflow-illustration.png" title="Nebri OS workflow from YWeather to Twitter" width="320" height="262" /><p class="wp-caption-text">Key-value pairs as trigger for event driven Nebri OS workflow</p></div><br />
<span id="more-842"></span><br />
The workflow starts with Drips, a scheduler (<code>cron</code>) where key value-pairs (KVP) is created at certain time. A rule script (<code>yweather</code>) is triggered when this KVP is created. The weather results are sets of later KVPs feeding the <code>twitter</code> rule script where our simple Nebri workflow ends. This is how I get multiple cities, by using different Drips, different events, running the same workflow. Both <code>yweather</code> and <code>twitter</code> scripts are also example of API connectivity to Nebri.</p>
<p>Many things already taken care by Nebri, hence unseasoned programmer should easily cope with writing simple Python rule and focus on the automation, nevertheless complex rule should also be accommodated. I was having trouble on using previous KVP from different PID though–moved them to comment in the script, but they seem to be <a href="https://nebrios.com/blog/releases-2689" title="Releases 2689" target="_blank">working on it</a>. Check their <a href="https://nebrios.com/blog/weather-alerts-in-multiple-locations" title="Weather Alerts In Multiple Locations" target="_blank">YWeather blog post</a> on how the basics work and compare <a href="https://github.com/bandono/nebri/tree/master/tweet_rain" title="Nebri: tweet rain Github" target="_blank">what I did in Github</a>. I embed an example tweet from <a href="https://twitter.com/twithujan" title="@twithujan" target="_blank">@twithujan</a> below. <a href="https://weather.yahoo.com/" title="Yahoo! Weather" target="_blank">Yahoo! Weather</a> frequency of measurement and accuracy are of different topic by the way.</p>
<blockquote class="twitter-tweet" lang="en"><p lang="en" dir="ltr">Bogor is Light Rain with temperature at 23 °C. Taken at Thu, 28 May 2015 7:00 pm WIT</p>
<p>&mdash; Twit Hujan (@twithujan) <a href="https://twitter.com/twithujan/status/603908598314434560">May 28, 2015</a></p></blockquote>
<p><script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script></p>
<p>PS: &#8220;<em>hujan</em>&#8221; means &#8220;rain&#8221; in Indonesian</p>
]]></content:encoded>
			<wfw:commentRss>https://lakm.us/logit/2015/06/nebri-automation-weather-feed-twitter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get Commuter Train Trouble Alert Delivered to Watch by IFTTT</title>
		<link>https://lakm.us/logit/2015/01/commuter-train-trouble-alert-delivered-watch-ifttt/</link>
		<comments>https://lakm.us/logit/2015/01/commuter-train-trouble-alert-delivered-watch-ifttt/#comments</comments>
		<pubDate>Sat, 17 Jan 2015 14:31:02 +0000</pubDate>
		<dc:creator>Arif</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Web Apps]]></category>
		<category><![CDATA[application]]></category>
		<category><![CDATA[job automation]]></category>
		<category><![CDATA[monitoring]]></category>
		<category><![CDATA[socialmedia]]></category>
		<category><![CDATA[wearable]]></category>
		<category><![CDATA[web-based]]></category>

		<guid isPermaLink="false">http://lakm.us/logit/?p=803</guid>
		<description><![CDATA[Imagine getting alerts of Commuter Line train service disruption right on your wrist! Well, the watch thing isn&#8217;t a must as any SMS-enabled phone will do. But without the watch, I won&#8217;t be introduced to &#8220;If-this-than-that&#8221; (IFTTT), a simple logic line that glues popular apps into trigger and action branded as recipes. Anyone can code [...]]]></description>
				<content:encoded><![CDATA[<p>Imagine getting alerts of Commuter Line train service disruption right on your wrist! Well, the watch thing isn&#8217;t a must as any SMS-enabled phone will do. But without the watch, I won&#8217;t be introduced to <a href="http://techcrunch.com/2014/08/28/ifttt-lands-30-million-series-b-from-norwest-venture-partners-a16z/" title="IFTTT Lands $30 Million Series B From Norwest Venture Partners, A16Z" target="_blank">&#8220;If-this-than-that&#8221;</a> (IFTTT), a simple logic line that glues popular apps into trigger and action branded as <a href="https://ifttt.com/recipes" title="IFTTT - Browse Recipes" target="_blank">recipes</a>. Anyone can code that line, a no-coding logic that cooks: <a href="https://ifttt.com/recipes/184610-natgeo-instagrams-wallpaper" title="IFTTT - NatGeo Instagrams - Wallpaper" target="_blank">sync wallpaper with Nat Geo&#8217; instagram</a>, <a href="https://ifttt.com/recipes/168783-so-mom-doesn-t-call-too-many-times" title="IFTTT - So mom doesn't call too many times" target="_blank">volume goes up when Mom calls</a>, <a href="https://ifttt.com/recipes/165588-change-the-color-of-the-lights-when-the-space-station-flies-over-a-specific-location" title="IFTTT - Change the color of the lights when the Space Station flies over a specific location" target="_blank">change bulb light color after some space station moves</a>, etc. As personal recipe, bring <a href="https://www.kickstarter.com/projects/cuckoo/cookootm-the-watch-for-the-connected-generation" title="KickStarter - cookoo™ - the watch for the connected generation" target="_blank">COOKOO connected watch</a> to the table and I&#8217;ve leveraged public service disruption–no matter how ironic–into edgy personal business.</p>
<div class="wp-caption aligncenter" style="width: 460px"><img alt="" src="../../../../images/ifttt-commuter-line-trouble-notifications.png" title="If this than that recipes alert for Commuter Train trouble" width="450" height="211" /><p class="wp-caption-text">If this than that recipes alert for Commuter Train trouble</p></div>
<p>The ingredient is tweet, <a href="https://twitter.com/search" title="Twitter Search" target="_blank">Twitter Search</a> use case is no longer just sentiment analysis, its function extends to alert, even close to real time–I&#8217;m pretty optimistic given the number of Commuter Line users joining the conversation. Now, the no-code part of our recipe, a <a href="https://twitter.com/search?f=realtime&#038;q=%28to%3Akrlmania%20OR%20%40krlmania%20OR%20from%3ACommuterLine%29%20AND%20%28gangguan%20OR%20pantograf%20OR%20wesel%20OR%20patah%29%20-semoga%20-smoga%20-moga&#038;src=typd" title="Twitter Search - Commuter Line Trouble" target="_blank">Twitter search query</a>, that is</p>
<p><span id="more-803"></span></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#40;</span>to:krlmania OR <span style="color: #000000; font-weight: bold;">@</span>krlmania OR from:CommuterLine<span style="color: #7a0874; font-weight: bold;">&#41;</span>
AND <span style="color: #7a0874; font-weight: bold;">&#40;</span>gangguan OR pantograf OR wesel OR patah<span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #660033;">-semoga</span> <span style="color: #660033;">-smoga</span> <span style="color: #660033;">-moga</span></pre></div></div>

<p>and a brief explanation is that it queries for some keywords for potential trouble within mentions/replies to <a href="http://twitter.com/krlmania" title="@krlmania" target="_blank">@krlmania</a> and official announcements of <a href="http://twitter.com/CommuterLine" title="@CommuterLine" target="_blank">@CommuterLine</a>. Exclusion added to the search, the sentiment part of tweets, expressing wishes to shoo trouble away–I&#8217;m sorry, but keep praying online anyway.</p>
<p>When Twitter launched Twitter Stories in 2011, I read <a href="https://stories.twitter.com/en/ravi_pina.html" title="RAVI PINA shares train information through crowd sourcing and Twitter" target="_blank">about Ravi Pina</a> running the crowd sourced <a href="http://twitter.com/Caltrain" title="@Caltrain" target="_blank">@Caltrain</a>. Later now I see that official accounts like <a href="https://twitter.com/smrt_singapore" title="@SMRT_singapore" target="_blank">@SMRT_Singapore</a> is also a model of service disruption info center. We can go deeper to better stats from the API web service that shows real time position (<a href="https://play.google.com/store/apps/details?id=com.raia.infokrl&#038;hl=en" title="Google Play - Info KRL" target="_blank">an app is out there</a> showing that the location data API is working), but until its <a href="http://en.wikipedia.org/wiki/Open_data" title="Wikipedia - Open Data" target="_blank">open data</a> status is known, crowd sourcing stays as the most reliable solution, independent to regulation, and easiest to implement. Does the recipe work? During the first week of testing, alerts were flooding–within limit of course–as trouble really happened. So, cook your own ingredients or get my recipes served <a href="https://ifttt.com/p/bandono/shared" title="IFTTT - bandono" target="_blank">here</a>. </p>
<div class="wp-caption aligncenter" style="width: 460px"><iframe class="vine-embed" src="https://vine.co/v/OpU6LTOADvi/embed/simple" width="320" height="320" frameborder="0"></iframe><script async src="//platform.vine.co/static/scripts/embed.js" charset="utf-8"></script><p class="wp-caption-text">Train trouble alert on my watch</p></div>
]]></content:encoded>
			<wfw:commentRss>https://lakm.us/logit/2015/01/commuter-train-trouble-alert-delivered-watch-ifttt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<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>How DHCP/DNS Server Works in Web Proxy Autodiscovery Protocol (WPAD) for Today&#8217;s Browsers</title>
		<link>https://lakm.us/logit/2013/05/how-dhcp-dns-server-works-web-proxy-autodiscovery-protocol-wpad-today-major-browsers/</link>
		<comments>https://lakm.us/logit/2013/05/how-dhcp-dns-server-works-web-proxy-autodiscovery-protocol-wpad-today-major-browsers/#comments</comments>
		<pubDate>Wed, 15 May 2013 07:22:42 +0000</pubDate>
		<dc:creator>Arif</dc:creator>
				<category><![CDATA[General Linux]]></category>
		<category><![CDATA[autodiscovery]]></category>
		<category><![CDATA[DHCP]]></category>
		<category><![CDATA[DNS]]></category>
		<category><![CDATA[MikroTik]]></category>
		<category><![CDATA[proxy]]></category>

		<guid isPermaLink="false">http://lakm.us/logit/?p=665</guid>
		<description><![CDATA[Web Proxy Autodiscovery Protocol (WPAD) protocol draft expired in 1999, but today&#8217;s major browsers are still supporting it as will be shown later. Two types of DHCP server are tested to describe how WPAD behaves prior to/after starting up the internet browser. To be clear, uploaded packet captures are shared in CloudShark. DNS and domain [...]]]></description>
				<content:encoded><![CDATA[<p>Web Proxy Autodiscovery Protocol <a href="http://tools.ietf.org/html/draft-ietf-wrec-wpad-01" title="Web Proxy Auto-Discovery Protocol" target="_blank">(WPAD) protocol draft</a> expired in 1999, but today&#8217;s major browsers are still supporting it as will be shown later. Two types of DHCP server are tested to describe how WPAD behaves prior to/after starting up the internet browser. To be clear, uploaded packet captures are shared in <a href="http://www.cloudshark.org/" title="CloudShark" target="_blank">CloudShark</a>. DNS and domain resolution is a must for the WPAD to work when MS Windows Internet Options configured to &#8220;<a href="http://https://github.com/bandono/proxyConf/blob/v1.1/www/images/winxp-internet-properties-02-lan-settings.png" title="proxyConf Github: screenshot of Windows Internet Options proxy setting" target="_blank">Automatically detect settings</a>&#8221; (for <a href="http://en.wikipedia.org/wiki/Internet_Explorer_6">IE 6 in Windows XP desktop</a>, <a href="http://en.wikipedia.org/wiki/Internet_Explorer_8" target="_blank">IE 8 in Windows 7 desktop</a>, and <a href="https://www.google.com/intl/en/chrome/browser/" title="Chrome Browser - Google" target="_blank">Google Chrome</a>) or Firefox to &#8220;<a href="https://github.com/bandono/proxyConf/blob/v1.1/www/images/firefox-03-auto-proxy-config-url.png" title="proxyConf Github: screenshot of Firefox proxy setting" target="_blank">Auto-detect proxy settings for this network</a>&#8220;. As simplest DNS setting should work, this post will not cover its configuration. </p>
<div class="wp-caption aligncenter" style="width: 460px"><img alt="Low level view of WPAD interactions involving DHCP, DNS, and HTTP servers in packet capture (shared in CloudShark)" src="../../../../images/proxy-wpad-dhcp-dns-packet-capture-cloudshark.png" title="Low level view of WPAD interactions involving DHCP, DNS, and HTTP servers in packet capture (shared in CloudShark)" width="390" height="328" /><p class="wp-caption-text">Low level view of WPAD interactions involving DHCP, DNS, and HTTP servers in packet capture (shared in CloudShark)</p></div>
<p>In DHCP discovery-offer-request-acknowledgement cycle, WPAD information is given in option 252 (check <a href="http://tools.ietf.org/html/draft-ietf-wrec-wpad-01#section-4.4.1" target="_blank">section 4.4.1 of the draft</a>). I used <a href="http://packages.ubuntu.com/precise/dhcp3-server" target="_blank"><code>dhcpd3-server</code> package</a> in Ubuntu and setup <code>/ip dhcp-server option add code=252 ...</code> in <a href="http://www.mikrotik.com/download/CHANGELOG_5" target="_blank">Mikrotik 5.20</a> for example variations. For both, trailing &#8220;<code>\n</code>&#8221; are added to <code>wpad.dat</code> URL value as most howtos recommend.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #ff0000;">&quot;http://wpad.some-company.net/wpad.dat<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span></pre></div></div>

<p>In the above example value, <code>wpad.dat</code> is hosted in <a href="http://packages.ubuntu.com/precise/apache2" target="_blank">Apache2 HTTP server</a> resolvable by the DNS to the actual host IP of <code>wpad.some-company.net</code>. When the client use all DHCP offered items, it gets domain name (option 15) <code>some-company.net</code> besides other things e.g.  router (option 3), DNS (option 6), etc. In a case where the client use its own DNS (only use IP from DHCP), <strong>WPAD likely won&#8217;t work</strong> unless it is able to resolve the example <code>some-company.net</code> or <code>wpad.some-company.net</code>. Following the tail of <code>/var/log/apache2/access.log</code>, successful <code>wpad.dat</code> request will appear as</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">192.168.40.75 - - <span style="color: #7a0874; font-weight: bold;">&#91;</span>01<span style="color: #000000; font-weight: bold;">/</span>May<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2013</span>:<span style="color: #000000;">21</span>:<span style="color: #000000;">51</span>:<span style="color: #000000;">15</span> +0700<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #ff0000;">&quot;GET /wpad.dat HTTP/1.1&quot;</span> <span style="color: #000000;">200</span> <span style="color: #000000;">1070</span> <span style="color: #ff0000;">&quot;-&quot;</span> <span style="color: #ff0000;">&quot;-&quot;</span></pre></div></div>

<p><span id="more-665"></span><br />
In the above tail, I enabled a Windows 7&#8242;s network adapter (from previously disabled) and it would soon try to HTTP <code>GET</code> the <code>wpad.dat</code> even when no browser opened yet.</p>
<p>From testing with Windows XP, Windows 7, and Ubuntu (with different browsers mostly), <code>DHCP Inform</code>&#8216;s WPAD behavior can be seen with Windows 7 test by analyzing the packet going out after some time since the initial DHCP stream (check <a href="http://www.cloudshark.org/captures/1dc9e4cb8ca1" title="WPAD packet capture: Windows 7 client with ISC DHCP server running in Ubuntu 12.04" target="_blank">the packet capture</a> for 7 seconds after <code>DHCP Discover</code>). It asked for WPAD in one of the <code>Parameter Request List Item</code> (apply the filter <code>bootp.option.request_list_item == 252</code> for a closer look), but received no answer.</p>
<p>I failed to reproduce other samples of <code>DHCP Inform</code> packet asking for WPAD. Hence, for the rest, it&#8217;s the browser who is doing the <code>GET</code> to <code>http://wpad.some-company.net/wpad.dat</code> with DHCP only supplied domain name instead of complete WPAD (check <a href="http://www.cloudshark.org/captures/5d73416a18d5" target="_blank">another packet capture</a>, this time for <a href="http://packages.ubuntu.com/precise/firefox" target="_blank">Ubuntu with Firefox 20</a>). The <code>GET</code> attempt isn&#8217;t actually one shot attempt. When it fails to find the <code>wpad.dat</code> in <code>http://wpad.some-company.net/wpad.dat</code>, it should iteratively try to find within the higher domain e.g. <code>http://some-company.net/wpad.dat</code>.</p>
<div class="wp-caption aligncenter" style="width: 460px"><img alt="Getting proxy setting (WPAD) from DHCP or directly by browser iterative decision" src="../../../../images/proxy-wpad-dhcp-browser-iteration-decision-illustration.png" title="Getting proxy setting (WPAD) from DHCP or directly by browser iterative decision" width="292" height="193" /><p class="wp-caption-text">Getting proxy setting (WPAD) from DHCP or directly by browser iterative decision</p></div>
<p>DHCP server configuration used, <code>wpad.dat</code> file example (I simply use symbolic link to <code>proxy.pac</code>), and Apache2 <code>VirtualHost</code> config are available in <a href="https://github.com/bandono/proxyConf/tree/v1.1" target="_blank">my github, an attempt to integrate Squid3 cache with WPAD, PAC, and DHCP</a>.</p>
<p><a id="History" href="#History" rel="bookmark" title="History"><br />
<h4>History</h4>
<p></a></p>
<p>For trailing character in WPAD value mentioned earlier, I once configured option 252 value with &#8220;<code>wpad.dat\?</code>&#8220;, &#8220;<code>proxy.pa</code>&#8220;, and some other likely wrong variations. I also configured the browser in Windows XP and 7 with these variations of wrong values before getting the browser to use proxy auto-discovery again. Somehow it kept the wrong <code>GET</code> with trailing character resulting in 404 (page not found):</p>
<ol>
<li>Firefox</li>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">192.168.40.78 - - <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">30</span><span style="color: #000000; font-weight: bold;">/</span>Apr<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2013</span>:<span style="color: #000000;">16</span>:<span style="color: #000000;">20</span>:<span style="color: #000000;">39</span> +0700<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #ff0000;">&quot;GET /wpad.dat/ HTTP/1.1&quot;</span> <span style="color: #000000;">404</span> <span style="color: #000000;">478</span> <span style="color: #ff0000;">&quot;-&quot;</span> <span style="color: #ff0000;">&quot;Mozilla/4.0 (compatible; MSIE 6.0; Win32)&quot;</span></pre></div></div>

<li>IE 6</li>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">192.168.40.78 - - <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">30</span><span style="color: #000000; font-weight: bold;">/</span>Apr<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2013</span>:<span style="color: #000000;">16</span>:<span style="color: #000000;">28</span>:07 +0700<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #ff0000;">&quot;GET /wpad.dat/ HTTP/1.1&quot;</span> <span style="color: #000000;">404</span> <span style="color: #000000;">478</span> <span style="color: #ff0000;">&quot;-&quot;</span> <span style="color: #ff0000;">&quot;Mozilla/4.0 (compatible; MSIE 6.0; Win32)&quot;</span></pre></div></div>

<li>IE 8</li>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">192.168.40.77 - - <span style="color: #7a0874; font-weight: bold;">&#91;</span>01<span style="color: #000000; font-weight: bold;">/</span>May<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2013</span>:<span style="color: #000000;">20</span>:07:<span style="color: #000000;">24</span> +0700<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #ff0000;">&quot;GET /wpad.dat/? HTTP/1.1&quot;</span> <span style="color: #000000;">404</span> <span style="color: #000000;">534</span> <span style="color: #ff0000;">&quot;-&quot;</span> <span style="color: #ff0000;">&quot;-&quot;</span></pre></div></div>

</ol>
<p>I was able to force it to <code>GET</code> the correct WPAD value by adding new network adapter which received different IP lease from DHCP server. Afterwards, connecting with the old adapter will also keep correct behavior.</p>
<p>I still don&#8217;t know how they keep the previously incorrect behavior. <strong>In short we can&#8217;t rely on WPAD alone</strong>, but there is probability that some portions of the network clients will find the proxy this way, automatically without technical assistance.</p>
]]></content:encoded>
			<wfw:commentRss>https://lakm.us/logit/2013/05/how-dhcp-dns-server-works-web-proxy-autodiscovery-protocol-wpad-today-major-browsers/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Running Two Squid Instances in Upstart Init</title>
		<link>https://lakm.us/logit/2013/05/running-two-multiple-squid-instances-upstart-init-job/</link>
		<comments>https://lakm.us/logit/2013/05/running-two-multiple-squid-instances-upstart-init-job/#comments</comments>
		<pubDate>Fri, 10 May 2013 08:55:16 +0000</pubDate>
		<dc:creator>Arif</dc:creator>
				<category><![CDATA[General Linux]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[daemon]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[squid]]></category>
		<category><![CDATA[startup]]></category>
		<category><![CDATA[workaround]]></category>

		<guid isPermaLink="false">http://lakm.us/logit/?p=644</guid>
		<description><![CDATA[After installing squid3 from repository, Ubuntu will place the init in upstart style (instead of /etc/rc*.d/ or /etc/init.d/ style used to maintain backward compatibility to legacy System-V init). The upstart job is placed in /etc/init/squid3.conf with default runlevel (2,3,4 or 5) to start the instance during reboot and relevant start/stop command using service: $ sudo [...]]]></description>
				<content:encoded><![CDATA[<p>After installing <a href="http://www.squid-cache.org/" target="_blank">squid3</a> from <a href="http://packages.ubuntu.com/precise/squid3" target="_blank">repository</a>, Ubuntu will place the <code>init</code> in <a href="http://upstart.ubuntu.com/" target="_blank">upstart</a> style (instead of <code>/etc/rc*.d/</code> or <code>/etc/init.d/</code> style used to maintain backward compatibility to legacy <a href="http://en.wikipedia.org/wiki/Init" target="_blank">System-V init</a>). The upstart job is placed in <code>/etc/init/squid3.conf</code> with default <code>runlevel</code> (2,3,4 or 5) to start the instance during reboot and relevant start/stop command using <code>service</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> service squid3 <span style="color: #7a0874; font-weight: bold;">&#123;</span>start<span style="color: #000000; font-weight: bold;">|</span>stop<span style="color: #000000; font-weight: bold;">|</span>restart<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

<p>To specify what to run, an <code>upstart</code> <a href="http://upstart.ubuntu.com/getting-started.html" target="_blank">must have</a> <code>exec</code> or <code>script</code> stanza. When the goal is to start two or more (multiple) instances of <code>squid3</code>, <code>exec</code> is meant <a href="http://manpages.ubuntu.com/manpages/precise/man3/exec.3.html" target="_blank">to replace existing process image</a> of <code>/usr/sbin/squid3</code> executable, therefore will not start two instances.</p>
<div class="wp-caption aligncenter" style="width: 460px"><img alt="Eltek Smartpack Controller type with SNMP Support" src="../../../../images/squid3-two-instances-illustration.png" title="Multiple squid3 instances started via upstart exec" width="385" height="188" /><p class="wp-caption-text">Multiple squid3 instances started via upstart exec</p></div>
<p>As workaround we can have symbolic link to <code>squid3</code> executable instead and add new <code>upstart</code> job configuration with <code>exec</code> call to the link. I need two instances running in the same machine due to the implementation design where the fist instance is HTTP proxy cache while the second one is accelerator/interceptor (reverse proxy) that serves default landing page telling user to use proxy (and how to do that). Hence, for the second instance I add:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">lrwxrwxrwx <span style="color: #000000;">1</span> root root <span style="color: #000000;">6</span> May  <span style="color: #000000;">3</span> 09:<span style="color: #000000;">25</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>squid3ins2 -<span style="color: #000000; font-weight: bold;">&gt;</span> squid3
<span style="color: #660033;">-rw-r--r--</span> <span style="color: #000000;">1</span> root root <span style="color: #000000;">1156</span> May  <span style="color: #000000;">6</span> <span style="color: #000000;">13</span>:<span style="color: #000000;">30</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init<span style="color: #000000; font-weight: bold;">/</span>squid3ins2.conf</pre></div></div>

<p>and for the first instance I add:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #660033;">-rw-r--r--</span> <span style="color: #000000;">1</span> root root <span style="color: #000000;">298</span> May  <span style="color: #000000;">3</span> <span style="color: #000000;">10</span>:<span style="color: #000000;">13</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init<span style="color: #000000; font-weight: bold;">/</span>squid3.override</pre></div></div>

<p><code>squid3ins2</code> is our link and <code>/etc/init/squid3ins2.conf</code> contains <code>exec</code> call to it to run second <code>squid3</code>. For the first instance I choose to write an override (<code>/etc/init/squid3.override</code>) so that the original job configuration file is left intact. For the complete content of all files check <a href="https://github.com/bandono/proxyConf/tree/v1.1/init" target="_blank">my github v1.1</a> of the Squid integration. There, in details you&#8217;ll also find how both instances PID, log, etc. are differentiated by each instance config via the following directives:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">http_port
cache_dir
pid_filename
cache_access_log
cache_log</pre></div></div>

</pre>
]]></content:encoded>
			<wfw:commentRss>https://lakm.us/logit/2013/05/running-two-multiple-squid-instances-upstart-init-job/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>
	</channel>
</rss>
