<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>VCT Labs</title><link href="http://www.vctlabs.com/" rel="alternate"></link><link href="http://www.vctlabs.com/feeds/all.atom.xml" rel="self"></link><id>http://www.vctlabs.com/</id><updated>2018-04-18T00:00:00-07:00</updated><entry><title>GNU screen cheatsheet: text-console session manager</title><link href="http://www.vctlabs.com/posts/2018/Apr/18/screen_cheatsheet/" rel="alternate"></link><updated>2018-04-18T00:00:00-07:00</updated><author><name>Stephanie Lockwood-Childs</name></author><id>tag:www.vctlabs.com,2018-04-18:posts/2018/Apr/18/screen_cheatsheet/</id><summary type="html">&lt;p&gt;cheatsheet for &lt;span class="caps"&gt;GNU&lt;/span&gt;&lt;/p&gt;
&lt;div class="section" id="gnu-screen"&gt;
&lt;h2&gt;&lt;span class="caps"&gt;GNU&lt;/span&gt;&amp;nbsp;screen&lt;/h2&gt;
&lt;div class="section" id="multi-user-sessions"&gt;
&lt;h3&gt;Multi-user&amp;nbsp;sessions&lt;/h3&gt;
&lt;p&gt;Suppose &lt;cite&gt;user1st&lt;/cite&gt; and &lt;cite&gt;user2nd&lt;/cite&gt; are the login names of the would-be collaborators
on a single computer where the screen&amp;nbsp;session&lt;/p&gt;
&lt;p&gt;Commands for &lt;cite&gt;user1st&lt;/cite&gt; who starts the screen&amp;nbsp;session&lt;/p&gt;
&lt;pre class="literal-block"&gt;
screen
&amp;lt;hit a key to dismiss intro screen&amp;gt;
&amp;lt;ctrl-a&amp;gt; :multiuser on
&amp;lt;ctrl-a&amp;gt; :addacl user2nd
&lt;/pre&gt;
&lt;p&gt;Note the space between &lt;cite&gt;ctrl-a&lt;/cite&gt; keystroke and &lt;cite&gt;:&lt;/cite&gt; is not meant to be typed;
just here for readability (makes the &lt;cite&gt;:&lt;/cite&gt; less likely to be&amp;nbsp;overlooked)&lt;/p&gt;
&lt;p&gt;Command for &lt;cite&gt;user2nd&lt;/cite&gt; to join the same screen&amp;nbsp;session&lt;/p&gt;
&lt;pre class="literal-block"&gt;
screen -rx user1st/
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class="section" id="scrollback"&gt;
&lt;h3&gt;Scrollback&lt;/h3&gt;
&lt;p&gt;Start scrollback&amp;nbsp;mode&lt;/p&gt;
&lt;pre class="literal-block"&gt;
&amp;lt;ctrl-a&amp;gt; &amp;lt;esc&amp;gt;
&lt;/pre&gt;
&lt;p&gt;Note if you are already in scrollback mode when you do this sequence,
you will receive the cryptic status message &amp;quot;Must be on a window layer&amp;quot;
but it doesn&amp;#8217;t hurt anything (you will still be in scrollback mode as&amp;nbsp;intended).&lt;/p&gt;
&lt;p&gt;Navigation&lt;/p&gt;
&lt;p&gt;Can use arrow keys, page-up/page-down keys, vi-style navigation, and/or emacs-style navigation.
This includes navigation by searching for literal strings, with both vi-style &lt;cite&gt;/&lt;/cite&gt; (forwards) &lt;cite&gt;?&lt;/cite&gt; (backwards)
and emacs-style &lt;cite&gt;&amp;lt;ctrl-s&lt;/cite&gt; key-mappings&amp;nbsp;supported.&lt;/p&gt;
&lt;p&gt;End scrollback&amp;nbsp;mode&lt;/p&gt;
&lt;pre class="literal-block"&gt;
&amp;lt;esc&amp;gt;
&lt;/pre&gt;
&lt;p&gt;You will see status message &amp;quot;Copy mode&amp;nbsp;aborted&amp;quot;&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="logging"&gt;
&lt;h3&gt;Logging&lt;/h3&gt;
&lt;p&gt;Start logging to a file &lt;cite&gt;/tmp/scroll-session.txt&lt;/cite&gt;&lt;/p&gt;
&lt;pre class="literal-block"&gt;
&amp;lt;ctrl-a&amp;gt; :logfile /tmp/scroll-session.txt
&amp;lt;ctrl-a&amp;gt; :log on
&lt;/pre&gt;
&lt;p&gt;You will see status &amp;quot;Creating logfile /tmp/scroll-session.txt&amp;quot; if the file doesn&amp;#8217;t exist;
status &amp;quot;Appending to logfile /tmp/scroll-session.txt&amp;quot; if it already does&amp;nbsp;exist.&lt;/p&gt;
&lt;p&gt;End&amp;nbsp;logging&lt;/p&gt;
&lt;pre class="literal-block"&gt;
&amp;lt;ctrl-a&amp;gt; :log off
&lt;/pre&gt;
&lt;p&gt;The resulting status message &amp;quot;Logfile /tmp/scroll-session.txt closed&amp;quot; will remind you
where your logfile is&amp;nbsp;located.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
</summary><category term="GNU screen"></category><category term="multi-user session"></category></entry><entry><title>Embedded-board Serial Console Cheatsheet</title><link href="http://www.vctlabs.com/posts/2015/Dec/24/serial_console_cheatsheet/" rel="alternate"></link><updated>2015-12-24T00:00:00-08:00</updated><author><name>Stephanie Lockwood-Childs</name></author><id>tag:www.vctlabs.com,2015-12-24:posts/2015/Dec/24/serial_console_cheatsheet/</id><summary type="html">&lt;div class="section" id="conventions"&gt;
&lt;h2&gt;Conventions&lt;/h2&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;span class="caps"&gt;TX&lt;/span&gt;/&lt;span class="caps"&gt;RX&lt;/span&gt; is labeled from perspective of development host (opposite of target board), thus called &amp;quot;host &lt;span class="caps"&gt;TX&lt;/span&gt;&amp;quot; and &amp;quot;host &lt;span class="caps"&gt;RX&lt;/span&gt;&amp;quot;&lt;/li&gt;
&lt;li&gt;unless otherwise noted, software serial configuration is 15200 baud, 8N1, no flow&amp;nbsp;control&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class="section" id="adafruit-usb-serial-cable"&gt;
&lt;h2&gt;Adafruit &lt;span class="caps"&gt;USB&lt;/span&gt;-Serial&amp;nbsp;Cable&lt;/h2&gt;
&lt;p&gt;Adafruit &lt;span class="caps"&gt;PL2303&lt;/span&gt; 3.3V serial cable
&lt;a class="reference external" href="https://www.adafruit.com/product/954"&gt;https://www.adafruit.com/product/954&lt;/a&gt;&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;span class="caps"&gt;GND&lt;/span&gt;      &lt;span class="caps"&gt;BLACK&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;host &lt;span class="caps"&gt;TX&lt;/span&gt;  &lt;span class="caps"&gt;GREEN&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;host &lt;span class="caps"&gt;RX&lt;/span&gt;  &lt;span class="caps"&gt;WHITE&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class="section" id="minnowboard-max"&gt;
&lt;h2&gt;Minnowboard&amp;nbsp;Max&lt;/h2&gt;
&lt;p&gt;Serial port is single-row right-angle 6-pin connector&amp;nbsp;J4&lt;/p&gt;
&lt;p&gt;Schematic: &lt;a class="reference external" href="http://wiki.minnowboard.org/images/6/6d/MinnowBoard_Max_RevA2_sch.pdf"&gt;http://wiki.minnowboard.org/images/6/6d/MinnowBoard_Max_RevA2_sch.pdf&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Numbering below starts from the left while holding board with serial port
along top edge, so Pin 1 is closest to &lt;span class="caps"&gt;SATA&lt;/span&gt;&amp;nbsp;connector&lt;/p&gt;
&lt;p&gt;&lt;a class="reference external" href="http://wiki.minnowboard.org/MinnowBoard_MAX#4-Wire_Serial_Console"&gt;http://wiki.minnowboard.org/MinnowBoard_MAX#4-Wire_Serial_Console&lt;/a&gt;&lt;/p&gt;
&lt;table border="1" class="docutils"&gt;
&lt;colgroup&gt;
&lt;col width="19%" /&gt;
&lt;col width="27%" /&gt;
&lt;col width="54%" /&gt;
&lt;/colgroup&gt;
&lt;tbody valign="top"&gt;
&lt;tr&gt;&lt;td&gt;Pin #&lt;/td&gt;
&lt;td&gt;Role&lt;/td&gt;
&lt;td&gt;Adafruit color&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Pin 1&lt;/td&gt;
&lt;td&gt;&lt;span class="caps"&gt;GND&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span class="caps"&gt;BLACK&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Pin 4&lt;/td&gt;
&lt;td&gt;host &lt;span class="caps"&gt;TX&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span class="caps"&gt;GREEN&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Pin 5&lt;/td&gt;
&lt;td&gt;host &lt;span class="caps"&gt;RX&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span class="caps"&gt;WHITE&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Note that these are not consecutive: pins 2, 3, and 6 should be empty.
This is standard arrangement for boards compatible with an &lt;span class="caps"&gt;FTDI&lt;/span&gt; serial&amp;nbsp;cable.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="beaglebone-black"&gt;
&lt;h2&gt;Beaglebone&amp;nbsp;Black&lt;/h2&gt;
&lt;p&gt;Serial port is single-row 6-pin connector J1 running along the inner side of
one of the expansion sockets for &amp;quot;cape&amp;quot;&amp;nbsp;daughtercards&lt;/p&gt;
&lt;p&gt;Schematic: &lt;a class="reference external" href="https://github.com/CircuitCo/BeagleBone-Black/blob/master/BBB_SCH.pdf?raw=true"&gt;https://github.com/CircuitCo/BeagleBone-Black/blob/master/BBB_SCH.pdf?raw=true&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Numbering starts from the left while holding board with the serial port
towards the bottom, so Pin 1 is the one closest to 5V power&amp;nbsp;connector&lt;/p&gt;
&lt;p&gt;&lt;a class="reference external" href="http://dave.cheney.net/2013/09/22/two-point-five-ways-to-access-the-serial-console-on-your-beaglebone-black"&gt;http://dave.cheney.net/2013/09/22/two-point-five-ways-to-access-the-serial-console-on-your-beaglebone-black&lt;/a&gt; note text accompanying picture uses &lt;span class="caps"&gt;TX&lt;/span&gt;/&lt;span class="caps"&gt;RX&lt;/span&gt; from target&amp;nbsp;perspective&lt;/p&gt;
&lt;table border="1" class="docutils"&gt;
&lt;colgroup&gt;
&lt;col width="19%" /&gt;
&lt;col width="27%" /&gt;
&lt;col width="54%" /&gt;
&lt;/colgroup&gt;
&lt;tbody valign="top"&gt;
&lt;tr&gt;&lt;td&gt;Pin #&lt;/td&gt;
&lt;td&gt;Role&lt;/td&gt;
&lt;td&gt;Adafruit color&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Pin 1&lt;/td&gt;
&lt;td&gt;&lt;span class="caps"&gt;GND&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span class="caps"&gt;BLACK&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Pin 4&lt;/td&gt;
&lt;td&gt;host &lt;span class="caps"&gt;TX&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span class="caps"&gt;GREEN&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Pin 5&lt;/td&gt;
&lt;td&gt;host &lt;span class="caps"&gt;RX&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span class="caps"&gt;WHITE&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Note that these are not consecutive: pins 2, 3, and 6 should be empty.
This is standard arrangement for boards compatible with an &lt;span class="caps"&gt;FTDI&lt;/span&gt; serial&amp;nbsp;cable.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="raspberry-pi"&gt;
&lt;h2&gt;Raspberry&amp;nbsp;Pi&lt;/h2&gt;
&lt;p&gt;Serial port is on double-row 26-pin connector&amp;nbsp;J8&lt;/p&gt;
&lt;p&gt;&lt;a class="reference external" href="https://www.raspberrypi.org/documentation/hardware/raspberrypi/schematics/README.md"&gt;https://www.raspberrypi.org/documentation/hardware/raspberrypi/schematics/&lt;span class="caps"&gt;README&lt;/span&gt;.md&lt;/a&gt; (these are only partial schematics, and nothing posted yet for RPi 2, but &lt;span class="caps"&gt;GPIO&lt;/span&gt; header is same as RPi&amp;nbsp;B+)&lt;/p&gt;
&lt;p&gt;Numbering below starts from top-row left while holding board with
serial port along top edge, so Pin 1 is at top-left corner of board (note
this is &lt;span class="caps"&gt;NOT&lt;/span&gt; the same as connector pin numbering on diagrams or board silkscreen,
which is an inconvenient arrangement for this&amp;nbsp;purpose)&lt;/p&gt;
&lt;p&gt;&lt;a class="reference external" href="http://elinux.org/RPi_Serial_Connection"&gt;http://elinux.org/RPi_Serial_Connection&lt;/a&gt;&lt;/p&gt;
&lt;table border="1" class="docutils"&gt;
&lt;colgroup&gt;
&lt;col width="19%" /&gt;
&lt;col width="27%" /&gt;
&lt;col width="54%" /&gt;
&lt;/colgroup&gt;
&lt;tbody valign="top"&gt;
&lt;tr&gt;&lt;td&gt;Pin #&lt;/td&gt;
&lt;td&gt;Role&lt;/td&gt;
&lt;td&gt;Adafruit color&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Pin 3&lt;/td&gt;
&lt;td&gt;&lt;span class="caps"&gt;GND&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span class="caps"&gt;BLACK&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Pin 4&lt;/td&gt;
&lt;td&gt;host &lt;span class="caps"&gt;RX&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span class="caps"&gt;WHITE&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Pin 5&lt;/td&gt;
&lt;td&gt;host &lt;span class="caps"&gt;TX&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span class="caps"&gt;GREEN&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Note that these are consecutive, but the first 2 pins are skipped and the
&lt;span class="caps"&gt;RX&lt;/span&gt;/&lt;span class="caps"&gt;TX&lt;/span&gt; order is opposite of boards that are compatible with &lt;span class="caps"&gt;FTDI&lt;/span&gt; serial cables,
e.g. Minnowboard or &lt;span class="caps"&gt;BBB&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="imx233-olinuxino-maxi-mini"&gt;
&lt;h2&gt;iMX233 OLinuXino&amp;nbsp;Maxi/Mini&lt;/h2&gt;
&lt;p&gt;Serial port is single-row 4-pin connector&amp;nbsp;U_DEBUG&lt;/p&gt;
&lt;p&gt;Schematic: &lt;a class="reference external" href="https://github.com/OLIMEX/OLINUXINO/tree/master/HARDWARE"&gt;https://github.com/&lt;span class="caps"&gt;OLIMEX&lt;/span&gt;/&lt;span class="caps"&gt;OLINUXINO&lt;/span&gt;/tree/master/&lt;span class="caps"&gt;HARDWARE&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Numbering below starts from the left while holding board with reset and
power switches along top edge, so Pin 1 is closest to board&amp;nbsp;edge&lt;/p&gt;
&lt;table border="1" class="docutils"&gt;
&lt;colgroup&gt;
&lt;col width="19%" /&gt;
&lt;col width="27%" /&gt;
&lt;col width="54%" /&gt;
&lt;/colgroup&gt;
&lt;tbody valign="top"&gt;
&lt;tr&gt;&lt;td&gt;Pin #&lt;/td&gt;
&lt;td&gt;Role&lt;/td&gt;
&lt;td&gt;Adafruit color&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Pin 1&lt;/td&gt;
&lt;td&gt;host &lt;span class="caps"&gt;TX&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span class="caps"&gt;WHITE&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Pin 2&lt;/td&gt;
&lt;td&gt;host &lt;span class="caps"&gt;RX&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span class="caps"&gt;GREEN&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Pin 3&lt;/td&gt;
&lt;td&gt;&lt;span class="caps"&gt;GND&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span class="caps"&gt;BLACK&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Note that these are consecutive, but pin order is different from boards
that are compatible with &lt;span class="caps"&gt;FTDI&lt;/span&gt; serial cables, e.g. Minnowboard or &lt;span class="caps"&gt;BBB&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;
</summary><category term="embedded"></category><category term="BeagleBone"></category><category term="BBB"></category><category term="MinnowBoard"></category><category term="OLinuXino"></category><category term="Raspberry Pi"></category><category term="RPi"></category></entry><entry><title>Upcoming SELinux Enhancements</title><link href="http://www.vctlabs.com/posts/2015/Jul/12/selinux_cil/" rel="alternate"></link><updated>2015-07-12T00:00:00-07:00</updated><author><name>Stephanie Lockwood-Childs</name></author><id>tag:www.vctlabs.com,2015-07-12:posts/2015/Jul/12/selinux_cil/</id><summary type="html">&lt;p&gt;SELinux userspace policy tools have been undergoing a significant under-the-hood
design change in order to make local policy customizations much more&amp;nbsp;practical&lt;/p&gt;
&lt;div class="section" id="goals-of-selinux-userspace-redesign"&gt;
&lt;h2&gt;Goals of SELinux Userspace&amp;nbsp;Redesign&lt;/h2&gt;
&lt;p&gt;SELinux is widely used as part of the security architecture of high-security
government systems, but its adoption in the commercial space has been hindered
by the difficulty that system administrators have in adapting SELinux policies
for local needs.  This is not entirely surprising, given that SELinux grew out
of government projects for improving security, and typical government processes
require that specialized security experts be in charge of security configurations,
which system administrators maintaining the systems must &lt;em&gt;not&lt;/em&gt; change.
In contrast, private companies frequently put their system administrators /
devops staff in charge of implementing security policies on the servers,
and those staff members frequently find SELinux impractical to work with
in a more dynamic commercial environment. Some commercial infrastructures are more
dynamic than others, but almost all are dynamic compared to the high-security
certified-at-every-stage environment from which SELinux was&amp;nbsp;born.&lt;/p&gt;
&lt;p&gt;The main gaps in SELinux policy maintenance, hindering commercial usage,&amp;nbsp;include:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;lack of mature high-level tools for customizing and reviewing&amp;nbsp;policies&lt;/li&gt;
&lt;li&gt;inability to make certain classes of changes with even low-level&amp;nbsp;tools&lt;/li&gt;
&lt;li&gt;poor support for preserving local changes across system&amp;nbsp;updates&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This current incomplete support for maintaining local SELinux customizations
places extra responsibility at the level of policy designer, who should not
merely provide secure defaults, but also foresee what parts of the policy
might need boolean &amp;quot;knobs&amp;quot; for admins to be able to turn them on and&amp;nbsp;off.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="approach-to-selinux-userspace-redesign"&gt;
&lt;h2&gt;Approach to SELinux Userspace&amp;nbsp;Redesign&lt;/h2&gt;
&lt;p&gt;The SELinux maintainers have decided to address the gaps in policy maintenance
by introducing an intermediate language, quite descriptively named
&lt;a class="reference external" href="https://github.com/SELinuxProject/cil/wiki"&gt;Common Intermediate Language (&lt;span class="caps"&gt;CIL&lt;/span&gt;)&lt;/a&gt;, between the current text policy definitions
and the binary policy format actually loaded the SELinux kernel&amp;nbsp;layer.&lt;/p&gt;
&lt;p&gt;Not surprisingly, &lt;span class="caps"&gt;CIL&lt;/span&gt; supports all core constructs existing in the current
SELinux policy language, since backward compatibility at a source file level
is being provided via a compiler from the old language to &lt;span class="caps"&gt;CIL&lt;/span&gt;. Thus the initial
deployment of &lt;span class="caps"&gt;CIL&lt;/span&gt; will not require re-writes to all existing SELinux policies,
which should allow a relatively smooth&amp;nbsp;adoption.&lt;/p&gt;
&lt;div class="section" id="addressing-lack-of-mature-high-level-policy-tools"&gt;
&lt;h3&gt;Addressing lack of mature high-level policy&amp;nbsp;tools&lt;/h3&gt;
&lt;p&gt;The &lt;a class="reference external" href="http://selinuxproject.org/page/PolicyLanguage#Kernel_Policy_Language_Definition_Links"&gt;current text language&lt;/a&gt; used for defining SELinux policy has not proved
amenable for the development of high-level tools; the current lack of mature
high-level tools is not because high-level tools have never been attempted, but
because they never got good enough to gain wide usage and thus become worth
maintaining in the long-run. Allowing high-level tools to target an
language intentionally designed as an intermediate language is a proven
strategy for efficient support of a variety of frontends;
see &lt;a class="reference external" href="https://en.wikipedia.org/wiki/LLVM#LLVM_Intermediate_Representation"&gt;&lt;span class="caps"&gt;LLVM&lt;/span&gt; Intermediate Representation&lt;/a&gt;
for a shining example of an intermediate language put to good&amp;nbsp;use.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="addressing-limitations-in-low-level-tools"&gt;
&lt;h3&gt;Addressing limitations in low-level&amp;nbsp;tools&lt;/h3&gt;
&lt;p&gt;&lt;span class="caps"&gt;CIL&lt;/span&gt; introduces advanced namespace support, including inheritance, which enables
the development of more powerful administration tools. For an example of the
limitations to the current SELinux tools, the existing &lt;a class="reference external" href="http://linux.die.net/man/8/semanage"&gt;semanage&lt;/a&gt; tool can add a
new port label, and subsequently modify or delete its own label, but it can not
override a port label created by the installed policy files. Porting semanage
to work with the policy at the &lt;span class="caps"&gt;CIL&lt;/span&gt; level will allow it to create custom policy
blocks that inherit from the standard policy, but override specific&amp;nbsp;pieces.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="addressing-local-policy-changes-and-policy-updates"&gt;
&lt;h3&gt;Addressing local policy changes and policy&amp;nbsp;updates&lt;/h3&gt;
&lt;p&gt;With the pre-&lt;span class="caps"&gt;CIL&lt;/span&gt; SELinux userspace implementation, some changes made it
necessary to &lt;a class="reference external" href="https://wiki.gentoo.org/wiki/Project:SELinux/Development"&gt;create local policy modules&lt;/a&gt; that replaced corresponding default
policy modules. There was no automated method of updating those local
replacement modules to incorporate changes pushed out as an update to the
default&amp;nbsp;policy.&lt;/p&gt;
&lt;p&gt;The same &lt;span class="caps"&gt;CIL&lt;/span&gt; features that will allow administrative tools such as semanage
to become more capable, providing namespaces with inheritance, will also allow
better handling of policy updates by allowing most local changes to be
maintained as specific overrides to the default policy. Unrelated changes
could then be pushed to the default policy and take effect without&amp;nbsp;conflict.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="early-adopters-developers"&gt;
&lt;h2&gt;Early Adopters /&amp;nbsp;Developers&lt;/h2&gt;
&lt;p&gt;Those adventurous souls who are interested in following progress in SELinux
policy management by getting their hands dirty with the &lt;a class="reference external" href="https://github.com/SELinuxProject/selinux"&gt;latest code from
github&lt;/a&gt; should consider installing Gentoo for such experiments.
The Gentoo SELinux team is already preparing to take advantage of
the upcoming changes, and the team lead Sven Vermeulen has provided
&lt;a class="reference external" href="http://blog.siphos.be/2015/06/live-selinux-userspace-ebuilds/"&gt;live ebuilds&lt;/a&gt; that allow convenient building of the latest
upstream versions of relevant packages. Sven also provides friendly and
knowledgeable advice to those working with Gentoo SELinux via the
&lt;a class="reference external" href="https://wiki.gentoo.org/wiki/Project:Hardened#Participation"&gt;Hardened Gentoo mailing list&lt;/a&gt; &amp;#8212; the primary avenue of support
for new topics such as &lt;span class="caps"&gt;CIL&lt;/span&gt; that are not yet covered by the otherwise excellent
&lt;a class="reference external" href="https://wiki.gentoo.org/wiki/SELinux"&gt;Gentoo SELinux documentation&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
</summary><category term="SELinux"></category><category term="security"></category><category term="CIL"></category></entry><entry><title>Run Gentoo or Ubuntu Linux On The New Acer Tegra K1 Chromebook</title><link href="http://www.vctlabs.com/posts/2015/Jan/22/tegra_chromebook_hack/" rel="alternate"></link><updated>2015-01-22T00:00:00-08:00</updated><author><name>Stephen Arnold</name></author><id>tag:www.vctlabs.com,2015-01-22:posts/2015/Jan/22/tegra_chromebook_hack/</id><summary type="html">&lt;p&gt;Quick and easy script for making a bootable SDCard loaded with Ubuntu, already stocked with ChromeOS graphics blobs and&amp;nbsp;kernel:&lt;/p&gt;
&lt;blockquote&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;Quick install steps are documented in the &lt;a class="reference external" href="https://github.com/VCTLabs/chrubuntu-tegra"&gt;readme file&amp;nbsp;here&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;More info on the &lt;a class="reference external" href="http://chromeos-cr48.blogspot.com/2013/05/chrubuntu-one-script-to-rule-them-all_31.html"&gt;chrubuntu script arguments&amp;nbsp;here&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Reference for &lt;a class="reference external" href="https://github.com/lgeek/gnu-linux-on-acer-chromebook-13"&gt;custom kernel build&amp;nbsp;here&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;p&gt;Follow the quick install steps in the readme above to make a bootable SDCard with&amp;nbsp;xubuntu.&lt;/p&gt;
&lt;p&gt;The Gentoo steps are essentially the same as those documented in the custom kernel reference above, where you can of course build natively on another &lt;span class="caps"&gt;ARM&lt;/span&gt; box, or use the cross-compile method documented above (which is suitably modified for gentoo&amp;nbsp;below).&lt;/p&gt;
&lt;div class="section" id="for-cross-compiling"&gt;
&lt;h2&gt;For&amp;nbsp;Cross-Compiling&lt;/h2&gt;
&lt;p&gt;First grab the latest crossdev-9999 and the required tools, then build a current armv7a hardfloat&amp;nbsp;toolchain:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
# emerge uboot-tools vboot-utils dtc bc -v
# emerge crossdev -v
# crossdev -v -t armv7a-hardfloat-linux-gnueabi
&lt;/pre&gt;
&lt;p&gt;You may need to add the following to your package.keywords&amp;nbsp;file:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
sys-devel/crossdev **
&lt;/pre&gt;
&lt;p&gt;Next grab the chromeos kernel sources and configure/build a&amp;nbsp;kernel:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
# git clone https://chromium.googlesource.com/chromiumos/third_party/kernel linux-chromeos
# cd linux-chromeos
# git checkout chromeos-3.10
&lt;/pre&gt;
&lt;p&gt;Get the &lt;span class="caps"&gt;USB&lt;/span&gt; firmware (from &lt;a class="reference external" href="https://chromium.googlesource.com/chromiumos/overlays/board-overlays/+/master/overlay-nyan/sys-kernel/xhci-firmware/xhci-firmware-2014.11.06.00.00.ebuild"&gt;this overlay&lt;/a&gt;) and prepare the config&amp;nbsp;file:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
# wget http://commondatastorage.googleapis.com/chromeos-localmirror/distfiles/xhci firmware-2014.11.06.00.00.tbz2
# tar xf xhci-firmware-2014.11.06.00.00.tbz2
# cp -R lib/firmware/ .
# rm -R ./lib/firmware/
# ./chromeos/scripts/prepareconfig chromeos-tegra
# WIFIVERSION=-3.8 ARCH=arm CROSS_COMPILE=armv7a-hardfloat-linux-gnueabi- make menuconfig
&lt;/pre&gt;
&lt;p&gt;According to the reference above, the &lt;span class="caps"&gt;WIFIVERSION&lt;/span&gt; variable is required to build the drivers in &lt;tt class="docutils literal"&gt;&lt;span class="pre"&gt;drivers/net/wireless-3.8&lt;/span&gt;&lt;/tt&gt;; the mwifiex driver in /drivers/net/wireless/ does not support the Chromebook&amp;#8217;s adapter.  CROSS_COMPILE should be set to the correct prefix for your&amp;nbsp;toolchain.&lt;/p&gt;
&lt;p&gt;In the kernel config, set &lt;tt class="docutils literal"&gt;Device Drivers &amp;gt; Generic Driver Options &amp;gt; External firmware blobs to build into the kernel binary&lt;/tt&gt; to &lt;tt class="docutils literal"&gt;nvidia/tegra124/xusb.bin&lt;/tt&gt;.  Make any other desired changes, and build the kernel, modules, and dtb&amp;nbsp;file:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
# WIFIVERSION=-3.8 ARCH=arm CROSS_COMPILE=armv7a-hardfloat-linux-gnueabi- make zImage
# WIFIVERSION=-3.8 ARCH=arm CROSS_COMPILE=armv7a-hardfloat-linux-gnueabi- make modules
# WIFIVERSION=-3.8 ARCH=arm CROSS_COMPILE=armv7a-hardfloat-linux-gnueabi- make tegra124-nyan-big.dtb
&lt;/pre&gt;
&lt;p&gt;Build a Flattened Image Tree using the provided configuration&amp;nbsp;file:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
# wget https://raw.githubusercontent.com/lgeek/gnu-linux-on-acer-chromebook-13/master/nyan-big-fit.cfg
# mkimage -f nyan-big-fit.cfg nyan-big-kernel
&lt;/pre&gt;
&lt;p&gt;Now create the kernel args and a bootable (signed) vboot&amp;nbsp;image:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
# echo &amp;quot;noinitrd console=tty1 debug verbose root=/dev/mmcblk1p7 rootwait rw lsm.module_locking=0 net.ifnames=0 rootfstype=ext4&amp;quot; &amp;gt; ./cmdline
# vbutil_kernel --arch arm --pack kernel.bin --keyblock /usr/share/vboot/devkeys/kernel.keyblock --signprivate /usr/share/vboot/devkeys/kernel_data_key.vbprivk --version 1 --config cmdline --vmlinuz nyan-big-kernel
&lt;/pre&gt;
&lt;p&gt;Now insert your prepared SDCard (see below) and copy the signed kernel image to your kernel partition, install the kernel modules, and copy your rootfs; here we&amp;#8217;ll use a stage3 armv7&amp;nbsp;tarball:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
# dd if=./kernel.bin of=/dev/sdb6
# mkfs.ext4 /dev/sdb7
# export mount_point=&amp;quot;/mnt/card/root/&amp;quot;
# mkdir -p $mount_point
# mount /dev/sdb7 $mount_point
# INSTALL_MOD_PATH=$mount_point WIFIVERSION=-3.8 ARCH=arm CROSS_COMPILE=armv7a-hardfloat-linux-gnueabi- make modules_install
# tar xpf /path/to/downloads/stage3-armv7a_hardfp-20141023.tar.bz2 -C $mount_point
&lt;/pre&gt;
&lt;div class="admonition-note admonition"&gt;
&lt;p class="first admonition-title"&gt;Note&lt;/p&gt;
&lt;p class="last"&gt;The above partion numbers match the SDCard section below; just use the matching values if yours are different (eg, use 1 and 2 instead of 6 and&amp;nbsp;7).&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;Now you can complete the normal Gentoo embedded install, ie, set the root password, configure and enable networking, etc.  Insert the card in your Chromebook (make sure it&amp;#8217;s in &amp;quot;developer&amp;quot; mode) and Ctrl-U at the warning&amp;nbsp;screen.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="for-native-builds"&gt;
&lt;h2&gt;For Native&amp;nbsp;Builds&lt;/h2&gt;
&lt;p&gt;Once you have a bootable SDCard, you&amp;#8217;re free to build more components on the card itself, or even better, use an external &lt;span class="caps"&gt;SSD&lt;/span&gt; or hard disk with a &lt;span class="caps"&gt;USB3&lt;/span&gt; interface.  This works well on even the older &lt;span class="caps"&gt;ARM&lt;/span&gt; Chromebooks (velcro, as always, is your friend, along with a short right-angle &lt;span class="caps"&gt;USB3&lt;/span&gt; cable).  For new kernels, simply omit the &lt;span class="caps"&gt;ARCH&lt;/span&gt; and CROSS_COMPILE variables and build/install as&amp;nbsp;above.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="make-an-sdcard"&gt;
&lt;h2&gt;Make an&amp;nbsp;SDCard&lt;/h2&gt;
&lt;p&gt;For either build method, you&amp;#8217;ll need an SDCard with the right partition format, which you can do by hand or with the chrubuntu script.  The one caveat is that the latest Chromeos on my own Acer 13 is missing some key tools compared to previous revisions, mainly parted and partprobe.  The workaround is that you must make a &lt;span class="caps"&gt;GPT&lt;/span&gt; partition table on the SDCard first, using another Linux machine (ie, not your shiny new Chromebook).  So first on another Linux machine, insert your (blank or unimportant) SDCard and run the following command, where &amp;quot;target_disk&amp;quot; is most likely either sdX for &lt;span class="caps"&gt;USB&lt;/span&gt; card readers or mmcblkX for built-in&amp;nbsp;devices:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
# export target_disk=&amp;quot;/dev/sdb&amp;quot;
# parted --script ${target_disk} &amp;quot;mktable gpt&amp;quot;
&lt;/pre&gt;
&lt;p&gt;The following can be done on the chromebook, which is what the chrubuntu script expects.  Since we&amp;#8217;re not running chrubuntu, we&amp;#8217;ll manually create some partitions, one for the kernel image, and one for the&amp;nbsp;rootfs:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
# ext_size=&amp;quot;`blockdev --getsz ${target_disk}`&amp;quot;
# aroot_size=$((ext_size - 65600 - 33 - 4*1024*1024*1024/512))
# cgpt create ${target_disk}
# cgpt add -i 6 -b 64 -s 32768 -S 1 -P 5 -l KERN-A -t &amp;quot;kernel&amp;quot; ${target_disk}
# cgpt add -i 7 -b 65600 -s $aroot_size -l ROOT-A -t &amp;quot;rootfs&amp;quot; ${target_disk}
# sync
# blockdev --rereadpt ${target_disk}
&lt;/pre&gt;
&lt;div class="admonition-note admonition"&gt;
&lt;p class="first admonition-title"&gt;Note&lt;/p&gt;
&lt;p class="last"&gt;The above assumes at least a 16 or 32 &lt;span class="caps"&gt;GB&lt;/span&gt; card.  4 &lt;span class="caps"&gt;GB&lt;/span&gt; is known not to&amp;nbsp;work.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;Now you can go back to installing Gentoo, or, if you must, run the chrubuntu script and&amp;nbsp;wait&amp;#8230;&lt;/p&gt;
&lt;/div&gt;
</summary><category term="Gentoo"></category><category term="low power"></category><category term="Ubuntu"></category><category term="chrubuntu"></category><category term="embedded"></category><category term="ARM"></category><category term="Tegra"></category><category term="Nvidia"></category><category term="Linux"></category></entry><entry><title>Stock and Custom PiTFT Kernel Options with Your Choice of rootfs</title><link href="http://www.vctlabs.com/posts/2014/Oct/22/pitft_kernel/" rel="alternate"></link><updated>2014-10-22T00:00:00-07:00</updated><author><name>Stephen Arnold</name></author><id>tag:www.vctlabs.com,2014-10-22:posts/2014/Oct/22/pitft_kernel/</id><summary type="html">&lt;p&gt;This is primarily useful if you have one of the Adafruit (or similar) small &lt;span class="caps"&gt;TFT&lt;/span&gt;/&lt;span class="caps"&gt;LCD&lt;/span&gt; displays for Raspberrypi (one possible non-Adafruit vendor is SainSmart).  The Adafruit displays are available in several sizes and configurations, both touch and non-touch, some come in kit or assembled form, and some are available in both Capacitive and Resistive Touch (&lt;span class="caps"&gt;CT&lt;/span&gt; / &lt;span class="caps"&gt;RT&lt;/span&gt;) varieties. The particular display tested here is the Adafruit 2.8 inch PiTFT resistive touchscreen display.  It&amp;#8217;s just a bit smaller than the bezel on the Pibow acrylic case, with the button pads exposed along the &amp;quot;bottom&amp;quot; of the board (which needs a default 90 degree rotation argument passed to the&amp;nbsp;kernel).&lt;/p&gt;
&lt;p&gt;Since the upstream raspberrypi kernel and firmware does not yet have support for these devices, you&amp;#8217;ll need to do one of the following: download a new rootfs or kernel image, update your existing raspbian image using the Adafruit script, or build your own custom kernel using either the modified Adafruit kernel source or adding the fbtft device drivers to your own kernel source and rebuild.  The current support is still maintained in the &lt;a class="reference external" href="https://github.com/adafruit"&gt;Adafruit forks&lt;/a&gt; of the &lt;a class="reference external" href="https://github.com/raspberrypi"&gt;raspberrypi.org repos&lt;/a&gt; on&amp;nbsp;Github.&lt;/p&gt;
&lt;p&gt;The best documentation I know of for assembling and testing the Adafruit displays are on the Adafruit site, specifically &lt;a class="reference external" href="https://learn.adafruit.com/adafruit-pitft-28-inch-resistive-touchscreen-display-raspberry-pi/overview"&gt;Adafruit PiTFT 2.8 inch Touchscreen Display for Raspberry Pi&lt;/a&gt; for the display described&amp;nbsp;here.&lt;/p&gt;
&lt;div class="section" id="easy-raspbian-install-upgrade"&gt;
&lt;h2&gt;Easy Raspbian&amp;nbsp;Install/Upgrade&lt;/h2&gt;
&lt;p&gt;If you already have a recent Raspbian install, the easiest way is to use the upgrade script provided by Adafruit.  Since it&amp;#8217;s a Bash shell script, you can read through it fairly easily to see what it will do.  Download the script from the Easy Install section and follow the steps in the excellent Adafruit document linked&amp;nbsp;above.&lt;/p&gt;
&lt;div class="admonition-note admonition"&gt;
&lt;p class="first admonition-title"&gt;Note&lt;/p&gt;
&lt;p class="last"&gt;If you don&amp;#8217;t have a current Raspbian image, then download the &lt;a class="reference external" href="http://adafruit-download.s3.amazonaws.com/PiTFT28R_raspbian140620_2014_08_25.zip"&gt;Adafruit image here&lt;/a&gt; and burn it to a card (no extra configuration should be&amp;nbsp;required).&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;If you&amp;#8217;d rather do things by hand and/or leave things largely unmodified, then you can manually upgrade your kernel and firmware by cloning the Adafruit firmware repo on Github and manually update your running card as follows, after logging into your&amp;nbsp;pi:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ cd ~/
$ sudo mount /boot  # make sure /boot is mounted
$ git clone https://github.com/adafruit/rpi-firmware.git
$ sudo cp /boot/kernel.img kernel.bak
$ cd rpi-firmware
$ sudo cp -v boot/* /boot/
$ sudo cp -v extra/Module.symvers /boot/
$ sudo cp -av modules/3.15.8+ /lib/modules/
&lt;/pre&gt;
&lt;p&gt;Depending on your actual hardware, the above kernel config may be missing the correct config to work with the modules and options documented in the Adafruit guide.  If the latest Adafruit kernel does not load the fbtft_device module correctly, then download and unpack the .deb packages in the script and manually install the 3.12.x kernel using the above&amp;nbsp;process.&lt;/p&gt;
&lt;p&gt;At some point later you can update your userland (vcgraphics) software as well, but for now we only need to test the kernel and display.  This may very well suffice for your needs, so feel free to stop here and finish the config manually (or maybe go back and run the install script).  The rest of this document is mainly for building your own custom kernel; if that&amp;#8217;s what you want to do keep&amp;nbsp;reading&amp;#8230;&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="custom-pitft-kernel-and-rootfs"&gt;
&lt;h2&gt;Custom PiTFT Kernel and&amp;nbsp;Rootfs&lt;/h2&gt;
&lt;p&gt;Currently the &amp;quot;upstream&amp;quot; for Adafruit hardware support are their repos on Github (of which there are many).  In this case, the important ones are their forks of the &amp;quot;official&amp;quot; raspberrypi kernel source and firmware, along with the fbtft framebuffer drivers (which get automatically included as a submodule in the kernel source&amp;nbsp;repo).&lt;/p&gt;
&lt;blockquote&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;a class="reference external" href="https://github.com/adafruit/adafruit-raspberrypi-linux"&gt;https://github.com/adafruit/adafruit-raspberrypi-linux&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class="reference external" href="https://github.com/adafruit/rpi-firmware"&gt;https://github.com/adafruit/rpi-firmware&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class="reference external" href="https://github.com/adafruit/adafruit-rpi-fbtft"&gt;https://github.com/adafruit/adafruit-rpi-fbtft&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;p&gt;If you&amp;#8217;re running Gentoo, you can add the following overlay and use the adafruit-raspberrypi-sources ebuild and ignore the manual clone steps for the kernel, et al, in the next subsection.  For&amp;nbsp;Gentoo:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ cd /usr/local/
$ git clone https://github.com/sarnold/arm.git
&lt;/pre&gt;
&lt;p&gt;Add /usr/local/arm to your PORTDIR_OVERLAY in make.conf,&amp;nbsp;then:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ echo &amp;quot;=sys-kernel/adafruit-raspberrypi-sources-3.15.9999 **&amp;quot; &amp;gt;&amp;gt; /etc/portage/package.accept_keywords
$ sudo emerge adafruit-raspberrypi-sources
&lt;/pre&gt;
&lt;p&gt;For other distros, continue with the manual steps&amp;nbsp;below.&lt;/p&gt;
&lt;p&gt;To build your own kernel and update your boot firmware, you&amp;#8217;ll need to clone the first two repos above (if you already have the firmware repo, you can omit the second one below).  You&amp;#8217;ll also need to either clone recursively or do the git submodule dance to actually bring the fbtft source files into the drivers/video/fbtft directory.  Note the following steps assume you&amp;#8217;re either building native on the Pi itself, or in an appropriate &lt;span class="caps"&gt;ARM&lt;/span&gt; chroot or virtual environment.  If you need to cross-comppile the kerrnel, then you can follow the usual &lt;a class="reference external" href="http://elinux.org/Raspberry_Pi_Kernel_Compilation"&gt;Raspberrypi&lt;/a&gt; cross-compile process (you will of course need an appropriate cross toolchain and build&amp;nbsp;environment).&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ sudo -i
# git clone --recursive https://github.com/adafruit/adafruit-raspberrypi-linux.git
# git clone https://github.com/adafruit/rpi-firmware.git
# cd adafruit-raspberrypi-linux
# git checkout rpi-3.15.y -b rpi-3.15-working   # create local branch
# cp arch/arm/configs/adafruit_defconfig .config
# sed -i -e &amp;quot;s/CONFIG_DMA_BCM2708=m/CONFIG_DMA_BCM2708=y/&amp;quot; .config
# sed -i -e &amp;quot;s/CONFIG_DMA_VIRTUAL_CHANNELS=m/CONFIG_DMA_VIRTUAL_CHANNELS=y/&amp;quot; .config
# make oldconfig
&lt;/pre&gt;
&lt;p&gt;There are only two active branches in the adafruit-raspberrypi-linux repo, rpi-3.10.y and rpi-3.15.y so make sure you&amp;#8217;ve checked out the branch you want (note 3.10 is&amp;nbsp;default).&lt;/p&gt;
&lt;p&gt;Now you can proceed with building the default kernel config, however, you may want to modify it further to suit your own needs (eg, to enable the zram block device or the latest nftables&amp;nbsp;support).&lt;/p&gt;
&lt;div class="admonition-note admonition"&gt;
&lt;p class="first admonition-title"&gt;Note&lt;/p&gt;
&lt;p class="last"&gt;The adafruit-raspberrypi-sources ebuild takes care of the above two sed commands for you, otherwise you must do it manually.  This is very important or else the fbtft_device module will not load correctly when following the Adafruit&amp;nbsp;instructions.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;Once you&amp;#8217;re ready, proceed as you normally would to build/deploy a&amp;nbsp;kernel:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
# make menuconfig
# make -jN
# make modules_install
# mount /boot
# cp /boot/kernel.img ~/kernel.bak
# cp arch/arm/boot/zImage /boot/kernel.img
# cp Module.symvers /boot/
&lt;/pre&gt;
&lt;p&gt;If you didn&amp;#8217;t follow the above steps to update your boot files, you should do that now (be careful not to clobber your new kernel.img file).  Also, with newer u-boot, the above (compressed) kernel zImage file should work fine, but if it doesn&amp;#8217;t boot use the (uncompressed) Image file instead (note that you only need one, not both, just rename either one to &amp;quot;kernel.img&amp;quot; when you copy it to&amp;nbsp;/boot).&lt;/p&gt;
&lt;p&gt;Now is a good time to reboot and test the new kernel (however, the display won&amp;#8217;t really be usable until we finish the configuration).  Make sure all your normal services are working and everything looks nominal.  If not, copy your backup kernel from above back to /boot/kernel.img and try reverting any suspect config changes (you can always start from the defconfig again if&amp;nbsp;necessary).&lt;/p&gt;
&lt;p&gt;As mentioned, we still need to make the required config changes for the framebuffer modules, boot arguments, environment variables, etc.  The required changes are all documented in the Adafruit guide above, as welll as in the bash install script for raspbian.  You may or may not want all of the changes, depending on how you plan to use your display.  For example, if you want to display specific output or other data, simiilar to how you might use one of the 2-line character &lt;span class="caps"&gt;LED&lt;/span&gt; displays, then you probably don&amp;#8217;t want to use it as a login console.  It all depends on &lt;em&gt;your&lt;/em&gt; requirements, so we&amp;#8217;ll walk through each major change&amp;nbsp;below.&lt;/p&gt;
&lt;p&gt;Although the following configuration snippets are strictly &amp;quot;optional&amp;quot;, if you want your display to actually &lt;em&gt;do&lt;/em&gt; anything besides light up with a white backlight, then you&amp;#8217;ll at least want to configure the module parameters for your display device, and (optionally) autoload the modules on&amp;nbsp;boot.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="configure-modules"&gt;
&lt;h2&gt;Configure&amp;nbsp;Modules&lt;/h2&gt;
&lt;p&gt;Raspbian (and similar) will load the modules specified in /etc/modules, while Gentoo uses&amp;nbsp;/etc/conf.d/modules:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
modules=&amp;quot;i2c-dev bcm2708-rng snd-bcm2835 spi-bcm2708 i2c-bcm2708 fbtft_device&amp;quot;
&lt;/pre&gt;
&lt;p&gt;The last three are required for the display device, with the following default parameters.  Feel free to experiment (within limits) with the clock speed and rotation.  Most distros use various conf files in /etc/modprobe.d to configure modules; in this case the &lt;a class="reference external" href="https://learn.adafruit.com/adafruit-pitft-28-inch-resistive-touchscreen-display-raspberry-pi/software-installation"&gt;Adafruit Software Install section&lt;/a&gt; asks you to create /etc/modprobe.d/adafruit.conf with the following&amp;nbsp;contents:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
options fbtft_device name=adafruitrt28 rotate=90 frequency=3200000
&lt;/pre&gt;
&lt;p&gt;Note the &amp;quot;name&amp;quot; parameter is specific to the 2.8 inch &lt;span class="caps"&gt;RT&lt;/span&gt; display, while the others are recommended defaults (90 degree rotation puts the button pads along the bottom of the display).  These values should take effect whether modules are loaded manually or at boot&amp;nbsp;time.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="configure-kernel-command-line"&gt;
&lt;h2&gt;Configure Kernel Command&amp;nbsp;Line&lt;/h2&gt;
&lt;p&gt;Modifying the command line will switch the default console device to the small display on boot, so depends on how you want to use the display.  With the options below, the display will switch when the fbtft_device module loads (how much of the boot process you can see depends on the size of the kernel log buffer).  If you want the console display to switch, then you&amp;#8217;ll need to edit /boot/cmdline.txt (which is simply a single line of kernel parameters).  Add the last two parameters to whatever is currently there as&amp;nbsp;shown:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait fbcon=map:10 fbcon=font:VGA8x8
&lt;/pre&gt;
&lt;p&gt;Be sure it stays all on one line of text.  In Gentoo you can change fonts in your consolefont config, otherwise use &amp;quot;dpkg-reconfigure console-setup&amp;quot; to change your console&amp;nbsp;font.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="configure-xorg"&gt;
&lt;h2&gt;Configure&amp;nbsp;Xorg&lt;/h2&gt;
&lt;p&gt;Xorg needs to know both which display to use and what the touchscreen calibration values are.  To get started, create a default set of &amp;quot;touch&amp;quot; input values in /etc/X11/xorg.conf.d/99-calibration.conf and use the following&amp;nbsp;values:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
Section &amp;quot;InputClass&amp;quot;
Identifier &amp;quot;calibration&amp;quot;
MatchProduct &amp;quot;stmpe-ts&amp;quot;
Option &amp;quot;Calibration&amp;quot; &amp;quot;3800 200 200 3800&amp;quot;
Option &amp;quot;SwapAxes&amp;quot; &amp;quot;1&amp;quot;
EndSection
&lt;/pre&gt;
&lt;p&gt;You can recalibrate later for more accuracy.  Somewhere in your environment (either user or system) you also need to set &lt;span class="caps"&gt;FRAMEBUFFER&lt;/span&gt;=/dev/fb1 so X will know where to point the display output.  In Raspbian, you can set that in ~/.profile or /etc/profile and will also probably need to move the fbdev-turbo config out of&amp;nbsp;/etc/X11/xorg.conf.d/.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="configure-udev"&gt;
&lt;h2&gt;Configure&amp;nbsp;Udev&lt;/h2&gt;
&lt;p&gt;The actual touchscreen driver for the 2.8 inch &lt;span class="caps"&gt;RT&lt;/span&gt; display will load on its own, however, the following udev rule is recommended.  Add the rule file /etc/udev/rules.d/95-stmpe.rules with the following&amp;nbsp;contents:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
SUBSYSTEM==&amp;quot;input&amp;quot;, ATTRS{name}==&amp;quot;stmpe-ts&amp;quot;, ENV{DEVNAME}==&amp;quot;*event*&amp;quot;, SYMLINK+=&amp;quot;input/touchscreen&amp;quot;
&lt;/pre&gt;
&lt;p&gt;Once you reload the module, the output of &amp;quot;ls -l /dev/input/touchscreen&amp;quot; should be symlink to an eventN&amp;nbsp;device.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="manual-calibration"&gt;
&lt;h2&gt;Manual&amp;nbsp;Calibration&lt;/h2&gt;
&lt;p&gt;Follow the &lt;a class="reference external" href="https://learn.adafruit.com/adafruit-pitft-28-inch-resistive-touchscreen-display-raspberry-pi/touchscreen-install-and-calibrate"&gt;Touchscreen Install and Calibration section&lt;/a&gt; of the Adafruit documentation to install the tools and manually calibrate your touchscreen (they also have an &amp;quot;auto&amp;quot; calibration&amp;nbsp;script).&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="testing-video-playback"&gt;
&lt;h2&gt;Testing Video&amp;nbsp;Playback&lt;/h2&gt;
&lt;p&gt;Follow the &lt;a class="reference external" href="https://learn.adafruit.com/adafruit-pitft-28-inch-resistive-touchscreen-display-raspberry-pi/playing-videos"&gt;Playing Videos section&lt;/a&gt; of the Adafruit documentation to test your display with a small animated video.  Since mplayer doesn&amp;#8217;t use the accelerated RPi graphics libs, it seems to be right on the edge of being able to play the test video correctly (ie, with audio and video in sync and without dropping too many frames).  It seems to play correctly in Raspbian, however, in Gentoo the audio was always several seconds delayed without additional configuration options in&amp;nbsp;~/.mplayer/config:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
lavdopts=lowres=1:fast=1:skiploopfilter=all
vfm=ffmpeg

# ao is the audio output and should be pulse if using pulseaudio
ao=alsa

# af is the audio filter, using re-sampling in this case, to provide audible sound
#af=lavcresample=44100

# Allow framedropping might reduce video quality, but allows video and audio to stay synced
framedrop = yes

fps=24.0
&lt;/pre&gt;
&lt;p&gt;The key option in this case is fps=24 for smooth/synced playback.  The &lt;span class="caps"&gt;CPU&lt;/span&gt; utilization is just a little over 50%.  Use the above config options with the following command&amp;nbsp;line:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ mplayer -vo fbdev2:/dev/fb1 -x 240 -y 320 bigbuckbunny320p.mp4
&lt;/pre&gt;
&lt;p&gt;With the above parameters the test video would play with audio and video in sync and decent quality for both audio and video.  Note that audio quality can suffer if running from a noisy power source (such as a cheap battery).  If audio is noisy, try a decent quality power&amp;nbsp;brick.&lt;/p&gt;
&lt;/div&gt;
</summary><category term="Gentoo"></category><category term="Debian"></category><category term="Linux kernel"></category><category term="Raspberrypi"></category><category term="PiTFT"></category><category term="LCD display"></category></entry><entry><title>Maintaining Your Stock BeagleBone Angstrom Images and Demos</title><link href="http://www.vctlabs.com/posts/2014/Sep/14/beaglebone_images/" rel="alternate"></link><updated>2014-09-14T00:00:00-07:00</updated><author><name>Stephen Arnold</name></author><id>tag:www.vctlabs.com,2014-09-14:posts/2014/Sep/14/beaglebone_images/</id><summary type="html">&lt;p&gt;In a previous news article, we described building and deploying the latest U-boot
and Linux kernels on several armv7 machines, &lt;a class="reference external" href="/posts/2014/Jun/18/armv7_kernels/"&gt;including a BeagleBoneBlack&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;In this &amp;quot;&lt;span class="caps"&gt;HOWTO&lt;/span&gt;&amp;quot; we&amp;#8217;ll talk about restoring/upgrading/maintaining your stock
Angstrom install on both BeagleBone White and Black.  Why would we do this?
Several reasons, but typically to restore the default install or upgrade to
the latest build.  The nice thing about BeagleBoneBlack is that Angstrom lives
on the eMMC and you can always boot whatever you need off the SDCard.  Since
BeagleBoneWhite only has an SDCard, you simply swap your default 4 &lt;span class="caps"&gt;GB&lt;/span&gt; card
with Angstrom for another (possibly larger) card running your &lt;span class="caps"&gt;OS&lt;/span&gt;/Distro of
choice.  The two models have slightly different bleeding-edge patch sets
and hardware interfaces, but otherwise are very&amp;nbsp;similar:&lt;/p&gt;
&lt;blockquote&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;BeagleBoneBlack Rev &lt;span class="caps"&gt;A6A&lt;/span&gt; - &lt;a class="reference external" href="http://eewiki.net/display/linuxonarm/BeagleBone+Black"&gt;http://eewiki.net/display/linuxonarm/BeagleBone+Black&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;BeagleBoneWhite Rev A6 - &lt;a class="reference external" href="https://eewiki.net/display/linuxonarm/BeagleBone"&gt;https://eewiki.net/display/linuxonarm/BeagleBone&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;BeagleBoargd.org info - &lt;a class="reference external" href="http://beagleboard.org/static/beaglebone/latest/README.htm"&gt;http://beagleboard.org/static/beaglebone/latest/&lt;span class="caps"&gt;README&lt;/span&gt;.htm&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Bonescript and documentation repos - &lt;a class="reference external" href="https://github.com/jadonk"&gt;https://github.com/jadonk&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;div class="section" id="out-of-the-box"&gt;
&lt;h2&gt;Out of the&amp;nbsp;Box&lt;/h2&gt;
&lt;p&gt;Depending on when it was produced/packaged, your BeagleBone will most likely
come with one of the Angstrom builds for SDCard and/or eMMC install.  There
are some builds which are supposed to support both White and Black, as well
as an SDCard image for &amp;quot;flashing&amp;quot; the eMMC on the Black.  There are changes
in both the Bone101/Cloud9 &lt;span class="caps"&gt;IDE&lt;/span&gt; and Gnome desktop config in the various builds
so it&amp;#8217;s probably worth it to try a couple of them (some seem to have a less
optimal Cloud9 bonescript environment than&amp;nbsp;others).&lt;/p&gt;
&lt;p&gt;The recommended builds are given below, &amp;quot;latest&amp;quot; for Black, and a slightly
older one for White (recommended for a good new user experience).  Simply
download the desired image, either from the archive or the latest link, and
use the standard tools (dd or WinDiskImager) to uncomnpress and write the
image to your SDCard device (be sure and select the .img file unless you
want to manually create your card and deploy the rootfs, etc).  Use the
links above for the manual method, otherwise download one or more of the
following&amp;nbsp;images:&lt;/p&gt;
&lt;blockquote&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;a class="reference external" href="http://downloads.angstrom-distribution.org/demo/beaglebone/archive/BBB-eMMC-flasher-2013.09.07.img.xz"&gt;Latest eMMC flasher for&amp;nbsp;Black&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class="reference external" href="http://downloads.angstrom-distribution.org/demo/beaglebone/archive/Angstrom-Cloud9-IDE-GNOME-eglibc-ipk-v2012.05-beaglebone-2012.11.22.img.xz"&gt;Recommended SDCard image for&amp;nbsp;White&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class="reference external" href="http://downloads.angstrom-distribution.org/demo/beaglebone/archive/"&gt;Archive of &lt;span class="caps"&gt;OS&lt;/span&gt;, u-boot, and kernel&amp;nbsp;images&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class="reference external" href="http://beagleboard.org/latest-images/"&gt;Latest &lt;span class="caps"&gt;OS&lt;/span&gt; images for all Beagle boards, both Angstrom and&amp;nbsp;Debian&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;div class="admonition-note admonition"&gt;
&lt;p class="first admonition-title"&gt;Note&lt;/p&gt;
&lt;p class="last"&gt;The BeagleBoneWhite Rev A6 I received came with the above 2012.11.22 image on a 4 &lt;span class="caps"&gt;GB&lt;/span&gt; SDCard.  The
Bone101 slideshow is highly recommended for new&amp;nbsp;users.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;Although these kernels are fairly recent, they are several versions
behind the latest kernel source (typically 3.10.x rather than 3.16.x)
and do not yet support &lt;span class="caps"&gt;HDMI&lt;/span&gt; out.  A future &lt;span class="caps"&gt;HOWTO&lt;/span&gt; will discuss building
your own &lt;span class="caps"&gt;OS&lt;/span&gt; images with custom kernels,&amp;nbsp;etc.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="beaglebonewhite-cloud9-ide-and-bone101-web-tutorial"&gt;
&lt;h2&gt;BeagleBoneWhite Cloud9 &lt;span class="caps"&gt;IDE&lt;/span&gt; and Bone101 Web&amp;nbsp;Tutorial&lt;/h2&gt;
&lt;p&gt;One of the hardware differences on the White is a built-in &lt;span class="caps"&gt;USB&lt;/span&gt; serial
converter on the mini-&lt;span class="caps"&gt;USB&lt;/span&gt; port, so as long as your desktop kernel (or
other &lt;span class="caps"&gt;OS&lt;/span&gt; drivers) is configured properly, you should have a serial
console as soon as you plug in the &lt;span class="caps"&gt;USB&lt;/span&gt; cable (use minicom or putty
to connect at 115200,8N1, no flow control).  However, even more
interesting is the web server and Cloud9 &lt;span class="caps"&gt;IDE&lt;/span&gt; running on the network
interface, which should configure itself if you have &lt;span class="caps"&gt;DHCP&lt;/span&gt; (if not
you&amp;#8217;ll need to configure it manually via the serial console (login
as root with no&amp;nbsp;password).&lt;/p&gt;
&lt;p&gt;Download one of the Cloud9-&lt;span class="caps"&gt;IDE&lt;/span&gt; build images and write it to a&amp;nbsp;card:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ wget http://downloads.angstrom-distribution.org/demo/beaglebone/archive/Angstrom-Cloud9-IDE-GNOME-eglibc-ipk-v2012.05-beaglebone-2012.11.22.img.xz
$ xz -d Angstrom-Cloud9-IDE-GNOME-eglibc-ipk-v2012.05-beaglebone-2012.11.22.img.xz
$ sudo dd if=Angstrom-Cloud9-IDE-GNOME-eglibc-ipk-v2012.05-beaglebone-2012.11.22.img of=/dev/sdX bs=4M
&lt;/pre&gt;
&lt;p&gt;(where sdX is your SDCard&amp;nbsp;device)&lt;/p&gt;
&lt;p&gt;Once your BeagleBoneWhite is on the network, use Avahi/Zeroconf or
the serial console to discover the &lt;span class="caps"&gt;IP&lt;/span&gt; address, then point your browser
at the &lt;span class="caps"&gt;IP&lt;/span&gt; address of your White (anything modern except &lt;span class="caps"&gt;IE&lt;/span&gt; should work).
You should see the Bone101 introduction, which will introduce you to,
and allow you to interact with, your new &lt;span class="caps"&gt;BBW&lt;/span&gt;.  There are bonescript
demos and hardware diagrams, including details on the board itself and
all the pinouts.  Click on the Cloud9 &lt;span class="caps"&gt;IDE&lt;/span&gt; link and try some of the
demo scripts (note the BlinkLED demo calls out an external &lt;span class="caps"&gt;LED&lt;/span&gt;, but
should also trigger the onboard &lt;span class="caps"&gt;USR3&lt;/span&gt; &lt;span class="caps"&gt;LED&lt;/span&gt;).&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="beagleboneblack-emmc-flashing-tool-w-latest-cloud9-ide-and-documentation"&gt;
&lt;h2&gt;BeagleBoneBlack eMMC Flashing Tool w/ Latest Cloud9 &lt;span class="caps"&gt;IDE&lt;/span&gt; and&amp;nbsp;Documentation&lt;/h2&gt;
&lt;p&gt;In addition to the bootable micro-SDCard slot, the Black also has onboard
eMMC flash (not technically true flash, but consider it like a faster and
built-in SDCard).  The Black should come out of the box with one of the
recent builds listed above; if yours is older or corrupted and you&amp;#8217;d like
to update to the latest &amp;quot;official&amp;quot; build (including the latest Cloud9 &lt;span class="caps"&gt;IDE&lt;/span&gt;
and documentation) then perform the following&amp;nbsp;steps.&lt;/p&gt;
&lt;p&gt;Download the latest Cloud9-&lt;span class="caps"&gt;IDE&lt;/span&gt; build image and write it to a&amp;nbsp;card:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ wget http://downloads.angstrom-distribution.org/demo/beaglebone/archive/BBB-eMMC-flasher-2013.09.07.img.xz
$ xz -d BBB-eMMC-flasher-2013.09.07.img.xz
$ sudo dd if=BBB-eMMC-flasher-2013.09.07.img.xz of=/dev/sdX bs=4M
&lt;/pre&gt;
&lt;p&gt;(where sdX is your SDCard&amp;nbsp;device)&lt;/p&gt;
&lt;div class="admonition-note admonition"&gt;
&lt;p class="first admonition-title"&gt;Note&lt;/p&gt;
&lt;p class="last"&gt;If your BeagleBoneBlack is a Rev C, it should have a 4 &lt;span class="caps"&gt;GB&lt;/span&gt; eMMC,
and you can use one of the larger flash&amp;nbsp;images.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;Boot the Black with the new card and wait (you can connect a network
cable if you like; this will allow you to login and check the status).
Once the kernel loads, the LEDs will blink in their default&amp;nbsp;config:&lt;/p&gt;
&lt;blockquote&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;span class="caps"&gt;USR0&lt;/span&gt; - blink in a heartbeat&amp;nbsp;pattern&lt;/li&gt;
&lt;li&gt;&lt;span class="caps"&gt;USR1&lt;/span&gt; - light during microSD card&amp;nbsp;accesses&lt;/li&gt;
&lt;li&gt;&lt;span class="caps"&gt;USR2&lt;/span&gt; - light during &lt;span class="caps"&gt;CPU&lt;/span&gt;&amp;nbsp;activity&lt;/li&gt;
&lt;li&gt;&lt;span class="caps"&gt;USR3&lt;/span&gt; - light during eMMC&amp;nbsp;accesses&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;p&gt;The &lt;span class="caps"&gt;USR3&lt;/span&gt; &lt;span class="caps"&gt;LED&lt;/span&gt; will (for the most part) stay lit while the flashing
script does the formatting, unpacking, and configuration of the
rootfs.  When this process is finished, all 4 &lt;span class="caps"&gt;USR&lt;/span&gt; LEDs will light
up solid.  You can then power down and remove the card, then boot
your new Angstrom&amp;nbsp;install.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="beaglebone-usb-ethernet-network-configuration-and-automation"&gt;
&lt;h2&gt;BeagleBone &lt;span class="caps"&gt;USB&lt;/span&gt;/Ethernet Network Configuration and&amp;nbsp;Automation&lt;/h2&gt;
&lt;p&gt;Both Black and White BeagleBones default to &lt;span class="caps"&gt;DHCP&lt;/span&gt; for the ethernet
interface, so the &lt;span class="caps"&gt;IP&lt;/span&gt; address will depend on your own local network
setup.  While the White has the serial console on the mini &lt;span class="caps"&gt;USB&lt;/span&gt;
interface, the Black has the same port configured as a &lt;span class="caps"&gt;USB&lt;/span&gt; gadget
interface.  &lt;span class="caps"&gt;IF&lt;/span&gt; your kernel is properly configured, it should appear
as 3 devices: an ethernet interface (either usb0 or ethX), an &lt;span class="caps"&gt;ACM&lt;/span&gt;
tty device (/dev/ttyACM0), and a &lt;span class="caps"&gt;USB&lt;/span&gt; storage device.  Check dmesg
or the kernel log for something similar to&amp;nbsp;this:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
kernel: usb 2-6: new high-speed USB device number 5 using ehci-pci
kernel: usb 2-6: New USB device found, idVendor=1d6b, idProduct=0104
kernel: usb 2-6: New USB device strings: Mfr=2, Product=3, SerialNumber=4
kernel: usb 2-6: Product: BeagleBoneBlack
kernel: usb 2-6: Manufacturer: Circuitco
kernel: usb 2-6: SerialNumber: 6A-0314BBBK4860
kernel: usb-storage 2-6:1.4: USB Mass Storage device detected
kernel: scsi12 : usb-storage 2-6:1.4
mtp-probe: checking bus 2, device 5: &amp;quot;/sys/devices/pci0000:00/0000:00:13.2/usb2/2-6&amp;quot;
mtp-probe: bus: 2, device: 5 was not an MTP device
kernel: cfg80211: Calling CRDA to update world regulatory domain
kernel: usbcore: registered new interface driver cdc_ether
kernel: rndis_host 2-6:1.0 eth1: register 'rndis_host' at usb-0000:00:13.2-6, RNDIS device, 90:59:af:68:74:cf
kernel: usbcore: registered new interface driver rndis_host
kernel: usbcore: registered new interface driver rndis_wlan
kernel: cdc_acm 2-6:1.2: This device cannot do calls on its own. It is not a modem.
kernel: cdc_acm 2-6:1.2: ttyACM0: USB ACM device
kernel: usbcore: registered new interface driver cdc_acm
kernel: cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
kernel: cfg80211: World regulatory domain updated:
kernel: cfg80211:   (start_freq - end_freq &amp;#64; bandwidth), (max_antenna_gain, max_eirp)
kernel: cfg80211:   (2402000 KHz - 2472000 KHz &amp;#64; 40000 KHz), (N/A, 2000 mBm)
kernel: cfg80211:   (2457000 KHz - 2482000 KHz &amp;#64; 40000 KHz), (N/A, 2000 mBm)
kernel: cfg80211:   (2474000 KHz - 2494000 KHz &amp;#64; 20000 KHz), (N/A, 2000 mBm)
kernel: cfg80211:   (5170000 KHz - 5250000 KHz &amp;#64; 80000 KHz), (N/A, 2000 mBm)
kernel: cfg80211:   (5735000 KHz - 5835000 KHz &amp;#64; 80000 KHz), (N/A, 2000 mBm)
kernel: cfg80211:   (57240000 KHz - 63720000 KHz &amp;#64; 2160000 KHz), (N/A, 0 mBm)
kernel: ip_tables: (C) 2000-2006 Netfilter Core Team
kernel: nf_conntrack version 0.5.0 (16384 buckets, 65536 max)
kernel: scsi 12:0:0:0: Direct-Access     Linux    File-CD Gadget   0308 PQ: 0 ANSI: 2
kernel: sd 12:0:0:0: [sdb] 144522 512-byte logical blocks: (73.9 MB/70.5 MiB)
kernel: sd 12:0:0:0: [sdb] Write Protect is off
kernel: sd 12:0:0:0: [sdb] Mode Sense: 0f 00 00 00
kernel: sd 12:0:0:0: [sdb] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
&lt;/pre&gt;
&lt;p&gt;The gadget ethernet device can be configured just like any other,
whether manually, with a script, or your distro&amp;#8217;s config tools.
The latter is recommended; for example on Gentoo you can add a
new config file in /etc/conf.d for the ethernet interface (eth1
in this example).  You must also allow network hotplugging in
rc.conf (or /etc/conf.d/rc if your system is old).  The default
&lt;span class="caps"&gt;IP&lt;/span&gt; address on the Black side of gadget ethernet is 192.168.7.2,
and will assign 192.168.7.1 to the desktop side if left to &lt;span class="caps"&gt;DHCP&lt;/span&gt;
(here we hard-code a static address since this is a local&amp;nbsp;subnet).&lt;/p&gt;
&lt;p&gt;From&amp;nbsp;/etc/rc.conf:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
# This allows all services to be hotplugged
rc_hotplug=&amp;quot;*&amp;quot;
&lt;/pre&gt;
&lt;p&gt;And&amp;nbsp;/etc/conf.d/net.eth1:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
config_eth1=&amp;quot;192.168.7.1 netmask 255.255.255.0 brd 192.168.7.255&amp;quot;
routes_eth1=&amp;quot;default via 192.168.7.1&amp;quot;

preup() {
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.7.0/24
echo 1 &amp;gt; /proc/sys/net/ipv4/ip_forward
iptables -P FORWARD ACCEPT
return 0
}

postdown() {
echo 0 &amp;gt; /proc/sys/net/ipv4/ip_forward
iptables -t nat -F
return 0
}
&lt;/pre&gt;
&lt;p&gt;It&amp;#8217;s also possible to use a udev rule or manual script instead, but
I prefer the network-config approach best.  The above configuration
should configure everything automatically on the host side when the
Black &lt;span class="caps"&gt;USB&lt;/span&gt; cable is plugged in.  Now you can browse the web interface
over the BeagleBone gadget ethernet (just point your browser to&amp;nbsp;192.168.7.2).&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="default-beaglebone-usbnet-config-missing-dns-servers-and-default-route"&gt;
&lt;h2&gt;Default BeagleBone USBNet Config Missing &lt;span class="caps"&gt;DNS&lt;/span&gt; Servers and Default&amp;nbsp;Route&lt;/h2&gt;
&lt;p&gt;If you&amp;#8217;re logged in remotely to your BeagleBone over the &lt;span class="caps"&gt;USB&lt;/span&gt; ethernet
connection, you might notice there&amp;#8217;s only a host route and the default
&lt;span class="caps"&gt;DNS&lt;/span&gt; server is the loopback address.  If you want your BeagleBone to see
outside the local subnet, then you&amp;#8217;ll need to add a default&amp;nbsp;route:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
# route add default gw 192.168.7.1
&lt;/pre&gt;
&lt;p&gt;You can do this permanently by editing the default dhcp udev rule. You&amp;#8217;ll
need to edit /etc/udev/rules.d/udhcpd.rules and change&amp;nbsp;this:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
SUBSYSTEM==&amp;quot;net&amp;quot;,ACTION==&amp;quot;add&amp;quot;,KERNEL==&amp;quot;usb0&amp;quot;,RUN+=&amp;quot;/sbin/ifconfig usb0 192.168.7.2 netmask 255.255.255.252&amp;quot;,RUN+=&amp;quot;/bin/systemctl start udhcpd.service&amp;quot;
&lt;/pre&gt;
&lt;p&gt;to&amp;nbsp;this:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
SUBSYSTEM==&amp;quot;net&amp;quot;,ACTION==&amp;quot;add&amp;quot;,KERNEL==&amp;quot;usb0&amp;quot;,RUN+=&amp;quot;/sbin/ifconfig usb0 192.168.7.2 netmask 255.255.255.252&amp;quot;,RUN+=&amp;quot;/sbin/route add default gw 192.168.7.1&amp;quot;,RUN+=&amp;quot;/bin/systemctl start udhcpd.service&amp;quot;
&lt;/pre&gt;
&lt;p&gt;and then add your preferred &lt;span class="caps"&gt;DNS&lt;/span&gt; servers to&amp;nbsp;/etc/resolv.conf.&lt;/p&gt;
&lt;/div&gt;
</summary><category term="embedded"></category><category term="kernel"></category><category term="u-boot"></category><category term="Gentoo"></category><category term="Angstrom"></category><category term="BeagleBone"></category><category term="BBB"></category><category term="bonescript"></category></entry><entry><title>gadgetfs regression workaround</title><link href="http://www.vctlabs.com/posts/2014/Sep/01/gadgetfs_workaround/" rel="alternate"></link><updated>2014-09-01T00:00:00-07:00</updated><author><name>Stephanie Lockwood-Childs</name></author><id>tag:www.vctlabs.com,2014-09-01:posts/2014/Sep/01/gadgetfs_workaround/</id><summary type="html">&lt;p&gt;The &lt;em&gt;gadgetfs&lt;/em&gt; driver has had a &lt;a class="reference external" href="https://bugzilla.kernel.org/show_bug.cgi?id=83721"&gt;module refcount bug&lt;/a&gt; in all recent kernels, from
v3.10 up through present (last tag from Linus currently being v3.17-rc3).
Embedded developers interested in using gadgetfs module with kernels 3.10 through 3.16
may wish to try this &lt;a class="reference external" href="/downloads/gadgetfs-fix-refcount.patch"&gt;version of the patch&lt;/a&gt; rather than the one attached to the &lt;a class="reference external" href="https://bugzilla.kernel.org/show_bug.cgi?id=83721"&gt;bug report&lt;/a&gt;
(the only difference being paths: before or after the gadgetfs driver got shuffled into a &amp;quot;legacy&amp;quot;&amp;nbsp;subdirectory).&lt;/p&gt;
</summary><category term="gadgetfs"></category><category term="linux"></category><category term="patch"></category></entry><entry><title>liblockdep fix was merged in kernel 3.16</title><link href="http://www.vctlabs.com/posts/2014/Aug/30/liblockdep_merge/" rel="alternate"></link><updated>2014-08-30T00:00:00-07:00</updated><author><name>Stephanie Lockwood-Childs</name></author><id>tag:www.vctlabs.com,2014-08-30:posts/2014/Aug/30/liblockdep_merge/</id><summary type="html">&lt;p&gt;The &lt;em&gt;liblockdep&lt;/em&gt; userspace lock debugging tool was merged to the mainline
kernel tree in version 3.14. Unfortunately, the very next official release,
linux 3.15, had a lockdep change that happened to break &lt;em&gt;liblockdep&lt;/em&gt;.  The
&lt;a class="reference external" href="/downloads/liblockdep-fix-regression.patch"&gt;patch&lt;/a&gt; for this regression was submitted just after Linux tagged 3.16-rc4, and
being a fix for a regression (as opposed to a new feature) Linus was still
willing to &lt;a class="reference external" href="https://github.com/torvalds/linux/commit/b10827814e9c81c5a14fb73c5a6e06bd85df3f94"&gt;merge&lt;/a&gt; it in time for the 3.16 release without any fuss.
Users of liblockdep should thus upgrade to 3.16 or&amp;nbsp;later.&lt;/p&gt;
</summary><category term="liblockdep"></category><category term="linux"></category><category term="patch"></category></entry><entry><title>Fix for liblockdep regression in kernel 3.15</title><link href="http://www.vctlabs.com/posts/2014/Jul/15/liblockdep_fix/" rel="alternate"></link><updated>2014-07-15T00:00:00-07:00</updated><author><name>Stephanie Lockwood-Childs</name></author><id>tag:www.vctlabs.com,2014-07-15:posts/2014/Jul/15/liblockdep_fix/</id><summary type="html">&lt;p&gt;The &lt;em&gt;liblockdep&lt;/em&gt; userspace lock debugging tool was merged to the mainline
kernel tree in version 3.14. Unfortunately, the very next official release,
linux 3.15, had a lockdep change that happened to break &lt;em&gt;liblockdep&lt;/em&gt;.
I have submitted a patch to fix the regression, but it is currently two steps
away from the mainline tree (first Ingo Molnar will need to &lt;a class="reference external" href="https://lkml.org/lkml/2014/7/7/465"&gt;pull the fix
from Sasha Levin&lt;/a&gt;, then Linus will need to pull from Ingo). Thus 3.16 might
also get released without this fix. Here is a copy of the patch for those
who wish to apply it manually to an affected kernel (3.15, and possibly 3.16): &lt;a class="reference external" href="/downloads/liblockdep-fix-regression.patch"&gt;liblockdep-fix-regression.patch&lt;/a&gt;&lt;/p&gt;
</summary><category term="liblockdep"></category><category term="linux"></category><category term="patch"></category></entry><entry><title>Do-It-Yourself Home Automation with the Belkin WeMo</title><link href="http://www.vctlabs.com/posts/2014/Jul/13/home-automation/" rel="alternate"></link><updated>2014-07-13T12:40:00-07:00</updated><author><name>Donald Burr</name></author><id>tag:www.vctlabs.com,2014-07-13:posts/2014/Jul/13/home-automation/</id><summary type="html">&lt;h3&gt;By Donald&amp;nbsp;Burr&lt;/h3&gt;
&lt;hr /&gt;
&lt;p&gt;For many years futurists and sci-fi authors have been promising us the &amp;#8220;smart home&amp;#8221; that senses and responds to our needs, automating many daily tasks and allowing us to monitor and control every aspect of the house&amp;#8217;s operation from anywhere.  This so-called &lt;a href="http://en.wikipedia.org/wiki/Home_automation" title="HA"&gt;&amp;#8220;Home Automation&amp;#8221;&lt;/a&gt; (&lt;span class="caps"&gt;HA&lt;/span&gt;) has been a pipe dream until fairly recently, when the required technology became cheap enough to mass produce.  Unfortunately today&amp;#8217;s technology still cannot realize some of the more advanced &amp;#8220;smart home&amp;#8221; concepts &amp;#8212; for example, we don&amp;#8217;t yet have robots that can perform menial tasks such as cooking, dishes and laundry &amp;#8212; but the technology that we do have lets us do some pretty cool &amp;#8212; and useful &amp;#8212;&amp;nbsp;things.&lt;/p&gt;
&lt;p&gt;Commercial &lt;span class="caps"&gt;HA&lt;/span&gt; systems have existed for some time now that can do a wide variety of things.  (Some of these are so complex that they pretty closely approach the sci-fi portrayal of the automated home in terms of capabilities, minus robots of course.)  However they are proprietary, expensive, and require custom installation, so are out of reach for most hobbyists, newbies and the curious.  The good news is that, with &lt;span class="caps"&gt;HA&lt;/span&gt;&amp;#8217;s recent growth in popularity (it&amp;#8217;s become &lt;em&gt;the&lt;/em&gt; topic &lt;em&gt;du jour&lt;/em&gt; among the tech press these days) many companies are coming out with some very attractive and affordable &lt;span class="caps"&gt;HA&lt;/span&gt; options.  In fact, this sudden growth in &lt;span class="caps"&gt;HA&lt;/span&gt; has not gone unnoticed by the mobile industry, and now major players in the mobile space such as &lt;a href="https://developer.apple.com/homekit/" title="HomeKit"&gt;Apple&lt;/a&gt; and &lt;a href="http://www.forbes.com/sites/brucerogers/2014/07/08/apple-and-google-dominate-internet-of-things-influence-with-home-automation-efforts/" title="Google HA"&gt;Google&lt;/a&gt; have announced some big &lt;span class="caps"&gt;HA&lt;/span&gt; initiatives.  This is a smart move, since the two technologies really go hand in hand &amp;#8212; smartphones and tablets serve as perfect control surfaces for interacting with and controlling &lt;span class="caps"&gt;HA&lt;/span&gt;&amp;nbsp;peripherals.&lt;/p&gt;
&lt;p&gt;For the longest time, &lt;a href="http://en.wikipedia.org/wiki/X10_(industry_standard)" title="X-10"&gt;X-10&lt;/a&gt; was the dominant standard in consumer-grade &lt;span class="caps"&gt;HA&lt;/span&gt;, and is still a major player in the industry.  A wide variety of X-10 compatible controllers exist, giving users the ability to interface with a large selection of household appliances.  However the X-10 standard is quite old (almost 40 years now!) and its communications protocols are slow and inefficient.  Today, while X-10 devices are still quite popular, a number of companies have jumped on the &lt;span class="caps"&gt;HA&lt;/span&gt; bandwagon and have released a slew of really cool and innovative &lt;span class="caps"&gt;HA&lt;/span&gt; products.  Unfortunately this has created a bit of a &amp;#8220;Tower of Babel&amp;#8221; situation in that these various devices use different protocols and are (in general) not cross-compatible with each other.  Several companies (for example, &lt;a href="http://www.smartthings.com" title="SmartThings"&gt;SmartThings&lt;/a&gt; and &lt;a href="http://www.openhab.org" title="OpenHAB"&gt;OpenHAB&lt;/a&gt;) have taken the interesting tack of releasing hardware- and/or software-based platforms that &amp;#8220;speak&amp;#8221; all of the various &lt;span class="caps"&gt;HA&lt;/span&gt; device protocols and therefore essentially act as hubs tying disparate &lt;span class="caps"&gt;HA&lt;/span&gt; devices together &amp;#8212; essentially a &amp;#8220;Universal Translator&amp;#8221; for &lt;span class="caps"&gt;HA&lt;/span&gt;&amp;nbsp;systems.&lt;/p&gt;
&lt;p&gt;One of the many companies entering the &lt;span class="caps"&gt;HA&lt;/span&gt; arena is Belkin, the venerable consumer networking giant.  Their &lt;a href="http://www.belkin.com/us/Products/home-automation/c/wemo-home-automation/" title="Belkin's WeMo page"&gt;WeMo&lt;/a&gt; devices, which connect to your home network via WiFi, are available in several flavors, including a remotely-controllable power outlet (WeMo Switch,) a remotely-controllable wall light switch (somewhat confusingly named the WeMo Light Switch,) a remotely-controllable power outlet with built-in energy usage meter (WeMo Insight Switch,) a remotely dimmable &lt;span class="caps"&gt;LED&lt;/span&gt; light bulb (WeMo &lt;span class="caps"&gt;LED&lt;/span&gt;,) and, oddly enough, a remotely-controllable Crock-Pot (Crock-Pot Smart Slow Cooker with WeMo) which, as silly as it may sound, actually makes sense since a Crock-Pot is a device you&amp;#8217;d want to be able to remotely control and monitor.  In addition, Belkin&amp;#8217;s webcam has been enhanced with WeMo technology, plus they also make available a separate motion sensor; these devices can be used to trigger other WeMo devices, for example turning the lights on when you get home, or turning on floodlights if motion is detected in your yard.  WeMo devices are particularly attractive because they are readily available, reasonably priced and use a simple &lt;span class="caps"&gt;XML&lt;/span&gt;-based &lt;span class="caps"&gt;REST&lt;/span&gt;-like &lt;span class="caps"&gt;API&lt;/span&gt;, and thus can be easily manipulated using Open Source&amp;nbsp;tools.&lt;/p&gt;
&lt;p&gt;In this article I will be focusing on the &lt;a href="http://www.belkin.com/us/p/P-F7C027/" title="WeMo Switch"&gt;WeMo Switch&lt;/a&gt; since that is the one I have; also it is the cheapest of the WeMo devices.  I will take you through the procedure for setting up and configuring the device, and will end with a few use cases that should give you an idea of the many things you can do with these&amp;nbsp;devices.&lt;/p&gt;
&lt;h4&gt;Getting&amp;nbsp;Started&lt;/h4&gt;
&lt;p&gt;First you will need to buy a WeMo switch.  They are &lt;a href="http://www.amazon.com/dp/B00BB2MMNE/?tag=otakunocast-20" title="WeMo device"&gt;available on Amazon&lt;/a&gt; which is extremely convenient.  Once your WeMo arrives, &lt;em&gt;resist the urge to plug it in right away&lt;/em&gt;.  Instead, make a note of the device&amp;#8217;s &lt;span class="caps"&gt;MAC&lt;/span&gt; address, which is located on a sticker on the back (wall plug end) of the&amp;nbsp;device.&lt;/p&gt;
&lt;p&gt;You&amp;#8217;ll want to assign your WeMos static &lt;span class="caps"&gt;IP&lt;/span&gt; addresses, since you always want to be able to reach them, and with dynamic &lt;span class="caps"&gt;IP&lt;/span&gt; addresses there is a chance that the WeMo might get assigned a different &lt;span class="caps"&gt;IP&lt;/span&gt; address sometimes.  The problem is that WeMo devices &lt;em&gt;don&amp;#8217;t&lt;/em&gt; support assigning static &lt;span class="caps"&gt;IP&lt;/span&gt; addresses - they always pick up their &lt;span class="caps"&gt;IP&lt;/span&gt; addresses using &lt;span class="caps"&gt;DHCP&lt;/span&gt;.  Fortunately, most home routers these days have the capability to assign static &lt;span class="caps"&gt;IP&lt;/span&gt; addresses to a given device based on its &lt;span class="caps"&gt;MAC&lt;/span&gt; address.  (Look for a menu option in your router labeled &amp;#8220;Static &lt;span class="caps"&gt;DHCP&lt;/span&gt;&amp;#8221; or &amp;#8220;Reservation &lt;span class="caps"&gt;DHCP&lt;/span&gt;&amp;#8221; or something similar.)  Then enter your WeMo&amp;#8217;s &lt;span class="caps"&gt;MAC&lt;/span&gt; address, and give it a static &lt;span class="caps"&gt;IP&lt;/span&gt;.  Once the router has updated its configuration, you can plug in the&amp;nbsp;WeMo.&lt;/p&gt;
&lt;p&gt;Next you will need an iOS or Android smartphone or tablet.  At this time the only way to perform initial setup on the WeMo (give it a name,  tell it how to connect to your WiFi network, etc.) is by using the WeMo app for &lt;a href="https://itunes.apple.com/us/app/wemo/id511376996?mt=8&amp;amp;at=10lrq4" title="WeMo App for iOS"&gt;iOS&lt;/a&gt; or &lt;a href="https://play.google.com/store/apps/details?id=com.belkin.wemoandroid&amp;amp;hl=en" title="WeMo App for Android"&gt;Android&lt;/a&gt;.  (The app is free.)  Once the initial setup is complete, you can control the WeMo from any Linux computer.  If you don&amp;#8217;t have a smartphone or tablet, you can just borrow a friend&amp;#8217;s to perform the initial setup.  You may want to consider getting one though; as I mentioned earlier, they make excellent &lt;span class="caps"&gt;HA&lt;/span&gt; controllers, plus they have many other uses as well.  Decent Android tablets can be had for $150-200 nowadays, and used iOS devices aren&amp;#8217;t that much more.  (If you are willing to set up a separate &lt;em&gt;unencrypted&lt;/em&gt; network for use exclusively by your WeMo devices, &lt;a href="http://hackaday.com/2013/02/23/wemo-without-a-smartphone/" title="WeMo Without a Smartphone"&gt;there is a way&lt;/a&gt; to set up the WeMo without the aid of a smartphone or tablet.  This dedicated network need not be connected to the Internet or your home network, but any computers that you want to be able to control your WeMos must be able to connect to it.  I would wager that this is something most people won&amp;#8217;t want to do, so my advice to you is just borrow a smartphone/tablet or consider getting&amp;nbsp;one.)&lt;/p&gt;
&lt;p&gt;Access your mobile device&amp;#8217;s WiFi settings screen.  You should see a new WiFi access point named &lt;code&gt;"WeMo-*string of random alphanumeric characters*."&lt;/code&gt; Connect to it, then launch the WeMo app.  It will guide you through the setup procedure, which includes assigning the WeMo a &amp;#8220;friendly name&amp;#8221; (a name to easily identify this particular WeMo) and connecting it to your WiFi network.  Once that&amp;#8217;s complete, go back to your mobile device&amp;#8217;s WiFi screen and reconnect to your usual WiFi network.  If all is well, then when you next run the WeMo app, your new WeMo should appear on&amp;nbsp;screen.&lt;/p&gt;
&lt;p&gt;(By the way, as you run the setup procedure, the app will probably inform you that a firmware update is available for your new WeMo.  It would be wise to install these whenever they come out, as they are always coming out with bug fixes and improvements.  This is another reason why you should have a smartphone/tablet and the WeMo app; it is the only way that you can run firmware&amp;nbsp;updates.)&lt;/p&gt;
&lt;p&gt;Now head on over to your Linux &lt;span class="caps"&gt;PC&lt;/span&gt;, and &lt;code&gt;ping&lt;/code&gt; the WeMo to make sure it&amp;#8217;s alive.  Once you have confirmed its aliveness, go off and download, &lt;code&gt;gunzip&lt;/code&gt; and install &lt;a href="https://dl.dropboxusercontent.com/u/169813/wemo.gz" title="WeMo shell script (my version)"&gt;this shell script&lt;/a&gt;.  (Installation is simple: just copy it to &lt;code&gt;/usr/local/bin&lt;/code&gt; or &lt;code&gt;$HOME/bin&lt;/code&gt; or wherever you keep random shell scripts.)  This script is based on one I found at the &lt;a href="http://moderntoil.com/?p=839" title="WeMo shell script"&gt;Modern Toil blog&lt;/a&gt; with some bugfixes and additional features.  You&amp;#8217;ll also need to have the &lt;code&gt;curl&lt;/code&gt; utility installed; this utility is installed by default on most systems, but if not, it should be available in your distribution&amp;#8217;s package&amp;nbsp;repository.&lt;/p&gt;
&lt;p&gt;Usage is quite&amp;nbsp;simple:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;wemo IP_ADDRESS[:PORT] ON/OFF/GETSTATE/GETSIGNALSTRENGTH/GETFRIENDLYNAME&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;where &lt;code&gt;IP_ADDRESS&lt;/code&gt; is the &lt;span class="caps"&gt;IP&lt;/span&gt; address of the WeMo you wish to control, and &lt;code&gt;:PORT&lt;/code&gt; (optional) specifies the port to communicate on.  (If unspecified, the script will probe for the correct port.)  The final argument is the command you wish to give your WeMo.  Commands can be entered in uppercase or lowercase.  The following commands are&amp;nbsp;available:  &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;ON&lt;/code&gt; - turns on the device plugged into the&amp;nbsp;WeMo&lt;/li&gt;
&lt;li&gt;&lt;code&gt;OFF&lt;/code&gt; - turns off the device plugged into the&amp;nbsp;WeMo&lt;/li&gt;
&lt;li&gt;&lt;code&gt;GETSTATE&lt;/code&gt; - gets the current state of the WeMo (whether it is turned on or off.)  This status is printed to the terminal, and the shell script&amp;#8217;s exit code is also set based on this information (&lt;code&gt;0&lt;/code&gt; if off, and &lt;code&gt;1&lt;/code&gt; if&amp;nbsp;on.)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;GETSIGNALSTRENGTH&lt;/code&gt; - prints out the signal strength of the WiFi it&amp;#8217;s connected to.  (Seems to be a percentage, in other words a value of &lt;code&gt;100&lt;/code&gt; means full signal, &lt;code&gt;50&lt;/code&gt; means ok signal,&amp;nbsp;etc.)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;GETFRIENDLYNAME&lt;/code&gt; - prints out the WeMo&amp;#8217;s &amp;#8220;friendly name.&amp;#8221;  This name can be set during initial setup and is a handy way of identifying your WeMo&amp;nbsp;devices.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;(By the way, for you language junkies, there are WeMo libraries for &lt;a href="https://github.com/ericblue/Perl-Belkin-WeMo-API" title="Perl-Belkin-WeMo-API"&gt;Perl&lt;/a&gt; and &lt;a href="https://github.com/iancmcc/ouimeaux" title="Ouimeaux"&gt;Python&lt;/a&gt; as well.  In fact, I&amp;#8217;d wager that there is probably a WeMo library for whatever language floats your boat, I&amp;#8217;m sure.  &lt;a href="http://lmgtfy.com/?q=wemo+scripting+language+support" title="WeMo search"&gt;Google is your friend.&lt;/a&gt;)&lt;/p&gt;
&lt;p&gt;There is one final tool you might want to take a look at, a free(!) and extremely useful Web service called &lt;a href="http://ifttt.com/" title="If This Then That"&gt;&lt;span class="caps"&gt;IFTTT&lt;/span&gt;&lt;/a&gt; (&amp;#8220;If This Then That.&amp;#8221;)  This web service allows you to connect many disparate web technologies together using the simple concept of &amp;#8220;&lt;strong&gt;If&lt;/strong&gt; &lt;em&gt;a certain trigger is detected/set off&lt;/em&gt;, &lt;strong&gt;then&lt;/strong&gt; &lt;em&gt;perform a certain action&lt;/em&gt;.&amp;#8221;  So, for example, you can set up a &amp;#8220;recipe&amp;#8221; (as they call these formulae) along the lines of, for example, &amp;#8220;&lt;strong&gt;If&lt;/strong&gt; &lt;em&gt;you get a new email at your Gmail account&lt;/em&gt;, &lt;strong&gt;then&lt;/strong&gt; &lt;em&gt;turn on the flashing police light/siren plugged into your WeMo&lt;/em&gt;.&amp;#8221;  (Hey, nobody said you couldn&amp;#8217;t have a little fun with this stuff!)  This service is extremely powerful and very useful for non-&lt;span class="caps"&gt;HA&lt;/span&gt; uses as well, so I recommend you check it&amp;nbsp;out.&lt;/p&gt;
&lt;p&gt;Now, armed with the above tools, it&amp;#8217;s time to check out some use cases.  These are ones that I am actually using, and should give you some ideas as to the cool ways you can use these&amp;nbsp;devices.&lt;/p&gt;
&lt;h4&gt;Use Case #1: The Lights Are On (But Nobody&amp;#8217;s&amp;nbsp;Home)&lt;/h4&gt;
&lt;p&gt;We don&amp;#8217;t travel very often, but when we do we are always nervous about leaving the house unattended.  In general, thieves pass over houses that look like they have people in them (i.e. there is observable activity, lights turning on and off, etc.)  Conversely, they tend to zero in on those houses that always remain dark and look unoccupied.  So whenever we go away, we always set up some light timers to turn on and off lights and certain appliances (&lt;span class="caps"&gt;TV&lt;/span&gt;, radio, etc.) at various times throughout the day and evening.  The problem with these is that they are ridiculously hard to program.  Also, they operate on a fixed schedule - in other words, once you program them to turn on/off at a given time of day, they &lt;em&gt;always&lt;/em&gt; turn on/off at that exact time.  A determined thief who cases the joint for several days on end could easily notice this pattern and deduce that timers are in&amp;nbsp;use.&lt;/p&gt;
&lt;p&gt;With the WeMo, you can easily write up a shell script (or Perl script, or Python script, or whatever) to turn various lights and other devices on or off at a given time.  And, since you have the full power of your Linux computer at your disposal, you can do cool things like randomize the times when things turn on or off, or vary the patterns of what devices to turn on or off to further throw off observant thieves (e.g. one day just turn on and off the lights, but the next day throw the &lt;span class="caps"&gt;TV&lt;/span&gt; and the radio into the mix.)  Finally, since this &amp;#8220;not at home&amp;#8221; functionality can be easily disabled when not needed (just stop running your shell script,) you can leave your WeMos plugged in all of the time; there&amp;#8217;s no need to go crawling behind furniture to plug/unplug those stupid timers whenever you go away and return&amp;nbsp;home.&lt;/p&gt;
&lt;h4&gt;Use Case #2: Lazy Man&amp;#8217;s Christmas Lights of&amp;nbsp;Doom!&lt;/h4&gt;
&lt;p&gt;Christmas has always been one of my favorite holidays.  Seeing friends and relatives whom I&amp;#8217;ve lost touch with over the years, the wonderful foods traditionally associated with the season, and of course there&amp;#8217;s the giving (and more to the point, receiving) presents part.  But, being a geek, one of my favorite parts of Christmas is the lights.  Not surprising, since most geeks I know tend to like things with lots of lights on them, especially &lt;a href="http://en.wikipedia.org/wiki/Blinkenlights" title="Blinkenlights"&gt;blinking ones&lt;/a&gt;.  &lt;em&gt;Setting up&lt;/em&gt; the lights, on the other hand, is &lt;em&gt;not&lt;/em&gt; my favorite part of the holiday, and is quite frankly something that I would rather not have to deal with at all.  So we foisted this chore off onto someone else.  :)  (Sorry Scott.  Delegation &lt;span class="caps"&gt;FTW&lt;/span&gt;.)  Once the holiday was over, we thought about taking down the lights, but we decided that having to go do it all over again when next Christmas rolled around was too repulsive to bear.  So we decided to just leave them up year-round, but obviously turned off during non-Christmas&amp;nbsp;months.&lt;/p&gt;
&lt;p&gt;Anyway our exterior Christmas lights plug in to an outlet located inside our garage, by way of a super long extension cord.  Going out to the garage in the bitter cold to plug them in at dusk and unplug them before going to bed was a real pain.  Sometimes, on especially cold nights, I would conveniently &amp;#8220;forget&amp;#8221; to unplug them before going to bed.  I thought about setting up a timer to automate this chore, but those things are a real pain.  (See my timer rant above.)  Fortunately we ditched our ancient incandescent light string and replaced it with &lt;span class="caps"&gt;LED&lt;/span&gt; Christmas lights a while ago, so if we did accidentally leave them on, it wasn&amp;#8217;t a huge energy waste.  Still, it is using energy, if only a small amount.  Plus it looks kinda weird.  Likewise, I was always forgetting to turn off our interior Christmas&amp;nbsp;tree.&lt;/p&gt;
&lt;p&gt;Of course, a WeMo would make this task ridiculously easy.  This can be accomplished either with a shell script or &lt;span class="caps"&gt;IFTTT&lt;/span&gt;; &lt;span class="caps"&gt;IFTTT&lt;/span&gt; recipes can use the time of day as a trigger, so you can say, &amp;#8220;&lt;strong&gt;If&lt;/strong&gt; &lt;em&gt;it&amp;#8217;s 5:30 &lt;span class="caps"&gt;PM&lt;/span&gt;&lt;/em&gt;, &lt;strong&gt;then&lt;/strong&gt; &lt;em&gt;turn on the Christmas lights&lt;/em&gt;.&amp;#8221;  &lt;span class="caps"&gt;IFTTT&lt;/span&gt; can even determine the time that the sun rises and sets for you if you give it your location (not your exact location, just your &lt;span class="caps"&gt;ZIP&lt;/span&gt; code;) so you can say, &amp;#8220;&lt;strong&gt;If&lt;/strong&gt; &lt;em&gt;it&amp;#8217;s sunset&lt;/em&gt;, &lt;strong&gt;then&lt;/strong&gt; &lt;em&gt;turn on the Christmas lights&lt;/em&gt;.&amp;#8221;&lt;/p&gt;
&lt;h4&gt;Use Case #3: New Email Indicator Light (or alarm, or whatever) of&amp;nbsp;Doom!&lt;/h4&gt;
&lt;p&gt;If you never want to miss an incoming email, it is pretty trivial to set things up so that a WeMo turns on and off when a new email arrives.  Perhaps you can flash your desk lamp when an email comes in, or briefly turn on a police siren, or something.  If you have the equipment, you can even set up multiple levels of alerts; for example, flash a red lamp if the email is important (comes from your boss or wife) or a white lamp for all other emails.  If you have control over your mailserver, then you can easily set up a &lt;code&gt;procmail&lt;/code&gt; rule to run the &lt;code&gt;wemo&lt;/code&gt; shell script to perform these tasks whenever the desired type of email comes in.  If not, then &lt;span class="caps"&gt;IFTTT&lt;/span&gt; can handle that&amp;nbsp;task.&lt;/p&gt;
&lt;p&gt;Granted, for most of us this function is perhaps of more value as a novelty than an actual productivity tool.  However, for a deaf or hard of hearing individual, this type of visual alert is an absolute&amp;nbsp;necessity.&lt;/p&gt;
&lt;h4&gt;Use Case #4: Automated &amp;#8220;On the Air&amp;#8221; Light of&amp;nbsp;Doom!&lt;/h4&gt;
&lt;p&gt;In my spare time I &lt;a href="http://otakunopodcast.com/" title="Otaku no Podcast"&gt;podcast&lt;/a&gt; about Japanese animation, food, travel and culture.  A while ago I got myself a cheap &lt;a href="http://www.amazon.com/dp/B009CF5VUS/?tag=otakunocast-20" title="On the Air sign"&gt;&amp;#8220;On the Air&amp;#8221; sign&lt;/a&gt; just like the ones you see in radio and &lt;span class="caps"&gt;TV&lt;/span&gt; studios.  I&amp;#8217;ll admit it, I did this mostly because it looked cool.  But it actually serves as a useful indication to others that I need things quiet, so that people know not to make loud noises or barge into my room unannounced and mess up my recording.  Of course, it is something that I needed to manually switch on and off, so I was always either forgetting to turn it on, or forgetting to turn it off once I was done&amp;nbsp;recording.&lt;/p&gt;
&lt;p&gt;With the WeMo, I set up a &lt;a href="http://unix.stackexchange.com/questions/28548/how-to-run-custom-scripts-upon-usb-device-plug-in" title="Udev rules"&gt;&lt;code&gt;udev&lt;/code&gt; rule&lt;/a&gt; so that, whenever I plug in my &lt;span class="caps"&gt;USB&lt;/span&gt; microphone, the &lt;code&gt;wemo&lt;/code&gt; script runs to turn on the &amp;#8220;On the Air&amp;#8221; sign; likewise, when I am finished recording and unplug my &lt;span class="caps"&gt;USB&lt;/span&gt; microphone, the &lt;code&gt;wemo&lt;/code&gt; script runs again, this time turning off power to the &amp;#8220;On the Air&amp;#8221; sign.  Automation &lt;span class="caps"&gt;FTW&lt;/span&gt;!&lt;/p&gt;
&lt;h4&gt;Use Case #5: Automatic Cable Modem Resetter of&amp;nbsp;Doom!&lt;/h4&gt;
&lt;p&gt;Our home Internet connection is generally fast and reliable&amp;#8230; except when it&amp;#8217;s not.  Every now and then, for whatever reason my cable modem decides to go catatonic and suddenly stops communicating with the outside world.  Power cycling the cable modem usually brings it back from the dead.  This requires me to stop whatever it is I&amp;#8217;m doing, wander over to the &lt;span class="caps"&gt;NOC&lt;/span&gt; (my name for the part of my office where all the networking gear is,) and power cycle the cable modem.  Annoying, yes, but not overly so.  (Honestly, I find the hue and cry of &amp;#8220;The Internet is down!!!&amp;#8221; from housemates and visitors much more annoying.)  But when I&amp;#8217;m away from home, this problem turns from being a minor annoyance, to being a critical showstopper.  I frequently need to access my home computers while I&amp;#8217;m on the road.  For one thing, my &lt;span class="caps"&gt;VPN&lt;/span&gt; server, which I use whenever I am traveling and am using a potentially unsafe network, is located on a machine at home.  I also often need to log in to and remotely control one of my machines at home, or to fetch a file that I need from my &lt;span class="caps"&gt;NAS&lt;/span&gt;, and so on.  Having the cable modem lock up and my Internet connection go down when I&amp;#8217;m not at home is a major&amp;nbsp;problem.&lt;/p&gt;
&lt;p&gt;I struggled at trying to find a solution to this problem for quite a while.  Detecting a net outage was the easy part: I just set up a script that ran periodically from &lt;code&gt;cron&lt;/code&gt; that tries to &lt;code&gt;ping&lt;/code&gt; a &amp;#8220;reliable&amp;#8221; Internet server (one that is known to be up most, if not all of the time; Google&amp;#8217;s &lt;span class="caps"&gt;DNS&lt;/span&gt; server at &lt;code&gt;8.8.8.8&lt;/code&gt; is a good candidate.)  If the &lt;code&gt;ping&lt;/code&gt; fails, then the script assumes that the net connection is down.  The problem then became how to remotely power cycle the modem?  Since we don&amp;#8217;t yet have the full-on &lt;span class="caps"&gt;HA&lt;/span&gt; with robots, a robotic solution was right out.  I thought about acquiring an &lt;a href="http://www.aviosys.com/9258st.html" title="IP Power"&gt;&lt;span class="caps"&gt;IP&lt;/span&gt; power controller&lt;/a&gt;.  These devices are often installed in remote locations such as radio and &lt;span class="caps"&gt;TV&lt;/span&gt; broadcast towers and allow engineers to monitor power usage and remotely power cycle problematic equipment.  However these devices are extremely pricy and way too fancy for my simple needs.  Then, one day, I was ranting and raving about my predicament to a friend, and he was like &amp;#8220;Dude, just get a WeMo.&amp;#8221;  (This is, in fact, how I first encountered the WeMo.)  With the WeMo in the equation, my script was complete: when it detects a network outage, it commands the WeMo attached to my cable modem to power cycle itself.  This setup works like a charm and I have never had an unrecoverable network outage since.  Feel free to &lt;a href="https://dl.dropboxusercontent.com/u/169813/net_tester.gz" title="Net Tester script"&gt;download&lt;/a&gt; and use it yourself.  Simply edit the script to suit your particular needs (it is liberally commented) run this script periodically out of &lt;code&gt;cron&lt;/code&gt; and you&amp;#8217;re all&amp;nbsp;set.&lt;/p&gt;
&lt;h4&gt;Use Case #6: Automated Pool Reinflater of&amp;nbsp;Doom!&lt;/h4&gt;
&lt;p&gt;A while ago I picked up a small above-ground swimming pool during a super closeout sale.  It&amp;#8217;s a popular attraction when our friends with kids come over for a visit, plus it&amp;#8217;s nice to float around in when the weather turns uncomfortably warm (which has been happening more often as of late.)  This particular type of above-ground pool consists of a vinyl floor and walls, and an inflatable ring at the top of the side walls which helps to hold the walls up and prevents water from spilling over.  Unfortunately, this inflatable ring recently developed a slow leak that has proven impossible to locate, even using the old &amp;#8220;spray it with soapy water and watch for bubbles&amp;#8221; trick.  So every other day or so I have to reinflate the ring in order to maintain the pool&amp;#8217;s structural integrity, or else risk a flood of Biblical proportions.  After a couple weeks of doing this (or, more to the point, &lt;em&gt;forgetting&lt;/em&gt; to do this) I cobbled together an automated solution using mostly parts I had lying about.  I took the &lt;a href="http://www.amazon.com/dp/B000FE7J0A/?tag=otakunocast-20" title="Air Pump"&gt;air pump&lt;/a&gt; that I already had and attached its hose to the pool ring&amp;#8217;s air inlet valve, plugged the pump into a WeMo, and wrote up a quick &lt;code&gt;cron&lt;/code&gt; job that turns the pump on for about 10 seconds every other day (just long enough to reinflate the ring to full capacity.)  Unfortunately there was nothing in the system to prevent air from leaking back out through the valve when the pump wasn&amp;#8217;t powered on.  So I devised a one-way air valve (allowing air to flow only into the pool ring) using a &lt;a href="http://www.amazon.com/dp/B00B95U5NW/?tag=otakunocast-20" title="PVC check valve"&gt;&lt;span class="caps"&gt;PVC&lt;/span&gt; check valve&lt;/a&gt; combined with some &lt;a href="http://www.amazon.com/dp/B0046ECKZ4/?tag=otakunocast-20" title="PVC tubing"&gt;&lt;span class="caps"&gt;PVC&lt;/span&gt; tubing&lt;/a&gt;, all put together and sealed using liberal amounts of &lt;a href="http://www.amazon.com/dp/B001HT720O/?tag=otakunocast-20" title="Duct tape"&gt;duct tape&lt;/a&gt;.  &lt;a href="https://www.dropbox.com/s/0dqw1i57fw0thyb/inflater_1.JPG" title="Inflater pic #1"&gt;This setup&lt;/a&gt; is admittedly &lt;a href="https://www.dropbox.com/s/hqg2fcshzva5sr9/inflater_2.JPG" title="Inflater pic #2"&gt;a bit ugly&lt;/a&gt;, but it works amazingly well, and is in fact airtight.  Thanks to this solution, we haven&amp;#8217;t found the need to construct an ark in our backyard and gather up as many animals as we could&amp;nbsp;find.&lt;/p&gt;
&lt;h3&gt;Conclusion&lt;/h3&gt;
&lt;p&gt;Home Automation is not only useful, it&amp;#8217;s just plain &lt;em&gt;fun&lt;/em&gt;.  And, thanks to a plethora of available devices and falling prices, it is within reach of everybody.  Now go forth and&amp;nbsp;automate!&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;em&gt;&lt;a href="http://DonaldBurr.com/" title="Donald Burr's Blog"&gt;Donald Burr&lt;/a&gt; has been using &amp;#8212; and abusing &amp;#8212; computers and gadgets practically since the day he was born.  (Rumor has it he was born with a keyboard in one hand and a mouse in the other.)  He is an &lt;a href="http://DonaldBurr.com/apps/" title="Donald Burr's Apps"&gt;avid amateur app developer&lt;/a&gt; and is &lt;a href="http://donaldburr.com/contact-me/" title="Contact Me"&gt;available for hire&lt;/a&gt; if you need a little help getting started in app writing.  When he&amp;#8217;s not geeking around with tech, he can be found blogging and podcasting about Japanese animation and culture at &lt;a href="http://otakunopodcast.com/" title="Otaku no Podcast"&gt;Otaku no Podcast&lt;/a&gt;.  He can be found on the Twitters as &lt;a href="http://twitter.com/dburr/" title="Donald Burr on Twitter"&gt;@dburr&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;</summary><category term="home automation"></category><category term="ha"></category><category term="scripting"></category><category term="belkin"></category><category term="wemo"></category><category term="automation"></category><category term="ifttt"></category></entry><entry><title>liblockdep: userspace lockdep</title><link href="http://www.vctlabs.com/posts/2014/Jul/09/liblockdep/" rel="alternate"></link><updated>2014-07-09T00:00:00-07:00</updated><author><name>Stephanie Lockwood-Childs</name></author><id>tag:www.vctlabs.com,2014-07-09:posts/2014/Jul/09/liblockdep/</id><summary type="html">&lt;div class="section" id="what-is-lockdep"&gt;
&lt;h2&gt;What is&amp;nbsp;lockdep?&lt;/h2&gt;
&lt;p&gt;Lockdep is the kernel-lock validator. Core kernel developer Ingo Molnar
originally designed lockdep to help clean up deadlocks left over from
the kernel&amp;#8217;s transition in &lt;span class="caps"&gt;SMP&lt;/span&gt; implementation strategy, from a single
&amp;quot;Big Kernel Lock&amp;quot; in early days to increasingly fine-grained&amp;nbsp;locking.&lt;/p&gt;
&lt;p&gt;Tracking locks necessarily adds some overhead to the code under observation,
and thus experienced developers might wonder whether running code with
lockdep enabled would tend to change timing enough that race conditions
triggering deadlocks would disappear, the &lt;a class="reference external" href="http://en.wikipedia.org/wiki/Heisenbug"&gt;&amp;quot;heisenbug&amp;quot; effect&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The good news is that the lockdep validation strategy is not at all dependent
on timing &amp;#8212; it tracks patterns of lock acquisition and determines whether
code &lt;em&gt;could&lt;/em&gt; lock if one thread ran code block X while another thread happened
to be running code block Y, and generates a warning regardless of whether
that concurrency happened or not. Kernel developers can thus use lockdep to
track down locking errors without attempting to reproduce an obscure race
condition that only pops up on &lt;em&gt;other&lt;/em&gt; people&amp;#8217;s systems to trigger&amp;nbsp;deadlocks.&lt;/p&gt;
&lt;p&gt;Lockdep was officially released in the mainline kernel back in 2006 with
version 2.6.18, and it has helped kernel developers clean up many locking bugs
since&amp;nbsp;then:&lt;/p&gt;
&lt;blockquote&gt;
over the past 2-3 years the term &amp;quot;hard lockup&amp;quot; in regression reports has
gone down by about an order of magnitude - and much of that can be
attributed to the lockdep coverage we have in place -Ingo Molnar&lt;/blockquote&gt;
&lt;p&gt;&lt;a class="reference external" href="http://lwn.net/Articles/321670/"&gt;http://lwn.net/Articles/321670/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;A very nice overview on lockdep architecture can be found at &lt;a class="reference external" href="http://lwn.net/Articles/185666/"&gt;&lt;span class="caps"&gt;LWN&lt;/span&gt;&lt;/a&gt;,
and some practical implementation details can be found in the Linux source
code as&amp;nbsp;linux/Documentation/lockdep-design.txt&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="what-is-userspace-lockdep-aka-liblockdep"&gt;
&lt;h2&gt;What is userspace lockdep aka&amp;nbsp;liblockdep?&lt;/h2&gt;
&lt;p&gt;Fast-forwarding from 2.6 kernel days to the 3.13 era, lockdep was still a
widely used tool among kernel developers; not only for fixing deadlocks, but
also proactively auditing locking sanity of proposed code. Lockdep is
lightweight enough to allow fairly normal use of a system while it is enabled,
quite a major feature for debugging complicated systems &amp;#8212; enough to inspire
some jealousy by developers on the other side of the kernel/userspace divide.
Free software developers dealing with complicated locking in pthread code
needed a lot of patience to run it under the valgrind lock&amp;nbsp;checker.&lt;/p&gt;
&lt;p&gt;Finally in early 2013, Sasha Levin decided that since the lockdep algorithm is
not really tied to any kernel concepts, the lockdep code could be
repurposed as a pthread lock validator. He did this by wrapping the core
lockdep code, adding redefinitions and stubs that converted the kernel
implementation into a pthread implementation. Ingo Molnar approved of
Sasha&amp;#8217;s leveraging of lockdep code without uglifying the original kernel
implementation, and helped pave the way for the userspace lockdep wrapper
(or &amp;quot;liblockdep&amp;quot;) to be merged into kernel version 3.14 as part of the
tools/ subdirectory alongside other kernel-related userspace tools such
as &lt;a class="reference external" href="https://perf.wiki.kernel.org"&gt;perf&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Unfortunately liblockdep suffered a regression in the very next official
release kernel 3.15. I have submitted a patch which Sasha Levin has included
in his &lt;cite&gt;latest git pull request&amp;lt;pull&amp;gt;_&lt;/cite&gt;, so hopefully the breakage will be
fixed by the upcoming 3.16 kernel release. As liblockdep matures, regressions
like this will become&amp;nbsp;unlikely.&lt;/p&gt;
&lt;p&gt;For further discussion on liblockdep try this &lt;a class="reference external" href="https://lwn.net/Articles/536363/"&gt;&lt;span class="caps"&gt;LWN&lt;/span&gt; article&lt;/a&gt;; there are no
official docs in the kernel source code&amp;nbsp;yet.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="when-is-liblockdep-useful"&gt;
&lt;h2&gt;When is Liblockdep&amp;nbsp;useful&lt;/h2&gt;
&lt;p&gt;Valgrind helgrind and &lt;span class="caps"&gt;DRD&lt;/span&gt; modules are the main Free Software alternatives to
liblockdep for userspace lock debugging, so it is useful to consider what
conditions might favor use of liblockdep over&amp;nbsp;valgrind:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;consider liblockdep to reduce runtime overhead
If the application is complex and the system running it does not
have plenty of spare resources (&lt;span class="caps"&gt;CPU&lt;/span&gt; and memory), valgrind may not be
practical. For instance, performance is often important when trying to
debug an embedded Linux program, either in an emulator (which often adds
plenty of overhead itself) or on the native&amp;nbsp;hardware.&lt;/li&gt;
&lt;li&gt;consider liblockdep for cross-compile support in niche environments
Valgrind has been ported to the most popular architectures and
is included in most popular embedded linux build systems (yocto/&lt;span class="caps"&gt;OE&lt;/span&gt;,
OpenWrt, buildroot) but that can&amp;#8217;t match liblockdep, which should
build easily for anything that has a mainlined kernel&amp;nbsp;port.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;There are also circumstances that rule out the use of&amp;nbsp;liblockdep:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p class="first"&gt;can&amp;#8217;t use liblockdep if the application uses non-pthread locks
According to its docs, Valgrind can do lock validation with custom locks,
as long as all locking code is suitably&amp;nbsp;annotated.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p class="first"&gt;don&amp;#8217;t use liblockdep with recursive mutexes
If possible, clean up the code so that recursive mutexes are not needed,
but otherwise use something else to debug the&amp;nbsp;locking.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The kernel hates recursive locks. They promote incorrect usage of locking
semantics and are completely unsupported in the&amp;nbsp;kernel.&lt;/p&gt;
&lt;p&gt;As you might guess from the above, this also means that lockdep doesn&amp;#8217;t
work at all with recursive locks, and will just detect a trivial deadlock
when an attempt to lock a lock twice is&amp;nbsp;made.&lt;/p&gt;
&lt;p&gt;Therefore, liblockdep is completely useless in code which relies on
recursive locks, and I doubt the situation will change at any point in the
future since I don&amp;#8217;t see the kernel adopting recursive locking.
-Sasha Levin (quoted with permission from an&amp;nbsp;email)&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class="section" id="making-use-of-liblockdep"&gt;
&lt;h2&gt;Making Use of&amp;nbsp;Liblockdep&lt;/h2&gt;
&lt;div class="section" id="building-liblockdep"&gt;
&lt;h3&gt;Building&amp;nbsp;liblockdep&lt;/h3&gt;
&lt;p&gt;If using kernel 3.15 (and perhaps 3.16 which hasn&amp;#8217;t been released at the
time of writing), start by applying &lt;a class="reference external" href="downloads/liblockdep-fix-regression.patch"&gt;this&amp;nbsp;patch&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;From toplevel kernel source&amp;nbsp;dir,&lt;/p&gt;
&lt;pre class="literal-block"&gt;
patch -p1 &amp;lt; liblockdep-fix-regression.patch
&lt;/pre&gt;
&lt;p&gt;After either applying the patch or determining it is not needed,
the build can be run from the toplevel kernel source&amp;nbsp;dir&lt;/p&gt;
&lt;pre class="literal-block"&gt;
make -C tools/lib/lockdep
&lt;/pre&gt;
&lt;p&gt;or in new enough releases (&amp;gt;&amp;nbsp;3.14)&lt;/p&gt;
&lt;pre class="literal-block"&gt;
make -C tools liblockdep
&lt;/pre&gt;
&lt;p&gt;For a cross-compile build, just add &lt;span class="caps"&gt;ARCH&lt;/span&gt; and CROSS_COMPILE
variables like when building the corresponding kernel,&amp;nbsp;e.g.&lt;/p&gt;
&lt;pre class="literal-block"&gt;
make -C tools liblockdep ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi-
&lt;/pre&gt;
&lt;div class="section" id="or"&gt;
&lt;h4&gt;or&lt;/h4&gt;
&lt;blockquote&gt;
export &lt;span class="caps"&gt;ARCH&lt;/span&gt;=arm CROSS_COMPILE=arm-none-linux-gnueabi-
make -C tools liblockdep&lt;/blockquote&gt;
&lt;p&gt;output files will be found under tools/lib/lockdep/ &amp;#8212;
liblockdep.a and liblockdep.so.&amp;lt;version&amp;gt; for static and shared libraries&amp;nbsp;respectively.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="testing-liblockdep"&gt;
&lt;h3&gt;Testing&amp;nbsp;liblockdep&lt;/h3&gt;
&lt;p&gt;liblockdep comes with a nice set of unit tests. It is a good idea to make sure
the tests pass before trying to use liblockdep to do real&amp;nbsp;work.&lt;/p&gt;
&lt;p&gt;Running the tests natively on the build host is quite simple:
starting from the toplevel kernel source&amp;nbsp;directory,&lt;/p&gt;
&lt;pre class="literal-block"&gt;
cd tools/lib/lockdep
./run_tests.sh
&lt;/pre&gt;
&lt;p&gt;Every test will say &amp;quot;&lt;span class="caps"&gt;PASSED&lt;/span&gt;&amp;quot; if this is a good build of&amp;nbsp;liblockdep.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="running-liblockdep"&gt;
&lt;h3&gt;Running&amp;nbsp;liblockdep&lt;/h3&gt;
&lt;p&gt;liblockdep build creates both a static library and a shared library,
so type of linking can be decided based on needs of the&amp;nbsp;project.&lt;/p&gt;
&lt;p&gt;Static&amp;nbsp;library&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;need to use the static version if application under test is statically&amp;nbsp;linked&lt;/li&gt;
&lt;li&gt;watch out for licensing issues &amp;#8212; can only ship apps with builtin liblockdep
if all the source is GPLv2 compatible (fine to use liblockdep in local
test builds with any source though, just can&amp;#8217;t release to users if non-&lt;span class="caps"&gt;GPL&lt;/span&gt;)&lt;/li&gt;
&lt;li&gt;run application normally, no changes to command&amp;nbsp;line&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Shared&amp;nbsp;library&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p class="first"&gt;application under test must be dynamically linked to&amp;nbsp;libpthread&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p class="first"&gt;use LD_PRELOAD on command line to allow liblockdep to override pthread
locking&amp;nbsp;functions&lt;/p&gt;
&lt;pre class="literal-block"&gt;
LD_PRELOAD=/usr/src/linux/tools/lib/lockdep/liblockdep.so some_thready_application
&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Tips common to both styles of&amp;nbsp;linking&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;liblockdep traces currently go to stdout, so make sure stdout is not&amp;nbsp;closed&lt;/li&gt;
&lt;li&gt;stack traces in output are improved if application is built with -rdynamic
(functions will be listed instead of just&amp;nbsp;addresses)&lt;/li&gt;
&lt;li&gt;like compiler errors, focus on fixing first complaint from the output,
since single error can cascade to generate multiple&amp;nbsp;complaints&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
</summary><category term="linux"></category><category term="debugging"></category><category term="locks"></category></entry><entry><title>Third Early Adopter Release of SailfishOS (1.0.7.16) for Nexus 4</title><link href="http://www.vctlabs.com/posts/2014/Jun/30/sailfish_prerelease/" rel="alternate"></link><updated>2014-06-30T00:00:00-07:00</updated><author><name>Stephen Arnold</name></author><id>tag:www.vctlabs.com,2014-06-30:posts/2014/Jun/30/sailfish_prerelease/</id><summary type="html">&lt;p&gt;As the title and the announcement below says, this is now available for
Nexus4 and other devices (see the upstream site for details).  Follow the
steps below to flash your device and you should see a nice sailing ship
on the next&amp;nbsp;boot.&lt;/p&gt;
&lt;p&gt;Although it runs on top of an &amp;quot;android&amp;quot; &lt;span class="caps"&gt;ROM&lt;/span&gt; the gesture-based interface
is altogether different, and sweet once you get used to it.  Try it and&amp;nbsp;see&amp;#8230;&lt;/p&gt;
&lt;div class="section" id="email-announcement"&gt;
&lt;h2&gt;Email&amp;nbsp;Announcement&lt;/h2&gt;
&lt;p&gt;Dear early adopter of SailfishOS for Android devices. This is important -
read this whole mail through and follow all steps exactly as&amp;nbsp;written.&lt;/p&gt;
&lt;p&gt;&lt;span class="caps"&gt;IMPORTANT&lt;/span&gt;: If you choose to publish this mail through blogs, news sites,
forums, or others, quote it as-is and in complete form &lt;span class="caps"&gt;ONLY&lt;/span&gt;, or people&amp;#8217;s
devices may be at&amp;nbsp;risk.&lt;/p&gt;
&lt;p&gt;We&amp;#8217;re happy to publish the third Early Adopter Release of SailfishOS
(1.0.7.16) for Nexus 4 (mako) to&amp;nbsp;you.&lt;/p&gt;
&lt;p&gt;We are still working on the SailfishOS Hardware Adaptation Development
Kit, which describes how to port SailfishOS to existing devices based on
CyanogenMod 10.1. Newer versions of &lt;span class="caps"&gt;CM&lt;/span&gt; will be supported eventually.
We&amp;#8217;ll publish the &lt;span class="caps"&gt;HADK&lt;/span&gt; in the very near&amp;nbsp;future.&lt;/p&gt;
&lt;p&gt;This installation image is for early adopters only, meaning we know that
some things are not functional or perhaps even broken &amp;#8212; please see the
release notes below. We are excited to get all of you properly included
in the early stages of the project. Do note that this SailfishOS image
is strictly for personal and non-commercial usage&amp;nbsp;only.&lt;/p&gt;
&lt;p&gt;We&amp;#8217;ve prepared a &amp;#8216;demo&amp;#8217; version of the image which contains the kind of
preinstalled &amp;#8216;marketing&amp;#8217; content and the core apps used for
demonstrations - this helps you quickly get a feel for all the
interactions that are avalable on a device that has been used for a
while but isn&amp;#8217;t really what you want for personal use. You can however
cleanly remove the demo&amp;nbsp;content.&lt;/p&gt;
&lt;p&gt;We want to build a community around SailfishOS for Android devices that
is based on mutual trust and respect for what we are all doing. Hence &amp;#8212;
we ask that whenever you do screenshots, videos, forum or blog posts
(and we&amp;#8217;re happy if you do!) or the like, you emphasise that this is an
under-development snapshot and not a final product&amp;nbsp;release.&lt;/p&gt;
&lt;p&gt;It is important for Jolla that the correct expectations are set for
those who might be users of the final product &amp;#8212; and that they
understand what they see is not a released product. If you do demo
videos, you can take advantage of our new &amp;#8216;demo content&amp;#8217; image that has
pre-set contacts/imagery/messages/etc to show full functionality of&amp;nbsp;SailfishOS.&lt;/p&gt;
&lt;p&gt;&lt;span class="caps"&gt;WARNING&lt;/span&gt;: Modifying or replacing your device’s software may void your
device’s warranty, lead to data loss, hearing loss, hair loss, financial
loss, privacy loss, security breaches, or other damage, and therefore
must be done entirely at your own risk. No one affiliated with this
project is responsible for your actions but yourself. Good&amp;nbsp;luck.&lt;/p&gt;
&lt;p&gt;&lt;span class="caps"&gt;NOTE&lt;/span&gt;: You will lose your on-device data (including /sdcard), so make a
proper backup and make sure to copy that backup to your &lt;span class="caps"&gt;PC&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;&lt;span class="caps"&gt;NOTE&lt;/span&gt;: Make sure to read all the release notes below. Please &lt;span class="caps"&gt;DO&lt;/span&gt; &lt;span class="caps"&gt;NOT&lt;/span&gt;
contact Jolla Care for any issues encountered with this Early Adopters
build, instead use communication channels listed&amp;nbsp;below.&lt;/p&gt;
&lt;p&gt;To install this release of SailfishOS on a Nexus 4&amp;nbsp;device:&lt;/p&gt;
&lt;ol class="arabic simple"&gt;
&lt;li&gt;Install adb and&amp;nbsp;fastboot&lt;/li&gt;
&lt;/ol&gt;
&lt;blockquote&gt;
&lt;ol class="loweralpha simple"&gt;
&lt;li&gt;Debian/Ubuntu: apt-get install android-tools-adb&amp;nbsp;android-tools-fastboot&lt;/li&gt;
&lt;li&gt;Fedora: yum install&amp;nbsp;android-tools&lt;/li&gt;
&lt;li&gt;Mac &lt;span class="caps"&gt;OS&lt;/span&gt; X: Install Homebrew from &lt;a class="reference external" href="http://brew.sh/"&gt;http://brew.sh/&lt;/a&gt;, then: brew install&amp;nbsp;android-platform-tools&lt;/li&gt;
&lt;li&gt;Windows: See &lt;a class="reference external" href="http://wiki.cyanogenmod.org/w/Doc:_fastboot_intro"&gt;http://wiki.cyanogenmod.org/w/Doc:_fastboot_intro&lt;/a&gt; for&amp;nbsp;instructions&lt;/li&gt;
&lt;/ol&gt;
&lt;/blockquote&gt;
&lt;ol class="arabic simple" start="2"&gt;
&lt;li&gt;Install Android 4.2.2 (&lt;span class="caps"&gt;JDQ39&lt;/span&gt;) to your Nexus&amp;nbsp;4&lt;/li&gt;
&lt;/ol&gt;
&lt;blockquote&gt;
&lt;ol class="loweralpha simple"&gt;
&lt;li&gt;Instructions here: &lt;a class="reference external" href="https://developers.google.com/android/nexus/images#instructions"&gt;https://developers.google.com/android/nexus/images#instructions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Download links can be found here: &lt;a class="reference external" href="https://developers.google.com/android/nexus/images#occamjdq39"&gt;https://developers.google.com/android/nexus/images#occamjdq39&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/blockquote&gt;
&lt;ol class="arabic simple" start="3"&gt;
&lt;li&gt;Download CyanogenMod 10.1.3 for your Nexus&amp;nbsp;4&lt;/li&gt;
&lt;/ol&gt;
&lt;blockquote&gt;
&lt;ol class="loweralpha simple"&gt;
&lt;li&gt;Perform Factory Reset and wipe contents of the /data/ partition in case of leftovers from previous&amp;nbsp;ROMs&lt;/li&gt;
&lt;li&gt;The file you want to download is&amp;nbsp;cm-10.1.3-mako.zip&lt;/li&gt;
&lt;li&gt;Download links can be found here: &lt;a class="reference external" href="http://wiki.cyanogenmod.org/w/Install_CM_for_mako"&gt;http://wiki.cyanogenmod.org/w/Install_CM_for_mako&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/blockquote&gt;
&lt;ol class="arabic simple" start="4"&gt;
&lt;li&gt;Download the SailfishOS for Android image for&amp;nbsp;&amp;quot;mako&amp;quot;&lt;/li&gt;
&lt;/ol&gt;
&lt;blockquote&gt;
&lt;ol class="loweralpha simple"&gt;
&lt;li&gt;The file you want to download is &lt;a class="reference external" href="http://releases.sailfishos.org/sfa-ea/sailfishos-mako-release-1.0.7.16-EA3.zip"&gt;http://releases.sailfishos.org/sfa-ea/sailfishos-mako-release-1.0.7.16-&lt;span class="caps"&gt;EA3&lt;/span&gt;.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Another flavour filled with demo content: &lt;a class="reference external" href="http://releases.sailfishos.org/sfa-ea/sailfishos-mako-release-1.0.7.16-EA3-demo-content.zip"&gt;http://releases.sailfishos.org/sfa-ea/sailfishos-mako-release-1.0.7.16-&lt;span class="caps"&gt;EA3&lt;/span&gt;-demo-content.zip&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/blockquote&gt;
&lt;ol class="arabic simple" start="5"&gt;
&lt;li&gt;Install CyanogenMod 10.1.3 on your Nexus&amp;nbsp;4&lt;/li&gt;
&lt;/ol&gt;
&lt;blockquote&gt;
&lt;ol class="loweralpha simple"&gt;
&lt;li&gt;Follow the instructions at: &lt;a class="reference external" href="http://wiki.cyanogenmod.org/w/Install_CM_for_mako"&gt;http://wiki.cyanogenmod.org/w/Install_CM_for_mako&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/blockquote&gt;
&lt;ol class="arabic simple" start="6"&gt;
&lt;li&gt;After flashing the &amp;quot;cm-10.1.3-mako.zip&amp;quot; file, flash the SailfishOS .zip file in the same way (&amp;quot;on top of&amp;nbsp;it&amp;quot;)&lt;/li&gt;
&lt;li&gt;Reboot bootloader, SailfishOS should boot and be&amp;nbsp;visible&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;We recommend reading through &lt;a class="reference external" href="http://jolla.com/guide/"&gt;http://jolla.com/guide/&lt;/a&gt; &amp;#8212; some parts may not apply to Nexus&amp;nbsp;4&lt;/p&gt;
&lt;p&gt;If you want to go back to normal&amp;nbsp;CyanogenMod:&lt;/p&gt;
&lt;ol class="loweralpha simple"&gt;
&lt;li&gt;Boot into recovery&amp;nbsp;mode&lt;/li&gt;
&lt;li&gt;Choose &amp;quot;Wipe data / factory&amp;nbsp;reset&amp;quot;&lt;/li&gt;
&lt;li&gt;Flash&amp;nbsp;cm-10.1.3-mako.zip&lt;/li&gt;
&lt;li&gt;(to go back to SailfishOS, flash the SailfishOS .zip on top of&amp;nbsp;it)&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;If you want to go back to stock&amp;nbsp;Android:&lt;/p&gt;
&lt;ol class="loweralpha simple"&gt;
&lt;li&gt;Download the stock image from &lt;a class="reference external" href="https://developers.google.com/android/nexus/images#occam"&gt;https://developers.google.com/android/nexus/images#occam&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Extract the package and follow the instructions for&amp;nbsp;reflashing/re-locking&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;To &lt;span class="caps"&gt;SSH&lt;/span&gt; into your device via &lt;span class="caps"&gt;USB&lt;/span&gt;&amp;nbsp;(Linux)&lt;/p&gt;
&lt;ol class="arabic simple"&gt;
&lt;li&gt;Enable remote connection in Settings-&amp;gt;System-&amp;gt;Developer&amp;nbsp;mode&lt;/li&gt;
&lt;li&gt;Set your &lt;span class="caps"&gt;USB&lt;/span&gt; interface on host machine to &lt;span class="caps"&gt;IP&lt;/span&gt;&amp;nbsp;192.168.2.2&lt;/li&gt;
&lt;li&gt;ssh &lt;a class="reference external" href="mailto:nemo&amp;#64;192.168.2.1"&gt;nemo&amp;#64;192.168.2.1&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Use the password from developer mode to log&amp;nbsp;in&lt;/li&gt;
&lt;li&gt;Use the &amp;#8216;devel-su&amp;#8217; command with the same password in order to gain&amp;nbsp;root&lt;/li&gt;
&lt;li&gt;To &lt;span class="caps"&gt;SSH&lt;/span&gt; over &lt;span class="caps"&gt;WLAN&lt;/span&gt;, use &lt;span class="caps"&gt;IP&lt;/span&gt; listed in developer mode under &amp;quot;&lt;span class="caps"&gt;WLAN&lt;/span&gt; &lt;span class="caps"&gt;IP&lt;/span&gt;&amp;nbsp;address&amp;quot;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Read Sailfish &lt;span class="caps"&gt;OS&lt;/span&gt; release notes: &lt;a class="reference external" href="https://together.jolla.com/question/45064/release-notes-software-version-10716-saapunki/"&gt;https://together.jolla.com/question/45064/release-notes-software-version-10716-saapunki/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Release notes/Known issues in &lt;span class="caps"&gt;EA3&lt;/span&gt;:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;span class="caps"&gt;EXPERIMENTAL&lt;/span&gt;: Jolla Store is now available, you&amp;#8217;ll need to register with your Jolla Account&lt;ul&gt;
&lt;li&gt;&lt;span class="caps"&gt;NOTE&lt;/span&gt;: Booting Nexus 4 with &lt;span class="caps"&gt;SIM&lt;/span&gt; first, and then removing &lt;span class="caps"&gt;SIM&lt;/span&gt; (or vice versa) may cause Jolla Store to see it as two different devices and cause potential breakage. Please stick to either &lt;span class="caps"&gt;SIM&lt;/span&gt; available or not when running SailfishOS on Nexus 4.&lt;ul&gt;
&lt;li&gt;There may be a bug with oFono &lt;span class="caps"&gt;RIL&lt;/span&gt; support that makes it not report &lt;span class="caps"&gt;IMEI&lt;/span&gt; value causing this and will be sorted out in a later&amp;nbsp;update.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;span class="caps"&gt;DISCLAIMER&lt;/span&gt;: Using Jolla Store with Jolla Account might break applications on your other devices, use it at your own&amp;nbsp;risk!&lt;/li&gt;
&lt;li&gt;Android support is not available from the Store, even if you can see Android apps listed (those will be removed eventually from store&amp;nbsp;view)&lt;/li&gt;
&lt;li&gt;This functionality means that image comes with only minimal set of pre-installed apps. Use Store to download the ones you&amp;nbsp;need.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;The backlight is dark during first launch, but can be fix by switching the currently-not-working ambient light sensor off (uncheck Settings-&amp;gt;System-&amp;gt;Display-&amp;gt;Adjust&amp;nbsp;automatically)&lt;/li&gt;
&lt;li&gt;When display is blanked, power management sets &lt;span class="caps"&gt;WLAN&lt;/span&gt; to the lowest speed state&lt;ul&gt;
&lt;li&gt;Can be noticed in a &lt;span class="caps"&gt;SSH&lt;/span&gt;-over-&lt;span class="caps"&gt;WLAN&lt;/span&gt;&amp;nbsp;session&lt;/li&gt;
&lt;li&gt;Chat notifications may arrive with a slight&amp;nbsp;delay&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Fixes after &lt;span class="caps"&gt;EA2&lt;/span&gt;:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;Watermark&amp;nbsp;removed&lt;/li&gt;
&lt;li&gt;Phone-call audio volume can now be changed with the help of volume&amp;nbsp;buttons&lt;/li&gt;
&lt;li&gt;Improved responsiveness when waking phone up with the power&amp;nbsp;button&lt;/li&gt;
&lt;li&gt;Settings-&amp;gt;System-&amp;gt;Developer Mode or About Product do not freeze&amp;nbsp;anymore&lt;/li&gt;
&lt;li&gt;Reverted to the original (non-Silica)&amp;nbsp;Fingerterm&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Fixes after &lt;span class="caps"&gt;EA1&lt;/span&gt;:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;Phone-calls with audio&amp;nbsp;work&lt;/li&gt;
&lt;li&gt;Timers and alarms (with device powered on)&amp;nbsp;work&lt;/li&gt;
&lt;li&gt;&lt;span class="caps"&gt;HTML5&lt;/span&gt; video+audio works in Browser (tested splash on &lt;a class="reference external" href="http://jolla.com"&gt;http://jolla.com&lt;/a&gt;&amp;nbsp;)&lt;/li&gt;
&lt;li&gt;Update is based on SailfishOS version&amp;nbsp;1.0.5.16&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Release notes/Known issues in &lt;span class="caps"&gt;EA2&lt;/span&gt;:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;To securely power off the device, during its boot-up keep Volume Down pressed to enter bootloader mode. Using volume keys, select &amp;quot;Power off&amp;quot; option, then press the Power&amp;nbsp;key&lt;/li&gt;
&lt;li&gt;If not auto-detected from &lt;span class="caps"&gt;SIM&lt;/span&gt;, set-up mobile internet data settings via Settings-&amp;gt;System-&amp;gt;Mobile network-&amp;gt;(long tap on the first toggle-item under &amp;quot;Mobile data&amp;quot; section)-&amp;gt;(enter settings given by your&amp;nbsp;operator)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Nexus4-specific known issues reported by the adopters (in &lt;span class="caps"&gt;EA2&lt;/span&gt;):&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;Chinese text input not&amp;nbsp;working&lt;/li&gt;
&lt;li&gt;Localhost name is shown as&amp;nbsp;Jolla&lt;/li&gt;
&lt;li&gt;Switching between the online and offline status in the status information setting takes very long and often doesn’t switch&amp;nbsp;properly&lt;/li&gt;
&lt;li&gt;Google contacts which are put together with different information, are now split up into several contacts in&amp;nbsp;Sailfish&lt;/li&gt;
&lt;li&gt;The battery display seems to be a bit buggy because it loses about 15% from one second to&amp;nbsp;another&lt;/li&gt;
&lt;li&gt;The calendar overview when filled with events seems to be a bit&amp;nbsp;laggy&lt;/li&gt;
&lt;li&gt;The email push is not working correctly, I do not receive any emails until I push the refresh&amp;nbsp;button&lt;/li&gt;
&lt;li&gt;Splitting words in the German translation: e.g. in the open apps on the home screen it says: &amp;quot;Kurzzeitmesse&amp;quot; and in the next line the missing&amp;nbsp;&amp;quot;r&amp;quot;&lt;/li&gt;
&lt;li&gt;&lt;span class="caps"&gt;NOTE&lt;/span&gt;: all other Sailfish &lt;span class="caps"&gt;OS&lt;/span&gt; issues have already been reported on &lt;span class="caps"&gt;TJC&lt;/span&gt; - &lt;a class="reference external" href="http://together.jolla.com"&gt;http://together.jolla.com&lt;/a&gt; - and many of them were fixed in this 1.0.5.16&amp;nbsp;release&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Release notes/Known Issues in &lt;span class="caps"&gt;EA1&lt;/span&gt;:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;Developer mode is activated at all&amp;nbsp;times&lt;/li&gt;
&lt;li&gt;There has been no throughout testing of telephony related functionality (roaming, airplane mode, etc) and any use of this functionality is at your own&amp;nbsp;risk&lt;/li&gt;
&lt;li&gt;Sensors, Device lock, Reset device, Bluetooth, &lt;span class="caps"&gt;USB&lt;/span&gt; control + &lt;span class="caps"&gt;MTP&lt;/span&gt;, Bluetooth, &lt;span class="caps"&gt;WLAN&lt;/span&gt; hotspot, Camera(photography, video recording), and video playback is not supported in this&amp;nbsp;release&lt;/li&gt;
&lt;li&gt;The image &lt;span class="caps"&gt;SW&lt;/span&gt; is not currently upgradeable, nor is any typically licensed multimedia codecs (&lt;span class="caps"&gt;MP3&lt;/span&gt;, etc), &lt;span class="caps"&gt;HERE&lt;/span&gt; maps, Android application compatibility layer, or word prediction for virtual keyboard&amp;nbsp;preinstalled&lt;/li&gt;
&lt;li&gt;This image does not include any typically licensed multimedia codecs (&lt;span class="caps"&gt;MP3&lt;/span&gt;, etc), &lt;span class="caps"&gt;HERE&lt;/span&gt; maps, Android application compatibility layer, Microsoft Exchange support, or word prediction for virtual keyboard&amp;nbsp;preinstalled&lt;/li&gt;
&lt;li&gt;It is not possible to double-tap to wake up the&amp;nbsp;device&lt;/li&gt;
&lt;li&gt;Powering off device puts it into a state of deep slumber; possible to get out of by holding power button and volume down key with a bit of&amp;nbsp;persistence&lt;/li&gt;
&lt;li&gt;Fingerterm keyboard is not at its best due to the portrait-only&amp;nbsp;mode&lt;/li&gt;
&lt;li&gt;&lt;span class="caps"&gt;FPS&lt;/span&gt; drop while scrolling in homescreen due to non-batching when rendering of application icon&amp;nbsp;grid&lt;/li&gt;
&lt;li&gt;Icons/graphics appear unproportionally small in browser toolbar, time select widget, and Settings favourite&amp;nbsp;icons&lt;/li&gt;
&lt;li&gt;Multiboot/Multirom is not supported yet but we&amp;#8217;re happy if you would like to teach/help&amp;nbsp;us&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We will all meet in #sailfishos-porters (note, new location) on irc.freenode.net and please use us (thp, alterego, Stskeeps, lbt, sledges) to work together, report any bugs, graphical glitches or missing functionality that you find, which are not included in the release notes above. You can also find the hardware adaptation source code at &lt;a class="reference external" href="http://github.com/mer-hybris"&gt;http://github.com/mer-hybris&lt;/a&gt;&amp;nbsp;.&lt;/p&gt;
&lt;p&gt;You are also welcome to participate in threads at &lt;a class="reference external" href="http://forum.xda-developers.com/nexus-4/general"&gt;http://forum.xda-developers.com/nexus-4/general&lt;/a&gt; about Nexus 4 and SailfishOS as well as for more general SailfishOS topics at &lt;a class="reference external" href="http://forum.xda-developers.com/jolla-sailfish/general"&gt;http://forum.xda-developers.com/jolla-sailfish/general&lt;/a&gt;&lt;/p&gt;
&lt;pre class="literal-block"&gt;
Best regards,
Carsten Munk (Stskeeps) on behalf of the SailfishOS for Everyone team.
Chief Research Engineer &amp;#64; Jolla
&lt;/pre&gt;
&lt;/div&gt;
</summary><category term="android"></category><category term="cyanogenmod"></category><category term="jolla"></category><category term="sailfishOS"></category><category term="Nexus 4"></category></entry><entry><title>ARMv7 3.15.0 Kernel and U-Boot Images for Gentoo / Other Linux</title><link href="http://www.vctlabs.com/posts/2014/Jun/18/armv7_kernels/" rel="alternate"></link><updated>2014-06-18T00:00:00-07:00</updated><author><name>Stephen Arnold</name></author><id>tag:www.vctlabs.com,2014-06-18:posts/2014/Jun/18/armv7_kernels/</id><summary type="html">&lt;p&gt;ARMv7 Linux kernel (3.15.0) and U-Boot (2014.07-rc3) images are available
for use, built from the &lt;a class="reference external" href="https://github.com/RobertCNelson?tab=repositories"&gt;github repos&lt;/a&gt; of Robert C Nelson, the current
upstream maintainer of several board-specifc kernel patch sets, u-boot
patches, custom build scripts, and eewiki&amp;nbsp;docs.&lt;/p&gt;
&lt;p&gt;The primary (patch) sources used for these builds&amp;nbsp;are:&lt;/p&gt;
&lt;blockquote&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;a class="reference external" href="https://github.com/RobertCNelson/Bootloader-Builder"&gt;https://github.com/RobertCNelson/Bootloader-Builder&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class="reference external" href="https://github.com/RobertCNelson/armv7-multiplatform"&gt;https://github.com/RobertCNelson/armv7-multiplatform&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class="reference external" href="https://github.com/RobertCNelson/bb-kernel"&gt;https://github.com/RobertCNelson/bb-kernel&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;p&gt;The primary tested hardware and deployment docs for these builds consisted&amp;nbsp;of:&lt;/p&gt;
&lt;blockquote&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;BeagleBoneBlack Rev &lt;span class="caps"&gt;A6A&lt;/span&gt; - &lt;a class="reference external" href="http://eewiki.net/display/linuxonarm/BeagleBone+Black"&gt;http://eewiki.net/display/linuxonarm/BeagleBone+Black&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;WandBoard Quad - &lt;a class="reference external" href="http://eewiki.net/display/linuxonarm/Wandboard"&gt;http://eewiki.net/display/linuxonarm/Wandboard&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Udoo Quad -&lt;a class="reference external" href="http://eewiki.net/display/linuxonarm/UDOO"&gt;http://eewiki.net/display/linuxonarm/&lt;span class="caps"&gt;UDOO&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;p&gt;The build output and a stage &amp;quot;4&amp;quot; Gentoo rootfs are available&amp;nbsp;here:&lt;/p&gt;
&lt;blockquote&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;a class="reference external" href="http://www.gentoogeek.org/files/armv7-multiplatform/"&gt;http://www.gentoogeek.org/files/armv7-multiplatform/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class="reference external" href="http://www.gentoogeek.org/files/arm-u-boot-multi/"&gt;http://www.gentoogeek.org/files/arm-u-boot-multi/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class="reference external" href="http://www.gentoogeek.org/files/arm-bb_kernel/"&gt;http://www.gentoogeek.org/files/arm-bb_kernel/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;p&gt;You can always build your own from the above github repos (which is the subject
of a future article) and these are really provided just to get started, ie, boot
up the hardware, do some test and checkout, maybe chroot using a &lt;span class="caps"&gt;SATA&lt;/span&gt; or &lt;span class="caps"&gt;USB&lt;/span&gt; disk.
These choices are left as an exercise for the&amp;nbsp;reader&amp;#8230;&lt;/p&gt;
&lt;div class="section" id="quick-start"&gt;
&lt;h2&gt;Quick&amp;nbsp;Start&lt;/h2&gt;
&lt;p&gt;For Wandboard quad, download the following, similarly for Wandboard dual, Udoo,&amp;nbsp;etc:&lt;/p&gt;
&lt;blockquote&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;a class="reference external" href="http://www.gentoogeek.org/files/armv7-multiplatform/"&gt;http://www.gentoogeek.org/files/armv7-multiplatform/&lt;/a&gt;&lt;ul&gt;
&lt;li&gt;3.15.0-rc8-armv7-x1.2.zImage&lt;/li&gt;
&lt;li&gt;3.15.0-rc8-armv7-x1.2-dtbs.tar.gz&lt;/li&gt;
&lt;li&gt;3.15.0-rc8-armv7-x1.2-firmware.tar.gz&lt;/li&gt;
&lt;li&gt;3.15.0-rc8-armv7-x1.2-modules.tar.gz&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;p&gt;Download the latest u-boot image for your specific board from the appropriate&amp;nbsp;subdir:&lt;/p&gt;
&lt;blockquote&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;a class="reference external" href="http://www.gentoogeek.org/files/armv-u-boot-multi/"&gt;http://www.gentoogeek.org/files/armv-u-boot-multi/&lt;/a&gt;&lt;ul&gt;
&lt;li&gt;u-boot-wandboard_quad-v2014.07-rc3-r8.imx&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;p&gt;For BeagleBoneBlack, use the above &lt;span class="caps"&gt;BBB&lt;/span&gt; u-boot image, but substitute the following&amp;nbsp;kernel:&lt;/p&gt;
&lt;blockquote&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;a class="reference external" href="http://www.gentoogeek.org/files/arm-bb_kernel/"&gt;http://www.gentoogeek.org/files/arm-bb_kernel/&lt;/a&gt;&lt;ul&gt;
&lt;li&gt;3.15.0-bone1.zImage&lt;/li&gt;
&lt;li&gt;3.15.0-bone1-dtbs.tar.gz&lt;/li&gt;
&lt;li&gt;3.15.0-bone1-firmware.tar.gz&lt;/li&gt;
&lt;li&gt;3.15.0-bone1-modules.tar.gz&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;p&gt;Follow the eewiki doc (above) for the appropriate board to make an sdcard, and choose
a rootfs.  For a basic Gentoo stage &amp;quot;4&amp;quot; rootfs with a portage tree and a few other tools,
download the following tarball and edit the password file, hostname, and net
config.  Otherwise try one of the distros recommended on the eewiki&amp;nbsp;doc.&lt;/p&gt;
&lt;p&gt;Gentoo armv7a-hardfloat stage&amp;nbsp;4:&lt;/p&gt;
&lt;blockquote&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;a class="reference external" href="http://www.gentoogeek.org/files/armv7-multiplatform/"&gt;http://www.gentoogeek.org/files/armv7-multiplatform/&lt;/a&gt;&lt;ul&gt;
&lt;li&gt;stage4-armv7a_hardfp-rootfs-20140614.tar.bz2&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div class="section" id="extra-details"&gt;
&lt;h2&gt;Extra&amp;nbsp;Details&lt;/h2&gt;
&lt;div class="section" id="download-the-kernel-and-u-boot"&gt;
&lt;h3&gt;Download the kernel and&amp;nbsp;u-boot&lt;/h3&gt;
&lt;p&gt;Download all of the kernel and u-boot files for your board; each board
has a separate directory for u-boot images (choose the version you want)
whereas the armv7-multiplatform kernels support multiple boards (again,
choose the version you want).  If you have a BeagleBoneBlack, you can
try the multiplatform kernel, but the bb_kernel repository patches
seem to be more&amp;nbsp;current.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="download-a-rootfs"&gt;
&lt;h3&gt;Download a&amp;nbsp;rootfs&lt;/h3&gt;
&lt;p&gt;You can choose a Gentoo Stage 3 tarball (or the stage 4 listed above)
or any other appropriate rootfs (ie, Debian Wheezy armhf).  Substitute
whatever rootfs tarball you like when you get to that step.  The stage 4
provided here is essentially the latest Gentoo stage 3 for ARMv7 hardfloat,
with some extra apps (distcc, ccache, gkrellm, nfs-utils, screen, ntp,
zram-init, portage&amp;nbsp;tree).&lt;/p&gt;
&lt;p&gt;See the eewiki links for supported distros, or the Gentoo mirror list for
&lt;span class="caps"&gt;ARM&lt;/span&gt; stage 3 tarballs and portage snapshots.  Download the stage 4 at the
link&amp;nbsp;above.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="prepare-an-sdcard"&gt;
&lt;h3&gt;Prepare an&amp;nbsp;SDCard&lt;/h3&gt;
&lt;p&gt;Follow the steps for your board/device; the key difference lies mainly
in which u-boot files are used and how they are installed.  It isn&amp;#8217;t
strictly required to reformat the card each time, depending on what
your needs are, ie, you can preserve an existing rootfs and manually
update the bootloader and/or kernel as&amp;nbsp;needed.&lt;/p&gt;
&lt;p&gt;If the card seems slow when running, then check top and look for a piggy
process (sometimes the mmc driver can be seen taking up too much cpu)..
Some cards can feel faster or slower depending on how they&amp;#8217;re formatted,
so feel free to test some of the recommended formatting options (although
the partition allignment should be fine with default fdisk; whether or not
you want ext4 to use a journal and setting a specific stride option is up
to personal&amp;nbsp;choice).&lt;/p&gt;
&lt;p&gt;Lastly, make sure your mount options include relatime/diratime or similar
for decent card performance.  Also consider using a small zram swap device
and/or tmpfs device for /tmp if you have enough physical &lt;span class="caps"&gt;RAM&lt;/span&gt;.  The latter
options actually help quite a lot for general performance and on most compile
jobs, but make sure your parallel make setting isn&amp;#8217;t too high when you compile
things like binutils/gcc/glibc, and especially webkit-gtk and&amp;nbsp;firefox&amp;#8230;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
</summary><category term="kernel"></category><category term="u-boot"></category><category term="rootfs"></category><category term="Gentoo"></category><category term="Debian"></category><category term="Wandboard"></category><category term="Udoo"></category><category term="BeagleBoneBlack"></category></entry><entry><title>The Mercury Programming Language</title><link href="http://www.vctlabs.com/posts/2014/May/24/mercury_programming_language/" rel="alternate"></link><updated>2014-05-24T00:00:00-07:00</updated><author><name>Nick Lockwood</name></author><id>tag:www.vctlabs.com,2014-05-24:posts/2014/May/24/mercury_programming_language/</id><summary type="html">&lt;p&gt;High-level discussion of the Mercury programming language, covering its origin and
how it is categorized in various common language-classification&amp;nbsp;schemes&lt;/p&gt;
&lt;div class="section" id="infrequently-asked-question-iaq-what-is-the-mercury-programming-language-and-what-is-the-point-of-it"&gt;
&lt;h2&gt;Infrequently Asked Question (&lt;span class="caps"&gt;IAQ&lt;/span&gt;): What is the Mercury programming language, and what is the point of&amp;nbsp;it?&lt;/h2&gt;
&lt;p&gt;The Mercury programming language was developed in Australia, by the computer science
department at the University of Melbourne.  It was funded by various grants.  The
code for the reference implementation, developed there, is all delivered under the &lt;span class="caps"&gt;GPL&lt;/span&gt;
license, i.e., entirely open-source.  There are other implementations.  The Mercury project
has left the University of Melbourne, and now may be accessed at the website&amp;nbsp;www.mercurylang.org.&lt;/p&gt;
&lt;p&gt;Programming languages and their features are classified by computer science in a number
of categories.  The ideas summarized here are well covered by Wikipedia and other net
sources, not to mention possibly an education in computer&amp;nbsp;science.&lt;/p&gt;
&lt;div class="section" id="low-level-versus-high-level"&gt;
&lt;h3&gt;Low-level versus&amp;nbsp;high-level&lt;/h3&gt;
&lt;p&gt;A low-level language requires closer attention to the specific hardware features of the
computer system running the program than a higher-level language would demand.  At the
lowest level is the binary command set for the cpu.  C and C++ are higher-level than
that, and Fortran, Ruby and Ada are high level languages.  Although many higher-level
languages have special features allowing contact to specific hardware features, it is
easy in these languages to write programs that run properly with little or no attention
to the specific hardware it runs on.
&lt;em&gt;Mercury is a high-level&amp;nbsp;language.&lt;/em&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="practical-versus-research"&gt;
&lt;h3&gt;Practical versus&amp;nbsp;research&lt;/h3&gt;
&lt;p&gt;A practical computer language is directed toward usage by those who are interested
in getting data processed at a reasonable time and cost.  They are interested in
answers, not arcane computer science questions.  They want their analysts and
programmers to write software with a minimal amount of bugs and which is not hard
to maintain. A research language supports scientific investigations, either
computer science or any other investigations requiring something special not
easily available using the usual languages (like Fortran, C, Visual Basic, Perl,
Python etc.).  In order to satisfy unique research requirements, investigators
will put up with a remarkable amount of inconvenience with respect to obtaining
an exotic language, building the compiler or other support software, struggling
with the documentation, and so on.  This is not what the commercial user wants
to deal with.
&lt;em&gt;Mercury aims to be a practical&amp;nbsp;language.&lt;/em&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="compiled-versus-interpreted"&gt;
&lt;h3&gt;Compiled versus&amp;nbsp;interpreted&lt;/h3&gt;
&lt;p&gt;This refers to the expected run-time environment for the language.  The same
program could be either compiled or interpreted, depending on what run-time
software is used.  When a language is compiled, it is transformed to a form
which can be run as process under the operating environment of the computer
system.  When a language is interpreted, it is transformed to data which is
to be used by an additional program, the interpreter, which is running
on the target computer system.  The introduction of the interpreter as a
middleman results in additional consumption of computer resources (time and/or
space) when the program is run.
&lt;em&gt;Mercury is a compiled language.  This is in the interest of speed, as Mercury aims
to be used for large practical&amp;nbsp;problems.&lt;/em&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="imperative-versus-declarative"&gt;
&lt;h3&gt;Imperative versus&amp;nbsp;declarative&lt;/h3&gt;
&lt;p&gt;Computer languages started out all being imperative.  That means the main
emphasis is on the algorithms used to process the data.  There has been
a movement among both computer scientists and actual software developers
in which some persons want the computer languages they use to more closely
reflect the problems they are solving.  This is in opposition to closely
reflecting the computer architecture they are using, and constitutes a shift
toward a higher level.  Some speak of &amp;quot;compilable requirements&amp;quot;, meaning that
by the time you have an accurate requirements specification there is enough
exact information available that a computer could produce the acutual
runnable program.  Lisp is a good example of a declarative language, as
is Prolog, which is a logic language.
&lt;em&gt;Mercury is in the declarative&amp;nbsp;camp.&lt;/em&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="iteration-versus-recursion"&gt;
&lt;h3&gt;Iteration versus&amp;nbsp;recursion&lt;/h3&gt;
&lt;p&gt;Iteration refers to repeating a process on some data by repeating an action on each
chunk of data.  In some languages, iteration is not available directly. Instead,
operation on a big structure is accomplished by finding that the big structure is made
up of a bunch of structures to the big structure, so that the routine after acting with
respect to the big structure calls itself to deal with the similar component structures.
(If this seems confusing, it is not surprising&amp;#8212;most people not already familiar with
recursive methods need more than an introductory paragraph to get comfortable with it).
&lt;em&gt;Mercury uses recursion, not iteration.  This goes with being a declarative logic&amp;nbsp;language.&lt;/em&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="object-oriented-programming"&gt;
&lt;h3&gt;Object-oriented&amp;nbsp;programming&lt;/h3&gt;
&lt;p&gt;This is a technique in which the problem environment is modeled in terms
of &amp;quot;objects&amp;quot;, which are entities each of which have data attributes and operations
upon them.  Some languages do not directly support this concept:  examples,
C or Fortran.  Some languages provide support for this style of programming,
but it is not exactly built into the language, and it is not necessary to
progam in an &amp;quot;object-oriented&amp;quot; way.  Examples:  Perl, ocaml.  Some languages
are defined from the ground up for object-oriented programming.  Examples:
C++,Python,Ruby,Java.
&lt;em&gt;Mercury is like Perl or ocaml, in that features are provided to aid programmers
who wish to adopt an object-oriented&amp;nbsp;style.&lt;/em&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="functional-programming"&gt;
&lt;h3&gt;Functional&amp;nbsp;programming&lt;/h3&gt;
&lt;p&gt;This refers to languages which organize computations into functions
which have the property that the result of applying the function algorithm
to its inputs depends only on the inputs to the function.  This means
that a routine cannot have so-called &amp;quot;side effects&amp;quot;, that is, do something
not implied just by the inputs.  Printing out results is a side effect,
and so are various other things you might want your computer to do.
The implication is that you can have the bulk of your code purely
functional, but you must also somewhere have a part that is not purely
functional.  For some languages this involves a few contortions, but
this is &lt;span class="caps"&gt;OK&lt;/span&gt; if they are minimal, and you gain the desired benefit of
the rest of your code (presumably the hard part) being especially
easy to understand and maintain.
&lt;em&gt;Mercury is a functional programming language like &lt;span class="caps"&gt;ML&lt;/span&gt;, Haskell or ocaml.
It has very precise tracking of the necessary &amp;quot;impure&amp;quot;&amp;nbsp;code.&lt;/em&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="logic-programming"&gt;
&lt;h3&gt;Logic&amp;nbsp;programming&lt;/h3&gt;
&lt;p&gt;Logic programming languages address the problem of finding valid consequences
of given axioms and postulates.  These languages are based on mathematical
logic, comparable to, for instance relational database being based on set
theory.  Logic programs have application in artificial intelligence.  They
also have been used to prove that certain programs are valid, i.e., are
doing what they are supposed to.  An example would be showing an encryption
program is valid.  Program proving is so difficult it is not widely done.
&amp;quot;Research Continues&amp;quot;
&lt;em&gt;Mercury is a logic programming&amp;nbsp;language.&lt;/em&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="backtracking-versus-other"&gt;
&lt;h3&gt;Backtracking versus&amp;nbsp;other&lt;/h3&gt;
&lt;p&gt;Backtracking refers to the feature of a language which applies when at a certain
point the computation can proceed along alternative paths (each of which may
require extensive calculations) but it is not known which (if any) will provide
an acceptable result.  The backtracking feature allows a checkpoint to be taken
so that if this path does not work out, the computation revert to before the
alternatives, and another alternative can be tried.  This could be all arranged
by the programmer, but it is immensely easier when the language supports it.
&lt;em&gt;Mercury provides backtracking, like Prolog or transaction rollback in &lt;span class="caps"&gt;SQL&lt;/span&gt;.&lt;/em&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="compile-time-type-checking-versus-run-time-type-checking"&gt;
&lt;h3&gt;Compile-time type-checking versus run-time&amp;nbsp;type-checking&lt;/h3&gt;
&lt;p&gt;In programs, data structures are assigned types, which determine what operations
may be performed on them.  It is easy to make mistakes, and write a programming
command which specifies an invalid operation.  There are three options for what
happens next:
1.  The error is not found except possibly by detection of bad output when the
program is used.  This is the worst outcome.
2.  The error is found when the program is run, because the program contains checks
which signal that an invalid operation was attempted, or that the result of an
operation was invalid.  Here at least we know that there was a problem.
3.  The error is found when the program is compiled.  The programmer can fix the
problem before delivering a bug.
Which option is desirable depends on how important is is for the program to be
reliable.  Option 2 means a lot of work by the programmer if reliability is to be
achieved.  However, it is not hard to get programs to compile, and compilers are
relatively cheap to develop and thus to buy.
Option 3 requires plenty of work to develop a compiler, and demands careful type
definition and use by the programmer.  All this is to detect bugs earlier and
make it less likely that a bug will be delivered.
&lt;em&gt;Mercury, like Ada or ocaml, performs extensive compile-time&amp;nbsp;checking.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Mercury is the result of adding functional programming (like Haskell) and full
compile-time type checking (like Ada or ocaml) to logic programming (like Prolog).
Some might look at this as having the both the desirablity and the likelyhood of
a successful effort to hybridize armadillos and hyenas.  Nonetheless, the project
has produced a running compiler and a full build environment.  It works on Linux
and Windows and some other places.  The compiler is fast and so are the resulting
programs (relatively&amp;nbsp;speaking).&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
</summary><category term="mercury language"></category><category term="functional programming"></category><category term="logic programming"></category></entry><entry><title>Yet Another Git Intro: A basic introduction with command-line examples</title><link href="http://www.vctlabs.com/posts/2014/May/03/git-intro/" rel="alternate"></link><updated>2014-05-03T00:00:00-07:00</updated><author><name>Stephen Arnold</name></author><id>tag:www.vctlabs.com,2014-05-03:posts/2014/May/03/git-intro/</id><summary type="html">&lt;div class="section" id="getting-started"&gt;
&lt;h2&gt;Getting&amp;nbsp;Started&lt;/h2&gt;
&lt;div class="section" id="installing-git"&gt;
&lt;h3&gt;Installing&amp;nbsp;git&lt;/h3&gt;
&lt;p&gt;Fedora 7, Ubuntu 8, and later: The git-core package is available through the standard package repositories.  Other Linux and &lt;span class="caps"&gt;BSD&lt;/span&gt; environments should be similar, eg, &lt;em&gt;emerge git&lt;/em&gt; on Gentoo will install the needed commands and dependencies.  If your platform does not package git, you can download the latest stable release from &amp;quot;&lt;a class="reference external" href="http://www.kernel.org/pub/software/scm/git/"&gt;http://www.kernel.org/pub/software/scm/git/&lt;/a&gt;&amp;quot;.  Windows users are recommended to install either TortiseGit or Cygwin (the latter includes a bash shell and many other Linux&amp;nbsp;programs).&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="basic-tasks"&gt;
&lt;h3&gt;Basic&amp;nbsp;Tasks&lt;/h3&gt;
&lt;p&gt;First, note that you can get documentation for a command such as git log &amp;#8212;graph&amp;nbsp;with:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ man git-log
&lt;/pre&gt;
&lt;p&gt;or:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ git help log
&lt;/pre&gt;
&lt;p&gt;With the latter command, you can use the manual viewer of your choice; see the git-help(1) man page for more&amp;nbsp;information.&lt;/p&gt;
&lt;p&gt;You should configure git with your name and preferred email address before doing any operation. The easiest way to do so&amp;nbsp;is:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ git config --global user.name &amp;quot;Your Name Here&amp;quot;
$ git config --global user.email you&amp;#64;domain.example.com
&lt;/pre&gt;
&lt;p&gt;To download a new package from a git&amp;nbsp;repository:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ git clone https://username&amp;#64;github.com/VCTLabs/vct-web.git
&lt;/pre&gt;
&lt;p&gt;To avoid the username part of the above &lt;span class="caps"&gt;URL&lt;/span&gt;, use a .netrc file to store your login &lt;span class="caps"&gt;ID&lt;/span&gt;, or use an ssh public key on github and the ssh &lt;span class="caps"&gt;URL&lt;/span&gt;:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ git clone git&amp;#64;github.com:VCTLabs/vct-web.git
&lt;/pre&gt;
&lt;p&gt;To update a package to the latest upstream version (&amp;quot;fast-forward&amp;nbsp;merge&amp;quot;):&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ git pull origin &amp;lt;branch-name&amp;gt;
&lt;/pre&gt;
&lt;p&gt;or more simply, to pull from the default branch/location from which you&amp;nbsp;cloned:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ git pull
&lt;/pre&gt;
&lt;p&gt;will pull from the origin repository and default branch defined in the package-name/.git/config&amp;nbsp;file.&lt;/p&gt;
&lt;p&gt;One way to undo all local&amp;nbsp;modifications:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ git checkout -f
&lt;/pre&gt;
&lt;p&gt;To check in your own local modifications (e.g. update the web site, do some refactoring, fix a bug, or apply a&amp;nbsp;patch):&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ vi vct-custom.css pelicanconf.py
&lt;/pre&gt;
&lt;div class="admonition-note admonition"&gt;
&lt;p class="first admonition-title"&gt;Note&lt;/p&gt;
&lt;p class="last"&gt;Don&amp;#8217;t forget to run &amp;#8216;git add&amp;#8217; and &amp;#8216;git rm&amp;#8217; if adding or removing&amp;nbsp;files.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;To check in all local modifications to your local&amp;nbsp;repository:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ git commit -a -m &amp;quot;added new stylesheet and updated pelican config for enabling plugins&amp;quot;
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class="section" id="undo-recent-commits"&gt;
&lt;h3&gt;Undo recent&amp;nbsp;commits&lt;/h3&gt;
&lt;p&gt;If the commits are local only, then &amp;quot;git reset&amp;quot; is probably appropriate.  &lt;span class="caps"&gt;OTOH&lt;/span&gt;, if the commits are already public, ie, they&amp;#8217;ve been pushed to a remote repository and potentially cloned by someone else, then &amp;quot;git reset&amp;quot; is most likely &lt;strong&gt;not&lt;/strong&gt; the right answer.  That said, if you&amp;#8217;re working completely by yourself, then any method is viable (again, depending on what your goals&amp;nbsp;are).&lt;/p&gt;
&lt;p&gt;To make one or more commits go away cleanly when working with others, the right tool is almost certainly &amp;quot;git revert&amp;quot;.  You can specify one commit or a range, and git will make a new commit that exactly reverts the changes made by the specified commit(s).  Suppose you wanted to get rid of two commits, and you&amp;#8217;ve already made two new commits (on top of the bad ones) that you want to keep.  First, get the commit hashes for the two bad commits, then revert&amp;nbsp;them:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ git log --oneline | head -n 4

498e425 added three new drafts, still need metadata
87b2a14 latest updates to static pages
6dcdf91 added artile template with example rst metadata
6fcd2c0 Add note for ubuntu users to use apt-get version of pip instead

$ git revert 6fcd2c0..6dcdf91
&lt;/pre&gt;
&lt;p&gt;Sometimes you have made a few commits, or just pulled a change, and simply want those commits to go away&amp;nbsp;completely:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ git reset --hard HEAD~2   # erase last 2 commits
&lt;/pre&gt;
&lt;p&gt;This will essentially erase the top two commits, as if you had never made them. &lt;strong&gt;&lt;span class="caps"&gt;DO&lt;/span&gt; &lt;span class="caps"&gt;NOT&lt;/span&gt;&lt;/strong&gt; do this, if you&amp;#8217;ve already pushed said commits (at least not without coordination with others who may have pulled those commis).  Note that this is quite different from &lt;em&gt;git revert&lt;/em&gt;, which applies a reversed patch as an additional&amp;nbsp;commit.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="listing-changes-in-your-working-dir-in-diff-format"&gt;
&lt;h3&gt;Listing changes in your working dir, in diff&amp;nbsp;format&lt;/h3&gt;
&lt;p&gt;Display changes since last &amp;#8216;git add&amp;#8217; or &amp;#8216;git&amp;nbsp;rm&amp;#8217;:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ git diff
&lt;/pre&gt;
&lt;p&gt;Display changes since last&amp;nbsp;commit:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ git diff HEAD
&lt;/pre&gt;
&lt;p&gt;Obtain summary of all changes in working&amp;nbsp;dir:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ git status
&lt;/pre&gt;
&lt;p&gt;List all commits on the current branch, with&amp;nbsp;descriptions:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ git log
&lt;/pre&gt;
&lt;p&gt;The &amp;#8216;git log&amp;#8217; option &amp;quot;-p&amp;quot; shows diffs in addition to commit messages. The option &amp;quot;&amp;#8212;stat&amp;quot; shows the&amp;nbsp;diffstat.&lt;/p&gt;
&lt;p&gt;List all commits to a specific&amp;nbsp;file:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ git log content/pages/contact.rst
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="branches"&gt;
&lt;h2&gt;Branches&lt;/h2&gt;
&lt;div class="section" id="basics"&gt;
&lt;h3&gt;Basics&lt;/h3&gt;
&lt;p&gt;List all local branches (add -a to see remote branches&amp;nbsp;too):&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ git branch
&lt;/pre&gt;
&lt;p&gt;Make desired branch current in working&amp;nbsp;directory:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ git checkout $branch
&lt;/pre&gt;
&lt;p&gt;Create a new branch from master, and make it&amp;nbsp;current:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ git checkout -b alternate-theme master
&lt;/pre&gt;
&lt;p&gt;Examine which branch is&amp;nbsp;current:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ git status
&lt;/pre&gt;
&lt;p&gt;(&amp;#8216;git branch&amp;#8217; also shows you the current branch, using a &amp;quot;*&amp;quot; in&amp;nbsp;front)&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="obtain-a-diff-between-current-branch-and-master-branch"&gt;
&lt;h3&gt;Obtain a diff between current branch, and master&amp;nbsp;branch&lt;/h3&gt;
&lt;p&gt;In most trees with branches, .git/refs/heads/master contains the current &amp;#8216;vanilla&amp;#8217; upstream tree, for easy diffing and merging. (in trees without branches, &amp;#8216;master&amp;#8217; simply contains your latest changes).  The following is equivalent to git diff &lt;span class="caps"&gt;HEAD&lt;/span&gt;, when used with &lt;span class="caps"&gt;HEAD&lt;/span&gt;&amp;nbsp;branch:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ git diff master..HEAD
&lt;/pre&gt;
&lt;p&gt;Obtain a list of changes between current branch, and master&amp;nbsp;branch:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ git log master..HEAD
&lt;/pre&gt;
&lt;p&gt;(this is equivalent to git log, when used with &lt;span class="caps"&gt;HEAD&lt;/span&gt;)&lt;/p&gt;
&lt;p&gt;Rather than full changeset descriptions, obtain a one-line summary of each&amp;nbsp;changes:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ git shortlog master..HEAD
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class="section" id="merging-changes-from-one-branch-to-another"&gt;
&lt;h3&gt;Merging changes from one branch to&amp;nbsp;another&lt;/h3&gt;
&lt;p&gt;Suppose that you do work on two different branches, and after work on those two branches is complete, you merge the work into&amp;nbsp;master:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ git checkout master       # switch to branch master
$ git merge drafts          # merge drafts into master
$ git merge new-theme       # merge new-theme into master
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="misc-topics"&gt;
&lt;h2&gt;Misc.&amp;nbsp;Topics&lt;/h2&gt;
&lt;div class="section" id="optimize-your-repository"&gt;
&lt;h3&gt;Optimize your&amp;nbsp;repository&lt;/h3&gt;
&lt;p&gt;git is heavily optimized for fast storage and retrieval on a per-command basis. However, over a long period of time, it can be useful to perform further optimizations, including packing all git objects into single &amp;quot;packfile&amp;quot; for fast retrieval and less wasted disk space.  The&amp;nbsp;following:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ git gc
&lt;/pre&gt;
&lt;p&gt;will optimize your repository.  You don&amp;#8217;t need to run this frequently — git is quite fast even without it.  See the &amp;#8216;git gc&amp;#8217; man page for more&amp;nbsp;details.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="don-t-forget-to-download-tags-from-time-to-time"&gt;
&lt;h3&gt;Don&amp;#8217;t forget to download tags from time to&amp;nbsp;time&lt;/h3&gt;
&lt;p&gt;Doing a &amp;quot;git pull&amp;quot; only downloads new commits from the remote, and updates the requested remote head.  This misses updates to the .git/refs/tags/ and .git/refs/heads/ directories.  For tags, run git fetch &amp;#8212;tags in your local&amp;nbsp;repo.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="tagging-a-particular-commit"&gt;
&lt;h3&gt;Tagging a particular&amp;nbsp;commit&lt;/h3&gt;
&lt;p&gt;In many cases, you will want to give interesting or significant commits a name, known as a tag.  The Linux kernel uses tags for each kernel version: &amp;quot;v2.6.21&amp;quot;, &amp;quot;v2.6.22&amp;quot;, etc.  For example, to create a new tag after a particular&amp;nbsp;commit:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ git tag my-tag
&lt;/pre&gt;
&lt;p&gt;This creates a new tag named &amp;quot;my-tag&amp;quot;, based on the current commit. You can also make an &amp;quot;annotated&amp;quot; tag, or a &lt;span class="caps"&gt;GPG&lt;/span&gt;-signed tag, so read the man page for more&amp;nbsp;details.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="further-reading"&gt;
&lt;h3&gt;Further&amp;nbsp;reading&lt;/h3&gt;
&lt;p&gt;A (larger) good introduction is the &lt;a class="reference external" href="http://schacon.github.com/git/gittutorial.html"&gt;Git&amp;nbsp;tutorial&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;More complete documentation is available in the &lt;a class="reference external" href="http://gitref.org/"&gt;Git community book&lt;/a&gt;, as well as the &lt;a class="reference external" href="http://gitref.org/"&gt;Git Reference&lt;/a&gt; and git man page&amp;nbsp;documentation.&lt;/p&gt;
&lt;p&gt;And for even more information on Git, check out &lt;a class="reference external" href="http://progit.org/book/"&gt;the Pro Git book&lt;/a&gt;.&lt;/p&gt;
&lt;div class="admonition-note admonition"&gt;
&lt;p class="first admonition-title"&gt;Note&lt;/p&gt;
&lt;p class="last"&gt;This article was originally adapted and expanded from another Git Intro found on the web; I just can&amp;#8217;t remember where&amp;nbsp;:/&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</summary><category term="source code"></category><category term="source code repository"></category><category term="software configuration management"></category><category term="git"></category></entry><entry><title>Mobile App Development</title><link href="http://www.vctlabs.com/posts/2014/Apr/25/mobiledev/" rel="alternate"></link><updated>2014-04-25T23:40:00-07:00</updated><author><name>Donald Burr</name></author><id>tag:www.vctlabs.com,2014-04-25:posts/2014/Apr/25/mobiledev/</id><summary type="html">&lt;h1&gt;So You Wanna Write an&amp;nbsp;App?&lt;/h1&gt;
&lt;h3&gt;Jumping feet first into the wild world of app&amp;nbsp;development&lt;/h3&gt;
&lt;h4&gt;by Donald&amp;nbsp;Burr&lt;/h4&gt;
&lt;hr /&gt;
&lt;p&gt;It happens to all of us eventually.  Perhaps you&amp;#8217;re having a frustrating time using an app, and wish that the developer could have written it &lt;em&gt;this&lt;/em&gt; way, or added &lt;em&gt;that&lt;/em&gt; feature.  Maybe a brilliant idea for the Next Big Thing(&lt;span class="caps"&gt;TM&lt;/span&gt;) hit you while you were in the shower one day, but you are hesitant to hire a programmer to help realize your dream, lest they decide to run off and &lt;a href="http://www.aljazeerah.info/News/2011/April/11%20n/Did%20Mark%20Zuckerberg%20Steal%20the%20Facebook%20Idea%20from%20the%20Winklevoss%20Twin%20Brothers.htm" title="Steal"&gt;steal your idea&lt;/a&gt; (or perhaps you just can&amp;#8217;t afford to hire anybody.)  Or maybe you&amp;#8217;re trying to get something done, but as it turns out, there just isn&amp;#8217;t &amp;#8220;an app for that.&amp;#8221;  (It happens more often than you&amp;nbsp;think!)&lt;/p&gt;
&lt;p&gt;In cases like this, you might have wished that you could write your own app.  But the mere thought of doing so sends a chill of fear and dread up your spine.  &lt;em&gt;It&amp;#8217;s hard!&lt;/em&gt;  &lt;em&gt;I have to learn how to code!&lt;/em&gt;  &lt;em&gt;It costs a lot of money!&lt;/em&gt;  &lt;em&gt;What if Apple rejects my app?!&lt;/em&gt;  Well, fear not my friend: I am here to tell you that developing apps for iOS and the Mac is not as scary as it sounds, nor is it as costly as you might think.  In fact, most of the tools and information you&amp;#8217;ll need are &lt;em&gt;entirely free of charge&lt;/em&gt;!&lt;/p&gt;
&lt;p&gt;&lt;span class="dquo"&gt;&amp;#8220;&lt;/span&gt;Whoa there!  Wait a minute!&amp;#8221; you might be saying to yourself right about now.  &amp;#8220;I thought it costs money to get into the Mac and iOS developer programs!&amp;#8221;  This is in fact correct: you must pay Apple $99 per year to join the &lt;a href="https://developer.apple.com/programs/mac/" title="Mac Developer Program"&gt;Mac&lt;/a&gt; and &lt;a href="https://developer.apple.com/programs/ios/" title="iOS Developer Program"&gt;iOS&lt;/a&gt; developer programs.  (That&amp;#8217;s $99 per program folks; so if you want to develop for both Mac and iOS, you&amp;#8217;re talking $198/year.)  However, you only need to pay if you wish to do the&amp;nbsp;following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;sell your apps in the App&amp;nbsp;Store&lt;/li&gt;
&lt;li&gt;sell your Mac apps outside of the App Store with a &lt;a href="https://developer.apple.com/resources/developer-id/" title="Developer ID"&gt;registered developer &lt;span class="caps"&gt;ID&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;test your iOS apps on actual iOS devices.  (Apple&amp;#8217;s developer tools come with a software-based iPhone and iPad emulator; if all you want to do is use this, then you need not pay&amp;nbsp;anything.)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In other words, if you&amp;#8217;re just getting started, or just want to experiment (get your feet wet, so to speak,) &lt;em&gt;you don&amp;#8217;t have to pay anything at all&lt;/em&gt;.  Only once you&amp;#8217;ve decided that, yes, this developing apps thing is my kind of gig, do you have to pay&amp;nbsp;up.&lt;/p&gt;
&lt;p&gt;But paying up does have its perks.  For one thing, you get to test new versions of iOS and Mac &lt;span class="caps"&gt;OS&lt;/span&gt; long before the public sees them.  This is of course vital to ensure that your apps will work with the &amp;#8220;next big thing&amp;#8221;; but it&amp;#8217;s also fun.  You also get access to the full Apple Developer website, with its wealth of information, technical documents, and training videos.  (all session videos from Apple&amp;#8217;s &lt;a href="https://developer.apple.com/wwdc/about/" title="WWDC"&gt;Worldwide Developers Conference&lt;/a&gt; (&lt;span class="caps"&gt;WWDC&lt;/span&gt;) are available for your perusal; it&amp;#8217;s the next best thing to being there!)  You also get access to the Developer Forums, an extremely useful place where you can chat with other developers, ask questions, and discuss the finer points of app development.  (Oftentimes you&amp;#8217;ll find Apple engineers monitoring the forums, so you can get your help from the&amp;nbsp;experts!)&lt;/p&gt;
&lt;h5&gt;So What Do You&amp;nbsp;Need?&lt;/h5&gt;
&lt;p&gt;First and foremost, you will need a Mac.  Odds are that, if you are reading this, you probably already have one.  If not, then go and get yourself one.  Fortunately it doesn&amp;#8217;t have to be a particularly powerful Mac; however it does need to run the current operating system of the day (which at the time of this writing is &lt;span class="caps"&gt;OS&lt;/span&gt; X 10.8 Mountain Lion.)  A Mac mini will do nicely, as will a MacBook Air.  Even a used Mac would work brilliantly, so long as it can run Mountain&amp;nbsp;Lion.&lt;/p&gt;
&lt;p&gt;You will also need &lt;a href="http://itunes.apple.com/us/app/xcode/id497799835?ls=1&amp;amp;mt=12" title="XCode"&gt;Xcode&lt;/a&gt;, Apple&amp;#8217;s &lt;a href="http://en.wikipedia.org/wiki/Integrated_development_environment" title="IDE"&gt;integrated development environment&lt;/a&gt;.  This comprehensive set of tools comes with everything you need to write, test, debug and package your app for sale or distribution.  Xcode is available for free in the Mac App&amp;nbsp;Store.&lt;/p&gt;
&lt;p&gt;Finally, while not strictly speaking a requirement, a cadre of friends, acquaintances, coworkers, etc. who would be willing to help out by testing your apps on their precious iDevices is extremely helpful.  The more testing your app gets, and the more variations on hardware and software that it is tested with, the&amp;nbsp;better.&lt;/p&gt;
&lt;h5&gt;Dipping Your Toe in the Shallow&amp;nbsp;End&lt;/h5&gt;
&lt;p&gt;Psst!  Did you know that you can create iOS apps &lt;em&gt;without even writing a single line of code&lt;/em&gt;?  It&amp;#8217;s true!  Using the &lt;a href="http://www.redfoundry.com" title="Red Foundry"&gt;RedFoundry&lt;/a&gt; web-based environment, you can quickly and easily create a basic iOS app by dragging and dropping &amp;#8220;widgets.&amp;#8221;  You can choose from a wide variety of widgets, such as &lt;span class="caps"&gt;RSS&lt;/span&gt; feed viewers, audio players, Twitter stream viewers, Flickr viewers, and more.  As you build your app, you can quickly test it on your actual iDevice using &lt;a href="http://itunes.apple.com/us/app/fusion-mobile/id536032952?mt=8" title="Red Foundry app"&gt;Red Foundry&amp;#8217;s free app&lt;/a&gt;.  When your app is all done, you can publish it to the App Store straight from the Red Foundry&amp;nbsp;website.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Red Foundry lets you easily build an iOS app by dragging and dropping widgets" src="https://dl.dropbox.com/u/169813/DevArticleImages/RedFoundry.png" title="Red Foundry screenshot" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Red Foundry lets you easily build an iOS app by dragging and dropping&amp;nbsp;widgets.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;There are many similar tools out there; for example &lt;a href="http://gamesalad.com/" title="GameSalad"&gt;GameSalad&lt;/a&gt; is specially geared toward writing games, and includes such features as physics engines, graphics sprites, collision detection, and so on.  Services such as RedFoundry and GameSalad are a great place to start, and are perfect if all you want to do is write a fairly simple&amp;nbsp;app.&lt;/p&gt;
&lt;p&gt;&lt;img alt="The beginnings of the Next Big Game.  I'm calling it &amp;quot;Belligerent Avians.&amp;quot;" src="https://dl.dropbox.com/u/169813/DevArticleImages/GameSalad1.png" title="GameSalad 1" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;The beginnings of the Next Big Game.  I&amp;#8217;m calling it &amp;#8220;Belligerent&amp;nbsp;Avians.&amp;#8221;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="In GameSalad, you can easily assign attributes and set up behaviors for your game's objects." src="https://dl.dropbox.com/u/169813/DevArticleImages/GameSalad2.png" title="GameSalad 2" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;In GameSalad, you can easily assign attributes and set up behaviors for your game&amp;#8217;s&amp;nbsp;objects.&lt;/em&gt;&lt;/p&gt;
&lt;h5&gt;Time to Swim Out to the Deep&amp;nbsp;End&lt;/h5&gt;
&lt;p&gt;Although tools such as Red Foundry and GameSalad are quite capable, there will come a time when what you want to accomplish is beyond their capabilities.  It&amp;#8217;s time to leave the shallow end and swim out to the deep end of the pool, and learn how to code.  But, as I said earlier, it really isn&amp;#8217;t as hard as it&amp;nbsp;sounds.&lt;/p&gt;
&lt;p&gt;A good place to start is the excellent book &lt;em&gt;&lt;a href="http://www.amazon.com/dp/0321706285/?tag=otakunocast-20" title="Objective-C Programming: The Big Nerd Ranch Guide"&gt;Objective-C Programming: The Big Nerd Ranch Guide&lt;/a&gt;&lt;/em&gt;, written by the fine folks over at the &lt;a href="http://bignerdranch.com/" title="Big Nerd Ranch"&gt;Big Nerd Ranch&lt;/a&gt;.  Big Nerd Ranch is a company that, among other things, teaches seminars on Mac and iOS programming; they also write apps on a contract basis.  So they know their stuff.  This book assumes you know nothing about programming at all, and teaches you the fundamentals of programming in Objective-C, the language Mac and iOS apps are written in.  It also teaches you the basics of Mac and iOS programming.  After this, you might want to check out their other books for more in-depth coverage of the particular platform you are interested in developing for: &lt;a href="http://www.amazon.com/dp/0321774086/?tag=otakunocast-20" title="Cocoa Programming for Mac OS X: The Big Nerd Ranch Guide"&gt;Cocoa Programming for Mac &lt;span class="caps"&gt;OS&lt;/span&gt; X: The Big Nerd Ranch Guide&lt;/a&gt; (for Mac development) and &lt;a href="http://www.amazon.com/dp/0321821521/?tag=otakunocast-20" title="iOS Programming: The Big Nerd Ranch Guide"&gt;iOS Programming: The Big Nerd Ranch Guide&lt;/a&gt; (for iOS&amp;nbsp;development.)&lt;/p&gt;
&lt;p&gt;&lt;img alt="No, you're not looking at the Matrix.  This is Xcode's code editor.  It has many features that help make entering code a lot easier." src="https://dl.dropbox.com/u/169813/DevArticleImages/XcodeCode.png" title="Xcode Code" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;No, you&amp;#8217;re not looking at &lt;a href="http://boscosgrindhouse.com/2012/07/30/boscos-franchise-collection-the-matrix-trilogy/" title="The Matrix"&gt;the Matrix&lt;/a&gt;.  This is Xcode&amp;#8217;s code editor.  It has many features that help make entering code a lot&amp;nbsp;easier.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Your local community college or Adult-Ed center might have courses on computer programming and app development that might help as well.  With the growing popularity of iOS devices and Macs, many institutions of higher education are jumping on the bandwagon and offering such&amp;nbsp;courses.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Using Xcode's Interface Builder, you can construct your app's User Interface by dragging and dropping from a palette of buttons, text fields and other common controls." src="https://dl.dropbox.com/u/169813/DevArticleImages/XcodeIB.png" title="Xcode Interface Builder" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Using Xcode&amp;#8217;s Interface Builder, you can construct your app&amp;#8217;s User Interface by dragging and dropping from a palette of buttons, text fields and other common&amp;nbsp;controls.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Or, if you are interested in iOS development, you might just want to stay at home and study online.  One of the best courses on iOS app development, &lt;a href="http://itunes.apple.com/itunes-u/ipad-iphone-application-development/id473757255?mt=10" title="CS193P"&gt;&lt;span class="caps"&gt;CS193P&lt;/span&gt;&lt;/a&gt; is available &lt;em&gt;for free&lt;/em&gt; on Apple&amp;#8217;s &lt;a href="http://www.apple.com/education/itunes-u/" title="iTunes U"&gt;iTunes U&lt;/a&gt; service (one of the most under-appreciated parts of iTunes in my opinion.)  This college-level course is taught at Stanford by instructors who really know their stuff; and since Stanford is practically in Apple &lt;span class="caps"&gt;HQ&lt;/span&gt;&amp;#8217;s backyard, you can often find Apple employees appearing as special guest lecturers.  Using the free &lt;a href="http://itunes.apple.com/us/app/itunes-u/id490217893?mt=8" title="iTunes U App"&gt;iTunes U app&lt;/a&gt; you can watch the lecture videos, view the lecture notes and slides, take notes and view the homework assignments.  (You can also download all the code you see the instructor working on in class, but you&amp;#8217;ll need to do that from your computer.)  It&amp;#8217;s all the benefit of a college education without the hassles (being graded, quizzes, finals, having to get up at the crack of dawn to make it to class on time,&amp;nbsp;etc.)&lt;/p&gt;
&lt;p&gt;&lt;img alt="iTunes U: All the benefit of a college education, without the hassle." src="https://dl.dropbox.com/u/169813/DevArticleImages/iTunesU.PNG" title="iTunes U image" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;iTunes U: All the benefit of a college education, without the&amp;nbsp;hassle.&lt;/em&gt;&lt;/p&gt;
&lt;h5&gt;Tips for Success (and Avoiding App&amp;nbsp;Rejection)&lt;/h5&gt;
&lt;p&gt;You&amp;#8217;ve probably heard the horror stories of developers toiliing long and hard on their masterpieces only to get flatly rejected by Apple.  It&amp;#8217;s true that Apple does reject a fair number of apps; however for each app rejection, there are also thousands of apps that &amp;#8220;made the cut.&amp;#8221;  You only hear about the rejections because they complain about it vociferously on Twitter and blogs.  (In other words, they are a &lt;em&gt;very&lt;/em&gt; vocal&amp;nbsp;minority.)&lt;/p&gt;
&lt;p&gt;But you would certainly want your app to be as good as it could be, and to really shine when viewed by the Apple review personnel; and to help with that I have the following&amp;nbsp;suggestions.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Beauty is more than skin deep.&lt;/strong&gt;  Apple products are known for their beauty, elegance, simplicity and ease of use.  The same applies to the apps that run on them.  Apps should pick a design aesthetic and adhere to it.  User interfaces should be as simple as possible and convey only the most necessary information.  Navigation should be intuitive and fluid.  Every year at &lt;span class="caps"&gt;WWDC&lt;/span&gt;, Apple hands out its &lt;a href="https://developer.apple.com/wwdc/awards/" title="Apple Design Awards"&gt;Apple Design Awards&lt;/a&gt; to apps that they feel exemplify the design and usability aesthetics of Apple.  You would do wisely to study these apps and learn from their success.  There is also a corollary to this tip, which&amp;nbsp;is:&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;If you want to create the best apps, use Apple&amp;#8217;s tools.&lt;/strong&gt;  Tools such as Red Foundry, GameSalad, etc. make pretty decent looking user interfaces; but when compared to apps written using Apple&amp;#8217;s tools, they look a bit &amp;#8220;off.&amp;#8221;  The user interface is &amp;#8220;kinda, sorta, almost&amp;#8221; Mac- or iOS-like.  But it&amp;#8217;s &lt;em&gt;just&lt;/em&gt; different enough that someone would notice.  For the most &amp;#8220;Mac-like&amp;#8221; or &amp;#8220;iOS-like&amp;#8221; experience, you really need to roll up your sleeves and dive into the Apple development&amp;nbsp;environment.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Keep your ear to the ground&amp;#8230;&lt;/strong&gt; Wayne Gretzky once said, &amp;#8220;A good hockey player plays where the puck is. A great hockey player plays where the puck is going to be.&amp;#8221;  Great apps come not from responding to the desires of users today (although that is certainly a good thing to do too,) but from anticipating what a user&amp;#8217;s needs will be in the future.  Keep an eye out on the various social networks.  Find out what the &amp;#8220;next big thing&amp;#8221; is ? the next big social network phenomenon that is starting to gain traction; trends in the types of games people like to play; etc.  When the &amp;#8220;Next Big Thing&amp;#8221; hits, you&amp;#8217;ll be ready with &amp;#8220;an app for&amp;nbsp;that.&amp;#8221;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&amp;#8230;but be prepared to jump out of the way if a train comes rushing by.&lt;/strong&gt;  Apple has been known to radically (and without much warning) change things in its software or its developer policies.  Don&amp;#8217;t be surprised if a feature or programming trick that you are relying on suddenly changes its function or stops working entirely.  Be ready with a workaround.  Joining the paid developer program really helps in this regard, since you get early access to new iOS and Mac &lt;span class="caps"&gt;OS&lt;/span&gt; releases before the public does; you can test your apps, change your code or create workarounds to counter Apple&amp;#8217;s changes, and be ready with an app update when the public gets their next &lt;span class="caps"&gt;OS&lt;/span&gt;&amp;nbsp;update.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Play by the rules.&lt;/strong&gt;  Heed Apple&amp;#8217;s developer agreements.  Most importantly, only use public APIs (the programmatic interfaces that Apple vends out.)  A good rule of thumb is: if it&amp;#8217;s documented in official Apple documentation, then it&amp;#8217;s fair game.  If, on the other hand, you heard of this really cool trick from a buddy, or saw an interesting function call while digging through Apple&amp;#8217;s code, then I would stay very far away.  Using private or undocumented APIs or coding tricks is the quickest way to get your app rejected.  And Apple, given its fickle nature, has been known to change their developer rules suddenly and without much notice (if any at all); so stay&amp;nbsp;alert!&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Respect your users&amp;#8217; privacy and security.&lt;/strong&gt;  Apple has made some tremendous strides in respecting a user&amp;#8217;s privacy, and so should you.  If you don&amp;#8217;t need a particular type of information (a user&amp;#8217;s &lt;a href="http://phys.org/news/2012-01-location-based-geo-fencing-apps-privacy.html" title="Location privacy"&gt;location&lt;/a&gt;, access to his/her &lt;a href="http://www.pcmag.com/article2/0,2817,2400016,00.asp" title="Path Debacle"&gt;contacts&lt;/a&gt; or calendars, etc.,) then don&amp;#8217;t ask for it.  If you do, provide a good reason ? Apple gives developers a way to inform the user as to why your app is requesting that information from him.  If you transfer any sensitive data online, encrypt it.  If you need to store any sensitive data on a user&amp;#8217;s phone (usernames and passwords, etc.) do so securely.  Apple&amp;#8217;s Keychain is an excellent and very secure method of safely storing usernames and passwords, and there are many code libraries (both from Apple as well as third parties or Open Source) suitable for use in encrypting data for transmission over the Internet.  And if a user decides not to trust your app with access to his/her information, please respect their&amp;nbsp;decision.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Apple gives you a lot of toys to play with.  Use them.&lt;/strong&gt;  Apple gives us developers a bevy of toys to play with, and users will expect you to take advantage of them.  Got an app that deals with significant amounts of data (databases, note taking apps, etc.)?  Use &lt;a href="http://www.apple.com/icloud/" title="iCloud"&gt;iCloud&lt;/a&gt;; many people have multiple iDevices nowadays, and expect their data to be available ubiquitously.  Are you writing a game?  Then by all means use &lt;a href="http://www.apple.com/game-center/" title="GameCenter"&gt;GameCenter&lt;/a&gt;!  Not only is it a great way to give users value (people &lt;em&gt;love&lt;/em&gt; challenging each other and boasting about their high scores,) but it is also a great way to promote your game.  Are you writing an app with regularly updating content (blog, magazine, newspaper, etc.)?  Then you should definitely be in &lt;a href="http://www.apple.com/ipad/from-the-app-store/newsstand.html" title="Newsstand"&gt;Newsstand&lt;/a&gt;.  And so on.  And&amp;nbsp;finally:&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Don&amp;#8217;t be disappointed if you don&amp;#8217;t make millions overnight.&lt;/strong&gt;  (&lt;span class="caps"&gt;OK&lt;/span&gt;, this doesn&amp;#8217;t really have any bearing on your app&amp;#8217;s chance at approval.  I just didn&amp;#8217;t have anywhere better to put this.)  The fact of the matter is that for every &lt;em&gt;Angry Birds&lt;/em&gt; and &lt;em&gt;Tweetbot&lt;/em&gt;, there are thousands of unsung heroes ? otherwise good (perhaps even great) apps that just didn&amp;#8217;t manage to grab peoples&amp;#8217; attention and interest.  It&amp;#8217;s all a &lt;a href="http://arstechnica.com/apple/2012/05/ios-app-success-is-a-lottery-and-60-of-developers-dont-break-even/" title="Numbers Game"&gt;numbers game&lt;/a&gt;, and with &lt;a href="http://ipod.about.com/od/iphonesoftwareterms/qt/apps-in-app-store.htm" title="Many apps"&gt;over 700,000 apps&lt;/a&gt; currently in the app store, getting noticed is pretty difficult.  Sadly the App Store is not as fertile a ground for making money as it was in the past.  That&amp;#8217;s not to say that you don&amp;#8217;t have any shot at all; it&amp;#8217;s just going to take some effort (and some good luck) on your part.  Talk about your app as much as you can on Twitter and Facebook without being annoying; show it off to friends, relatives, colleagues, guys off the street, anyone really; perhaps even call in to &lt;a href="http://techguylabs.com" title="The Tech Guy"&gt;a certain nationally syndicated radio talk show host&lt;/a&gt;.  But if you go into this whole app-making thing with the sole desire to &lt;a href="http://bjango.com/articles/golddigging/" title="Money"&gt;strike it rich&lt;/a&gt;, then &lt;a href="http://www.losethegame.com" title="You Lose The Game"&gt;you have lost the game&lt;/a&gt;.  Rather, the attitude I like to take is similar to the attitude I take toward podcasting: &amp;#8220;Do it because it&amp;#8217;s fun and/or interesting.  Do it as a pasttime or a hobby.  And if you happen to make some money, more power to&amp;nbsp;ya.&amp;#8221;&lt;/li&gt;
&lt;/ul&gt;
&lt;h5&gt;A Note about&amp;nbsp;Accessibility&lt;/h5&gt;
&lt;p&gt;Finally, let me talk a little about &lt;a href="http://en.wikipedia.org/wiki/Accessibility" title="Accessibility"&gt;accessibility&lt;/a&gt;.  (Besides, &lt;a href="http://podfeet.com/" title="NosillaCast"&gt;a certain podcaster&lt;/a&gt; and &amp;#8220;technology for the disabled&amp;#8221; advocate would have me drawn and quartered if I&amp;nbsp;didn&amp;#8217;t!)&lt;/p&gt;
&lt;p&gt;There are 314 million people worldwide who have some form of visual disability (partially sighted or totally blind)  278 million have moderate to severe hearing loss.  That&amp;#8217;s a &lt;em&gt;lot&lt;/em&gt; of users ? &lt;em&gt;more users than are on Facebook!&lt;/em&gt; ? and shutting yourself out of that sizable user base is sheer insanity.  Especially when adding accessibility to your app is &lt;a href="http://www.podfeet.com/wordpress/tutorials/build-accessible-ios-apps/" title="How to build accessible apps"&gt;a lot easier to do than you think&lt;/a&gt;  (In fact, in most cases Apple has already done most of the work for you!)  The iPhone is the world&amp;#8217;s most accessible smartphone.  Period.  Same goes for the Mac.  Apple has put a ton of effort into making their platforms accessible, and they are definitely the industry leader.  These devices have literally opened up a whole new world for the disabled, and you would be foolish not to enable them to use your&amp;nbsp;app.&lt;/p&gt;
&lt;h5&gt;That&amp;#8217;s it!  No, really, that&amp;#8217;s&amp;nbsp;it!&lt;/h5&gt;
&lt;p&gt;Don&amp;#8217;t get me wrong.  There will certainly be a fair amount of head-scratching and &amp;#8220;&lt;span class="caps"&gt;WTF&lt;/span&gt;&amp;#8221; moments as you dive in and learn the intricacies of coding.  But it&amp;#8217;s certainly not an insurmountable challenge, and definitely isn&amp;#8217;t something that you should run away from in fear.  Aside from the resources I have mentioned already, there are a ton of places where you can get help and more information online.  (Besides the Apple Developer Forums, &lt;a href="http://stackoverflow.com" title="Stack Overflow"&gt;Stack Overflow&lt;/a&gt; is an excellent place where you can ask programming-related questions and get really good answers.)  Programming is sort of like learning to ride a bicycle: you&amp;#8217;ll probably be quite a bit wobbly at first, you&amp;#8217;ll fall a lot and suffer many scrapes and bruises; but pretty soon you&amp;#8217;ll get the hang of it and will be zooming through code like nobody&amp;#8217;s&amp;nbsp;business.&lt;/p&gt;
&lt;p&gt;Now go forth and realize your dreams!  Who knows?  Maybe you&amp;#8217;ll end up writing the next &lt;em&gt;Angry Birds&lt;/em&gt;&amp;#8230; er, I mean &lt;em&gt;Belligerent Avians&lt;/em&gt;!&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;em&gt;&lt;a href="http://DonaldBurr.com/" title="Donald Burr's Blog"&gt;Donald Burr&lt;/a&gt; has been using &amp;#8212; and abusing &amp;#8212; computers and gadgets practically since the day he was born.  (Rumor has it he was born with a keyboard in one hand and a mouse in the other.)  He is an &lt;a href="http://DonaldBurr.com/apps/" title="Donald Burr's Apps"&gt;avid amateur app developer&lt;/a&gt; and is &lt;a href="http://donaldburr.com/contact-me/" title="Contact Me"&gt;available for hire&lt;/a&gt; if you need a little help getting started in app writing.  When he&amp;#8217;s not geeking around with tech, he can be found blogging and podcasting about Japanese animation and culture at &lt;a href="http://otakunopodcast.com/" title="Otaku no Podcast"&gt;Otaku no Podcast&lt;/a&gt;.  He can be found on the Twitters as &lt;a href="http://twitter.com/dburr/" title="Donald Burr on Twitter"&gt;@dburr&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;</summary><category term="ios"></category><category term="android"></category><category term="google"></category><category term="xcode"></category><category term="apple"></category><category term="iphone"></category><category term="ipad"></category><category term="ipod touch"></category></entry><entry><title>Dos and Don’ts for profiling and performance optimization</title><link href="http://www.vctlabs.com/posts/2014/Apr/17/profiling-with-grof/" rel="alternate"></link><updated>2014-04-17T00:00:00-07:00</updated><author><name>Stephen Arnold</name></author><id>tag:www.vctlabs.com,2014-04-17:posts/2014/Apr/17/profiling-with-grof/</id><summary type="html">&lt;div class="section" id="tips"&gt;
&lt;h2&gt;Tips&lt;/h2&gt;
&lt;div class="admonition-note admonition"&gt;
&lt;p class="first admonition-title"&gt;Note&lt;/p&gt;
&lt;ol class="last arabic simple"&gt;
&lt;li&gt;&lt;strong&gt;Do&lt;/strong&gt; profile your code to look for performance bottlenecks, but &lt;strong&gt;don&amp;#8217;t&lt;/strong&gt; worry about hand-optimizing your code right away.  Readable and obvious is much better from a maintenance standpoint than obtuse or cryptic.  Also, if you put too much into one line of code, you may actually be defeating the code coverage&amp;nbsp;analysis.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Do&lt;/strong&gt; think about Big &amp;quot;O&amp;quot; when making algorithm selections, but &lt;strong&gt;don&amp;#8217;t&lt;/strong&gt; worry about trying to out-think the compiler optimizations.  Trust in gcc/g++ at least up to the -O2 optimization level, but don&amp;#8217;t use -O3 (which is known to break certain&amp;nbsp;constructs).&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="using-gprof"&gt;
&lt;h2&gt;Using&amp;nbsp;gprof&lt;/h2&gt;
&lt;div class="section" id="compiling-for-profiling"&gt;
&lt;h3&gt;Compiling for&amp;nbsp;profiling&lt;/h3&gt;
&lt;p&gt;Before you can profile your program, you must first recompile it specifically for profiling.  To do so, add the -pg argument to the compiler&amp;#8217;s command&amp;nbsp;line:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ g++ -g -pg -o dummy dummy.cc
&lt;/pre&gt;
&lt;p&gt;This creates an executable called dummy from the source file dummy.cc with debugging and profiling turned on.  Another way to do this is to add -pg to the &lt;tt class="docutils literal"&gt;&lt;span class="caps"&gt;CFLAGS&lt;/span&gt;&lt;/tt&gt; line in your &lt;tt class="docutils literal"&gt;Makefile&lt;/tt&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="creating-gmon-out"&gt;
&lt;h3&gt;Creating&amp;nbsp;gmon.out&lt;/h3&gt;
&lt;p&gt;Once your program has been compiled with profiling turned on, running the program to completion causes a file named &lt;tt class="docutils literal"&gt;gmon.out&lt;/tt&gt; to be created in the current directory.  gprof works by analyzing data collected during the execution of your program after your program has finished running.  &lt;tt class="docutils literal"&gt;gmon.out&lt;/tt&gt; holds this data in a gprof-readable&amp;nbsp;format.&lt;/p&gt;
&lt;p&gt;Things to keep in&amp;nbsp;mind:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;If &lt;tt class="docutils literal"&gt;gmon.out&lt;/tt&gt; already exists, it will be&amp;nbsp;overwritten.&lt;/li&gt;
&lt;li&gt;The program must exit normally.  Pressing control-c or killing the process is &lt;strong&gt;not&lt;/strong&gt; a normal&amp;nbsp;exit.&lt;/li&gt;
&lt;li&gt;Since you are trying to analyze your program in a real-world situation, you should run the program exactly the same way as you normally would (same inputs, command line arguments,&amp;nbsp;etc.).&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class="section" id="running-gprof"&gt;
&lt;h3&gt;Running&amp;nbsp;gprof&lt;/h3&gt;
&lt;p&gt;Run gprof like&amp;nbsp;this:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ gprof program-name [ data-file ] [ &amp;gt; output-file ]
&lt;/pre&gt;
&lt;p&gt;If you don&amp;#8217;t specify the name of a data file, &lt;tt class="docutils literal"&gt;gmon.out&lt;/tt&gt; is assumed.  Following the gprof command with &amp;quot;&lt;tt class="docutils literal"&gt;&amp;gt; &lt;span class="pre"&gt;output-file&lt;/span&gt;&lt;/tt&gt;&amp;quot; causes the output of gprof to be saved to &lt;tt class="docutils literal"&gt;&lt;span class="pre"&gt;output-file&lt;/span&gt;&lt;/tt&gt; so you can examine it&amp;nbsp;later.&lt;/p&gt;
&lt;p&gt;For this example, the program name is dummy and we will save the output into a file called&amp;nbsp;dummy.output:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ gprof dummy &amp;gt; dummy.output
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class="section" id="analyzing-gprof-s-output"&gt;
&lt;h3&gt;Analyzing gprof&amp;#8217;s&amp;nbsp;output&lt;/h3&gt;
&lt;p&gt;After completing the last step, the gprof&amp;#8217;s analysis has been saved into the &lt;tt class="docutils literal"&gt;dummy.output file&lt;/tt&gt;.  You can use your favorite text editor to examine this file.  By default, two kinds of analysis are performed: the flat profile and the call graph. Both types are explained in the following&amp;nbsp;sections.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="interpreting-the-flat-profile"&gt;
&lt;h3&gt;Interpreting the flat&amp;nbsp;profile&lt;/h3&gt;
&lt;p&gt;The flat profile shows the total amount of time your program spent executing each function. At the end of the profile, you will see a legend describing what each of the columns of numbers means. Here is some of the output from the flat&amp;nbsp;profile:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
Flat profile:

Each sample counts as 0.01 seconds.
  %   cumulative   self              self     total
 time   seconds   seconds    calls  us/call  us/call  name
 37.50      0.15     0.15    48000     3.12     3.12  Life::neighbor_count(int, int)
 17.50      0.22     0.07                             _IO_do_write
 10.00      0.26     0.04                             __overflow
  7.50      0.29     0.03                             _IO_file_overflow
  7.50      0.32     0.03                             _IO_putc
  5.00      0.34     0.02       12  1666.67 14166.67  Life::update(void)
  5.00      0.36     0.02                             stdiobuf::overflow(int)
  5.00      0.38     0.02                             stdiobuf::sys_write(char const *, int)
  2.50      0.39     0.01                             ostream::operator&amp;lt;&amp;lt;(char)
  2.50      0.40     0.01                             internal_mcount
  0.00      0.40     0.00       12     0.00     0.00  Life::print(void)
  0.00      0.40     0.00       12     0.00     0.00  to_continue(void)
  0.00      0.40     0.00        1     0.00     0.00  Life::initialize(void)
  0.00      0.40     0.00        1     0.00     0.00  instructions(void)
  0.00      0.40     0.00        1     0.00 170000.00  main
&lt;/pre&gt;
&lt;p&gt;Note that the functions &lt;tt class="docutils literal"&gt;mcount&lt;/tt&gt; and &lt;tt class="docutils literal"&gt;profil&lt;/tt&gt; (profil does not appear in this listing) are part of the profiling aparatus; their time gives a measure of the amount of overhead due to profiling.  Also note that functions like &lt;tt class="docutils literal"&gt;&lt;span class="pre"&gt;stdiobuf::sys_write&lt;/span&gt;&lt;/tt&gt; and &lt;tt class="docutils literal"&gt;_IO_do_write&lt;/tt&gt; are part of the system libraries and not directly part of your&amp;nbsp;code.&lt;/p&gt;
&lt;p&gt;In this output, we can see that 37.5% of dummy&amp;#8217;s execution time is spent in &lt;tt class="docutils literal"&gt;&lt;span class="pre"&gt;Life::neighbor_count&lt;/span&gt;&lt;/tt&gt;.  This is the highest percentage for any function in the program.  It is also worthwhile to note that it gets called 48,000 times.  This is your first hint that &lt;tt class="docutils literal"&gt;&lt;span class="pre"&gt;Life::neighbor_count&lt;/span&gt;&lt;/tt&gt; might be the biggest bottleneck in the&amp;nbsp;code.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="interpreting-the-call-graph"&gt;
&lt;h3&gt;Interpreting the call&amp;nbsp;graph&lt;/h3&gt;
&lt;p&gt;The call graph shows how much time was spent in each function and its children. From this information, you can find functions that, while they themselves may not have used much time, called other functions that did use unusual amounts of time. Like for the flat profile, a legend appears after the call graph describing what each of the columns of numbers&amp;nbsp;means.&lt;/p&gt;
&lt;p&gt;Here is some of the output from the call&amp;nbsp;graph:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
                         Call graph (explanation follows)

granularity: each sample hit covers 4 byte(s) for 2.50% of 0.40 seconds

index % time    self  children    called     name
                0.02    0.15      12/12      main [2]
[1]     42.5    0.02    0.15      12         Life::update(void) [1]
                0.15    0.00   48000/48000   Life::neighbor_count(int, int) [4]
---------------------------------------------------------------------------
                0.00    0.17       1/1       _start [3]
[2]     42.5    0.00    0.17       1         main [2]
                0.02    0.15      12/12      Life::update(void) [1]
                0.00    0.00      12/12      Life::print(void) [13]
                0.00    0.00      12/12      to_continue(void) [14]
                0.00    0.00       1/1       instructions(void) [16]
                0.00    0.00       1/1       Life::initialize(void) [15]
---------------------------------------------------------------------------

[3]     42.5    0.00    0.17                 _start [3]
                0.00    0.17       1/1       main [2]
---------------------------------------------------------------------------
                0.15    0.00   48000/48000   Life::update(void) [1]
[4]     37.5    0.15    0.00   48000         Life::neighbor_count(int, int) [4]
---------------------------------------------------------------------------
&lt;/pre&gt;
&lt;p&gt;The lines full of dashes divide this table into &lt;em&gt;entries&lt;/em&gt;, one for each function. Each entry has one or more&amp;nbsp;lines.&lt;/p&gt;
&lt;p&gt;In each entry, the primary line is the one that starts with an index number in square brackets. The end of this line says which function the entry is&amp;nbsp;for.&lt;/p&gt;
&lt;p&gt;The preceding lines in the entry describe the callers of this function and the following lines describe its subroutines (also called &lt;em&gt;children&lt;/em&gt; when we speak of the call graph). If the caller of a function cannot be determined, &lt;tt class="docutils literal"&gt;&amp;lt;spontaneous&amp;gt;&lt;/tt&gt; is printed&amp;nbsp;instead.&lt;/p&gt;
&lt;p&gt;The entries are sorted by time spent in the function and its&amp;nbsp;subroutines.&lt;/p&gt;
&lt;p&gt;In this example, we see that the first entry is for &lt;tt class="docutils literal"&gt;&lt;span class="pre"&gt;Life::update&lt;/span&gt;&lt;/tt&gt;, the second entry is for &lt;tt class="docutils literal"&gt;main&lt;/tt&gt;, and so on.  42.5% of the program&amp;#8217;s execution time is spent in &lt;tt class="docutils literal"&gt;&lt;span class="pre"&gt;Life::update&lt;/span&gt;&lt;/tt&gt; and its children.  &lt;tt class="docutils literal"&gt;&lt;span class="pre"&gt;Life::update&lt;/span&gt;&lt;/tt&gt; only has one child, &lt;tt class="docutils literal"&gt;&lt;span class="pre"&gt;Life::neighbor_count&lt;/span&gt;&lt;/tt&gt;.  In the fourth entry, we see that &lt;tt class="docutils literal"&gt;&lt;span class="pre"&gt;Life::neighbor_count&lt;/span&gt;&lt;/tt&gt; consumes 37.5% of the program&amp;#8217;s execution time and has no children.  As in the flat profile, the call graph shows that &lt;tt class="docutils literal"&gt;&lt;span class="pre"&gt;Life::neighbor_count&lt;/span&gt;&lt;/tt&gt; was called 48,000&amp;nbsp;times.&lt;/p&gt;
&lt;p&gt;Based on this information and what we observed in the flat profile, we can conclude that &lt;tt class="docutils literal"&gt;&lt;span class="pre"&gt;Life::neighbor_count&lt;/span&gt;&lt;/tt&gt; is the main bottleneck in&amp;nbsp;dummy.&lt;/p&gt;
&lt;p&gt;For more detailed information on gprof, check out &lt;a class="reference external" href="http://www.gnu.org/manual/gprof-2.9.1/"&gt;the gprof Manual&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
</summary><category term="profiling"></category><category term="software testing"></category><category term="software performance"></category><category term="gprof"></category><category term="gcc"></category></entry><entry><title>Dos and Don’ts for generating code/test coverage data (for C, C++, Java, and Python)</title><link href="http://www.vctlabs.com/posts/2014/Apr/03/coverage-with-gcov/" rel="alternate"></link><updated>2014-04-03T00:00:00-07:00</updated><author><name>Stephen Arnold</name></author><id>tag:www.vctlabs.com,2014-04-03:posts/2014/Apr/03/coverage-with-gcov/</id><summary type="html">&lt;div class="section" id="tips"&gt;
&lt;h2&gt;Tips&lt;/h2&gt;
&lt;div class="admonition-note admonition"&gt;
&lt;p class="first admonition-title"&gt;Note&lt;/p&gt;
&lt;ol class="last arabic simple"&gt;
&lt;li&gt;&lt;strong&gt;Do&lt;/strong&gt; generate coverage data for your code; it should be especially helpful for pointing out where test drivers are exercising code (and where they aren&amp;#8217;t).  &lt;strong&gt;Don&amp;#8217;t&lt;/strong&gt; rely on just line or branch counts and shoot for higher numbers.  For exmple, use  the branch count information to make sure you&amp;#8217;re executing all the appropriate decision paths,&amp;nbsp;etc.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Do&lt;/strong&gt; try it under &amp;quot;normal&amp;quot; or ad-hoc execution conditions to look at the main flow(s) through your code. &lt;strong&gt;Don&amp;#8217;t&lt;/strong&gt; restrict your use of coverage data to testing&amp;nbsp;only.&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;p&gt;The current tools described here include the&amp;nbsp;following:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;gcov/lcov (for C, C++, and pretty much anything compiled with&amp;nbsp;gcc)&lt;/li&gt;
&lt;li&gt;coverage.py (for&amp;nbsp;Python)&lt;/li&gt;
&lt;li&gt;cobertura (for&amp;nbsp;Java)&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class="section" id="using-gcov"&gt;
&lt;h2&gt;Using&amp;nbsp;gcov&lt;/h2&gt;
&lt;p&gt;Once your code is at least running local unit tests, and &lt;em&gt;if&lt;/em&gt; you see any
performance issues, then you can add the profiling targets to your makefile
or python code.  For non-kernel code, you should add a make target by following
this simple&amp;nbsp;example:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ gcc -fprofile-arcs -ftest-coverage tmp.c
$ a.out
$ gcov tmp.c
90.00% of 10 source lines executed in file tmp.c
Creating tmp.c.gcov.
&lt;/pre&gt;
&lt;p&gt;Please try some of the available gcov options, such&amp;nbsp;as:&lt;/p&gt;
&lt;p&gt;-a&amp;nbsp;&amp;#8212;all-blocks&lt;/p&gt;
&lt;blockquote&gt;
Write individual execution counts for every basic block. Normally gcov outputs
execution counts only for the main blocks of a line. With this option you can
determine if blocks within a single line are not being executed.&lt;/blockquote&gt;
&lt;p&gt;-b&amp;nbsp;&amp;#8212;branch-probabilities&lt;/p&gt;
&lt;blockquote&gt;
Write branch frequencies to the output file, and write branch summary info to
the standard output. This option allows you to see how often each branch in your
program was taken. Unconditional branches will not be shown, unless the -u option
is given.&lt;/blockquote&gt;
&lt;p&gt;-c&amp;nbsp;&amp;#8212;branch-counts&lt;/p&gt;
&lt;blockquote&gt;
Write branch frequencies as the number of branches taken, rather than the
percentage of branches taken.&lt;/blockquote&gt;
&lt;p&gt;-f&amp;nbsp;&amp;#8212;function-summaries&lt;/p&gt;
&lt;blockquote&gt;
Output summaries for each function in addition to the file level summary.&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div class="section" id="generating-coverage-data-for-the-kernel"&gt;
&lt;h2&gt;Generating coverage data for the&amp;nbsp;kernel&lt;/h2&gt;
&lt;p&gt;To generate coverage data for the Linux kernel, it&amp;#8217;s as easy as rebuilding the
kernel with the following options&amp;nbsp;enabled:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
CONFIG_GCOV_KERNEL=y
CONFIG_GCOV_PROFILE_ALL=y
&lt;/pre&gt;
&lt;p&gt;and mounting the debugfs file system under /sys/kernel like&amp;nbsp;so:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
# mount -t debugfs none /sys/kernel/debug
&lt;/pre&gt;
&lt;p&gt;Then change to the kernel source&amp;nbsp;tree:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
# cd /tmp/linux
&lt;/pre&gt;
&lt;p&gt;and run the coverge tool on one or more source&amp;nbsp;files:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
# gcov kernel/gcov/base.c -o /sys/kernel/debug/gcov/tmp/linux/kernel/gcov/
File 'kernel/gcov/base.c'
Lines executed:52.17% of 46
kernel/gcov/base.c:creating 'base.c.gcov'
&lt;/pre&gt;
&lt;p&gt;Code coverage information for the specified source file(s) can be found in the
files created by gcov. Alternatively, use &lt;span class="caps"&gt;LCOV&lt;/span&gt; to obtain the information&amp;nbsp;automatically.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="quick-start-using-coverage-py"&gt;
&lt;h2&gt;Quick start using&amp;nbsp;coverage.py&lt;/h2&gt;
&lt;p&gt;Install coverage.py from the &lt;a class="reference external" href="http://pypi.python.org/pypi/coverage"&gt;coverage page on the Python Package Index&lt;/a&gt;, or by
using “easy_install coverage”.  For a few more details, see &lt;a class="reference external" href="http://nedbatchelder.com/code/coverage/install.html"&gt;Installation&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Use coverage run to run your program and gather&amp;nbsp;data:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ coverage run my_program.py arg1 arg2
blah blah ...your program's output... blah blah
&lt;/pre&gt;
&lt;p&gt;Use coverage report to report on the&amp;nbsp;results:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ coverage report -m
Name                      Stmts   Miss  Cover   Missing
-------------------------------------------------------
my_program                   20      4    80%   33-35, 39
my_other_module              56      6    89%   17-23
-------------------------------------------------------
TOTAL                        76     10    87%
&lt;/pre&gt;
&lt;p&gt;For a nicer presentation, use coverage html to get annotated &lt;span class="caps"&gt;HTML&lt;/span&gt; listings detailing
missed&amp;nbsp;lines:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ coverage html
&lt;/pre&gt;
&lt;p&gt;Then visit htmlcov/index.html in your browser, to see a nicely formatted&amp;nbsp;report.&lt;/p&gt;
&lt;/div&gt;
</summary><category term="code coverage"></category><category term="test coverage"></category><category term="software testing"></category><category term="gcov"></category><category term="gcc"></category></entry><entry><title>Tracing Cheatsheet</title><link href="http://www.vctlabs.com/posts/2011/Nov/26/tracing_cheatsheet/" rel="alternate"></link><updated>2011-11-26T00:00:00-08:00</updated><author><name>Stephanie Lockwood-Childs</name></author><id>tag:www.vctlabs.com,2011-11-26:posts/2011/Nov/26/tracing_cheatsheet/</id><summary type="html">&lt;p&gt;List of simple methods to enable tracing in various scripting languages (shell, python, ruby, perl, tcl)
and build tools (make, ant, cmake, scons). Basic tracing is normally possible without editing the code or
installing additional debugging&amp;nbsp;software.&lt;/p&gt;
&lt;div class="section" id="script-tracing"&gt;
&lt;h2&gt;Script&amp;nbsp;Tracing&lt;/h2&gt;
&lt;div class="section" id="tracing-shell-scripts"&gt;
&lt;h3&gt;Tracing shell&amp;nbsp;scripts&lt;/h3&gt;
&lt;p&gt;Trace every line, showing literally when read and after shell expansion whenever&amp;nbsp;executed:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ export PS4='+(${BASH_SOURCE[0]}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
$ bash -v -x &amp;lt;script&amp;gt;
&lt;/pre&gt;
&lt;p&gt;Tracing goes to stderr, so can be saved to a file separate from normal program output
on stdout, e.g. replace second line&amp;nbsp;with&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ bash -v -x &amp;lt;script&amp;gt; 1&amp;gt;/tmp/OUT 2&amp;gt;/tmp/TRACE
&lt;/pre&gt;
&lt;p&gt;Within the trace output, lines prefixed with &amp;#8216;+&amp;#8217; are post-shell-expansion and
the others are&amp;nbsp;pre-shell-expansion.&lt;/p&gt;
&lt;p&gt;In order to trace all the way down into scripts called from a toplevel script,
the toplevel script will need to be edited to run them with &amp;#8216;-v -x&amp;#8217;&amp;nbsp;options.&lt;/p&gt;
&lt;table class="docutils field-list" frame="void" rules="none"&gt;
&lt;col class="field-name" /&gt;
&lt;col class="field-body" /&gt;
&lt;tbody valign="top"&gt;
&lt;tr class="field"&gt;&lt;th class="field-name"&gt;&lt;span class="caps"&gt;NOTE&lt;/span&gt;:&lt;/th&gt;&lt;td class="field-body"&gt;When using zsh rather than bash, you should be able to use the same commands
except for replacing &amp;#8216;${BASH_SOURCE[0]&amp;#8217; with &amp;#8216;${(%):-%N}&amp;#8217; in the &amp;#8216;export&amp;#8217; command.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;div class="section" id="tracing-python-scripts"&gt;
&lt;h3&gt;Tracing python&amp;nbsp;scripts&lt;/h3&gt;
&lt;p&gt;Trace&amp;nbsp;everything:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ python -m trace --trace &amp;lt;script&amp;gt;
&lt;/pre&gt;
&lt;p&gt;Trace except for standard library&amp;nbsp;modules:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ python -m trace --trace --ignore-dir=/usr/lib/python&amp;lt;py-version&amp;gt; &amp;lt;script&amp;gt;
&lt;/pre&gt;
&lt;p&gt;where &amp;lt;py-version&amp;gt; is python version from &amp;#8216;python &amp;#8212;version&amp;#8217; minus the
trailing patch level, e.g. 2.7 or 3.2 rather than 2.7.4 or&amp;nbsp;3.2.2&lt;/p&gt;
&lt;p&gt;Trace except for specific&amp;nbsp;modules:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ python -m trace --trace --ignore-module=&amp;lt;module 1&amp;gt; --ignore-module=&amp;lt;module 2&amp;gt; &amp;lt;script&amp;gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class="section" id="tracing-ruby-scripts"&gt;
&lt;h3&gt;Tracing ruby&amp;nbsp;scripts&lt;/h3&gt;
&lt;p&gt;Trace every&amp;nbsp;line:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
ruby -rtracer &amp;lt;script&amp;gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class="section" id="tracing-perl-scripts"&gt;
&lt;h3&gt;Tracing perl&amp;nbsp;scripts&lt;/h3&gt;
&lt;p&gt;Trace every&amp;nbsp;line:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ export PERLDB_OPTS=&amp;quot;NonStop AutoTrace&amp;quot;
$ perl -d &amp;lt;script&amp;gt;
&lt;/pre&gt;
&lt;p&gt;Trace subroutine entry and exit points, displaying arg&amp;nbsp;list:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ export PERLDB_OPTS=&amp;quot;NonStop frame=14&amp;quot;
$ perl -d &amp;lt;script&amp;gt;
&lt;/pre&gt;
&lt;p&gt;Same, but copy trace to a file (can&amp;#8217;t just redirect&amp;nbsp;stdout/stderr):&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ export PERLDB_OPTS=&amp;quot;NonStop frame=14 LineInfo=TRACE.out&amp;quot;
$ perl -d &amp;lt;script&amp;gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class="section" id="tracing-tcl-scripts"&gt;
&lt;h3&gt;Tracing tcl&amp;nbsp;scripts&lt;/h3&gt;
&lt;p&gt;Trace&amp;nbsp;everything:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ tclsh
% &amp;lt;paste excerpt below&amp;gt;
% source &amp;lt;script&amp;gt;
&lt;/pre&gt;
&lt;p&gt;using this as the paste&amp;nbsp;contents:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
rename proc _proc
_proc proc {name arglist body} {
    uplevel 1 [list _proc $name $arglist $body]
    uplevel 1 [list trace add execution $name enterstep [list ::proc_start $name]]
}
_proc proc_start {name command op} {
    puts &amp;quot;$name &amp;gt;&amp;gt; $command&amp;quot;
}
&lt;/pre&gt;
&lt;p&gt;Recipe taken from &amp;quot;Trace&amp;quot; section of the &lt;a class="reference external" href="http://wiki.tcl.tk/473"&gt;debug page of the Tcler&amp;#8217;s Wiki&lt;/a&gt;,
which is a page worth exploring further if needing to do much tcl&amp;nbsp;debugging.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="build-tracing"&gt;
&lt;h2&gt;Build&amp;nbsp;Tracing&lt;/h2&gt;
&lt;div class="section" id="tracing-make-builds"&gt;
&lt;h3&gt;Tracing make&amp;nbsp;builds&lt;/h3&gt;
&lt;p&gt;Normal&amp;nbsp;tracing:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ make --debug -n &amp;lt;target&amp;gt;
&lt;/pre&gt;
&lt;p&gt;Note that &amp;#8216;-n&amp;#8217; is a simulation mode so commands are not actually run,
but it shows _all_ commands that would have been run (even commands that
would otherwise be quieted by &amp;#8216;&amp;#64;&amp;#8217;&amp;nbsp;prefix).&lt;/p&gt;
&lt;p&gt;Much improved&amp;nbsp;tracing:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ make SHELL='$(warning [$&amp;#64; ($^) ($?)])bash'
&lt;/pre&gt;
&lt;p&gt;This is essentially a suggestion from an excellent &lt;a class="reference external" href="http://www.drdobbs.com/tools/debugging-makefiles/197003338"&gt;Dr. Dobbs article on
Make debugging&lt;/a&gt; with the additional observation that often it
can be passed in on the command line without editing the Makefile
(unless some or all of the Makefiles are overriding &lt;span class="caps"&gt;SHELL&lt;/span&gt;&amp;nbsp;already).&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="tracing-ant-builds"&gt;
&lt;h3&gt;Tracing ant&amp;nbsp;builds&lt;/h3&gt;
&lt;p&gt;Normal&amp;nbsp;tracing:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ ant -v &amp;lt;target&amp;gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class="section" id="tracing-cmake-builds"&gt;
&lt;h3&gt;Tracing cmake&amp;nbsp;builds&lt;/h3&gt;
&lt;p&gt;Normal&amp;nbsp;tracing:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ cmake --trace &amp;lt;target&amp;gt;
&lt;/pre&gt;
&lt;p&gt;Tracing with extra debug&amp;nbsp;info:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ cmake --trace --debug-output &amp;lt;target&amp;gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class="section" id="tracing-scons-builds"&gt;
&lt;h3&gt;Tracing scons&amp;nbsp;builds&lt;/h3&gt;
&lt;p&gt;Normal&amp;nbsp;tracing:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ scons --taskmastertrace=&amp;lt;logfile&amp;gt; &amp;lt;target&amp;gt;
&lt;/pre&gt;
&lt;p&gt;where logfile can be a &amp;#8216;-&amp;#8216; to print dependency trace to&amp;nbsp;stdout&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
</summary><category term="debugging"></category><category term="shell"></category><category term="python"></category><category term="ruby"></category><category term="perl"></category><category term="tcl"></category><category term="make"></category><category term="ant"></category><category term="cmake"></category><category term="scons"></category></entry><entry><title>tcpdump cheatsheet: command-line capture of network traffic</title><link href="http://www.vctlabs.com/posts/2011/May/18/tcpdump_cheatsheet/" rel="alternate"></link><updated>2011-05-18T00:00:00-07:00</updated><author><name>Stephanie Lockwood-Childs</name></author><id>tag:www.vctlabs.com,2011-05-18:posts/2011/May/18/tcpdump_cheatsheet/</id><summary type="html">&lt;p&gt;tcpdump cheatsheet for command-line capture of network packets,
useful for cases where where using wireshark for capture is not practical
(e.g. network troubleshooting on remote servers or embedded&amp;nbsp;devices)&lt;/p&gt;
&lt;div class="section" id="tcpdump-cheatsheet"&gt;
&lt;h2&gt;tcpdump&amp;nbsp;cheatsheet&lt;/h2&gt;
&lt;div class="section" id="modes"&gt;
&lt;h3&gt;Modes&lt;/h3&gt;
&lt;p&gt;tcpdump has two main&amp;nbsp;modes&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;text display on console (but can be saved to file with&amp;nbsp;redirection)&lt;/li&gt;
&lt;li&gt;binary capture to file for detailed analysis (stored in pcap&amp;nbsp;format)&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class="section" id="overall-syntax"&gt;
&lt;h3&gt;Overall&amp;nbsp;syntax&lt;/h3&gt;
&lt;blockquote&gt;
tcpdump &amp;lt;options&amp;gt; &amp;lt;filter expression&amp;gt;&lt;/blockquote&gt;
&lt;p&gt;where both options and filter expression are&amp;nbsp;optional&lt;/p&gt;
&lt;p&gt;Using just the plain&amp;nbsp;command,&lt;/p&gt;
&lt;blockquote&gt;
tcpdump&lt;/blockquote&gt;
&lt;p&gt;tells tcpdump to use default&amp;nbsp;settings&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="default-settings"&gt;
&lt;h3&gt;Default&amp;nbsp;settings&lt;/h3&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;listen on first network interface (which is often&amp;nbsp;&amp;quot;eth0&amp;quot;)&lt;/li&gt;
&lt;li&gt;text display on console (as opposed to saving to&amp;nbsp;file)&lt;/li&gt;
&lt;li&gt;display summary of info from each packet&amp;nbsp;header&lt;/li&gt;
&lt;li&gt;display all&amp;nbsp;packets&lt;/li&gt;
&lt;li&gt;unlimited capture (don&amp;#8217;t quit until killed, e.g. with&amp;nbsp;ctrl-c)&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class="section" id="common-options"&gt;
&lt;h3&gt;Common&amp;nbsp;options&lt;/h3&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;which interface: &lt;em&gt;-i eth0&lt;/em&gt;, &lt;em&gt;-i eth1&lt;/em&gt;, &lt;em&gt;-i usb0&lt;/em&gt;, &lt;em&gt;-i any&lt;/em&gt;
(&amp;quot;any&amp;quot; is a virtual interface that includes packets from all&amp;nbsp;interfaces)&lt;/li&gt;
&lt;li&gt;skip name lookups for ip addresses or port numbers: &lt;em&gt;-n&lt;/em&gt;
(use this if &lt;span class="caps"&gt;DNS&lt;/span&gt; is having problems so that name lookups are slow or&amp;nbsp;failing)&lt;/li&gt;
&lt;li&gt;limit number of packets to capture: &lt;em&gt;-c 100&lt;/em&gt;, &lt;em&gt;-c&amp;nbsp;2000&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;display packet data in addition to header:  &lt;em&gt;-X&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;limit data size for each packet: &lt;em&gt;-s 100&lt;/em&gt;, &lt;em&gt;-s 2000&lt;/em&gt;
&lt;strong&gt;&lt;span class="caps"&gt;PROBABLY&lt;/span&gt; &lt;span class="caps"&gt;DO&lt;/span&gt; &lt;span class="caps"&gt;NOT&lt;/span&gt; &lt;span class="caps"&gt;WANT&lt;/span&gt; &lt;span class="caps"&gt;THIS&lt;/span&gt; &lt;span class="caps"&gt;WHEN&lt;/span&gt; &lt;span class="caps"&gt;STORING&lt;/span&gt; &lt;span class="caps"&gt;PACKETS&lt;/span&gt; &lt;span class="caps"&gt;FOR&lt;/span&gt; &lt;span class="caps"&gt;LATER&lt;/span&gt; &lt;span class="caps"&gt;ANALYSIS&lt;/span&gt;!&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;write captured packets to file: &lt;em&gt;-w&amp;nbsp;filename&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;read from existing file (instead of live capture): &lt;em&gt;-r&amp;nbsp;filename&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;verbose: &lt;em&gt;-v&lt;/em&gt;, &lt;em&gt;-vv&lt;/em&gt;, or -vvv for increasing verbosity
(when capturing to file, any of the above usefully enables a count of received&amp;nbsp;packets)&lt;/li&gt;
&lt;/ul&gt;
&lt;dl class="docutils"&gt;
&lt;dt&gt;&lt;strong&gt;&lt;span class="caps"&gt;NOTE&lt;/span&gt;:&lt;/strong&gt;&lt;/dt&gt;
&lt;dd&gt;when writing packets to file, full contents of packets are saved
in pcap format; flags such as &lt;em&gt;-X&lt;/em&gt; are only needed if displaying
on console, when the default display summarizes header info
and skips packet payloads&amp;nbsp;altogether&lt;/dd&gt;
&lt;/dl&gt;
&lt;/div&gt;
&lt;div class="section" id="filter-syntax"&gt;
&lt;h3&gt;Filter&amp;nbsp;syntax&lt;/h3&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;limit by ip address/hostname: host x.x.x.x, host&amp;nbsp;somehost.com&lt;/li&gt;
&lt;li&gt;limit by port number/port name: port 80, port http
official port names can be found in&amp;nbsp;/etc/services&lt;/li&gt;
&lt;li&gt;limit by packet type: ip, tcp, udp, icmp, arp, esp, ah
(last couple being &lt;span class="caps"&gt;IPSEC&lt;/span&gt;&amp;nbsp;packets)&lt;/li&gt;
&lt;li&gt;combine simple limits into more complex criteria: not, and,&amp;nbsp;or&lt;/li&gt;
&lt;li&gt;group operators in complex criteria: ( )
good idea to use quotes around the whole filter statement
if it is complicated enough to need&amp;nbsp;parentheses&amp;#8230;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class="section" id="examples"&gt;
&lt;h3&gt;Examples&lt;/h3&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;display summary of packets to/from eth1 network card, skipping hostname&amp;nbsp;lookups&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class="literal-block"&gt;
tcpdump -i eth1 -n
&lt;/pre&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;display summary of packets to/from any web&amp;nbsp;server&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class="literal-block"&gt;
tcpdump -i any port http
&lt;/pre&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;save summary of ping packets to/from google.com to a&amp;nbsp;file&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class="literal-block"&gt;
tcpdump -i any icmp and host google.com &amp;gt; /tmp/google_ping.txt
&lt;/pre&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;capture all traffic to a file for later analysis (e.g. in&amp;nbsp;wireshark)&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class="literal-block"&gt;
tcpdump -i any -w /tmp/saved_traffic.pcap -v
&lt;/pre&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;capture all traffic except your own ssh connection to a&amp;nbsp;file&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class="literal-block"&gt;
tcpdump -i any -w /tmp/saved_traffic.pcap -v &amp;quot;not ( port ssh and host me.org )&amp;quot;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
</summary><category term="tcpdump"></category><category term="troubleshooting"></category><category term="network"></category></entry><entry><title>Posix-style Regular Expressions</title><link href="http://www.vctlabs.com/posts/2009/Sep/24/regex_cheatsheet/" rel="alternate"></link><updated>2009-09-24T00:00:00-07:00</updated><author><name>Stephanie Lockwood-Childs</name></author><id>tag:www.vctlabs.com,2009-09-24:posts/2009/Sep/24/regex_cheatsheet/</id><summary type="html">&lt;p&gt;Posix regular expressions cheatsheet, where &amp;quot;posix&amp;quot; refers to the syntax
supported by traditional unix utilities (grep, sed, awk) without the additions
of perl-style &amp;quot;extended&amp;quot;&amp;nbsp;syntax&lt;/p&gt;
&lt;div class="section" id="regular-expression-syntax"&gt;
&lt;h2&gt;Regular expression&amp;nbsp;syntax&lt;/h2&gt;
&lt;table border="1" class="docutils"&gt;
&lt;colgroup&gt;
&lt;col width="14%" /&gt;
&lt;col width="33%" /&gt;
&lt;col width="53%" /&gt;
&lt;/colgroup&gt;
&lt;thead valign="bottom"&gt;
&lt;tr&gt;&lt;th class="head"&gt;Pattern&lt;/th&gt;
&lt;th class="head"&gt;Backslash needed (basic syntax)&lt;/th&gt;
&lt;th class="head"&gt;Meaning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody valign="top"&gt;
&lt;tr&gt;&lt;td&gt;.&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;&lt;span class="caps"&gt;ANY&lt;/span&gt; character&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;[:class:]&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Character inside pre-defined set named &amp;quot;class&amp;quot; &lt;a class="footnote-reference" href="#id2" id="id1"&gt;[1]&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;[abc]&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Character inside given set&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;[a-m]&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Character inside given range&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;[^abc]&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Character &lt;span class="caps"&gt;NOT&lt;/span&gt; inside given set&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;(abc)&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Cluster into pattern group&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;a|b&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Alternative patterns/groups&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;a?&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Repeat count: occurs zero or once&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;a*&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Repeat count: occurs &lt;span class="caps"&gt;ANY&lt;/span&gt; number of times (including 0)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;a+&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Repeat count: occurs one or more times&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;a{2,5}&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Repeat count: occurs some number within range&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;^abc&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Anchor: beginning of line&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;abc$&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Anchor: end of line&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;table class="docutils footnote" frame="void" id="id2" rules="none"&gt;
&lt;colgroup&gt;&lt;col class="label" /&gt;&lt;col /&gt;&lt;/colgroup&gt;
&lt;tbody valign="top"&gt;
&lt;tr&gt;&lt;td class="label"&gt;&lt;a class="fn-backref" href="#id1"&gt;[1]&lt;/a&gt;&lt;/td&gt;&lt;td&gt;there is no character class named &amp;quot;class&amp;quot;, merely serving as placeholder for the real classes
of which the most important are: alpha, digit, alnum, lower, upper, blank, and space&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;div class="section" id="basic-syntax-vs-extended-syntax"&gt;
&lt;h3&gt;Basic syntax vs extended&amp;nbsp;syntax&lt;/h3&gt;
&lt;p&gt;The only difference between &amp;quot;basic syntax&amp;quot; and &amp;quot;extended syntax&amp;quot; &lt;a class="footnote-reference" href="#id4" id="id3"&gt;[2]&lt;/a&gt; is
differing policies on&amp;nbsp;backslash-ification.&lt;/p&gt;
&lt;p&gt;Basic syntax requires certain characters to be backslashed to obtain the
special pattern-matching meaning (&amp;quot;Yes&amp;quot; in middle column of table above), while
other characters are assumed to have the special meaning &lt;em&gt;unless&lt;/em&gt; they are
backslashed to be meant literally (&amp;quot;No&amp;quot; in middle column of table&amp;nbsp;above).&lt;/p&gt;
&lt;p&gt;Extended syntax is much more consistent: omit the backslash to use the
pattern-matching meaning for all special characters, or include a backslash to
take the literal meaning of a&amp;nbsp;character.&lt;/p&gt;
&lt;table class="docutils footnote" frame="void" id="id4" rules="none"&gt;
&lt;colgroup&gt;&lt;col class="label" /&gt;&lt;col /&gt;&lt;/colgroup&gt;
&lt;tbody valign="top"&gt;
&lt;tr&gt;&lt;td class="label"&gt;&lt;a class="fn-backref" href="#id3"&gt;[2]&lt;/a&gt;&lt;/td&gt;&lt;td&gt;&amp;quot;extended&amp;quot; in this case refers to Posix-style extended syntax, not to perl-style extended syntax,
which adds entirely new syntax elements not included in this cheatsheet&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;div class="section" id="expression-grouping"&gt;
&lt;h3&gt;Expression&amp;nbsp;grouping&lt;/h3&gt;
&lt;p&gt;Reasons for grouping with&amp;nbsp;parenthesis:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;Apply count to whole group &lt;em&gt;(abc)?&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;Use groups as alternative choices  &lt;em&gt;(abc)|(xyz)&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;When using regexes to do substitutions, groups can be recalled as part of replacement&amp;nbsp;text&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="tips"&gt;
&lt;h2&gt;Tips&lt;/h2&gt;
&lt;div class="section" id="convenient-testing-from-the-command-line"&gt;
&lt;h3&gt;Convenient testing from the&amp;nbsp;command-line&lt;/h3&gt;
&lt;p&gt;Use &lt;em&gt;&amp;#8212;colour&lt;/em&gt; option of &lt;em&gt;egrep&lt;/em&gt; or &lt;em&gt;grep&lt;/em&gt; to do testing with a candidate&amp;nbsp;pattern&lt;/p&gt;
&lt;pre class="literal-block"&gt;
# matches &amp;quot;2014-02-15&amp;quot;
echo &amp;quot;2014-02-15: did stuff&amp;quot; | egrep --colour &amp;quot;^[^:]+&amp;quot;
&lt;/pre&gt;
&lt;p&gt;Develop complicated patterns in extended syntax with &lt;em&gt;egrep&lt;/em&gt;, then backslash-ify to basic
syntax and test with &lt;em&gt;grep&lt;/em&gt; if&amp;nbsp;needed&lt;/p&gt;
&lt;pre class="literal-block"&gt;
# matches &amp;quot;product ID 4234A&amp;quot;
echo &amp;quot;quantity 5: product ID 4234A-Z99&amp;quot; | egrep --colour &amp;quot;(product ID [0-9]+)+A&amp;quot;

# matches &amp;quot;product ID 4234A&amp;quot;
echo &amp;quot;quantity 5: product ID 4234A-Z99&amp;quot; | grep --colour &amp;quot;\(product ID [0-9]\+\)\+A&amp;quot;
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class="section" id="convenient-testing-from-a-browser"&gt;
&lt;h3&gt;Convenient testing from a&amp;nbsp;browser&lt;/h3&gt;
&lt;p&gt;A very friendly web app for interactive experiments with regular expressions:
small text box for the regex, large text box for the text to be matched,
and highlighting that shows all matches in&amp;nbsp;real-time&lt;/p&gt;
&lt;p&gt;&lt;a class="reference external" href="http://regexr.com/"&gt;http://regexr.com/&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="watch-out-for-vs"&gt;
&lt;h3&gt;Watch out for &amp;quot;*&amp;quot; vs&amp;nbsp;&amp;quot;+&amp;quot;&lt;/h3&gt;
&lt;p&gt;Choose carefully between &amp;quot;any number&amp;quot; and &amp;quot;one or more&amp;quot;; it is a common mistake
to use &amp;quot;any&amp;quot; when the match should specify &amp;quot;at least&amp;nbsp;one&amp;quot;&lt;/p&gt;
&lt;pre class="literal-block"&gt;
# matches &amp;quot;A&amp;quot;, but probably not intended
echo &amp;quot;HUMMA&amp;quot; | egrep --colour &amp;quot;(product ID [0-9]*)*A&amp;quot;

# no match
echo &amp;quot;HUMMA&amp;quot; | egrep --colour &amp;quot;(product ID [0-9]+)+A&amp;quot;
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class="section" id="relevant-man-pages"&gt;
&lt;h3&gt;Relevant man&amp;nbsp;pages&lt;/h3&gt;
&lt;p&gt;&amp;quot;man 7 regex&amp;quot;, &amp;quot;man&amp;nbsp;perlre&amp;quot;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
</summary><category term="regex"></category></entry><entry><title>Command-line Editing with Readline</title><link href="http://www.vctlabs.com/posts/2007/Dec/28/readline_cheatsheet/" rel="alternate"></link><updated>2007-12-28T00:00:00-08:00</updated><author><name>Stephanie Lockwood-Childs</name></author><id>tag:www.vctlabs.com,2007-12-28:posts/2007/Dec/28/readline_cheatsheet/</id><summary type="html">&lt;p&gt;Cheatsheet for readline command-line editing, aimed towards bash but
most functions are generally applicable to other shells and apps that
use&amp;nbsp;readline&lt;/p&gt;
&lt;div class="section" id="readline-usage"&gt;
&lt;h2&gt;Readline&amp;nbsp;usage&lt;/h2&gt;
&lt;div class="section" id="display-configuration"&gt;
&lt;h3&gt;Display&amp;nbsp;configuration&lt;/h3&gt;
&lt;p&gt;Use bash &amp;#8216;bind&amp;#8217; builtin&amp;nbsp;command:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
bind -v  # show readline options
bind -p  # show readline functions and corresponding key mappings
bind -q yank  # show key combination for function yank
&lt;/pre&gt;
&lt;p&gt;Details:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;bind -v shows current settings in native readline command format;
each line is a valid readline command for setting an option, e.g.
if the option &amp;#8216;bell-stype&amp;#8217; currently has value &amp;#8216;visible&amp;#8217;, it will
be displayed like&amp;nbsp;this:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class="literal-block"&gt;
set bell-style visible
&lt;/pre&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;bind -p shows functions and key mappings in native readline command format;
each line is a valid readline command for mapping a function to a
key combination, e.g. if &amp;#8216;ctrl-y&amp;#8217; key combination is bound to the function
&amp;#8216;yank&amp;#8217;, it will be displayed like&amp;nbsp;this:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class="literal-block"&gt;
&amp;quot;\C-b&amp;quot;: history-search-backward
&lt;/pre&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;bind -q &amp;lt;function&amp;gt; will show all the key combinations that will
trigger the given function (if any), e.g. if the function
&amp;#8216;yank&amp;#8217; is bound to &amp;#8216;ctrl-y&amp;#8217; key combination, it will be
displayed like&amp;nbsp;this:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class="literal-block"&gt;
yank can be invoked via &amp;quot;\C-y&amp;quot;
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class="section" id="modify-configuration"&gt;
&lt;h3&gt;Modify&amp;nbsp;configuration&lt;/h3&gt;
&lt;p&gt;Use bash &amp;#8216;bind&amp;#8217; builtin&amp;nbsp;command:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
bind 'set bell-style visible'             # select visual bell-style
bind ' &amp;quot;\C-b&amp;quot;: history-search-backward'   # map history-search-backward function to ctrl-b
bind -r &amp;quot;\C-k&amp;quot;                            # ctrl-k is unmapped
&lt;/pre&gt;
&lt;p&gt;Details:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;when setting an option or mapping a function to a key combination,
the syntax matches the output of the corresponding display command,
but with a pair of single quotes surrounding the whole readline command
(so that it will be interpreted by bash as a single&amp;nbsp;entity)&lt;/li&gt;
&lt;li&gt;when mapping a key combination, don&amp;#8217;t allow whitespace before &amp;#8216;:&amp;#8217; or
mapping may silently&amp;nbsp;fail&lt;/li&gt;
&lt;li&gt;bind -r &amp;lt;key-combo&amp;gt; can be used to remove a default function mapping from
a key sequence that tends be accidentally triggered by a habitual&amp;nbsp;typo&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To make changes to settings or mappings persistent, either put commands as above
in ~/.bashrc or edit ~/.inputrc (creating it if non-existent). The syntax in
.inputrc is the same as the arguments to &amp;#8216;bind&amp;#8217; command, except in the case of
unmapping a key combination (the &amp;#8216;bind -r&amp;#8217; syntax being just a&amp;nbsp;shortcut):&lt;/p&gt;
&lt;pre class="literal-block"&gt;
# select visual bell-style
set bell-style visible

# map history-search-backward function to ctrl-b
&amp;quot;\C-b&amp;quot; : history-search-backward

# ctrl-k is unmapped
&amp;quot;\C-k&amp;quot; : self-insert
&lt;/pre&gt;
&lt;p&gt;The advantage to using .inputrc instead of .bashrc is that custom keybindings
should be re-usable in other applications that use readline, rather than just&amp;nbsp;bash&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="reusing-history"&gt;
&lt;h3&gt;Reusing&amp;nbsp;history&lt;/h3&gt;
&lt;pre class="literal-block"&gt;
previous-history (up arrow, ctrl-p)
next-history (down arrow, ctrl-n)
history-search-backward (unbound by default)
history-search-forward (unbound by default)
reverse-search-history (ctrl-r)
forward-search-history (ctrl-s -- poorly chosen default)
yank-nth-arg (&amp;#64;&amp;lt;number&amp;gt; alt-ctrl-y)
shell-expand-line (alt-ctrl-e)
magic-space (unbound by default)
&lt;/pre&gt;
&lt;p&gt;Details:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;previous-history&lt;ul&gt;
&lt;li&gt;goes backwards through previous commands in historical&amp;nbsp;order&lt;/li&gt;
&lt;li&gt;one of the most commonly used readline functions, being conveniently
mapped to down arrow by&amp;nbsp;default&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;next-history&lt;ul&gt;
&lt;li&gt;goes forwards through previous commands in historical&amp;nbsp;order&lt;/li&gt;
&lt;li&gt;only useful for reversing direction after going backwards in history
via another function (sorry, no time-traveling into future&amp;nbsp;here)&lt;/li&gt;
&lt;li&gt;one of the most commonly used readline functions, being conveniently
mapped to up arrow by&amp;nbsp;default&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;history-search-backward&lt;ul&gt;
&lt;li&gt;searches backwards through commands &lt;strong&gt;starting&lt;/strong&gt; with the sequence
of characters &lt;strong&gt;already&amp;nbsp;typed&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;rarely used, due to being unbound by&amp;nbsp;default&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;history-search-forward&lt;ul&gt;
&lt;li&gt;searches forwards through commands &lt;strong&gt;starting&lt;/strong&gt; with the sequence
of characters &lt;strong&gt;already&amp;nbsp;typed&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;only useful for reversing direction after searching backwards in history
via &amp;#8216;history-search-backword&amp;#8217; (sorry, still no&amp;nbsp;time-traveling)&lt;/li&gt;
&lt;li&gt;rarely used, due to being unbound by&amp;nbsp;default&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;reverse-search-history&lt;ul&gt;
&lt;li&gt;searches backwards through commands &lt;strong&gt;including&lt;/strong&gt; the sequence of
characters &lt;strong&gt;typed after calling&amp;nbsp;function&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;can alternate between calling reverse-search-history or
forward-search-history and typing more letters to narrow down the&amp;nbsp;search&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;forward-search-history&lt;ul&gt;
&lt;li&gt;searches backwards through commands &lt;strong&gt;including&lt;/strong&gt; the sequence of
characters &lt;strong&gt;typed after calling&amp;nbsp;function&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;can alternate between calling reverse-search-history or
forward-search-history and typing more letters to narrow down the&amp;nbsp;search&lt;/li&gt;
&lt;li&gt;only useful for reversing direction after going backwards in history
via another function (nope, no&amp;nbsp;time-traveling)&lt;/li&gt;
&lt;li&gt;has a positively &lt;strong&gt;unusable&lt;/strong&gt; default binding of ctrl-s, which is
interpreted by terminals as &lt;a class="reference external" href="http://en.wikipedia.org/wiki/Software_flow_control"&gt;&lt;span class="caps"&gt;XOFF&lt;/span&gt; flow-control signal&lt;/a&gt; and stops all input
until crtl-q = &lt;span class="caps"&gt;XON&lt;/span&gt; is&amp;nbsp;typed&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;yank-nth-arg&lt;ul&gt;
&lt;li&gt;without number arg, yanks 1st word from prev&amp;nbsp;command&lt;/li&gt;
&lt;li&gt;with number arg, yanks that word from prev command (numbering starts with&amp;nbsp;0)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;shell-expand-line&lt;ul&gt;
&lt;li&gt;expands current command-line using bash expansion rules, allowing further&amp;nbsp;editing&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;magic-space&lt;ul&gt;
&lt;li&gt;performs history expansion and inserts space after&amp;nbsp;it&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class="section" id="completions"&gt;
&lt;h3&gt;Completions&lt;/h3&gt;
&lt;pre class="literal-block"&gt;
complete (tab)
menu-complete (unbound by default)
dynamic-complete-history (alt-tab)
&lt;/pre&gt;
&lt;p&gt;Details:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;complete&lt;ul&gt;
&lt;li&gt;attempts to complete current word, if enough has been typed to be&amp;nbsp;unique&lt;/li&gt;
&lt;li&gt;one of the most commonly used readline functions, being conveniently
mapped to tab by&amp;nbsp;default&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;menu-complete&lt;ul&gt;
&lt;li&gt;rotates through possible completions on successive&amp;nbsp;presses&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;dynamic-complete-history&lt;ul&gt;
&lt;li&gt;uses history words as possible completions for current&amp;nbsp;word&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class="section" id="editing-commands"&gt;
&lt;h3&gt;Editing&amp;nbsp;commands&lt;/h3&gt;
&lt;pre class="literal-block"&gt;
transpose-chars (ctrl-t)
undo (ctrl-_)
revert-line (alt-r)
&lt;/pre&gt;
&lt;p&gt;Details:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;transpose-chars&lt;ul&gt;
&lt;li&gt;swaps current character with&amp;nbsp;previous&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;undo&lt;ul&gt;
&lt;li&gt;undoes last change to&amp;nbsp;line&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;revert-line&lt;ul&gt;
&lt;li&gt;undoes all changes to&amp;nbsp;line&lt;/li&gt;
&lt;li&gt;useful when going back to a line from history and accidentally mangling&amp;nbsp;it&lt;/li&gt;
&lt;li&gt;not as useful when starting from a fresh line (unless you just want to clear&amp;nbsp;it&amp;#8230;)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class="section" id="movement-commands"&gt;
&lt;h3&gt;Movement&amp;nbsp;Commands&lt;/h3&gt;
&lt;pre class="literal-block"&gt;
beginning-of-line (ctrl-a)
end-of-line (ctrl-e)
backward-word (alt-b)
forward-word (alt-f)
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class="section" id="readline-on-results-of-history-expansion"&gt;
&lt;h3&gt;Readline on results of history&amp;nbsp;expansion&lt;/h3&gt;
&lt;p&gt;set bash histverify&amp;nbsp;option&lt;/p&gt;
&lt;pre class="literal-block"&gt;
shopt -s histverify
&lt;/pre&gt;
&lt;p&gt;when using history substitution (e.g. &amp;quot;!!&amp;quot; and so forth),
hit &amp;#8216;return&amp;#8217; and see the command after the substitution, edit if desired using normal
readline features, and hit &amp;#8216;return&amp;#8217; again to finally accept the&amp;nbsp;command&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
</summary><category term="readline"></category><category term="bash"></category></entry><entry><title>Overview of the GNU autotools approach to source code configuration</title><link href="http://www.vctlabs.com/posts/2006/Mar/30/gnu_autotools_overview/" rel="alternate"></link><updated>2006-03-30T00:00:00-08:00</updated><author><name>Stephanie Lockwood-Childs</name></author><id>tag:www.vctlabs.com,2006-03-30:posts/2006/Mar/30/gnu_autotools_overview/</id><summary type="html">&lt;p&gt;Overview of &lt;span class="caps"&gt;GNU&lt;/span&gt; autotools from two different perspectives: software builder
and software developer (specifically, one maintaining a project&amp;#8217;s build&amp;nbsp;system)&lt;/p&gt;
&lt;div class="section" id="gnu-autotools-from-two-perspectives"&gt;
&lt;h2&gt;&lt;span class="caps"&gt;GNU&lt;/span&gt; Autotools from two&amp;nbsp;perspectives&lt;/h2&gt;
&lt;p&gt;&lt;span class="caps"&gt;GNU&lt;/span&gt; autotools, or commonly referred to as plain &amp;quot;autotools&amp;quot;, provides
source code configuration, allowing code to be customized in certain
ways as part of the build process. &lt;span class="caps"&gt;GNU&lt;/span&gt; autotools build-time customization
is an important part of the toolset for many Free Software projects,
who use it&amp;nbsp;to&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;implement compile-time optional&amp;nbsp;features&lt;/li&gt;
&lt;li&gt;account for differences in build&amp;nbsp;environments&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Let&amp;#8217;s look at autotools from two different perspectives, the &amp;quot;software builder&amp;quot; and
the &amp;quot;software&amp;nbsp;developer&amp;quot;.&lt;/p&gt;
&lt;p&gt;The software builder might be an end-user who is daring enough to try out some
software that has not yet been packaged up by the distro of their choice. Or,
it might be someone on the packaging-team of a distro, working to turn the
latest source code release into convenient packages for end-users. It could
even be a developer for another project, who needs a really fresh version of
some dependency used by their own&amp;nbsp;code.&lt;/p&gt;
&lt;p&gt;The software developer perspective in this case covers anyone on the software
project team who helps maintains the build process, in particular one that
allows source code to be built across a wide variety of hosts. This goal of
allowing source code to be built on hundreds or thousands of different hosts
across the world rather than just needing to build on a small number of
tightly-controlled corporate build servers has been a strong factor behind the
spread of autotools among Free Software projects rather than simpler, but
less-flexible, solutions such as hand-written&amp;nbsp;Makefiles.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="software-builder-s-view-of-autotools"&gt;
&lt;h2&gt;Software Builder&amp;#8217;s view of&amp;nbsp;autotools&lt;/h2&gt;
&lt;p&gt;Autotools is rather friendly and convenient from the software builder&amp;#8217;s perspective,
with a basic invocation that has been memorized by many a power-user of&amp;nbsp;Linux:&lt;/p&gt;
&lt;blockquote&gt;
./configure ; make ; make install&lt;/blockquote&gt;
&lt;p&gt;and additional customization power available when it is&amp;nbsp;needed:&lt;/p&gt;
&lt;blockquote&gt;
./configure &amp;#8212;enable-ssl &amp;#8212;prefix=/opt/newstuff ; make ; make install&lt;/blockquote&gt;
&lt;p&gt;The configure&amp;nbsp;script:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;accepts arguments to allow user to customize&amp;nbsp;software&lt;/li&gt;
&lt;li&gt;runs tests to characterize build environment and locate
build&amp;nbsp;dependencies&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;assuming all tests were&amp;nbsp;successful,&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;creates Makefiles that are adapted to&lt;ul&gt;
&lt;li&gt;available build tools and locations of&amp;nbsp;libraries&lt;/li&gt;
&lt;li&gt;customization choices made by the&amp;nbsp;user&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;(optional) creates config.h which has platform-dependent
information that allows source code to adapt itself to&lt;ul&gt;
&lt;li&gt;properties of the host&amp;nbsp;platform&lt;/li&gt;
&lt;li&gt;customization choices made by the&amp;nbsp;user&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class="section" id="software-developer-s-view-of-autotools"&gt;
&lt;h2&gt;Software developer&amp;#8217;s view of&amp;nbsp;autotools&lt;/h2&gt;
&lt;p&gt;Autotools from this perspective is significantly more complex than what the
software builder typically experiences. A source code release supporting the
convenience of &amp;quot;./configure ; make ; make install&amp;quot; typically&amp;nbsp;has&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;a configure script that&lt;ul&gt;
&lt;li&gt;offers appropriate options for customizing&amp;nbsp;package&lt;/li&gt;
&lt;li&gt;locates any external build dependencies (utilities, libraries,&amp;nbsp;headers)&lt;/li&gt;
&lt;li&gt;runs tests to detect platform&amp;nbsp;characteristics&lt;/li&gt;
&lt;li&gt;uses collected information to turn Makefile templates into actual&amp;nbsp;Makefiles&lt;/li&gt;
&lt;li&gt;(optional) uses collected information create config.h from a&amp;nbsp;template&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;corresponding Makefile&amp;nbsp;templates&lt;/li&gt;
&lt;li&gt;(optional) corresponding config.h&amp;nbsp;template&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The autotools suite is a framework for generating each of these pieces,
so each new project does not have write code from scratch to handle each aspect
of customization (command-line parsing, system characterization, and applying
the resulting configuration to build files and source&amp;nbsp;code)&lt;/p&gt;
&lt;p&gt;Input files maintained by&amp;nbsp;developer&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;toplevel&lt;ul&gt;
&lt;li&gt;configure.in &lt;span class="caps"&gt;OR&lt;/span&gt; (deprecated) configure.ac&lt;ul&gt;
&lt;li&gt;m4 macro calls with shell script fragments as&amp;nbsp;needed&lt;/li&gt;
&lt;li&gt;lists user-configurable options, system characterization tests,
and files to be generated from templates by variable&amp;nbsp;substitution&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;(optional) acinclude.m4&lt;ul&gt;
&lt;li&gt;custom m4 macro&amp;nbsp;definitions&lt;/li&gt;
&lt;li&gt;can define system tests not distributed with&amp;nbsp;autotools&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;per directory&lt;ul&gt;
&lt;li&gt;Makefile.am&lt;ul&gt;
&lt;li&gt;file lists and variable&amp;nbsp;definitions&lt;/li&gt;
&lt;li&gt;use &amp;#64;&lt;span class="caps"&gt;NAME&lt;/span&gt;&amp;#64; placeholders for variables to be substituted by&amp;nbsp;configure&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Autotools&amp;nbsp;utilities&lt;/p&gt;
&lt;table class="docutils field-list" frame="void" rules="none"&gt;
&lt;col class="field-name" /&gt;
&lt;col class="field-body" /&gt;
&lt;tbody valign="top"&gt;
&lt;tr class="field"&gt;&lt;th class="field-name"&gt;autoscan:&lt;/th&gt;&lt;td class="field-body"&gt;generate a preliminary configure.in by scanning source code for common portability issues&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="field"&gt;&lt;th class="field-name"&gt;aclocal:&lt;/th&gt;&lt;td class="field-body"&gt;collect all m4 macros needed by configure.in into aclocal.m4&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="field"&gt;&lt;th class="field-name"&gt;autoconf:&lt;/th&gt;&lt;td class="field-body"&gt;create configure script based on configure.in (with required macros in aclocal.m4)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="field"&gt;&lt;th class="field-name"&gt;automake:&lt;/th&gt;&lt;td class="field-body"&gt;create Makefile.in files based on configure.in (with required macros in aclocal.m4) and the corresponding Makefile.am&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="field"&gt;&lt;th class="field-name"&gt;autoheader:&lt;/th&gt;&lt;td class="field-body"&gt;(optional) create config.h.in from which configure script can generate config.h&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="field"&gt;&lt;th class="field-name"&gt;libtoolize:&lt;/th&gt;&lt;td class="field-body"&gt;install helper files used by libtool to abstract away platform-dependent details of building libraries&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="field"&gt;&lt;th class="field-name"&gt;autoreconf:&lt;/th&gt;&lt;td class="field-body"&gt;calls the various autotools in appropriate order&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;div class="section" id="relationship-between-tools-and-files"&gt;
&lt;h3&gt;Relationship between tools and&amp;nbsp;files&lt;/h3&gt;
&lt;p&gt;Prepare for&amp;nbsp;configuration&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;aclocal(configure.in + acinclude.m4 + autotool files) =&amp;nbsp;aclocal.m4&lt;/li&gt;
&lt;li&gt;autoconf(aclocal.m4 + configure.in) =&amp;nbsp;configure&lt;/li&gt;
&lt;li&gt;automake(aclocal.m4 + configure.in + Makefile.am) =&amp;nbsp;Makefile.in&lt;/li&gt;
&lt;li&gt;autoheader(configure.in) =&amp;nbsp;config.h.in&lt;/li&gt;
&lt;li&gt;libtoolize [installs some libtool files into toplevel&amp;nbsp;dir]&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Perform&amp;nbsp;configuration&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;configure(config.h.in) =&amp;nbsp;config.h&lt;/li&gt;
&lt;li&gt;configure(Makefile.in) =&amp;nbsp;Makefile&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Perform&amp;nbsp;build&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;make(Makefile + libtool files + source files) = build&amp;nbsp;products&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class="section" id="resources"&gt;
&lt;h3&gt;Resources&lt;/h3&gt;
&lt;table class="docutils field-list" frame="void" rules="none"&gt;
&lt;col class="field-name" /&gt;
&lt;col class="field-body" /&gt;
&lt;tbody valign="top"&gt;
&lt;tr class="field"&gt;&lt;th class="field-name" colspan="2"&gt;Autotools basics:&lt;/th&gt;&lt;/tr&gt;
&lt;tr class="field"&gt;&lt;td&gt;&amp;nbsp;&lt;/td&gt;&lt;td class="field-body"&gt;&lt;a class="reference external" href="http://sourceware.org/autobook/autobook/autobook_toc.html"&gt;http://sourceware.org/autobook/autobook/autobook_toc.html&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="field"&gt;&lt;th class="field-name" colspan="2"&gt;Autotools Mythbuster:&lt;/th&gt;&lt;/tr&gt;
&lt;tr class="field"&gt;&lt;td&gt;&amp;nbsp;&lt;/td&gt;&lt;td class="field-body"&gt;&lt;a class="reference external" href="https://www.flameeyes.eu/autotools-mythbuster/"&gt;https://www.flameeyes.eu/autotools-mythbuster/&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="field"&gt;&lt;th class="field-name" colspan="2"&gt;Autoconf macros archive:&lt;/th&gt;&lt;/tr&gt;
&lt;tr class="field"&gt;&lt;td&gt;&amp;nbsp;&lt;/td&gt;&lt;td class="field-body"&gt;&lt;a class="reference external" href="https://www.gnu.org/software/autoconf-archive/"&gt;https://www.gnu.org/software/autoconf-archive/&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
</summary><category term="autotools"></category><category term="autoconf"></category><category term="automake"></category><category term="aclocal"></category><category term="configure"></category></entry><entry><title>Yet another vim cheatsheet: vim basics</title><link href="http://www.vctlabs.com/posts/2005/Feb/24/vim_basics_cheatsheet/" rel="alternate"></link><updated>2005-02-24T00:00:00-08:00</updated><author><name>Stephanie Lockwood-Childs</name></author><id>tag:www.vctlabs.com,2005-02-24:posts/2005/Feb/24/vim_basics_cheatsheet/</id><summary type="html">&lt;p&gt;vim cheatsheet that covers editing basics (and which mostly applies
to other vi implementations as&amp;nbsp;well)&lt;/p&gt;
&lt;div class="section" id="vim-basics-cheatsheet"&gt;
&lt;h2&gt;vim basics&amp;nbsp;cheatsheet&lt;/h2&gt;
&lt;p&gt;This cheatsheet is intended to help those who &amp;quot;barely can get around&amp;quot;
in vi to become competent vim users. It is not intended for complete
beginners, since an understanding of vi editing modes is&amp;nbsp;assumed.&lt;/p&gt;
&lt;p&gt;Most of these commands come from original vi, and theoretically will work in
simple vi applications rather than just vim. &amp;quot;Theoretically&amp;quot; refers to a caveat
that many embedded systems run an extremely cut-down busybox vi, leaving
out a lot of supposedly standard vi features (sometimes explicitly warning
that a feature is &amp;quot;not implemented&amp;quot;, and sometimes just doing a weird edit
instead of the intended&amp;nbsp;one).&lt;/p&gt;
&lt;p&gt;Notable vim-specific commands included in this list for being incredibly
useful when&amp;nbsp;available:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;visual selection commands, in particular, column-selection mode for convenient
editing of text in fixed-width&amp;nbsp;columns&lt;/li&gt;
&lt;li&gt;macro recording and playback, which can simplify repetitive editing tasks so easily
that it has replaced many a throw-away perl/python/ruby/whatever&amp;nbsp;script&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="section" id="movement"&gt;
&lt;h3&gt;&lt;span class="caps"&gt;MOVEMENT&lt;/span&gt;&lt;/h3&gt;
&lt;pre class="literal-block"&gt;
absolute motion
   go to line number: &amp;lt;line number&amp;gt;G
   go to last line: G (without a number)
   show
relative motion
   by character: arrow keys or hjkl (mneumonic: video game controls)
   by word: w forwards and b backwards
   by page: &amp;lt;ctrl&amp;gt;f forwards and &amp;lt;ctrl&amp;gt;b backwards
   beginning of line: 0
   end of line: $
search
   initial search: / forwards and ? backwards, followed by pattern
   find next: n forwards and N backwards
   find word under cursor: #
markers
   go to marked line: '&amp;lt;marker letter&amp;gt; (normal single quote)
   go to marked character: \`&amp;lt;marker letter&amp;gt; (back tick)
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class="section" id="actions"&gt;
&lt;h3&gt;&lt;span class="caps"&gt;ACTIONS&lt;/span&gt;&lt;/h3&gt;
&lt;pre class="literal-block"&gt;
insert new text
   insert before letter under cursor: i
   insert at beginning of line: I
   append after letter under cursor: a
   append after end of line: A
   open new line after current line: o
   open new line before current line: O
copy text (Yank)
   copy range: y (followed by motion to end of range)
   copy line: yy
delete text
   delete character: x (mneumonic: like typewriter strikeout)
   backspace character: X
   delete range: d (followed by motion to end of range)
   delete line: dd
paste text
   put after cursor: p
   put before cursor: P
replace text
   replace single character: r
   enter replace mode: R (text not typed over is unchanged)
change text (like delete followed by insert)
   change range: c (followed by motion to end of range)
   change to end of line: C
undo/redo
   undo last action: u
   undo all actions on current line: U
   redo last action: &amp;lt;ctrl&amp;gt;r
line formatting
   join lines: J
   reformat range to current textwidth: gq (followed by motion to end of range)
macros
   define macro: q&amp;lt;letter for macro&amp;gt;
   replay macro: &amp;#64;&amp;lt;letter for macro&amp;gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class="section" id="defining-ranges"&gt;
&lt;h3&gt;&lt;span class="caps"&gt;DEFINING&lt;/span&gt; &lt;span class="caps"&gt;RANGES&lt;/span&gt;&lt;/h3&gt;
&lt;pre class="literal-block"&gt;
markers
   set marker: m&amp;lt;marker letter&amp;gt;
visual select (type again to cancel)
   visual select: v (followed by motion to end of range)
   line-mode visual select: V (followed by motion to end of range)
   column-mode visual select: &amp;lt;ctrl&amp;gt;v (followed by motion to end of range)
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class="section" id="important-colon-commands"&gt;
&lt;h3&gt;&lt;span class="caps"&gt;IMPORTANT&lt;/span&gt; &lt;span class="caps"&gt;COLON&lt;/span&gt; &lt;span class="caps"&gt;COMMANDS&lt;/span&gt;&lt;/h3&gt;
&lt;pre class="literal-block"&gt;
help :help
write file :w (use :w! to force a write when you get a warning)
quit :q (use :q! to force a quit when you get a warning)
revert to saved :e!
edit another file :e &amp;lt;filename&amp;gt;
syntax highlighting :syntax on (or &amp;quot;off&amp;quot; to disable)
set options :set &amp;lt;option&amp;gt; (use &amp;quot;:set all&amp;quot; to see list of available options)
horizontally split window :sp
vertically split window :vsp
substitute :&amp;lt;range&amp;gt; s/&amp;lt;search pattern&amp;gt;/&amp;lt;replacement text&amp;gt;/
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class="section" id="range-syntax-for-colon-commands"&gt;
&lt;h3&gt;&lt;span class="caps"&gt;RANGE&lt;/span&gt; &lt;span class="caps"&gt;SYNTAX&lt;/span&gt; &lt;span class="caps"&gt;FOR&lt;/span&gt; &lt;span class="caps"&gt;COLON&lt;/span&gt; &lt;span class="caps"&gt;COMMANDS&lt;/span&gt;&lt;/h3&gt;
&lt;pre class="literal-block"&gt;
'a,'z  = from marker a to marker z
.,$ = from current line to last line
1,. = from first line to last line
%  = whole file (short for &amp;quot;1,$&amp;quot;)
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class="section" id="useful-set-options"&gt;
&lt;h3&gt;&lt;span class="caps"&gt;USEFUL&lt;/span&gt; &lt;span class="caps"&gt;SET&lt;/span&gt; &lt;span class="caps"&gt;OPTIONS&lt;/span&gt;&lt;/h3&gt;
&lt;pre class="literal-block"&gt;
enable paste mode (turn off default settings that make pasting act weird) :set paste
show command being constructed :set showcmd
show cursor line &amp;amp; column :set ruler
number lines :set number
ignore case on searches :set ignorecase (or &amp;quot;ic&amp;quot;)
automatically break long lines :set textwidth=80 (or &amp;quot;tw&amp;quot;)
convert from dos line-endings :set fileformat=unix (then save the file)
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
</summary><category term="vim"></category><category term="vi"></category></entry></feed>