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

<channel>
	<title>Kosagi Blog</title>
	<atom:link href="http://www.kosagi.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.kosagi.com/blog</link>
	<description></description>
	<lastBuildDate>Sat, 18 May 2013 15:22:48 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Troubleshooting</title>
		<link>http://www.kosagi.com/blog/troubleshooting/</link>
		<comments>http://www.kosagi.com/blog/troubleshooting/#comments</comments>
		<pubDate>Wed, 18 Jan 2012 18:32:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Documentation]]></category>

		<guid isPermaLink="false">http://www.kosagi.com/blog/?p=346</guid>
		<description><![CDATA[My NeTV stucks at firmware < 20 and doesn't auto-update Bad news is firmware before 23 or so is looking for chumby.com.sg server, which has gone down permanently. Good news is you can force it update to later firmware (31 or later) and bring back auto-update mechanism. You&#8217;ll need Internet access on NeTV for this [...]]]></description>
				<content:encoded><![CDATA[<a name="My+NeTV+stucks+at+firmware+%3C+20+and+doesn%27t+auto-update"></a><h2>My NeTV stucks at firmware < 20 and doesn't auto-update</h2>
<p>Bad news is firmware before 23 or so is looking for <strong>chumby.com.sg</strong> server, which has gone down permanently.<br />
Good news is you can force it update to later firmware (31 or later) and bring back auto-update mechanism.</p>
<p>You&#8217;ll need Internet access on NeTV for this update, so first, please configure WiFi with the IR remote control or Android app.<br />
Then follow the following steps:</p>
<ul>
<li>Enable SSH under Settings menu (still using IR remote control)</li>
<li>Go into your NeTV with a SSH client (Windows users can use PuTTY, Mac/Linux users can use ssh from a terminal window)<br />
	<code class="codecolorer bash default"><span class="bash"><span style="color: #c20cb9; font-weight: bold;">ssh</span> 192.168.1.123 &nbsp; &nbsp;<span style="color: #666666; font-style: italic;">#substitue with your NeTV's IP address</span></span></code></li>
<li>Change to temp folder<br />
	<code class="codecolorer bash default"><span class="bash"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>tmp</span></code></li>
<li>Download new update script<br />
	<code class="codecolorer bash default"><span class="bash">curl <span style="color: #660033;">-o</span> update.sh http:<span style="color: #000000; font-weight: bold;">//</span>netv.bunnie-bar.com<span style="color: #000000; font-weight: bold;">/</span>updates<span style="color: #000000; font-weight: bold;">/</span>chumby-silvermoon-netv<span style="color: #000000; font-weight: bold;">/</span>update.sh</span></code></li>
<li>Make the script executable<br />
	<code class="codecolorer bash default"><span class="bash"><span style="color: #c20cb9; font-weight: bold;">chmod</span> +x update.sh</span></code></li>
<li>Execute it and wait&#8230; It may take as long as 15 minutes on a good Internet connection.<br />
	<code class="codecolorer bash default"><span class="bash">.<span style="color: #000000; font-weight: bold;">/</span>update.sh</span></code></li>
</ul>
<p>Here&#8217;s shorter version if you are a power user.</p>
<div class="codecolorer-container bash default codecolorer-noborder" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">ssh</span> 192.168.1.123 &nbsp; &nbsp;<span style="color: #666666; font-style: italic;">#substitue with your NeTV's IP address</span><br />
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<br />
curl <span style="color: #660033;">-o</span> update.sh http:<span style="color: #000000; font-weight: bold;">//</span>netv.bunnie-bar.com<span style="color: #000000; font-weight: bold;">/</span>updates<span style="color: #000000; font-weight: bold;">/</span>chumby-silvermoon-netv<span style="color: #000000; font-weight: bold;">/</span>update.sh<br />
<span style="color: #c20cb9; font-weight: bold;">chmod</span> +x update.sh<br />
.<span style="color: #000000; font-weight: bold;">/</span>update.sh</div></div>
]]></content:encoded>
			<wfw:commentRss>http://www.kosagi.com/blog/troubleshooting/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>The UI</title>
		<link>http://www.kosagi.com/blog/the-ui/</link>
		<comments>http://www.kosagi.com/blog/the-ui/#comments</comments>
		<pubDate>Wed, 11 Jan 2012 21:37:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Documentation]]></category>

		<guid isPermaLink="false">http://www.kosagi.com/blog/?p=205</guid>
		<description><![CDATA[NeTV local UI is entirely rendered by Webkit browser, running in a chromeless/fullscreen fashion. The UI is written in JavaScript &#038; HTML. Hardware integration is supported by submitting POST/GET request to http://localhost/bridge. (See HTTP API) A local copy of the UI is stored in /usr/share/netvserver/docroot From firmware 25 onwards, the latest UI code is pulled [...]]]></description>
				<content:encoded><![CDATA[<p>NeTV local UI is entirely rendered by Webkit browser, running in a chromeless/fullscreen fashion.<br />
The UI is written in JavaScript &#038; HTML.<br />
Hardware integration is supported by submitting POST/GET request to <a href="http://localhost/bridge.">http://localhost/bridge.</a> (See <a href="http://www.kosagi.com/blog/http-api">HTTP API</a>)<br />
<span id="more-205"></span><br />
A local copy of the UI is stored in /usr/share/netvserver/docroot<br />
From firmware 25 onwards, the latest UI code is pulled from <a href="https://github.com/sutajiokousagi/netv-controlpanel" title="github repository"></a> when NeTVBrowser starts/restarts to /media/storage/docroot<br />
Any local changes are discarded, hence it is not advisable to modify this 2 folder directly.<br />
To develop your own UI, change the docroot folder to another location and make your changes there.<br />
(See <a href="http://www.kosagi.com/blog/tricks/#Using+a+local+custom+Control+Panel">NeTV Tricks, Using a local custom Control Panel</a>)</p>
<p>The overlay effect is done using chroma key compositing.<br />
Any pixel color that is (240,0,240 or #F000F0) will be transparent &#038; hence reveals the background video stream.</p>
<a name="Start%2Fstop"></a><h2>Start/stop</h2>
<p>The executable file is located at /usr/bin/NeTVBrowser<br />
In order to initialize supporting drivers &#038; start it correctly, use the helper script<br />
<code class="codecolorer bash default"><span class="bash"><span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>chumby-netvbrowser start<br />
<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>chumby-netvbrowser stop<br />
<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>chumby-netvbrowser restart</span></code></p>
<a name="Setting+URL"></a><h2>Setting URL</h2>
<p>By default, tab 0 of the browser is pointing to <a href="http://localhost">http://localhost</a><br />
In order to point the browser at a different URL, use:<br />
<code class="codecolorer bash default"><span class="bash">NeTVBrowser SetUrl http:<span style="color: #000000; font-weight: bold;">//</span>www.yoururl.com</span></code><br />
Note:<br />
files:// protocol is not supported<br />
A keep-alive timer will kick in within 1 minute and switch it back to default URL. See &#8220;Keep-alive timer&#8221; section below</p>
<a name="Multitab"></a><h2>Multitab</h2>
<p>The recommended way to keep a page on screen without losing the Control Panel is to use the browser&#8217;s multi-tab feature<br />
<code class="codecolorer bash default"><span class="bash">NeTVBrowser Tab hideall <span style="color: #666666; font-style: italic;">#(hide all tabs except tab 0, will keep the tabs running)</span><br />
NeTVBrowser Tab closeall <span style="color: #666666; font-style: italic;">#(destroy all tabs except tab 0)</span><br />
NeTVBrowser Tab <span style="color: #000000;">1</span> http:<span style="color: #000000; font-weight: bold;">//</span>www.yoururl.com<br />
NeTVBrowser Tab <span style="color: #000000;">1</span> load http:<span style="color: #000000; font-weight: bold;">//</span>www.yoururl.com<br />
NeTVBrowser Tab <span style="color: #000000;">1</span> hide <span style="color: #666666; font-style: italic;">#(will keep the tab running)</span><br />
NeTVBrowser Tab <span style="color: #000000;">1</span> show <span style="color: #666666; font-style: italic;">#(will not destroy other tabs)</span><br />
NeTVBrowser Tab <span style="color: #000000;">1</span> close <span style="color: #666666; font-style: italic;">#(destroy the tab)</span></span></code><br />
Where the &#8217;1&#8242; argument is the index of the tab. Maximum 10 tabs are supported (index 9).<br />
Tab 0 is reserved for NeTV UI, can be changed but do keep in mind there&#8217;s a keep-alive timer.</p>
<a name="Keep-alive+timer"></a><h2>Keep-alive timer</h2>
<p>A keep-alive timer kicks in every 1 minute to check that tab 0 is alive &#038; the modules are loaded correctly.<br />
The timer essentially calls a JavaScript function fCheckAlive() and make sure that it returns &#8216;true&#8217;, otherwise it will reset tab 0 to default URL.<br />
To turn off the keep-alive timer<br />
<code class="codecolorer bash default"><span class="bash">NeTVBrowser KeepAlive off</span></code><br />
If you are using custom UI on tab 0, it is recommended to take advantage of this keep-alive timer rather than shutting it off.<br />
This is to make sure your UI doesn&#8217;t freeze and become useless.</p>
<a name="Inject+JavaScript"></a><h2>Inject JavaScript</h2>
<p>To call or inject JavaScript function from SSH console (remember to escape special characters):<br />
<code class="codecolorer bash default"><span class="bash">NeTVBrowser JavaScript <span style="color: #ff0000;">&quot;console.log('hello console');&quot;</span></span></code><br />
A new JavaScript function can be injected as followed:<br />
<code class="codecolorer bash default"><span class="bash">NeTVBrowser JavaScript <span style="color: #ff0000;">&quot;my_function(); &nbsp;function my_function() { console.log('hello console'); }&quot;</span></span></code></p>
<a name="Screen+rotation"></a><h2>Screen rotation</h2>
<p>By default, NeTV displays in landscape mode.<br />
It can be switched to inverted landscape, portrait and inverted portrait modes by the following command:<br />
<code class="codecolorer bash default"><span class="bash">NeTVBrowser Rotate <span style="color: #000000;">0</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">90</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">180</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">270</span> <span style="color: #666666; font-style: italic;">#pick one of the values</span></span></code><br />
When changing mode, a native browser resize event is triggered. JavaScript code can hook to this event to customize the behaviour.</p>
<a name="Show+debug+traces+%26%23038%3B+JavaScript+output"></a><h2>Show debug traces &#038; JavaScript output</h2>
<p>By default, all console output from NeTVBrowser, including JavaScript print out, are muted.<br />
To re-enable them, NeTVBrowser&#8217;s start up script needs to be modified.<br />
<code class="codecolorer bash default"><span class="bash"><span style="color: #c20cb9; font-weight: bold;">mount</span> <span style="color: #660033;">-o</span> remount,rw <span style="color: #000000; font-weight: bold;">/</span><br />
<span style="color: #c20cb9; font-weight: bold;">vi</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>chumby-netvbrowser</span></code><br />
Replace &#8221;&#8217;NeTVBrowser -qws -nomouse > /dev/null 2>&#038;1 &#038;&#8221;&#8217; with &#8221;&#8217;NeTVBrowser -qws -nomouse &#038;&#8221;&#8217;<br />
<code class="codecolorer bash default"><span class="bash"><span style="color: #c20cb9; font-weight: bold;">mount</span> <span style="color: #660033;">-o</span> remount,ro <span style="color: #000000; font-weight: bold;">/</span></span></code></p>
<a name="Simulate%2FInject+a+keyboard+event"></a><h2>Simulate/Inject a keyboard event</h2>
<p>A keyboard event can be triggered from console as followed:<br />
<code class="codecolorer bash default"><span class="bash">NeTVBrowser Key valid_key_name</span></code><br />
Some commonly used key names are: cpanel,widget,up,down,left,right,enter,center,esc,del,backspace,space &#038; alphanumeric keys.<br />
A full list of supported key names can be seen at the bottom of this [https://github.com/sutajiokousagi/chumby-netvbrowser/blob/master/mainwindow_common.cpp source file]<br />
This was designed only for quick testing from console terminal. It is very efficient for injecting long text string.</p>
<a name="Non-native+keyboard+input"></a><h2>Non-native keyboard input</h2>
<p>By default, buttons on infra-red remote control are override converted to JavaScript function calls on the current tab.<br />
To catch this event, implement a JavaScript function as below in the top level JavaScript document.</p>
<div class="codecolorer-container javascript default codecolorer-noborder" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp;<span style="color: #003366; font-weight: bold;">function</span> fButtonPress<span style="color: #009900;">&#40;</span>vButtonName<span style="color: #339933;">,</span> vCount<span style="color: #339933;">,</span> vOnHold<span style="color: #009900;">&#41;</span><br />
&nbsp;<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #006600; font-style: italic;">//vButtonName: cpanel, widget, up, down, left, right, center, setup</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #006600; font-style: italic;">//vCount: number of keypress within 1.5 second, only applicable to 'setup' button</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #006600; font-style: italic;">//vOnHold: true/false indicates that this is a key-repeat event</span><br />
&nbsp;<span style="color: #009900;">&#125;</span></div></div>
<p>Example code is available in /usr/share/netvserver/docroot/js/NeTV.js -> fButtonPress function</p>
<a name="Native+keyboard+input"></a><h2>Native keyboard input</h2>
<p>Buttons on infra-red remote control are treated as native keyboard keys in NeTV&#8217;s Linux kernel (/dev/input/event1).<br />
However, by default NeTVBrowser overrides key press events in order to handle key counting, key sequence/combo, page scrolling &#038; delivered directly to HTML Control panel as a JavaScript function call.<br />
Example: Hold the control panel button on IR remote for more than 3 seconds &#038; release it will reload/reset the Control Panel.<br />
In order to have the IR buttons events delivered directly to JavaScript as normal keyboard events, use:<br />
<code class="codecolorer bash default"><span class="bash">NeTVBrowser Nativekb on</span></code><br />
The JavaScript in the loaded HTML page will have to handle scrolling &#038; counting of key presses manually.<br />
The above mentioned reset functionality will be lost.<br />
An example of JavaScript code for handling keyboard event (based on jQuery) is available in /usr/share/netvserver/docroot/html_config/js/index.js</p>
<a name="Native+mouse+input"></a><h2>Native mouse input</h2>
<p>If an external mouse is connected to NeTV via USB extension board, NeTVBrowser will initialize its driver at start.<br />
However, by default NeTVBrowser hides mouse cursor.<br />
In order to show the mouse cursors, use:<br />
<code class="codecolorer bash default"><span class="bash">NeTVBrowser MouseCursor on</span></code><br />
NeTV UI was not design to work with mouse. Therefore clicking on the menu items has no effects.<br />
The WiFi configuration was partially made mouse-compatible. To try, go to Setting -> Reconnect to WIFI and turn on mouse cursor.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kosagi.com/blog/the-ui/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WiFi configuration</title>
		<link>http://www.kosagi.com/blog/command-line-wifi-configuration/</link>
		<comments>http://www.kosagi.com/blog/command-line-wifi-configuration/#comments</comments>
		<pubDate>Thu, 12 Jan 2012 05:23:39 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Documentation]]></category>

		<guid isPermaLink="false">http://www.kosagi.com/blog/?p=198</guid>
		<description><![CDATA[If you don&#8217;t have a remote control for your NeTV, or you lost it, you can still configure wifi via command line interface (ssh). Do the following: Plug NeTV into the USB port of your computer wait for NeTV to boot and register as an ethernet device. If this is the first time you&#8217;re plugging [...]]]></description>
				<content:encoded><![CDATA[<p>If you don&#8217;t have a remote control for your NeTV, or you lost it, you can still configure wifi via command line interface (ssh).<br />
<span id="more-198"></span><br />
Do the following:</p>
<ul>
<li>Plug NeTV into the USB port of your computer</li>
<li>wait for NeTV to boot and register as an ethernet device.<br />
If this is the first time you&#8217;re plugging the device in, you&#8217;ll probably have to wait for the NeTV to boot, register as an ethernet device, and then reboot it. The reason is that there is a 10-second window where the startup script checks for a valid ethernet connection to decide if to turn on sshd or not. If you miss the window, even though netv is booted and connected via USB, sshd will not be on.</li>
<li>ssh to 10.0.88.1 as root</li>
<li>from here, you will need to do the following:</li>
</ul>
<div class="codecolorer-container bash default codecolorer-noborder" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp;<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>psp<br />
&nbsp;<span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">&gt;</span> network_config<br />
&nbsp;<span style="color: #000000; font-weight: bold;">&lt;</span>configuration <span style="color: #007800;">allocation</span>=<span style="color: #ff0000;">&quot;dhcp&quot;</span> <span style="color: #007800;">encryption</span>=<span style="color: #ff0000;">&quot;AES&quot;</span> <span style="color: #007800;">auth</span>=<span style="color: #ff0000;">&quot;WPAPSK&quot;</span> <span style="color: #007800;">key</span>=<span style="color: #ff0000;">&quot;foobar&quot;</span> <span style="color: #007800;">ssid</span>=<span style="color: #ff0000;">&quot;yourssid&quot;</span> <span style="color: #007800;">type</span>=<span style="color: #ff0000;">&quot;wlan&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span><br />
&nbsp;^D<br />
&nbsp;<span style="color: #c20cb9; font-weight: bold;">killall</span> hostapd<br />
&nbsp;<span style="color: #c20cb9; font-weight: bold;">killall</span> dnsmasq<br />
&nbsp;<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>NetworkManager restart</div></div>
<p>This should get your device onto the wifi network with the specified SSID and encryption mechanism.</p>
<p>Other example network_config templates:</p>
<div class="codecolorer-container xml default codecolorer-noborder" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">'''open'''<br />
&nbsp;<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;configuration</span> <span style="color: #000066;">allocation</span>=<span style="color: #ff0000;">&quot;dhcp&quot;</span> <span style="color: #000066;">encryption</span>=<span style="color: #ff0000;">&quot;NONE&quot;</span> <span style="color: #000066;">auth</span>=<span style="color: #ff0000;">&quot;OPEN&quot;</span> <span style="color: #000066;">hwaddr</span>=<span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #000066;">ssid</span>=<span style="color: #ff0000;">&quot;ChumbyTest&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;wlan&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
<br />
'''WEP'''<br />
&nbsp;<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;configuration</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">'wlan'</span> <span style="color: #000066;">ssid</span>=<span style="color: #ff0000;">'wepAP'</span> <span style="color: #000066;">allocation</span>=<span style="color: #ff0000;">'dhcp'</span> <span style="color: #000066;">auth</span>=<span style="color: #ff0000;">'WEP'</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">'1234567890'</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">'hex'</span> <span style="color: #000066;">encryption</span>=<span style="color: #ff0000;">'WEPAUTO'</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
<br />
'''WPA2'''<br />
&nbsp;<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;configuration</span> <span style="color: #000066;">allocation</span>=<span style="color: #ff0000;">&quot;dhcp&quot;</span> <span style="color: #000066;">encryption</span>=<span style="color: #ff0000;">&quot;AES&quot;</span> <span style="color: #000066;">auth</span>=<span style="color: #ff0000;">&quot;WPAPSK&quot;</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">&quot;foobar&quot;</span> <span style="color: #000066;">ssid</span>=<span style="color: #ff0000;">&quot;yourssid&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;wlan&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></div></div>
]]></content:encoded>
			<wfw:commentRss>http://www.kosagi.com/blog/command-line-wifi-configuration/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>AMI Instance</title>
		<link>http://www.kosagi.com/blog/ami-instance/</link>
		<comments>http://www.kosagi.com/blog/ami-instance/#comments</comments>
		<pubDate>Thu, 05 Jan 2012 02:30:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Documentation]]></category>

		<guid isPermaLink="false">http://www.kosagi.com/blog/?p=176</guid>
		<description><![CDATA[Introduction What is AMI Instance? The Amazon AMI is a preconfigured machine image that can be used for developing on the chumby NeTV board. It comes with a copy of the chumby build system and source code, as well as a precompiled image suitable for burning directly onto an SD card. The public AMI ID [...]]]></description>
				<content:encoded><![CDATA[<a name="Introduction"></a><h2>Introduction</h2>
<a name="What+is+AMI+Instance%3F"></a><h3>What is AMI Instance?</h3>
<p>The Amazon AMI is a preconfigured machine image that can be used for developing on the chumby NeTV board.  It comes with a copy of the chumby build system and source code, as well as a precompiled image suitable for burning directly onto an SD card.<br />
<span id="more-176"></span><br />
The public AMI ID is <del>ami-e68ff4b4</del> ami-c0b3f692 (v1.3 now points to github for source), and it is bound to the Asia-Pacific (Singapore) region. For instructions on how to start an AMI, please see <a href="http://www.kosagi.com/blog/quickstart-oe/">Quickstarting OE</a> for a step-by-step howto. Please note that in order to access the more advanced features such as buildbot and gitweb, you will need to also add port 80 to the security group.</p>
<a name="Screenshots"></a><h3>Screenshots</h3>
<p>Here are some screenshots of the NeTV AMI in action.<br />

<a href='http://www.kosagi.com/blog/ami-instance/output/' title='Output View'><img width="150" height="150" src="http://www.kosagi.com/blog/wp-content/uploads/2012/01/output-150x150.png" class="attachment-thumbnail" alt="Output View" /></a>
<a href='http://www.kosagi.com/blog/ami-instance/cgit/' title='Cgit View'><img width="150" height="150" src="http://www.kosagi.com/blog/wp-content/uploads/2012/01/cgit-150x150.png" class="attachment-thumbnail" alt="Cgit View" /></a>
<a href='http://www.kosagi.com/blog/ami-instance/waterfall/' title='Waterfall View'><img width="150" height="150" src="http://www.kosagi.com/blog/wp-content/uploads/2012/01/waterfall-150x150.png" class="attachment-thumbnail" alt="Waterfall View" /></a>
</p>
<a name="Getting+started"></a><h3>Getting started</h3>
<p>To get started, log onto the instance as the &#8220;ubuntu&#8221; user.  Then switch to building image for chumby-silvermoon-netv, and build the chumby-image:</p>
<div class="codecolorer-container bash default codecolorer-noborder" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp;<span style="color: #7a0874; font-weight: bold;">cd</span> chumby-oe<br />
&nbsp;<span style="color: #7a0874; font-weight: bold;">source</span> setup-chumby.sh <span style="color: #666666; font-style: italic;"># Pick option 5 here</span><br />
&nbsp;bitbake chumby-image</div></div>
<p>Then, download the resulting ROM image by using your web browser to go to /output/ on your instance.  For example, http://169.254.169.254/output/.  Click on &#8220;images&#8221;, then on &#8220;chumby-silvermoon-netv&#8221;, then download &#8220;rom-chumby-silvermoon-netv-chumby-image.img.gz&#8221;.</p>
<a name="Development+Flows"></a><h3>Development Flows</h3>
<p>The system comes configured to support several development flows, including command line and GUI-assisted flows.<br />
Here are a couple of suggested flows:<br />
&#8221;&#8217;Local editing and building&#8221;&#8217;<br />
# ssh into the AMI<br />
# edit code locally on the AMI<br />
# initiate bitbake manually (e.g. bitbake chumby-image)<br />
# (first time only) copy ROM image from server and dd onto a microSD card<br />
# (successive builds, assuming network connectivity) use opkg update; opkg upgrade to grab the latest build and install on your local test machine</p>
<p>&#8221;&#8217;Remote editing and building&#8221;&#8217;<br />
# check out git repo from the AMI using ssh (git clone <a href="">ssh://ubuntu</a>@instance-address:chumby-oe/meta-chumby/.git)<br />
# edit code locally, and do a git push<br />
# buildbot will pick up the push and within a few minutes automatically kick off a build, or you can use the UI on the webpage to manually start a build<br />
# (first time only) navigate to the web directory on the server and copy the file locally, and burn to SD card<br />
# (successive builds, assuming network connectivity) use opkg update; opkg upgrade to grab the latest build and install on your local test machine</p>
<a name="Burning+images+to+disk"></a><h3>Burning images to disk</h3>
<p>To burn a ROM image to disk, you&#8217;ll first need to uncompress it.  Usually you can just double-click on the .gz file.  Once you have an uncompressed .img file, you&#8217;ll need to write it to a micro-SD card.  Place the card into a USB reader, and insert the card into your computer.</p>
<p>The instructions for writing a .img file to an SD card is described in detail at the [https://help.ubuntu.com/community/Installation/FromImgFiles Ubuntu IMG-install page].</p>
<p>Once the card has been burned, insert it into the NeTV and turn it on.  The<br />
blue light should begin flashing, which indicates the FPGA firmware has been<br />
loaded and the device is booting.</p>
<p>If the light doesn&#8217;t come on, then the image didn&#8217;t work.  Possible causes are:<br />
* Dirty contacts.  The SD card is very sensitive to dirt and grease.  Wipe off the contacts with a cloth and try the card again.<br />
* Card not inserted correctly.  The door should not be able to open on its own, even when the board is turned upside-down.<br />
* ROM file not uncompressed.  You must un-gzip the file before burning it.<br />
* ROM file copied, not burned.  You must burn the ROM file to the card, not copy it using e.g. Windows file explorer.  If you can add files to the SD card in either Windows or Mac, then the card has not been burned properly.</p>
<a name="Git"></a><h2>Git</h2>
<p>All chumby code used in this AMI instance comes from git.  Because git is a distributed version control system, you can make changes and commit code, and still track the main trunk.  This allows you to make changes and submit patches without having to set up your own server.</p>
<a name="Basics"></a><h3>Basics</h3>
<p>Before you check in any changes, you should set up your git username and email address.  This allows you to mail patches around and still be given credit for fixes and feature additions.  Run these commands inside the instance to personalize your settings:</p>
<div class="codecolorer-container bash default codecolorer-noborder" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp;<span style="color: #c20cb9; font-weight: bold;">git config</span> <span style="color: #660033;">--global</span> user.name <span style="color: #ff0000;">&quot;Firstname Lastname&quot;</span><br />
&nbsp;<span style="color: #c20cb9; font-weight: bold;">git config</span> <span style="color: #660033;">--global</span> user.email <span style="color: #ff0000;">&quot;your_email@youremail.com&quot;</span></div></div>
<p>To update a repository from the remote copy, run &#8220;git pull&#8221;.  To mark files as having changed, or to add new files to git, run &#8220;git add [filename]&#8220;.  To remove files, run &#8220;git rm [filename]&#8220;.  To commit a series of added/changed/removed files, run &#8220;git commit&#8221;.</p>
<a name="chumby-oe"></a><h3>chumby-oe</h3>
<p>There are three primary git repositories you will encounter while building images:<br />
* chumby-oe &#8211; Contains setup scripts and the bitbake program<br />
* openembedded &#8211; A mirror of the openembedded monolithic project<br />
* meta-chumby &#8211; An overlay on top of openembedded that implements chumby code</p>
<p>Most development will take place under meta-chumby.  You can sync your copy of the code by running &#8220;git pull&#8221; in each<br />
of the directories.</p>
<a name="Local+mirrors"></a><h3>Local mirrors</h3>
<p>In order to make development easier, local mirrors of the kernel and u-boot have been made.  They are located under ~/git/.  New recipes have been added under meta-chumby that cause locally-built images to look in this directory for source code rather than going to chumby&#8217;s git repo.</p>
<p>You can make and commit changes in the mirrored repos and still pull changes from master.  To submit a patch, use the &#8220;git format-patch&#8221; command.</p>
<a name="Cgit"></a><h3>Cgit</h3>
<p>You can use the web-based git interface by going to /cgit/cgit.cgi on your EC2 instance&#8217;s web server.  Checked-in changes are automatically displayed here.  CGit is configured by editing the file /etc/cgitrc.  Pages are cached in the directory /var/cache/cgit/, so if you update the config file you&#8217;ll need to clear the cache by removing the contents of /var/cache/cgit/.</p>
<a name="Openembedded"></a><h2>Openembedded</h2>
<a name="Overview"></a><h3>Overview</h3>
<p>The build system is based on openembedded, which uses the **bitbake** tool to assemble packages that are described by **recipes**.  The bitbake command uses recipes to determine how to compile and package software, as well as to build bootable images for various devices.</p>
<p>A recipe is a series of steps that are executed in order to fetch source, unpack source, configure, build, and install the package(s), and then distribute the resulting packages.  Recipes are defined in files that end in .bb, and are located in subdirectories under the recipes/ directory.  Each step is a shell script by default, unless explicitly defined as a python step.</p>
<p>Many steps are inherited automatically from chumby-oe/openembedded/classes/base.bbclass, and you can override any steps by explicitly specifying them in your recipe file.  You can inherit additional classes such as &#8220;qt4e&#8221; that will give you a pre-defined set of steps to draw from by adding &#8220;inherit qt4e&#8221; at the top of your recipe.</p>
<p>A package name (PN) is defined as the portion of a .bb filename before the underscore (_).  A package version (PV) is the portion after the underscore.  Thus, the PN for meta-chumby/recipes/netv-utils_0.bb is &#8220;netv-utils&#8221;, and the PV is 0.  Unless told otherwise, bitbake will always use the package with the highest PV.</p>
<a name="meta-chumby+Overlay"></a><h3>meta-chumby Overlay</h3>
<p>There is a chumby &#8220;overlay&#8221; on top of a minimally-modified openembedded tree that adds chumby-specific machine definitions and recipes.  If there are identically-named packages in both openembedded and meta-chumby, the package from meta-chumby will take precedence.  Additionally, the configuration file inside meta-chumby inherits the &#8220;amend&#8221; bbclass, which allows for meta-chumby to provide additional steps and patches to recipes in the openembedded directory.</p>
<p>In this way, meta-chumby modifies openembedded, allowing for it to work better with chumby devices.  If possible, avoid modifying files in the openembedded directory, and instead modify/add files to the meta-chumby directory.</p>
<a name="Packages"></a><h3>Packages</h3>
<p>A package is a combination of files and meta-data such as platform, dependencies, and install scripts.  A single recipe will usually build four packages, but can end up building any number of packages.  The four packages that will get built by default are:</p>
<p>* Application package.  Has the same package name (PN) as the recipe.<br />
* Debug package.  Named PN-dbg.  Contains debugging symbols for the binaries in the application package.<br />
* Development package.  Named PN-dev.  Usually empty.  Contains static libraries and headers useful for compilers.<br />
* Documentation package.  Named PN-doc.  Contains manpages, info pages, and any other documentation.</p>
<p>To install a package, copy it over to the device through scp, then install it:</p>
<div class="codecolorer-container bash default codecolorer-noborder" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp;<span style="color: #c20cb9; font-weight: bold;">mount</span> -oremount,rw <span style="color: #000000; font-weight: bold;">/</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;"># Remount / as read-write</span><br />
&nbsp;opkg <span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>package-name<span style="color: #7a0874; font-weight: bold;">&#93;</span>.ipk &nbsp;<span style="color: #666666; font-style: italic;"># Install the package</span></div></div>
<p>To remove a package, specify only the PN:</p>
<div class="codecolorer-container bash default codecolorer-noborder" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp;opkg remove <span style="color: #7a0874; font-weight: bold;">&#91;</span>package-name<span style="color: #7a0874; font-weight: bold;">&#93;</span></div></div>
<a name="Working+with+software"></a><h2>Working with software</h2>
<a name="A+hello-world+Package"></a><h3>A hello-world Package</h3>
<p>There is a &#8220;hello world&#8221; recipe that creates a package containing an executable that simply prints the canonical &#8220;Hello, world!&#8221; message.  It is located under meta-chumby/recipes/examples/hello-world_1.0.bb, and the source code is located under meta-chumby/recipes/examples/hello-world/.</p>
<p>To build the hello-world program, run &#8220;bitbake hello-world&#8221;.  This will cause openembedded to parse the .bb file, run each step in turn, and then generate a package.  You can find the resulting .ipk in ~/chumby-oe/output-angstrom-.9/deploy/eglibc/ipk/armv5te/ and it will be called hello-world_1.0-r1.9_armv5te.ipk.</p>
<p>If you run &#8220;bitbake hello-world&#8221; again, nothing will happen.  This is because the package has been marked as &#8220;already built&#8221;.  You have two options for forcing the package to get rebuilt:</p>
<p>* Run &#8220;bitbake -c clean hello-world; bitbake hello-world&#8221; to clean the package, then rebuild it<br />
* Edit hello_world-1.0.bb and change the PR variable from &#8220;r1&#8243; to &#8220;r2&#8243;</p>
<p>The last option is called &#8220;bumping the PR&#8221;, and is required if you share your changes.  If you change any source the package relies on, or if you modify the recipe in any way, you should bump the PR prior to checking the changes in.  That way, anyone who checks out your code will be forced to rebuild the package, and will get the new version.</p>
<a name="Modifying+the+kernel"></a><h3>Modifying the kernel</h3>
<p>In order to make kernel development easier, a local mirror of the chumby kernel has been made.  You can view and edit the source in the ~/ubuntu/git/linux-2.6.28-silvermoon directory.  Since it is a read-only git repo, you can pull from trunk and commit changes, but not push patches.  Any patches you make can be submitted upstream using the &#8220;git format-patch&#8221; command, and then emailing the resulting files.</p>
<p>The kernel configuration used in bitbake is stored in ~/chumby-oe/meta-chumby/recipes/linux/linux-silvermoon-netv/defconfig.  You will need to copy this before making any kernel changes.</p>
<p>You have several options for building the test kernel.  Perhaps the easiest method is to use the build scripts from bitbake.  You can manually run the do_compile script:</p>
<div class="codecolorer-container bash default codecolorer-noborder" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp;<span style="color: #7a0874; font-weight: bold;">cd</span> ~<span style="color: #000000; font-weight: bold;">/</span>git<span style="color: #000000; font-weight: bold;">/</span>linux-2.6.28-silvermoon<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span><br />
&nbsp;<span style="color: #c20cb9; font-weight: bold;">cp</span> ~<span style="color: #000000; font-weight: bold;">/</span>chumby-oe<span style="color: #000000; font-weight: bold;">/</span>meta-chumby<span style="color: #000000; font-weight: bold;">/</span>recipes<span style="color: #000000; font-weight: bold;">/</span>linux<span style="color: #000000; font-weight: bold;">/</span>linux-silvermoon-netv<span style="color: #000000; font-weight: bold;">/</span>defconfig ~<span style="color: #000000; font-weight: bold;">/</span>git<span style="color: #000000; font-weight: bold;">/</span>linux-2.6.28-silvermoon<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>.config<br />
&nbsp;~<span style="color: #000000; font-weight: bold;">/</span>chumby-oe<span style="color: #000000; font-weight: bold;">/</span>output-angstrom-.9<span style="color: #000000; font-weight: bold;">/</span>work<span style="color: #000000; font-weight: bold;">/</span>chumby-silvermoon-netv-angstrom-linux-gnueabi<span style="color: #000000; font-weight: bold;">/</span>linux-silvermoon-netv-2.6.28.local-r29<span style="color: #000000; font-weight: bold;">/</span>temp<span style="color: #000000; font-weight: bold;">/</span>run.do_compile.<span style="color: #000000; font-weight: bold;">*</span></div></div>
<p>The kernel itself will get compiled and the output image will be placed in arch/arm/boot/zImage.  Copy this image to your running NeTV board and install it there by connecting through SSH and running:</p>
<div class="codecolorer-container bash default codecolorer-noborder" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp;config_util <span style="color: #660033;">--cmd</span>=putblock <span style="color: #660033;">--block</span>=krnA <span style="color: #000000; font-weight: bold;">&lt;</span> ~<span style="color: #000000; font-weight: bold;">/</span>zImage</div></div>
<p>You will need to reboot to try out the new kernel.</p>
<p>When you are satisfied with your changes, add them to git:</p>
<div class="codecolorer-container bash default codecolorer-noborder" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp;<span style="color: #c20cb9; font-weight: bold;">git commit</span> <span style="color: #660033;">-a</span></div></div>
<p>Bump the PR in ~/chumby-oe/meta-chumby/recipes/linux/linux-silvermoon-netv_2.6.28.local.bb and rebuild the kernel package:</p>
<div class="codecolorer-container bash default codecolorer-noborder" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp;bitbake virtual<span style="color: #000000; font-weight: bold;">/</span>kernel</div></div>
<a name="Changing+kernel+config"></a><h4>Changing kernel config</h4>
<p>You will first need to install ncurses-dev, in order to be able to use the graphical kernel configuration screen:</p>
<div class="codecolorer-container bash default codecolorer-noborder" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp;<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get install</span> ncurses-dev</div></div>
<p>The kernel config used in the chumby distribution is located under meta-chumby.  To restore the default kernel config, copy it from meta-chumby to the kernel src directory:</p>
<div class="codecolorer-container bash default codecolorer-noborder" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp;<span style="color: #c20cb9; font-weight: bold;">cp</span> ~<span style="color: #000000; font-weight: bold;">/</span>chumby-oe<span style="color: #000000; font-weight: bold;">/</span>meta-chumby<span style="color: #000000; font-weight: bold;">/</span>recipes<span style="color: #000000; font-weight: bold;">/</span>linux<span style="color: #000000; font-weight: bold;">/</span>linux-silvermoon-netv<span style="color: #000000; font-weight: bold;">/</span>defconfig ~<span style="color: #000000; font-weight: bold;">/</span>git<span style="color: #000000; font-weight: bold;">/</span>linux-2.6.28-silvermoon<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>.config</div></div>
<p>To change kernel config, change to ~/git/linux-2.6.28-silvermoon/src/ and run &#8220;make ARCH=arm menuconfig&#8221;.  Make any changes you like.  When you&#8217;re satisfied with your changes, save and exit the editor.  To add the changes to the build system, run the following:</p>
<div class="codecolorer-container bash default codecolorer-noborder" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp;<span style="color: #c20cb9; font-weight: bold;">cp</span> ~<span style="color: #000000; font-weight: bold;">/</span>git<span style="color: #000000; font-weight: bold;">/</span>linux-2.6.28-silvermoon<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>.config ~<span style="color: #000000; font-weight: bold;">/</span>chumby-oe<span style="color: #000000; font-weight: bold;">/</span>meta-chumby<span style="color: #000000; font-weight: bold;">/</span>recipes<span style="color: #000000; font-weight: bold;">/</span>linux<span style="color: #000000; font-weight: bold;">/</span>linux-silvermoon-netv<span style="color: #000000; font-weight: bold;">/</span>defconfig<br />
<span style="color: #7a0874; font-weight: bold;">&#91;</span>ccwb_bash<span style="color: #7a0874; font-weight: bold;">&#93;</span><br />
<br />
Then bump the kernel PR and rebuild virtual<span style="color: #000000; font-weight: bold;">/</span>kernel.<br />
<br />
<span style="color: #000000; font-weight: bold;">&lt;</span>h4<span style="color: #000000; font-weight: bold;">&gt;</span>Compiling kernel modules<span style="color: #000000; font-weight: bold;">&lt;/</span>h4<span style="color: #000000; font-weight: bold;">&gt;</span><br />
<br />
To compile the kernel modules, <span style="color: #c20cb9; font-weight: bold;">make</span> sure you have already run the <span style="color: #ff0000;">&quot;do_compile&quot;</span> step, <span style="color: #000000; font-weight: bold;">then</span> run the <span style="color: #ff0000;">&quot;do_compile_kernelmodules&quot;</span> step:<br />
<span style="color: #7a0874; font-weight: bold;">&#91;</span>ccwb_bash<span style="color: #7a0874; font-weight: bold;">&#93;</span><br />
&nbsp;~<span style="color: #000000; font-weight: bold;">/</span>chumby-oe<span style="color: #000000; font-weight: bold;">/</span>output-angstrom-.9<span style="color: #000000; font-weight: bold;">/</span>work<span style="color: #000000; font-weight: bold;">/</span>chumby-silvermoon-netv-angstrom-linux-gnueabi<span style="color: #000000; font-weight: bold;">/</span>linux-silvermoon-netv-2.6.28.local-r29<span style="color: #000000; font-weight: bold;">/</span>temp<span style="color: #000000; font-weight: bold;">/</span>run.do_compile.<span style="color: #000000; font-weight: bold;">*</span><br />
&nbsp;~<span style="color: #000000; font-weight: bold;">/</span>chumby-oe<span style="color: #000000; font-weight: bold;">/</span>output-angstrom-.9<span style="color: #000000; font-weight: bold;">/</span>work<span style="color: #000000; font-weight: bold;">/</span>chumby-silvermoon-netv-angstrom-linux-gnueabi<span style="color: #000000; font-weight: bold;">/</span>linux-silvermoon-netv-2.6.28.local-r29<span style="color: #000000; font-weight: bold;">/</span>temp<span style="color: #000000; font-weight: bold;">/</span>run.do_compile_kernelmodules.<span style="color: #000000; font-weight: bold;">*</span></div></div>
<p>If you get errors such as &#8220;ERROR: &#8220;kmalloc_caches&#8221; [sound/usb/snd-usb-lib.ko] undefined!&#8221;, then you will need to re-run the do_compile step before running the do_compile_kernelmodules step.</p>
<a name="Modifying+the+bootloader"></a><h3>Modifying the bootloader</h3>
<p>The bootloader can be modified using the same process as the kernel.  Like the kernel, an additional bootloader recipe has been added that takes precedence over the stock u-boot recipe, and pulls from the git repository located at /home/ubuntu/git/u-boot-2009.07-silvermoon/.  When you want to make changes and want to force a rebuild, bump the PR in chumby-oe/meta-chumby/recipes/u-boot/u-boot-silvermoon_local.bb and rebuild the bootloader:</p>
<div class="codecolorer-container bash default codecolorer-noborder" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp;bitbake virtual<span style="color: #000000; font-weight: bold;">/</span>bootloader</div></div>
<a name="Buildbot"></a><h2>Buildbot</h2>
<p>There is a copy of buildbot running on the system.  Any time you check in changes to meta-chumby, openembedded, or chumby-oe, a five-minute timer starts.  If no more changes are checked in after five minutes, it automatically runs &#8220;bitbake chumby-image&#8221; to generate a new compressed rom image.</p>
<p>There is a second buildbot factory called netv-trunk, which automatically pulls the latest code from chumby&#8217;s master git repository.  This is separate from any development you do on the EC2 instance, and exists to demonstrate the ability to build a stock chumby firmware.  It will never automatically trigger.</p>
<p>oth builders have openembedded trees separate from ~/chumby-oe/.  They reside in ~/buildslave/(netv|netv-trunk)/work/ and have their own output directories.  You should avoid doing developent in these directories unless you&#8217;re trying to troubleshoot build system failures.</p>
<a name="Accessing"></a><h3>Accessing</h3>
<p>You can monitor build progress by going to /waterfall on your build machine&#8217;s web server.  When the build has completed, you can download the automatically-built images by navigating to /output-buildbot/ on the web server.  This is separate from builds you make on the command line, which can be accessed by going to /output/.</p>
<p>To start a build, navigate to /builders/netv and click &#8220;Force Build&#8221;.</p>
<a name="Modifying"></a><h3>Modifying</h3>
<p>Nearly all of the configuration takes place on the build master.  The configuration file is stored in ~/buildbot/master.cfg.  It is a python script.  It is documented at the [http://buildbot.net/buildbot/docs/0.8.4p2/full.html buildbot documentation] page.</p>
<p>Whenever you change the configuration file, be sure run a syntax check by running:</p>
<div class="codecolorer-container bash default codecolorer-noborder" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp;buildbot checkconfig ~<span style="color: #000000; font-weight: bold;">/</span>buildbot<span style="color: #000000; font-weight: bold;">/</span></div></div>
<p>To apply the config, restart buildbot:</p>
<div class="codecolorer-container bash default codecolorer-noborder" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp;buildbot stop ~<span style="color: #000000; font-weight: bold;">/</span>buildbot<span style="color: #000000; font-weight: bold;">/</span><br />
&nbsp;buildbot start ~<span style="color: #000000; font-weight: bold;">/</span>buildbot<span style="color: #000000; font-weight: bold;">/</span></div></div>
<a name="The+patch"></a><h3>The patch</h3>
<p>A patch was made to the buildbot source in order to support multiple git repos.  Without the patch, the automated builder would pull the wrong branch.  It is unclear whether this change will be accepted to buildbot trunk, but be aware of it if you decide to upgrade the installed copy of buildbot:</p>
<div class="codecolorer-container bash default codecolorer-noborder" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp;<span style="color: #c20cb9; font-weight: bold;">diff</span> <span style="color: #660033;">-ur</span> buildbot-0.8.4p2-stock<span style="color: #000000; font-weight: bold;">/</span>buildbot<span style="color: #000000; font-weight: bold;">/</span>steps<span style="color: #000000; font-weight: bold;">/</span>source.py<br />
&nbsp;buildbot-0.8.4p2<span style="color: #000000; font-weight: bold;">/</span>buildbot<span style="color: #000000; font-weight: bold;">/</span>steps<span style="color: #000000; font-weight: bold;">/</span>source.py<br />
&nbsp;<span style="color: #660033;">---</span> buildbot-0.8.4p2-stock<span style="color: #000000; font-weight: bold;">/</span>buildbot<span style="color: #000000; font-weight: bold;">/</span>steps<span style="color: #000000; font-weight: bold;">/</span>source.py &nbsp; &nbsp; <span style="color: #000000;">2011</span>-07-<span style="color: #000000;">17</span><br />
&nbsp;<span style="color: #000000;">12</span>:<span style="color: #000000;">49</span>:<span style="color: #000000;">06.000000000</span> +0800<br />
&nbsp;+++ buildbot-0.8.4p2<span style="color: #000000; font-weight: bold;">/</span>buildbot<span style="color: #000000; font-weight: bold;">/</span>steps<span style="color: #000000; font-weight: bold;">/</span>source.py &nbsp; <span style="color: #000000;">2011</span>-07-<span style="color: #000000;">29</span><br />
&nbsp;06:<span style="color: #000000;">49</span>:<span style="color: #000000;">53.000000000</span> +0800<br />
&nbsp;<span style="color: #000000; font-weight: bold;">@@</span> -<span style="color: #000000;">228</span>,<span style="color: #000000;">7</span> +<span style="color: #000000;">228</span>,<span style="color: #000000;">7</span> <span style="color: #000000; font-weight: bold;">@@</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #666666; font-style: italic;"># what source stamp would this build like to use?</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;s = self.build.getSourceStamp<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #666666; font-style: italic;"># if branch is None, then use the Step's &quot;default&quot; branch</span><br />
&nbsp;- &nbsp; &nbsp; &nbsp; &nbsp;branch = s.branch or self.branch<br />
&nbsp;+ &nbsp; &nbsp; &nbsp; &nbsp;branch = self.branch or s.branch<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #666666; font-style: italic;"># if revision is None, use the latest sources (-rHEAD)</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;revision = s.revision<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">if</span> not revision and not self.alwaysUseLatest:</div></div>
<a name="Advanced"></a><h2>Advanced</h2>
<a name="Creating+images"></a><h3>Creating images</h3>
<p>An image recipe is defined as a recipe that inherits from image.bbclass.  When built, an image will create a burnable ROM file that you can uncompress and write directly to an SD card.  The starter image recipe is located in ~/chumby-oe/meta-chumby/recipes/images/chumby-starter-image.bb.  A full chumby image, including the control panel and browser code, may be found in ~/chumby-oe/meta-chumby/recipes/images/chumby-image.bb.  Other images can be found under ~/chumby-ie/openembedded/recipes/images/.  Some of these image recipes won&#8217;t build due to missing dependencies such as OpenGL acceleration, which aren&#8217;t available on this particular platform.</p>
<p>To create your own image, copy &#8220;chumby-starter-image.bb&#8221; to another file, say &#8220;my-starter-image.bb&#8221;.  Then, add files to the &#8220;IMAGE_INSTALL&#8221; and the &#8220;DEPENDS&#8221; variables.  If you don&#8217;t add the package name to DEPENDS, then it might not get built.  On the other hand, if you don&#8217;t add the package to IMAGE_INSTALL, then it won&#8217;t get included in the image.</p>
<a name="Package+repositories"></a><h3>Package repositories</h3>
<p>When you build an image, bitbake looks at the environment variable &#8220;FEED_DEPLOYDIR_BASE_URI&#8221;.  If set, it instructs the resulting image to look to that URL to find packages.  If not, it will look up your hostname during the buld process by consulting <a href="http://ifconfig.me/host">http://ifconfig.me/host</a>, and set the URL to &#8220;<a href="http://hostname/">http://hostname/</a>${FEED_DEPLOYDIR_PATH}&#8221;.  If FEED_DEPLOYDIR_PATH is not defined, it defaults to /build/localhost/LATEST.  The setup-chumby.sh sets it to /output/ipk/, so the defaults should be okay.</p>
<p>The NeTV device will consult this URL if it needs to install packages.  To install packages, mount the root filesystem as read-write, update the list of packages, and install the package.  For example, to install &#8220;hello-world&#8221;, run:</p>
<div class="codecolorer-container bash default codecolorer-noborder" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp;<span style="color: #c20cb9; font-weight: bold;">mount</span> -oremount,rw <span style="color: #000000; font-weight: bold;">/</span> &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;"># Allow the root filesystem to be modified</span><br />
&nbsp;opkg update &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #666666; font-style: italic;"># Update the list of available packages</span><br />
&nbsp;opkg <span style="color: #c20cb9; font-weight: bold;">install</span> hello-world &nbsp; <span style="color: #666666; font-style: italic;"># Fetch and install hello-world package</span></div></div>
<p>The opkg command will examine the list of dependencies and install any required packages.</p>
<a name="Running+programs+at+startup"></a><h3>Running programs at startup</h3>
<p>The system uses a Sys-V startup style.  That means scripts are placed under /etc/init.d/ that accept &#8220;start&#8221;, &#8220;stop&#8221;, and &#8220;restart&#8221; arguments.  The system boots and runs every script in /etc/rc5.d/ alphabetically, and allows you to log on only after all the scripts have run.</p>
<p>There is an example recipe located in meta-chumby/recipes/examples/ called init_example-1.0.bb that uses the update-rc.d class to install a startup/shutdown script.  It installs a simple daemon that basically does nothing but stay running.</p>
<p>Build the package by running &#8220;bitbake init-example&#8221;, and then install it on your device.  As part of the package installation, the package will be added to /etc/rc5.d/ and the startup script will be called as &#8220;/etc/init.d/init-example-script start&#8221;.  When the system starts up in the future, the script will be called automatically.</p>
<p>If you remove the package, opkg will call &#8220;/etc/init.d/init-example-script stop&#8221; immediately prior to removing the package.  If you bump the package&#8217;s PR, and rebuild it, and then reinstall it, opkg will call &#8220;/etc/init.d/init-example-script restart&#8221;.</p>
<a name="Postinstall+scripts"></a><h3>Postinstall scripts</h3>
<p>Packages can run scripts after being installed.  For example, this is used by the bootloader recipe to load a new copy of the bootloader to the config block when it is installed.</p>
<p>The basic template of a postinstall script is:</p>
<div class="codecolorer-container bash default codecolorer-noborder" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp;pkg_postinst_<span style="color: #800000;">${PN}</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #666666; font-style: italic;"># Your shell script here</span><br />
&nbsp;<span style="color: #7a0874; font-weight: bold;">&#125;</span></div></div>
<p>The postinst script will get run as part of the do_rootfs when you bitbake an image.  If the script fails, or if you copy the package directly to the device, it will be run when it&#8217;s installed.  In order to force a package to get run on the device and not during do_rootfs, add this to the top of your postinst script:</p>
<div class="codecolorer-container bash default codecolorer-noborder" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp;<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #ff0000;">&quot;x<span style="color: #007800;">$D</span>&quot;</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #ff0000;">&quot;x&quot;</span>; <span style="color: #000000; font-weight: bold;">then</span> <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>; <span style="color: #000000; font-weight: bold;">fi</span> &nbsp;<span style="color: #666666; font-style: italic;"># Don't do postinst on build system</span></div></div>
<a name="Debugging+binary+programs"></a><h3>Debugging binary programs</h3>
<p>All packages are built with debugging symbols included, all of which are stripped as part of the do_package step.  Each binary in your package will have its symbols placed in a -dbg package.  For example, the &#8220;regutil&#8221; recipe creates a regutil package, as well as a regutil-dbg package.</p>
<p>In order to use these symbols, you must first install the &#8220;gdb&#8221; package.  Either add gdb to a custom image, or run &#8220;mount -oremount,rw /; opkg install gdb&#8221;.  If you try to install regutil-dbg, it will try to pull in all of the symbols for eglibc, so install the debug symbols package by running &#8220;opkg install -nodeps regutil-dbg&#8221;.</p>
<p>You can now launch regutil under gdb and step code by typing &#8220;gdb regutil&#8221;.  Alternately, you can attach to a running instance of regutil by figuring out its process id and running &#8220;gdb regutil
<process-id>&#8220;.  When you end a debugging session attached this way, the program will continue running.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kosagi.com/blog/ami-instance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quickstart OE</title>
		<link>http://www.kosagi.com/blog/quickstart-oe/</link>
		<comments>http://www.kosagi.com/blog/quickstart-oe/#comments</comments>
		<pubDate>Wed, 04 Jan 2012 18:30:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Documentation]]></category>

		<guid isPermaLink="false">http://www.kosagi.com/blog/?p=294</guid>
		<description><![CDATA[Background Amazon offers pay-as-you-use cloud servers. You can attach disks to virtual machines just like you would a physical machine. Disk images can be shared between users, and they are identified by a code known as an &#8220;AMI&#8221; (Amazon Machine Image). Chumby has pre-built an OE image, so that all of the packages are resident [...]]]></description>
				<content:encoded><![CDATA[<a name="Background"></a><h2>Background</h2>
<p>Amazon offers pay-as-you-use cloud servers. You can attach disks to virtual machines just like you would a physical machine. Disk images can be shared between users, and they are identified by a code known as an &#8220;AMI&#8221; (Amazon Machine Image).</p>
<p>Chumby has pre-built an OE image, so that all of the packages are resident and built, thus allowing you to get started on developing your application right away, without having to spend hours configuring and downloading the source code for the entire universe. You can use these AMIs as a starting point for development; and if you mess up, you can always restart the instance from a fresh image again (but back up your changes before you do that!). </p>
<p>Amazon offers several tiers of machines, with varying prices (<a href="http://aws.amazon.com/ec2/pricing/">http://aws.amazon.com/ec2/pricing/</a>). We recommend using a &#8220;medium high-CPU&#8221; or &#8220;small&#8221; instance type, which cost $0.17 and $0.085 per hour, respectively (pricing as of April 2011). Building is a very CPU and memory-intensive task, and on a &#8220;medium high-CPU&#8221; instance, a full build from clean takes 6 hours to complete. </p>
<p>Amazon also offers a free &#8220;micro&#8221; tier, but there are a number of restrictions on it, including a very tight 600 MB RAM limit, and a 10 GB EBS disk limit. Open embedded barely fits in a 10GB EBS volume, and in fact will not build from clean in 600 MB of RAM. However, we offer the pre-built image for micro tiers for users who just want to evaluate the solution to see if this is something they want to pay for. On a micro tier you can build a couple small packages and re-create images, sufficient for a quick hack or evaluation, but we do not recommend doing serious development on a micro instance. </p>
<p>&#8221;&#8217;Note&#8221;&#8217;: &#8220;free&#8221; micro images have limits on the amount of disk operations and bandwidth you can use before you are automatically charged, and there is no warning for when billing starts. On the other hand, most charges are on the order of pennies per quanta, so you are unlikely to run up a big bill during evaluation.</p>
<p>If you want to build your own OE image entirely from scratch, please see <a href="http://www.kosagi.com/blog/building-openembedded/">Building OpenEmbedded</a> for instructions on how to do that.</p>
<p>&#8221;Warning&#8221;: something that is not obvious is that if you use an &#8220;instance&#8221; store (/mnt by default), all data on that disk is lost when you reboot the instance. Instance stores are fast and free for access, but ephemeral and unreliable. EBS, which is the mechanism we use to distribute the OE image (mounted on &#8220;/&#8221; in our instance), is a reliable, permanent medium that is slower, archiveable and costs money to access, but at least you don&#8217;t lose the data when you reboot.<br />
<span id="more-294"></span></p>
<a name="AMI+numbers"></a><h3>AMI numbers</h3>
<p>The AMI for an EBS image with 30GB of space (enough to build a large number of packages, but not eligible for the free tier) is &#8221;&#8217;ami-840871d6&#8221;&#8217;.</p>
<p>The AMI for an EBS image with 10GB of space (eligible for free tier but not a lot of space to build) is &#8221;&#8217;ami-ee176ebc&#8221;&#8217;. NOTE: AWS has notified us that we needed to remove the SSH keys on the image to prevent a security breach, so a new AMI should be used: &#8221;&#8217;ami-062c5454&#8221;&#8217;. </p>
<p>The AMI for an EBS image with 50GB and a very complete, pre-built NeTV image with buildbot and gitweb pre-installed is &#8221;&#8217;ami-c0b3f692&#8221;&#8217;. We strongly recommend using at least a small instance, if not a medium-sized high-CPU instance, otherwise large builds can take forever.</p>
<p>&#8221;&#8217;Note&#8221;&#8217;: these AMI numbers are available only in the Singapore availability zone. It is possible to copy the AMI to any availability zone, you do so by creating a snapshot of the image and then creating a new volume in your zone.</p>
<a name="How+to+create+an+instance"></a><h2>How to create an instance</h2>
<p>First, register for the <a href="http://aws-portal.amazon.com/gp/aws/developer/subscription/index.html?productCode=AmazonEC2" target="_blank">Amazon EC2 service</a>. The process is fairly self-explanatory, and they do require a credit card to register. I believe you can even link this to an existing consumer/personal Amazon account, but we haven&#8217;t tested this.</p>
<p>You will be asked to make a key pair for yourself, certificates, and so forth; save them, as you will need the key pair to log into your instance. </p>
<p>Once you are approved for an account, you will see a console similar to the following:<br />
<a class="lightbox"  title ="instance_dashboard" href="http://www.kosagi.com/blog/?attachment_id=313"><img src="http://www.kosagi.com/blog/wp-content/uploads/2012/01/instance_dashboard-600x287.png" alt="" title="instance_dashboard" width="600" height="287" class="alignnone size-large wp-image-313" /></a></p>
<a name="Set+security+groups"></a><h3>Set security groups</h3>
<p>Before moving forward, click on Security Groups and enable ssh. If you are using the NeTV pre-built image, you will also want to enable HTTP (port 80) as well, to access buildbot and gitweb.<br />
<a class="lightbox"  title ="security_group" href="http://www.kosagi.com/blog/?attachment_id=314"><img src="http://www.kosagi.com/blog/wp-content/uploads/2012/01/security_group-600x379.png" alt="" title="security_group" width="600" height="379" class="alignnone size-large wp-image-314" /></a></p>
<a name="Launching+an+instance"></a><h3>Launching an instance</h3>
<p>Now, click on Launch Instance, and do the following:</p>
<p>* Click on community AMIs and enter the AMI number. Note that it can take up to a couple of minutes for the community AMI list to load, so be patient &#8212; the UI gives no hint of the loading process,<br />
so it&#8217;s easy to think nothing was found.<br />
<a class="lightbox"  title ="request_instance0" href="http://www.kosagi.com/blog/?attachment_id=315"><img src="http://www.kosagi.com/blog/wp-content/uploads/2012/01/request_instance0-600x382.png" alt="" title="request_instance0" width="600" height="382" class="alignnone size-large wp-image-315" /></a></p>
<p>* Select your instance type. </p>
<p><a href="http://kosagi.com/oe/request_instance1.png">http://kosagi.com/oe/request_instance1.png</a></p>
<p><a class="lightbox"  title ="request_instance1" href="http://www.kosagi.com/blog/?attachment_id=316"><img src="http://www.kosagi.com/blog/wp-content/uploads/2012/01/request_instance1-600x404.png" alt="" title="request_instance1" width="600" height="404" class="alignnone size-large wp-image-316" /></a></p>
<p>* Configure your instance details. I typically turn on termination protection, but here you can also map a new kernel to the device, if you need to do so. Sometimes I find I have to enter an explicit kernel ID, especially if after you start the instance nothing seems to happen. The default kernel ID is aki-13d5aa41 for both images, in case you need it.<br />
<a class="lightbox"  title ="request_instance2" href="http://www.kosagi.com/blog/?attachment_id=317"><img src="http://www.kosagi.com/blog/wp-content/uploads/2012/01/request_instance2-600x403.png" alt="" title="request_instance2" width="600" height="403" class="alignnone size-large wp-image-317" /></a></p>
<p>* Give your instance a name.<br />
<a class="lightbox"  title ="request_instance3" href="http://www.kosagi.com/blog/?attachment_id=318"><img src="http://www.kosagi.com/blog/wp-content/uploads/2012/01/request_instance3-600x406.png" alt="" title="request_instance3" width="600" height="406" class="alignnone size-large wp-image-318" /></a></p>
<p>* Pick your key pair. I can&#8217;t test this theory because I only have one account, but I believe the keypair you generated when you created your amazon account should be usable, and you don&#8217;t need the keypair that I made with the instance.<br />
<a class="lightbox"  title ="request_instance4" href="http://www.kosagi.com/blog/?attachment_id=319"><img src="http://www.kosagi.com/blog/wp-content/uploads/2012/01/request_instance4-600x405.png" alt="" title="request_instance4" width="600" height="405" class="alignnone size-large wp-image-319" /></a></p>
<p>* Pick your security group &#8212; default should be okay (assuming you enabled ssh access; your &#8220;new&#8221; account has all access shut off)</p>
<p>* Launch the instance!<br />
<a class="lightbox"  title ="request_instance5" href="http://www.kosagi.com/blog/?attachment_id=320"><img src="http://www.kosagi.com/blog/wp-content/uploads/2012/01/request_instance5-600x408.png" alt="" title="request_instance5" width="600" height="408" class="alignnone size-large wp-image-320" /></a></p>
<p>* Go back to the dashboard, and wait until the instance is running. Right click on the instance, and select connect. It will give you detailed instructions on how to connect. Note that the DNS mapping of your instance changes every time you restart it, but you can use elastic IP to make it fixed (at a charge!).<br />
<a class="lightbox"  title ="connect" href="http://www.kosagi.com/blog/?attachment_id=321"><img src="http://www.kosagi.com/blog/wp-content/uploads/2012/01/connect.png" alt="" title="connect" width="463" height="450" class="alignnone size-full wp-image-321" /></a></p>
<p>* Finally, log in with the username &#8220;ubuntu&#8221;. No password is needed, since you are already validated through the key pair. &#8220;ubuntu&#8221; has sudo privileges as well, so protect your keypair!<br />
<a class="lightbox"  title ="login" href="http://www.kosagi.com/blog/?attachment_id=312"><img src="http://www.kosagi.com/blog/wp-content/uploads/2012/01/login-600x424.png" alt="" title="login" width="600" height="424" class="alignnone size-large wp-image-312" /></a></p>
<p>Once you are logged in, there is a readme.txt that will help guide you through the rest.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kosagi.com/blog/quickstart-oe/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Where to buy?</title>
		<link>http://www.kosagi.com/blog/where-to-buy/</link>
		<comments>http://www.kosagi.com/blog/where-to-buy/#comments</comments>
		<pubDate>Tue, 03 Jan 2012 16:22:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://www.kosagi.com/blog/?p=98</guid>
		<description><![CDATA[NeTV is currently available in as a development kit for use by developers, reviewers, and other people interested in evaluating the product. You can buy it from AdaFruit Industries at http://adafruit.com/products/609 &#160;]]></description>
				<content:encoded><![CDATA[<p>NeTV is currently available in as a development kit for use by developers, reviewers, and other people interested in evaluating the product.<br />
You can buy it from AdaFruit Industries at <a href="http://adafruit.com/products/609">http://adafruit.com/products/609</a></p>
<p><a class="lightbox"  title ="neTVstarter_LRG" href="http://www.kosagi.com/blog/where-to-buy/netvstarter_lrg/"><img src="http://www.kosagi.com/blog/wp-content/uploads/2012/01/neTVstarter_LRG-300x230.jpg" alt="" title="neTVstarter_LRG" width="300" height="230" class="alignnone size-medium wp-image-264" /></a>&nbsp;<a class="lightbox"  title ="neTVstarterplastic_LRG" href="http://www.kosagi.com/blog/where-to-buy/netvstarterplastic_lrg/"><img src="http://www.kosagi.com/blog/wp-content/uploads/2012/01/neTVstarterplastic_LRG-300x230.jpg" alt="" title="neTVstarterplastic_LRG" width="300" height="230" class="alignnone size-medium wp-image-263" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kosagi.com/blog/where-to-buy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Motor controller board</title>
		<link>http://www.kosagi.com/blog/motor-controller-board/</link>
		<comments>http://www.kosagi.com/blog/motor-controller-board/#comments</comments>
		<pubDate>Wed, 21 Dec 2011 16:00:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Hardware]]></category>

		<guid isPermaLink="false">http://www.kosagi.com/blog/?p=143</guid>
		<description><![CDATA[Hardware Placeholder. Software All operations on motor board can be controlled via console terminal or various HTTP API. From console: mot_ctl FPGA control routine. r &#160; &#160; &#160; hardware reset of the FPGA to clean state for reconfiguration o &#160; &#160; &#160; return the state of the FPGA programming done pin V &#160; &#160; &#160; [...]]]></description>
				<content:encoded><![CDATA[<a name="Hardware"></a><h2>Hardware</h2>
<p>Placeholder.</p>
<a name="Software"></a><h2>Software</h2>
<p>All operations on motor board can be controlled via console terminal or various HTTP API.<br />
<span id="more-143"></span><br />
<strong>From console:</strong></p>
<div class="codecolorer-container text default codecolorer-noborder" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">mot_ctl<br />
FPGA control routine.<br />
r &nbsp; &nbsp; &nbsp; hardware reset of the FPGA to clean state for reconfiguration<br />
o &nbsp; &nbsp; &nbsp; return the state of the FPGA programming done pin<br />
V &nbsp; &nbsp; &nbsp; print the version number of the FPGA<br />
a [ch] &nbsp;read ADC value from channel ch0-7<br />
a &nbsp; &nbsp; &nbsp; dump all ADC &nbsp;channel values<br />
S [ch] [s,m] set channel ch[1,2] to mode [s,m] (servo or motor mode)<br />
S [ch] returns the servo mode status of channel [ch]<br />
s [ch] [val] set servo channel ch [1,2] to angle val [0.0-180.0, floating point]<br />
e [val] set servo pulse period to [val] microseconds (integer only)<br />
e &nbsp; &nbsp; &nbsp;get servo pulse period<br />
m [ch] [cmd] motor command for channel ch1-4. cmd = [f,r,s] -&gt; forward, reverse, stop<br />
M [xxxx] set motor channel [1234] to respective states [f,r,s,x] (x means don't change)<br />
p [ch] [dc] PWM duty cycle for channel ch1-4 and duty cycle dc0-255<br />
P [div] set PWM divider (div = 0-65535, rate = 101.5kHz / (div + 2))<br />
f [freq] set motor PWM to frequency [freq] Hz<br />
u [val] set digital output to value val<br />
u [ch] [val] set digital output bit [ch] to value [val]<br />
i &nbsp; &nbsp; &nbsp; print the value of the digital inputs<br />
i [ch] &nbsp;print the value of channel [ch]<br />
d &nbsp; &nbsp; &nbsp; dump the control set registers (raw values)<br />
d [adr] dump the the raw value at [adr]<br />
w [adr] [dat] write data [dat] to address [adr]<br />
D [tst] detect if the motor controller board is attached using test value [tst].<br />
A &nbsp; &nbsp; &nbsp; auto-detect if motor controller board is attached.<br />
n &nbsp; &nbsp; &nbsp; return device serial number</div></div>
<a name="Load+motor+firmware"></a><h3>Load motor firmware</h3>
<p>Motor firmware needs to be first loaded to FPGA to enable motor board features.<br />
To check if motor firmware is currently loaded.<br />
<code class="codecolorer text default"><span class="text">mot_ctl V</span></code><br />
If a single number is returned, eg. 139, it means the motor firmware is currently loaded. Otherwise, a long string as below is returned.</p>
<div class="codecolorer-container text default codecolorer-noborder" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">mot_ctl V<br />
FPGA is not configured to drive a motor board, please follow this procedure:<br />
1. Make sure the HDMI input is connected to the motor board. Do not connect an HDMI device to the port! We are not liable for damages if you wire this up wrong.<br />
2. Issue the command '/etc/init.d/netv_service motor'; this will switch the NeTV into motor driver mode.</div></div>
<p>Perform just that to load motor firmware to FPGA.</p>
<div class="codecolorer-container bash default codecolorer-noborder" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>netv_service motor</div></div>
<a name="HTTP+API"></a><h2>HTTP API</h2>
<p>A demo page showing all capabilities of the motor board is available at <a title="http://10.0.88.1/html_motor/js/utils_motor.js" href="http://10.0.88.1/html_motor/js/utils_motor.js">http://10.0.88.1/html_motor/</a><br />
It is recommended to try this page from a computer as the UI is heavily implemented with jQueryUI.<br />
Most features are implemented with NeCommand HTTP API calling <strong><em>mot_ctl</em></strong> command above.<br />
However, some features such as the sliders controlling motor speed &amp; PWM frequency are implemented using Motor HTTP API for better efficiency.</p>
<a name="JavaScript+library"></a><h3>JavaScript library</h3>
<p>All motor board features are encapsulated in a single stand_alone JS file at <a href="http://10.0.88.1/html_motor/js/utils_motor.js">http://10.0.88.1/html_motor/js/utils_motor.js</a> or <strong>/usr/share/netvserver/docroot/html_motor/js/utils_motor.js</strong><br />
It is self-explainatory through comments.<br />
Feel free to include or copy this file to your project folder if you are developing your own UI for motor board.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kosagi.com/blog/motor-controller-board/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mobile app</title>
		<link>http://www.kosagi.com/blog/mobile-app/</link>
		<comments>http://www.kosagi.com/blog/mobile-app/#comments</comments>
		<pubDate>Wed, 14 Dec 2011 16:00:17 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://www.kosagi.com/blog/?p=114</guid>
		<description><![CDATA[Android app is available for free in Android Market iOS app is available for free in AppStore Full source code is posted on github in the following respositories http://github.com/sutajiokousagi/netv-android http://github.com/sutajiokousagi/netv-ios Both platforms uses a combination of HTTP &#038; UDP API.]]></description>
				<content:encoded><![CDATA[<p><a class="lightbox"  title ="netv_ios" href="http://www.kosagi.com/blog/mobile-app/netv_ios/"><img src="http://www.kosagi.com/blog/wp-content/uploads/2011/12/netv_ios.png" alt="" title="netv_ios" width="600" height="480" class="alignnone size-full wp-image-124" /></a></p>
<p>Android app is available for free in <a href="https://market.android.com/details?id=com.bunniestudios.NeTV">Android Market</a><br />
iOS app is available for free in <a href="http://itunes.com/app/netv">AppStore</a><br />
<span id="more-114"></span><br />
Full source code is posted on github in the following respositories<br />
<a href="http://github.com/sutajiokousagi/netv-android" title="http://github.com/sutajiokousagi/netv-android" target="_blank">http://github.com/sutajiokousagi/netv-android</a><br />
<a href="http://github.com/sutajiokousagi/netv-ios" title="http://github.com/sutajiokousagi/netv-ios" target="_blank">http://github.com/sutajiokousagi/netv-ios</a></p>
<p>Both platforms uses a combination of HTTP &#038; UDP API.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kosagi.com/blog/mobile-app/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Firmware 31</title>
		<link>http://www.kosagi.com/blog/firmware-31/</link>
		<comments>http://www.kosagi.com/blog/firmware-31/#comments</comments>
		<pubDate>Mon, 12 Dec 2011 19:55:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Firmware releases]]></category>

		<guid isPermaLink="false">http://www.kosagi.com/blog/?p=4</guid>
		<description><![CDATA[Firmware 31 is pushed. The main purpose of this push is to transition to the new servers. You will notice some update in the iconography as well in this update. The only significant new feature added in this push is iOS foundation API support.]]></description>
				<content:encoded><![CDATA[<p>Firmware 31 is pushed. The main purpose of this push is to transition to the new servers. You will notice some update in the iconography as well in this update.</p>
<p>The only significant new feature added in this push is iOS foundation API support.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kosagi.com/blog/firmware-31/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Building OpenEmbedded</title>
		<link>http://www.kosagi.com/blog/building-openembedded/</link>
		<comments>http://www.kosagi.com/blog/building-openembedded/#comments</comments>
		<pubDate>Wed, 07 Dec 2011 04:18:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Documentation]]></category>

		<guid isPermaLink="false">http://www.kosagi.com/blog/?p=296</guid>
		<description><![CDATA[Overview OpenEmbedded[http://www.openembedded.org/index.php/Main_Page] is a build environment that contains a large number of packages. It&#8217;s possible to use OpenEmbedded to build a bootable image for certain chumby devices, such as the Falconwing-series of devices. These instructions assume you&#8217;re using Ubuntu 10.04 LTE, though they can be adapted to work on different platforms. Re-imaging a device requires [...]]]></description>
				<content:encoded><![CDATA[<a name="Overview"></a><h2>Overview</h2>
<p>OpenEmbedded[http://www.openembedded.org/index.php/Main_Page] is a build environment that contains a large number of packages.  It&#8217;s possible to use OpenEmbedded to build a bootable image for certain chumby devices, such as the Falconwing-series of devices.  These instructions assume you&#8217;re using Ubuntu 10.04 LTE, though they can be adapted to work on different platforms.</p>
<p>Re-imaging a device requires access to the internal micro-SD port.  You will also need a USB micro-SD reader of some sort.  These can be obtained very cheaply, and sometimes can be found bundled with micro-SD media.</p>
<p>These instructions assume you&#8217;re running on a Falconwing platform, such as the Hacker Board or a chumby One.  If you&#8217;re using a Silvermoon-based platform such as Infocast 8 or chumby 8, replace all instances of &#8220;falconwing&#8221; with &#8220;silvermoon&#8221;.</p>
<a name="Quickstart"></a><h2>Quickstart</h2>
<p>Building OE can take several hours, since it pulls down the source for the entire world and builds every piece from scratch; the initial build configuration is also a bit finicky at times.</p>
<p>In order to facilitate rapid evaluation and development, you can launch one of our public, pre-built Amazon EC2 cloud instance images. Please see [[quickstarting OE]] for directions on how to do this.</p>
<a name="Setting+up+the+Environment"></a><h2>Setting up the Environment</h2>
<p>This assumes you&#8217;re using Ubuntu 10.04 LTE, and also tested on Ubuntu 11.10 64-bit desktop</p>
<ul>
<li>Install prerequisites<br />
	<code class="codecolorer bash default"><span class="bash"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">aptitude</span> <span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #c20cb9; font-weight: bold;">cvs</span> subversion git-core coreutils <span style="color: #c20cb9; font-weight: bold;">unzip</span> texi2html texinfo libtool docbook-utils <span style="color: #c20cb9; font-weight: bold;">gawk</span> python-pysqlite2 diffstat help2man <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">gcc</span> build-essential <span style="color: #c20cb9; font-weight: bold;">g++</span> desktop-file-utils chrpath libxml2-utils xmlto <span style="color: #c20cb9; font-weight: bold;">screen</span> python-ply libxml2-utils xsltproc libssl-dev python-progressbar</span></code></li>
<li>Make /bin/sh not be part of dash<br />
	<code class="codecolorer bash default"><span class="bash"><span style="color: #c20cb9; font-weight: bold;">sudo</span> dpkg-reconfigure <span style="color: #c20cb9; font-weight: bold;">dash</span> <span style="color: #666666; font-style: italic;"># Select &quot;No&quot; at the prompt</span></span></code></li>
<li>Fix mmap_min_addr (required for qemu to run, generating libc keymap files, etc. has a potential security risk associated with this)<br />
	<code class="codecolorer bash default"><span class="bash"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">sh</span> <span style="color: #660033;">-c</span> <span style="color: #ff0000;">'echo 0 &gt; /proc/sys/vm/mmap_min_addr'</span></span></code><br />
	<code class="codecolorer bash default"><span class="bash"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">sh</span> <span style="color: #660033;">-c</span> <span style="color: #ff0000;">'echo &quot;vm.mmap_min_addr = 0&quot; &gt;&gt; /etc/sysctl.conf'</span></span></code></li>
<li>Download OpenEmbedded<br />
	<code class="codecolorer bash default"><span class="bash"><span style="color: #7a0874; font-weight: bold;">cd</span></span></code><br />
	<code class="codecolorer bash default"><span class="bash"><span style="color: #c20cb9; font-weight: bold;">git clone</span> git:<span style="color: #000000; font-weight: bold;">//</span>github.com<span style="color: #000000; font-weight: bold;">/</span>sutajiokousagi<span style="color: #000000; font-weight: bold;">/</span>chumby-oe.git</span></code><br />
	<code class="codecolorer bash default"><span class="bash"><span style="color: #7a0874; font-weight: bold;">cd</span> chumby-oe</span></code><br />
	<code class="codecolorer bash default"><span class="bash"><span style="color: #c20cb9; font-weight: bold;">git clone</span> git:<span style="color: #000000; font-weight: bold;">//</span>github.com<span style="color: #000000; font-weight: bold;">/</span>sutajiokousagi<span style="color: #000000; font-weight: bold;">/</span>openembedded.git</span></code><br />
	<code class="codecolorer bash default"><span class="bash"><span style="color: #c20cb9; font-weight: bold;">git clone</span> git:<span style="color: #000000; font-weight: bold;">//</span>github.com<span style="color: #000000; font-weight: bold;">/</span>sutajiokousagi<span style="color: #000000; font-weight: bold;">/</span>meta-chumby.git</span></code></li>
</ul>
<p>If desired, see <a href="http://www.kosagi.com/blog/advanced-openembedded/">Advanced OpenEmbedded</a>.</p>
<a name="Building+with+OpenEmbedded"></a><h2>Building with OpenEmbedded</h2>
<p>Every time you log onto your build system, you must set up the environment.  There is a command called &#8220;setup-chumby.sh&#8221; that will do this for you.  You must source the command and not run it.  If you&#8217;ve installed openembedded to a path other than ~/chumby-oe/ you must edit the command and change the variable TOPDIR.<br />
<code class="codecolorer bash default"><span class="bash"><span style="color: #7a0874; font-weight: bold;">source</span> setup-chumby.sh <span style="color: #666666; font-style: italic;"># Select your platform at the prompt</span></span></code></p>
<p>Once setup, you use the bitbake command to build packages and images.  Valid image files can be found in openembedded/recipes/images/and meta-chumby/recipes/images, and a full build from scratch can take ten hours or more.  Building individual recipes is much quicker.<br />
<code class="codecolorer bash default"><span class="bash">bitbake chumby-starter-image <span style="color: #666666; font-style: italic;"># As an example, build chumby-starter-image</span></span></code></p>
<p>&#8221;Need to add information here on how to roll back to a buildable snap-shot as it seems that packages are often checked into the git repository without validating this build process.&#8221;</p>
<a name="Writing+images+to+disk"></a><h2>Writing images to disk</h2>
<p>Built images go in output-angstrom-.9/deploy/eglibc/images/.  Full, bootable ROM images are named rom-chumby-MACHINE-IMAGENAME.img.  Other interesting files, such as the bootloader, boot shell, kernel, and boot graphics are also present in this directory.</p>
<p>To write a ROM file to disk, use dd, or on Windows use win32-image-writer.  If you&#8217;re working on a remote system, use SCP or SFTP to download the image file locally.  Then write the file out to an SD card:</p>
<a name="Linux"></a><h3>Linux</h3>
<ul>
<li>Determine what drive letter your SD card is.  After inserting the card, run &#8220;dmesg&#8221; and note the drive name.  For example, it might be &#8220;sdb&#8221; or &#8220;sdc&#8221; depending on how many hard drives your system has.</li>
<li>Unmount the drives</li>
<p>	<code class="codecolorer bash default"><span class="bash"><span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span> $<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-1</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sdb<span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>; <span style="color: #000000; font-weight: bold;">do</span> <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">umount</span> <span style="color: #007800;">$i</span>; <span style="color: #000000; font-weight: bold;">done</span></span></code></p>
<li>Write the ROM image out<br />
	<code class="codecolorer bash default"><span class="bash"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">dd</span> <span style="color: #007800;">if</span>=rom-chumby-silvermoon-chumby-starter-image.img <span style="color: #007800;">of</span>=<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sdX <span style="color: #007800;">bs</span>=8M</span></code></li>
</ul>
<a name="Windows"></a><h3>Windows</h3>
<ul>
<li>Download win32-image-writer from <a href="https://launchpad.net/win32-image-writer">https://launchpad.net/win32-image-writer</a></li>
</ul>
<p>An example of a ROM image may be downloaded from <a href="http://files.chumby.com/hacks/rom-chumby-falconwing-chumby-starter-image.img.gz.">http://files.chumby.com/hacks/rom-chumby-falconwing-chumby-starter-image.img.gz.</a> Un-gzip this file and write it to an SD card, then insert the card in a Falconwing-based device. It should boot, and eventually bring up a prompt on the serial console.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kosagi.com/blog/building-openembedded/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
