<?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>none of this matters &#187; linux</title>
	<atom:link href="http://blog.nemik.net/category/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.nemik.net</link>
	<description></description>
	<lastBuildDate>Thu, 10 Dec 2009 05:32:59 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Arduinoponics with OpenWRT</title>
		<link>http://blog.nemik.net/2009/12/arduinoponics-with-openwrt/</link>
		<comments>http://blog.nemik.net/2009/12/arduinoponics-with-openwrt/#comments</comments>
		<pubDate>Thu, 10 Dec 2009 05:28:49 +0000</pubDate>
		<dc:creator>nemik</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[hydroponics]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://blog.nemik.net/?p=89</guid>
		<description><![CDATA[I updated my GitHub repo: http://github.com/nemik/arduinoponics with code I wrote for the OpenWRT firmware (version 8.09.1). It provides an AJAXy-updating page to OpenWRT&#8217;s Luci web-interface which displays the analog pin values from the Arduino which the Arduinoponics sketch runs on.
Here is a screenshot, notice the extra &#8216;Sensors&#8217; link on the top right to access the [...]]]></description>
			<content:encoded><![CDATA[<p>I updated my GitHub repo: <a href="http://github.com/nemik/arduinoponics">http://github.com/nemik/arduinoponics</a> with code I wrote for the OpenWRT firmware (version 8.09.1). It provides an AJAXy-updating page to OpenWRT&#8217;s Luci web-interface which displays the analog pin values from the Arduino which the Arduinoponics sketch runs on.</p>
<p>Here is a screenshot, notice the extra &#8216;Sensors&#8217; link on the top right to access the info, the page does not require login<br />
<a href="http://blog.nemik.net/wp-content/uploads/2009/12/Picture-3.png" rel="lightbox[blog]"><img class="alignnone size-medium wp-image-91" title="Arduinoponics OpenWRT screenshot" src="http://blog.nemik.net/wp-content/uploads/2009/12/Picture-3-300x168.png" alt="Arduinoponics OpenWRT screenshot" width="300" height="168" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nemik.net/2009/12/arduinoponics-with-openwrt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fixing broken JFFS2 partition</title>
		<link>http://blog.nemik.net/2009/11/fixing-broken-jffs2-partition/</link>
		<comments>http://blog.nemik.net/2009/11/fixing-broken-jffs2-partition/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 04:17:14 +0000</pubDate>
		<dc:creator>nemik</dc:creator>
				<category><![CDATA[hydroponics]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://blog.nemik.net/?p=86</guid>
		<description><![CDATA[Lesson #1 of embedded development: don&#8217;t write all your code to your device and not backup/check-in. I did just that when writing some code for the hydroponics monitoring setup on my Fon2100 router running OpenWRT. After trying to opkg install ntpclient and getting a segfault and NTP not working, I restarted  the network on it [...]]]></description>
			<content:encoded><![CDATA[<p>Lesson #1 of embedded development: don&#8217;t write all your code to your device and not backup/check-in. I did just that when writing some code for the hydroponics monitoring setup on my Fon2100 router running <a href="http://openwrt.org/">OpenWRT</a>. After trying to opkg install ntpclient and getting a segfault and NTP not working, I restarted  the network on it which restarted the router. For whatever reason, the router choked and each restart went into failsafe mode. When I telnet&#8217;d into it, dmesg told me the jffs2 partition had trouble mounting with an error in jffs2_link_node_ref.</p>
<p>I had written a bunch of Lua code to read the serial communications coming from the ATMega168 microcontroller (it was sending its analog input values) and store it into files in /tmp which were then read by some more Lua code in the (awesome) <a href="http://luci.subsignal.org/">LuCI</a> framework to make those sensors all cool and AJAXy on the router&#8217;s web-admin menu. This worked great until the NTP attempt. So I wanted all this code back. So in case anyone is as foolish as I was to lose their code in the router, here are the steps I took to recover it. David Woodhouse (dwmw2) and dedekind at #mtd on irc.ipv6.oftc.net were extremely helpful with all this and pointed me in all the right directions.</p>
<ol>
<li>
<div>backup the jffs2 image from the router using dd. mine was coming up in failsafe mode so i had to telnet into 192.168.1.1 and then run command `dd if=/dev/mtdblock2 | gzip -c | ssh nemik@pillbox &#8216;dd of=/tmp/mtd2.gz&#8217; bs=2048` but make sure you do the right mtdblock2 device. do `cat /proc/mtd` and choose the one that is for “rootfs_data”. pillbox is a Linux box on my network I transferred this all to.</div>
</li>
<li>
<div>`gunzip /tmp/mtd2.gz` on the Linux box and i got my 5.5MB partition.</div>
</li>
<li>
<div>wget <a title="ftp://ftp.infradead.org/pub/mtd-utils/mtd-utils-1.2.0.tar.bz2" rel="nofollow" href="ftp://ftp.infradead.org/pub/mtd-utils/mtd-utils-1.2.0.tar.bz2">ftp://ftp.infradead.org/pub/mtd-utils/mtd-utils-1.2.0.tar.bz2</a>. untar, make, make install</div>
</li>
<li>
<div>`sudo mknod /dev/mtd0 c 90 0`</div>
</li>
<li>
<div>`sudo modprobe mtdblock`</div>
</li>
<li>
<div>`sudo dd if=/tmp/mtd2 of=/dev/mtd0 bs=2048`</div>
</li>
<li>
<div>`sudo mount -t jffs2 mtd0 /tmp/1/` THIS DIDN&#8217;T WORK! (right away). The Fon router and openWRT are big-endian and I was trying to mount this on a little-endian x86 box. I needed to recompile the jffs2 kernel module to be big-endian. David Woodhouse (creator of JFFS2) writes how here: [<a title="http://www.infradead.org/pipermail/linux-mtd/2007-May/018227.html" rel="nofollow" href="http://www.infradead.org/pipermail/linux-mtd/2007-May/018227.html">http://www.infradead.org/pipermail/linux-mtd/2007-May/018227.html</a>] I needed to get the kernel source and recompile the jffs2 module</div>
</li>
<li>
<div>get the kernel source `apt-get source linux-image-$(uname -r)`</div>
</li>
<li>
<div>go into the source and do `make prepare_modules`</div>
</li>
<li>
<div>copy /usr/src/linux-headers-2.6.27-14-generic/Module.symvers to the source. this will be different for you, but the Module.symvers is important otherwise the module won&#8217;t load properly</div>
</li>
<li>Change the native_endian #define in fs/jffs2/nodelist.h to be little_endian as David writes in the infraread link on step 7.</li>
<li>
<div>do `make CONFIG_MODVERSIONS=y M=fs/jffs2`</div>
</li>
<li>
<div>if it compiled correctly, you then have a jffs2.ko module. load it via `sudo insmod /home/nemik/code/jffs2/linux-2.6.27/fs/jffs2/jffs2.ko`</div>
</li>
<li>
<div>now try `sudo mount -t jffs2 /dev/mtdblock0 /tmp/1/` and it worked for me!</div>
</li>
</ol>
<p>I was now able to see all my lost files in /tmp/1/ !!! the whole filesystem was there and worked great. I extracted all the code I wrote and learned my lesson never to do development on a router and always backup and check in. Hopefully this helps someone out.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nemik.net/2009/11/fixing-broken-jffs2-partition/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
