<?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>Way of the exploding head &#187; Embedded Linux</title>
	<atom:link href="http://warmcat.com/_wp/category/embedded-linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://warmcat.com/_wp</link>
	<description>Embedded and desktop Linux</description>
	<lastBuildDate>Fri, 12 Feb 2010 23:49:41 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Don&#8217;t let Production Test Be Special</title>
		<link>http://warmcat.com/_wp/2010/02/12/dont-let-production-test-be-special/</link>
		<comments>http://warmcat.com/_wp/2010/02/12/dont-let-production-test-be-special/#comments</comments>
		<pubDate>Fri, 12 Feb 2010 23:49:41 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[Embedded Linux]]></category>
		<category><![CDATA[Hardware design]]></category>
		<category><![CDATA[Openmoko Lessons]]></category>
		<category><![CDATA[Software design]]></category>

		<guid isPermaLink="false">http://warmcat.com/_wp/?p=75</guid>
		<description><![CDATA[Lesson 3: Test is not special
Commonly in embedded work test is the &#8220;red-haired stepchild&#8221;, nobody wants to take care of it and by common, silent consent it is always left until last.  Eventually the need for a test plan becomes overwhelming as the date to go to the factory nears, and the task is assigned [...]]]></description>
			<content:encoded><![CDATA[<h2>Lesson 3: Test is not special</h2>
<p>Commonly in embedded work test is the &#8220;red-haired stepchild&#8221;, nobody wants to take care of it and by common, silent consent it is always left until last.  Eventually the need for a test plan becomes overwhelming as the date to go to the factory nears, and the task is assigned to the most junior engineers available, since everybody knows that test is the death knell of your career.</p>
<p>Coming cold to and excluded from being inside an already-existing project, the engineers try to create some kind of test coverage the best way they can.  At openmoko two giant test suites were created, DM1 and DM2, written by people who were learning C for the first time.  I got the job of modernizing this code so I know from experience the code was already truly terrible and bitrotted at an alarming rate.  However I had to admire the guys who wrote it, with everything against them and little experience they did manage to create something that did provide test coverage at the factory, however much it was on life-support.</p>
<h2>Totentanz</h2>
<p>Similarly, Openmoko used production test jigs, special additional PCBs that formed a kind of custom test environment for the PCB under test.  At one version of GTA03 there were so many test points added it was a serious concern that the board would break down under the overall pressure needed to mate the spring-loaded test probes to the test points.</p>
<p>Jigs and test points have an obvious advantage in terms of test throughput, but there are some big disadvantages.</p>
<p>First, you have to design and build the jig, and track changes to the actual device with it.  This effort is completely disconnected from moving your actual product on, except that it&#8217;s meant to help in production.</p>
<p>Second, test points don&#8217;t test your connectors; the test point may be connected OK but not the connector pin the user actually accesses.</p>
<p>Third, you need something else outside the device to assess what is happening on the test points, the code for that also has to be written and maintained against changes in the actual product.  It also means that it&#8217;s not possible for the tests to be casually performed outside the factory, or maybe by the original engineers if they have access to the ATE gear themselves.</p>
<h2>Pain into torture</h2>
<p>Additionally the bringup of GTA02 required special versions of U-Boot and kernel which had added &#8220;test magic&#8221; created by the test guys and unknown to anyone else.  These versions were seldom uplevelled.</p>
<p>Since GTA02 had raw NAND, it needed filling up at the factory with the rootfs.  The way to do this was via a very fragile OpenOCD using a custom USB &#8211; serial based device that was bitbanged.  It only worked with certain versions of the usb library needed to talk to it.</p>
<p>All of these quirks and requirements at the factory made production runs difficult and expensive to get right.</p>
<h2>I only hurt you because I love you</h2>
<p>I spent a lot of time thinking about how to avoid this end result next time I would design something.  The mistakes started in having anything special for test I concluded.  The jig: special, and so evil.  Test kernels or bootloader: special -&gt; evil.  Test rootfs -&gt; Evil.  test software, like Openmoko&#8217;s DM1 and DM2, evil.  The device should naturally be able to test itself with the arrangements that already exist inside it to operate at all.</p>
<p>The answer to the problem of &#8220;production test&#8221; is to completely subsume it into the rest of the design.  So it is the responsibility of Linux drivers to provide enough functionality by probe errors, or sysfs features, that one can perform test and diagnosis.  The &#8220;test suite&#8221; should boil down to a bash script that is using features exposed in a normal shipping rootfs and kernel.  Bash is ideal because most of the test action will be calling existing commandline tools like ifconfig, ping, l2ping and grepping or looking at their return code, this is what bash is best at.  It&#8217;s also easily understood and edited by anyone who has worked with Linux for a while.</p>
<p>The bootloader is required for test in only one capacity, it is the only part of the system that is capable to run the SDRAM tests; once you enter Linux you can&#8217;t perform a full SDRAM test any more.  But even that should be done by the one shipping bootloader image.</p>
<p>In many cases, device interfaces can be tested by external loopback connectors, this proves connectivity through the connectors and it leaves open the possibility of end-users being able to run the same tests on the shipping rootfs.</p>
]]></content:encoded>
			<wfw:commentRss>http://warmcat.com/_wp/2010/02/12/dont-let-production-test-be-special/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bootloader Envy</title>
		<link>http://warmcat.com/_wp/2010/02/08/bootloader_envy/</link>
		<comments>http://warmcat.com/_wp/2010/02/08/bootloader_envy/#comments</comments>
		<pubDate>Mon, 08 Feb 2010 20:14:54 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[Embedded Linux]]></category>
		<category><![CDATA[Linux peripherals]]></category>
		<category><![CDATA[Openmoko Lessons]]></category>
		<category><![CDATA[Software design]]></category>

		<guid isPermaLink="false">http://warmcat.com/_wp/?p=67</guid>
		<description><![CDATA[Lesson #2:  A bootloader is to load and boot Linux
On the first day of FOSDEM I sat through a presentation on what could be called another &#8220;U-Boot derivative&#8221;.  One of the greatest asspains at Openmoko was the various kinds of Hell caused by the U-Boot bootloader and its philosophy, which can be summed up as [...]]]></description>
			<content:encoded><![CDATA[<h2>Lesson #2:  A bootloader is to load and boot Linux</h2>
<p><img class="alignleft" title="Qi" src="http://warmcat.com/qi.png" alt="" width="126" height="183" />On the first day of FOSDEM I sat through a presentation on what could be called another &#8220;U-Boot derivative&#8221;.  One of the greatest asspains at Openmoko was the various kinds of Hell caused by the U-Boot bootloader and its philosophy, which can be summed up as &#8220;I wanna be Linux when I grow up&#8221;.</p>
<h2>Configure system is a bad alternative to good bootloader design</h2>
<p>First, it has a config system.  That should be good though, right?  The problem with the config system is that if anything differs from your current config, you must build another incompatible binary with another config and take care of that.  When you have more than a handful of different boards, you are in a maze of incompatible bootloaders.  Openmoko took it one step further, they mandated a different bootloader binary per PCB revision, so left unchecked there would have been a continuous proliferation of incompatible bootloaders, all basically the same.</p>
<h2>All persistent bootloader private state is EVIL</h2>
<p>Second, U-Boot thinks it&#8217;s a good idea to have these environment &#8220;scripts&#8221;, because it&#8217;s &#8220;configurable&#8221;.  Actually, the job of a bootloader is to Load, then Boot Linux.  You don&#8217;t need any configurability for that if the bootloader can figure out what it&#8217;s running on and therefore where the memory is and how much there is.  These scripts expose a really deadly trap I call &#8220;private bootloader state&#8221;.  It means the bootloader stores stuff in nonvolatile memory on the PCB and acts different according to what it hides there.  The end result is that two boards from the same factory may act totally different even with the same rootfs due to &#8220;bootloader secrets&#8221;.  This is totally needless and ALL private bootloader state can be eliminated by correct design of the bootloader leading to completely deterministic boot action per rootfs.</p>
<p>A good example how that lead you to the path to hell is hardcoding in the U-Boot environment of the amount of kernel image you will copy from somewhere.  People commonly set it to 2MBytes, forget about it and one day they generate a 2.1MB kernel image and wonder why decompress blows up.  Actually, that whole procedure is insane, the kernels are uImages that report their length in a header.  The bootloader should examine the header and compute the length of image to pull.  But that doesn&#8217;t fit with this &#8220;environment&#8221; nonsense.</p>
<h2>Do Linux Stuff In Linux</h2>
<p>In any of these bloated U-Boot style bootloaders, is there even one feature they do better than the same feature in Linux?  The startup time should be better by a few 100ms.  Other than that, no, every single bloated &#8220;I will add it to the bootloader beacuse I can&#8221; feature is shittier than you get in Linux.  Every single feature!</p>
<p>If you need some advanced capability or backup / recovery boot action, check for a button held down at boot-time in the bootloader and go fetch a different Linux partition + kernel.  Use standard Linux tools and shells.  In return, get really high quality network stack, proper USB support, NAND access that&#8217;s compatible to your main Linux system access in BBT / ECC terms, and all the other advantages of Linux.</p>
<h2>Do your peripheral bringup in drivers in Linux</h2>
<p>Typically you do not need ANY bringup in the bootloader except SDRAM controller and chip init, since it&#8217;s a prerequisite to put Linux in the RAM that it&#8217;s initialized.</p>
<p>That&#8217;s right, all the megabytes of source spent in U-Boot providing support for so many kinds of peripheral is a waste of time, effort and maintenance.  I am being kind saying &#8220;maintenance&#8221;, because the drivers in U-Boot are typically &#8220;dumbed down&#8221; versions of the equivalent Linux driver that were forked irretrievably the moment all the Linux APIs were ripped, so there&#8217;s no coherent effort to keep them up to date with the Linux ones .  Lately I saw that they try to ape some Linux APIs there&#8230; why not go the whole hog and just <strong>load and boot real Linux</strong>?  After all, modern CPUs can be running your driver probes in Linux in ~2 seconds from power using a bootloader that doesn&#8217;t get in the way.</p>
<p>You typically don&#8217;t even need to talk to the PMU in the bootloader, after all, you are running code fine already, right?  Otherwise you wouldn&#8217;t be able to run the bootloader code itself.</p>
<h2>Fat girl in Ibiza</h2>
<p>At least at Openmoko, code quality inside U-Boot was awful bad.  I called U-Boot on the lists there &#8220;the fat girl in Ibiza&#8221; because you know she&#8217;s going to do anything you want.  All kinds of constant-only code, weird new scripting keywords were added for test undocumented, you name it.  Hardware guys felt up to writing such code secretly by themselves once they learned the software engineering marvel that is *((unsigned int *)0x&#8230;) = 0x&#8230;;</p>
<h2>Your bootloader just tests SDRAM</h2>
<p>There&#8217;s only one test action your bootloader is suited to do, and that is SDRAM test.  Once you are in Linux, it can&#8217;t perform a full SDRAM test while it&#8217;s running.  But the bootloader is typically starting from on-CPU SRAM, it can actually run a true SRAM test from there.  Otherwise, the bootloader should be completely absent from the test plan.  All other tests should be performed in Linux via standard driver and rootfs tools.</p>
<p>More about board and test and board bringup will feature in another report of a lesson learned.</p>
<h2>Qi</h2>
<p>While at Openmoko (mainly) I wrote a bootloader that meets these ideals, you can find it <a title="Qi git" href="http://git.warmcat.com/cgi-bin/cgit/qi/log/?h=txtr">in git here</a> One of the nicest things about it is that unlike the bloated bootloaders whose job never finishes trying to become Linux cargo cult style, Qi has been pretty much complete for a few months.  It&#8217;s a new job to support a new CPU, a much smaller job to add a new board and it doesn&#8217;t want to talk to your peripherals anyway so no problem there.</p>
<p>Qi creates one binary per CPU, that supports all boards with that CPU.  That sounds like a big job but we don&#8217;t care about your peripherals so all boards with the same CPU look almost identical.  You have to find something that can detect your particular board at runtime, for example NOR device ID read check.  So there is zero build-time config and Qi generates all CPU support when it&#8217;s buit, it takes 3 sec or so typically.</p>
<p>Typical bootloader binary size per CPU is 28-30KBytes.  That supports VFAT, ext2/3/4 typcially the SD controller as well.  The single Qi image also supports being booted from NAND, JTAG or SD Card on processors that support it just by being copied into place and without any changes.</p>
<p>There is zero bootloader private state, however Qi can look in the rootfs and append kernel commandline text from the content of a filesystem file.  This maintains the rule that boot should be completely deterministic per rootfs.</p>
]]></content:encoded>
			<wfw:commentRss>http://warmcat.com/_wp/2010/02/08/bootloader_envy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fosdem and the Linux Cross Niche</title>
		<link>http://warmcat.com/_wp/2010/02/08/fosdem-and-the-linux-cross-niche/</link>
		<comments>http://warmcat.com/_wp/2010/02/08/fosdem-and-the-linux-cross-niche/#comments</comments>
		<pubDate>Mon, 08 Feb 2010 12:42:34 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[Embedded Linux]]></category>
		<category><![CDATA[Openmoko Lessons]]></category>
		<category><![CDATA[Software design]]></category>
		<category><![CDATA[fosdem cross build distro fedora]]></category>

		<guid isPermaLink="false">http://warmcat.com/_wp/?p=56</guid>
		<description><![CDATA[
I was at Fosdem over the weekend, there were several interesting talks I attended but the most interesting one for me was a roundtable about the future of Cross distributions.  I was invited to give a 5 minute talk there which I gave, but unfortunately it was right at the end and the people before [...]]]></description>
			<content:encoded><![CDATA[<p><img class=" alignleft" title="fosdem" src="http://warmcat.com/fosdem.png" alt="fosdem" width="121" height="116" /></p>
<p>I was at Fosdem over the weekend, there were several interesting talks I attended but the most interesting one for me was a roundtable about the future of Cross distributions.  I was invited to give a 5 minute talk there which I gave, but unfortunately it was right at the end and the people before had overrun, so there was no time to make much of a coherent case.   So I am going to write some articles covering the issues involved here.</p>
<h2>Cross as a niche</h2>
<p>Cross itself remains absolutely necessary for systems below a certain level of horsepower.  For example, 8051, ARM7, cortex M3 are not really capable to consider native build.  But processors get faster each year, a lot of things we would have used an 8051 on use an ARM7 or cortex M3 now, in a few years it is likely that baseline has moved further up and it&#8217;s an ARM9 equivalent.  What I am suggesting then is that over time, the niche where you need cross is shrinking.</p>
<p>All four of the cross distros at FOSDEM target a CPU that&#8217;s powerful enough to run Linux, but not powerful enough to build its own binaries.  That is the niche that I believe will shrink to the point that it won&#8217;t support all these cross Linux distro projects, possibly none of them in the end.</p>
<h2>My background with cross Linux</h2>
<p>A few years ago I created an RPM-based cross distro singlehanded, and used it on a product for a customer  This was AT91RM9200-based, a 200MHz ARM9 with 32MBytes of SDRAM.  The amount of effort needed to create a set of cross packages sufficient to create a workable rootfs was huge, it took me many weeks.  Some packages like perl were just so cross-unfriendly that they were basically out of reach (although I later saw other people have done the invasive magic necessary).  It did work well, and I added patches for busybox RPM support that allowed it to do more useful things like erase and keep a package database.  The packaging was valuable in itself but a nice advantage was the source RPMs it generated ensuring GPL compliance.</p>
<h2>My background with Openmoko</h2>
<p>Subsequently I spent 14 months as (mainly) the kernel maintainer for Openmoko.  Openmoko had an OpenEmbedded basis for it&#8217;s rootfs, also a cross system.  I attempted to use it for &#8220;hello world&#8221; while I was at Openmoko, but it broke because I was on a newly released Fedora.  How it broke was very revealing, the official way to get started with it was to run a huge script that wgetted and locally built 1100 packages.  It died due to some assumption somewhere breaking while it tried to build <strong>host</strong> dbus libraries.</p>
<p>What I wanted was a cross toolchain that would let me package &#8220;hello world&#8221;.  What I got was a massive host build action including host dbus libs.  I have perfectly good host dbus libs in my Fedora install, I enquired about it and was told they were the &#8220;wrong&#8221; libs for the expectation of the rest of the packages, so they had to be rebuilt.</p>
<p>I gave up on trying to use OpenEmbedded, as I guess most of Openmoko&#8217;s customers did.</p>
<p>After Openmoko imploded, I designed the software architecture (and influenced the hardware design in some aspects) for the txtr reader device.  On this device, I put into action various lessons I had learned in how not to do things from Openmoko.  I will write further about the other lessons in future articles, but here&#8217;s the first one:</p>
<h2>Lesson #1: Don&#8217;t compile your own rootfs</h2>
<p>I was told by a manager at Openmoko that Openmoko had hired most of the main devs of OpenEmbedded and were paying for that accordingly.  This was a pretty big drain on their resources over a long period.</p>
<p>In contrast, nowadays you can head over to <a title="Fedora ARM project" href="http://fedoraproject.org/wiki/Architectures/ARM" target="_blank">http://fedoraproject.org/wiki/Architectures/ARM</a> and download a generic <a title="rootfs tarball" href="http://ftp.linux.org.uk/pub/linux/arm/fedora/rootfs/rootfs-f12.tar.bz2">rootfs tarball </a>of prebuilt binaries for ARMv5 and above[1].  It&#8217;s made from unpacking prebuilt binary packages.  Once you boot into it, you can install further packages with the usual yum install type action.  You can be up in a high quality rootfs in five minutes flat.</p>
<p>You do not need to go around compiling everything personally when binary packages exist from a reputable distro already.  Normal distros provide -dev and -devel packages for you to link against too, so you do not need to recompile the universe just because you want to build &#8220;hello world&#8221; either.  That&#8217;s how we do things on desktop and server systems, as the processors involved get stronger embedded does not have to be different.</p>
<p>If you want to cross-build specific packages, you install the <a title="cross toolchain" href="http://fedoraproject.org/wiki/Architectures/ARM/CrossToolchain">Fedora ARM Cross Toolchain RPMs</a> on you host via yum and you are ready to go in a couple of minutes.  This is very useful for cooking the kernel on your host both to get started and during development; you can&#8217;t native-build the bootstrap stuff needed to boot your platform.  But that&#8217;s just a cross compiler and related pieces, it&#8217;s not a cross distro.  (The guy from emdebian at this FOSDEM talk also made this point that you do not need to get into making your own toolchain, your distro should have one you can just install).</p>
<p>Fedora ARM&#8217;s strategy is native build.  So you install gcc and other dependencies into the actual device, and use standard rpmbuild to build your package there; you can also just configure ; make ; make install for development too down there.  If something&#8217;s missing on the rootfs you can yum install it.</p>
<p><em>(1 To make the comparison fair to openmoko Fedora ARM came along too late for them to choose it from the start, and the GTA02 s3c2442 was not a v5 class processor, they would have been into a distro recook after changing the distro-level compile options.  However my worry is not repeating Openmoko&#8217;s errors and today Fedora ARM is available.)</em></p>
<h2>Quality and Quantity</h2>
<p>Another major issue is distro quality.  I was so surprised to hear at Fosdem Dr Mickey Lauer of OpenEmbedded boast about the number of devices that managed to use that distro (including the sad shape of the GTA02) and say that unlike the other cross distros, OpenEmbedded focused on &#8220;Quantity not Quality&#8221;.  From my experience I think he&#8217;s right alright about not focusing on quality, and he did go on to explain there are problems with OpenEmbedded they are trying to address.</p>
<p>In the near future, there will be a carcrash between these difficult cross distros that have relatively poor quality and strange requirements to use them and standard, &#8220;proper distros&#8221; like Fedora ARM, because on higher-end ARMv5s say 400MHz and above, it is already perfectly possible to compare the two worlds on the same device.  I think many devs currently are trained by their experience with buildroot type systems to assume they have to personally build everything Gentoo style.  However as CPUs increase in power at the same price point, the ways of working with these systems efficiently change, and desktop / server &#8220;treat it like a PC&#8221; lessons like the value of packaging start to really show their traditional advantages over rootfs tarballs.</p>
<p>Like Debian, Fedora has all kinds of rules and requirements about packaging to ensure high quality, there are a huge number of users of these two normal distributions that leads to tested and debugged basic packages and their dependencies.  OpenEmbedded&#8217;s boast about number of users is not even a blip in comparison to Fedora or Debian&#8217;s consumers and contributors.</p>
<h2>Cross distros are locked into local patch hell</h2>
<p>A worse problem against their quality even than not many users is the patch load these projects are carrying, I think all of the cross distro projects bemoaned that they were carrying huge patchsets across a large number of packages to get them to build cross at all, and that most upstreams did not care to take them (I assume they don&#8217;t want to have to get into testing them).  To uplevel packages, which distros have to daily when they have a large package universe, it can become a nightmare of breakage because of the private patchsets being dragged around.</p>
<p>(BTW I also saw in another presentation that the <a title="limo" href="http://www.limofoundation.org/">limo foundation</a> are carrying around more than 80MBytes of diff between their distro and the upstream projects, and these are the guys who sent out a <a title="limo whitepaper" href="http://www.limofoundation.org/images/stories/pdf/limo%20economic%20analysis.pdf">whitepaper</a> explaining the massive cost of delaying sending patches upstream in dollar terms.)</p>
<p>There was proposed a unified crossbuild patch promoting effort, but the effort seemed only to consist of a domain like &#8220;sends-patches.org&#8221; that you could use when sending patches instead of your own project name, which seems to just be tea and sympathy rather than a solution.</p>
<p>It&#8217;s clear that quality will tend to be higher if you are getting packages built with normal distro specfiles and no pile of local patches to get them to build cross (because they were built native).  Combined with higher quality thresholds at the project level and sheer number of users, native Fedora (or Debian) rootfs basis will provide Quantity <strong>and</strong> Quality if your processor is appropriate.</p>
<p>A couple of hours after the talk I had an interesting conversation with <a title="openinkpot" href="http://openinkpot.org">OpenInkpot</a> dev Mikhail Gusarov, who I found also <a title="openinkpot and openembedded" href="http://openinkpot.org/wiki/FAQ#Whyareyouusing.debsandIPlinux">shared my lack of enthusiasm for OpenEmbedded</a>, although he is trapped still in the cross niche generally by the weak processors he targets at the moment.</p>
<p>[update Feb 10 09:00] Mikhail has <a href="http://fossarchy.blogspot.com/2010/02/cross-build-systems-and-their-future.html">written his own response</a>, he still likes the speed of cross (and still hates OpenEmbedded).  But there&#8217;s some confusion about what Fedora ARM offers, it&#8217;s a generic ARMv5 rootfs, it doesn&#8217;t care what exact kind of CPU, vendor or peripherals available.  Build farms are less of a requirement when you are no longer building your rootfs but installing it from distro binary packages.  <a href="http://en.wikipedia.org/wiki/SheevaPlug">Sheevaplug</a> makes available a 1.2GHz Marvell ARM compatible with 512MBytes of SDRAM that Fedora ARM can work on if you need a native build machine.  Shortly fast dual processor Cortex A9 machines will become available.</p>
]]></content:encoded>
			<wfw:commentRss>http://warmcat.com/_wp/2010/02/08/fosdem-and-the-linux-cross-niche/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FIPS-140-2 and ENT validation vs ring RNG</title>
		<link>http://warmcat.com/_wp/2007/11/15/fips-140-2-and-ent-validation-vs-ring-rng/</link>
		<comments>http://warmcat.com/_wp/2007/11/15/fips-140-2-and-ent-validation-vs-ring-rng/#comments</comments>
		<pubDate>Thu, 15 Nov 2007 09:20:13 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[Embedded Linux]]></category>
		<category><![CDATA[Hardware design]]></category>

		<guid isPermaLink="false">http://warmcat.com/_wp/2007/11/15/fips-140-2-and-ent-validation-vs-ring-rng/</guid>
		<description><![CDATA[NIST lists some more test suites.  NIST also have their own suite, but it is now Windows-only, and lacks a necessary DLL to run there.  The last UNIX version segfaulted here before giving any results&#8230; sigh.  
I ran the last 10MByte sample against ENT and TestU01&#8230; to cut a long story short
$ [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://csrc.nist.gov/groups/ST/toolkit/rng/batteries_stats_test.html">NIST</a> lists some more test suites.  NIST also have their own suite, but it is now Windows-only, and lacks a necessary DLL to run there.  The last UNIX version segfaulted here before giving any results&#8230; sigh.  </p>
<p>I ran the last 10MByte sample against <a href="http://www.fourmilab.ch/random/">ENT</a> and <a href="http://www.iro.umontreal.ca/~simardr/testu01/TestU01.zip">TestU01</a>&#8230; to cut a long story short</p>
<blockquote><p><font size=-2>$ ./ent ../die.c/dump3<br />
Entropy = 7.999980 bits per byte.</p>
<p>Optimum compression would reduce the size<br />
of this 10002432 byte file by 0 percent.</p>
<p>Chi square distribution for 10002432 samples is 281.26, and randomly<br />
would exceed this value 25.00 percent of the times.</p>
<p>Arithmetic mean value of data bytes is 127.4958 (127.5 = random).<br />
Monte Carlo value for Pi is 3.140111525 (error 0.05 percent).<br />
Serial correlation coefficient is -0.000212 (totally uncorrelated = 0.0).</font></p></blockquote>
<p>7.9999 bits of entropy per byte!  TestU01 is less turnkey than the other suites &#8212; it&#8217;s literally a test library with some example code.  I amended an example to call the FIPS-140-2 tests:</p>
<blockquote><pre><font size=-2>============== Summary results of FIPS-140-2 ==============

 File:             dump3
 Number of bits:   20000

       Test          s-value        p-value    FIPS Decision
 --------------------------------------------------------
 Monobit               9933           0.83       Pass
 Poker                11.88           0.69       Pass

 0 Runs, length 1:     2482                      Pass
 0 Runs, length 2:     1227                      Pass
 0 Runs, length 3:      630                      Pass
 0 Runs, length 4:      319                      Pass
 0 Runs, length 5:      161                      Pass
 0 Runs, length 6+:     166                      Pass

 1 Runs, length 1:     2466                      Pass
 1 Runs, length 2:     1302                      Pass
 1 Runs, length 3:      620                      Pass
 1 Runs, length 4:      311                      Pass
 1 Runs, length 5:      140                      Pass
 1 Runs, length 6+:     146                      Pass

 Longest run of 0:       16           0.14       Pass
 Longest run of 1:       14           0.46       Pass
 ----------------------------------------------------------
 All values are within the required intervals of FIPS-140-2</font></pre>
</blockquote>
<p>So the design&#8217;s output is compliant to FIPS-140-2, a requirement for many uses.</p>
]]></content:encoded>
			<wfw:commentRss>http://warmcat.com/_wp/2007/11/15/fips-140-2-and-ent-validation-vs-ring-rng/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AT91RM9200 FIQ FAQ and simple Example code / patch</title>
		<link>http://warmcat.com/_wp/2007/09/17/at91rm9200-fiq-faq-and-simple-example-code-patch/</link>
		<comments>http://warmcat.com/_wp/2007/09/17/at91rm9200-fiq-faq-and-simple-example-code-patch/#comments</comments>
		<pubDate>Mon, 17 Sep 2007 08:34:29 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[Embedded Linux]]></category>

		<guid isPermaLink="false">http://warmcat.com/_wp/?p=40</guid>
		<description><![CDATA[One of the coolest features of the AT91RM9200 we have been designing with for a couple of years now is the FIQ, or Fast Interrupt Request.  This is basically the NMI of the ARM world.  It is a bit difficult to get working (Milosch Meriac helped me with the initial version some years [...]]]></description>
			<content:encoded><![CDATA[<p><img src="/parachute.png" align=left hspace=5>One of the coolest features of the AT91RM9200 we have been designing with for a couple of years now is the FIQ, or Fast Interrupt Request.  This is basically the NMI of the ARM world.  It is a bit difficult to get working (Milosch Meriac helped me with the initial version some years ago) because its job is to interrupt WHATEVER is happening and start running your FIQ handler within 1us or so NO EXCUSES.  This is the very very hard end of hard realtime, it does what it claims but it does not respect any privacy that Linux may need as an OS and we will see that needs care.</p>
<p><a href = "/at91-fiq.patch">Here is a patch against 2.6.20 with the AT91RM9200 patches</a>: it should probably apply okay to later kernels.  The patch adds many comments so you probably want to read that and this at the same time.  First the things you can&#8217;t do, which will save you much pain from finding them out yourself.</p>
<h3>Things you can&#8217;t do with FIQ</h3>
<p>One of the &#8220;private times&#8221; Linux needs to itself is the virtual memory pagetable management action.  It shuts off all interrupts and rewrites the pagetable at intervals, and then goes on as before.  That stops driver interrupts coming in and trying to do stuff while the pagetable is empty, or incomplete or just full of garbage.</p>
<p>However FIQ ignores any claim to privacy performed by shutting off normal interrupt response.  That means your FIQ ISR code can come in at a &#8220;bad time&#8221;, if it tries to access memory areas mapped through the pagetable it will instead find nothing or the wrong thing or&#8230;  the end result is that <b>the FIQ ISR cannot touch any memory mapped by vmalloc</b>.</p>
<p>Unfortunately, when a kernel module is loaded, its various memory footprints including the module code are allocated by&#8230; yep, vmalloc.  That means <b>your FIQ ISR code cannot live in a module, it has to be part of the monolithic kernel</b>.</p>
<p>Finally all sorts of Linux code also wants &#8220;private time&#8221; or to guard against multiple access to objects by spinlocks or whatever.  FIQ ISRs cannot play those games, it comes it in the middle of anything and has to get out quickly again too.  So <b>unless it is a simple macro, you can&#8217;t use any Linux APIs in the FIQ ISR</b>.</p>
<h3>Things you can do with FIQ</h3>
<p>Well reading those constraints, you&#8217;re probably wondering if it is still useful.  It sure is!  </p>
<p>You can touch the memory-mapped IO in the chip using the AT91RM9200 APIs.</p>
<p>FIQ has the super power it will run your ISR within ~1us NO EXCUSES.  That means you can rely on the ISR code to act like hardware, you trigger it and 1us later your programmed sequence occurs without fail.  In turn that means FIQ is perfect for many hardware interfacing tasks, in particular management of low latency (small buffer) PDC DMA setup.</p>
<p>Low latency for audio traffic for example is highly desirable, but of course if there are ANY delays setting up the next PDC DMA, you get dropouts and clicks.  If you allow the FIQ to handle generation of samples and management of PDC DMA, there won&#8217;t be any delays for sure, you will have perfect audio.</p>
<p>We found that the AT91RM9200 at 180MHz can easily handle 8kHz FIQs (a common rate for telephony) with an ISR duration of ~8us, without affecting the Ethernet or USB performance.</p>
<h3>IPC between the FIQ and kernel worlds</h3>
<p>The general communication for FIQ ISRs with the &#8220;real world&#8221; in the patch is to define a struct in include/asm-arm/arch-at91rm9200/at91rm9200_fiq_ipc_type.h that contains all of the data that is shared between FIQ and normal kernel code.  The example one looks like this:</p>
<p><code>
<pre>struct at91rm9200_fiq_ipc {
	int nCountFiqEvents;
};</pre>
<p></code></p>
<p>One of these structs is defined in the main part of the patch code in arch/arm/mach-at91rm9200/at91_fiq.c like this</p>
<p><code>struct at91rm9200_fiq_ipc at91rm9200_fiq_ipc;<br />
EXPORT_SYMBOL(at91rm9200_fiq_ipc);</code></p>
<p>That means in your other kernel code &#8212; which can be in a module, only the FIQ ISR must be in the kernel &#8212; you can have</p>
<p><code>
<pre>#include &lt;arch/at91rm9200_fiq_ipc_type.h&gt;
extern struct at91rm9200_fiq_ipc at91rm9200_fiq_ipc;</pre>
<p></code></p>
<p>and use the same struct to communicate with the FIQ ISR.</p>
<h3>How to customize summary</h3>
<p>1) Change struct at91rm9200_fiq_ipc in include/asm-arm/arch-at91rm9200/at91rm9200_fiq_ipc_type.h to have the data types you need</p>
<p>2) Add your FIQ ISR code to arch/arm/mach-at91rm9200/at91_fiq.c where it says &#8220;your C code goes here&#8221;</p>
<p>3) Import extern struct at91rm9200_fiq_ipc at91rm9200_fiq_ipc; in your own kernel module and communicate with the FIQ ISR using that.</p>
<h3>FIQ shadowing with IRQ</h3>
<p>Ultimately the FIQ actions are going to need to interface to Linux kernel objects sooner or later, perhaps there has to be some locking or blocking action for usermode access.  But we are banned from using Linux APIs in the FIQ ISR.  </p>
<p>A powerful solution is to physically tie the FIQ signal to an IRQ input additionally.  Code that is REALLY hard realtime, like the PDC DMA management, goes in FIQ, and a count of FIQs is kept.  Data out of FIQ can go into a software FIFO.  The less reliable IRQ watches the count of FIQs and compares it to its own count of IRQs, if it sees it has blacked out and has fallen behind, it will loop up to a certain number of times &#8220;catching up&#8221;, using the data placed by FIQ in the FIFO.</p>
<p>In this way, by splitting the code into &#8220;no excuses&#8221; realtime in the FIQ ISR, and &#8220;reliable only on average&#8221; realtime in the IRQ ISR, it is possible to bind actions in the FIQ to code in the ISR which can execute Linux APIs, and have the best of both worlds.</p>
]]></content:encoded>
			<wfw:commentRss>http://warmcat.com/_wp/2007/09/17/at91rm9200-fiq-faq-and-simple-example-code-patch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Embedded procmail and dovecot</title>
		<link>http://warmcat.com/_wp/2007/09/06/embedded-procmail-and-dovecot/</link>
		<comments>http://warmcat.com/_wp/2007/09/06/embedded-procmail-and-dovecot/#comments</comments>
		<pubDate>Thu, 06 Sep 2007 14:35:46 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[Embedded Linux]]></category>

		<guid isPermaLink="false">http://warmcat.com/_wp/?p=37</guid>
		<description><![CDATA[For over a year I have been using an 32MB ARM9-based board I designed with a 1GB USB stick as my mailserver.  It is powered from a USB port on my firewall box and takes around 1W.  
I use our Octotux Linux distro with Postfix as the MTA, gps for the greylisting and [...]]]></description>
			<content:encoded><![CDATA[<p><img src="/spiral.png" hspace=5 align=left>For over a year I have been using an 32MB ARM9-based board I designed with a 1GB USB stick as my mailserver.  It is powered from a USB port on my firewall box and takes around 1W.  </p>
<p>I use our <a href="http://octotux.com">Octotux Linux distro</a> with Postfix as the MTA, gps for the greylisting and Dovecot IMAP to provide secure access to the mailstore over SSL.  This has worked out really well, the warmcat.com MX record points directly to the external IP here, and the firewall box port-forwards port 25 to the embedded device.  It&#8217;s silent and runs cold 24 hours a day and has never missed a beat.</p>
<p>A couple of weeks ago I had to look at the box again because the greylisting software was hanging.  I discovered that we were being bombarded with spam, one new spam every two seconds on average, from all over the world.  I adjusted the ordering of the filtering in postfix to first reject on an unknown username, that stopped so many concurrent gps sessions being needed.  The server weathered that storm and the spam people gave up a few days later without getting a single one through.  (They were also targeting the warmcat.com A record IP, I suppose in case it was a backup for the real MX, but they had zero luck with that either).</p>
<p>However it reminded me of the one inadequacy of this mailserver&#8230; when you wake up your laptop in the morning, thunderbird takes ages to run all the filters and move the new mails remotely into the right IMAP folders.  That&#8217;s pretty annoying when you see the titles of mails you want to read but the USB stick on the server is maxxed out for a couple of minutes sorting eight hours worth of new emails into folders on the server.  I have been pondering changing the box to one with USB2 High Speed, but it occurred to me that otherwise, the existing USB 1.1 &#8220;Full Speed&#8221;, that is, 12Mbps is completely adequate.  Changing folders and moving to other emails in thunderbird is snappy.  It&#8217;s just the client mail filters under the load of 500 mails in the morning.  So I decided to port procmail to ARM9 Octotux, in effect to do the folder sorting as each mail came in, so there would no longer be any processing done at the client for that.</p>
<p><span id="more-37"></span><br />
Procmail was a little bit of a beast, the sources look horrible and it uses a nonstandard autotools script, which of course does not support crosscompile.  After a couple of hours I got it to build nicely in an Octotux RPM (Octotux is entirely crosscompiled RPM-based).  Not having used it before, I was surprised to see there was no configuration down /etc in the package, just four small binaries in /usr/bin and some manuals (which I broke out into procmail-docs package so as not to waste space on the target).  The binary package only came to 60K all told.</p>
<p>The first move was to direct postfix to deliver not to the maildir as before but through procmail.  This simply involved editing /etc/postfix/main.cf and adding this</p>
<p><code>mailbox_command = /usr/bin/procmail</code></p>
<p>After some googling I found that procmail is going to look at the unix user&#8217;s homedir that the mail is directed to, for a file ~/.procmailrc in order to find out what it should do.  Now my embdedded mailserver is setup to use Dovecot IMAP with the mailstore symlinked to the USB stick.  So my user &#8220;andy&#8221; on the embedded mailserver has this in the home dir</p>
<p><code># ll /home/andy<br />
lrwxrwxrwx    1 root     root           25 Jan 17  2007 Maildir -> /media/usbstick/mail/andy</code></p>
<p>I found looking around in the Dovecot Maildir structure in there that the mail needs to be delivered into /home/andy/Maildir/.(foldername)/new/ in order to get Dovecot to understand that it was given a new mail in a folder.  The resulting /home/andy/.procmailrc looks like this:</p>
<p><code>SHELL=/bin/sh<br />
PATH="/usr/bin:/usr/local/bin:/bin:/sbin:/usr/sbin"<br />
LOCKFILE=/home/andy/lockfile.loc<br />
DEFAULT=/home/andy/Maildir/<br />
BITBUCKET=/dev/null<br />
LOCKTIMEOUT=10<br />
LOGFILE=/tmp/procmail_log<br />
LOGABSTRACT=no<br />
VERBOSE=no</p>
<p>:0:<br />
* ^List-Id: For users of Fedora <fedora-list.redhat.com><br />
$DEFAULT/.fedora-list/new</p>
<p>:0:<br />
* ^List-Id: Development discussions related to Fedora<br />
$DEFAULT/.fedora-devel-list/new</code></p>
<p>You simply repeat the last stanzas with some unique identifying header part of mails that are to be filed in a given folder, and give the destination folder name preceded by a &#8216;.&#8217; and followed by /new as shown.  You don&#8217;t need to run anything or restart anything after making changes here, they will be immediately used on the next email that is delivered.  If your folder lives in a hierarchy, the folder on disk looks like, for example, .INBOX.CentOS for a folder CentOS that appears as a child of INBOX.  The stanza for that would look like</p>
<p><code>:0:<br />
* ^List-Id: CentOS mailing list <centos.centos.org><br />
$DEFAULT/.INBOX.CentOS/new</code></p>
<p>You can also direct procmail to use a central procmailrc file, presumably in /etc, by giving the path to it on the procmail invocation line in /etc/postfix/main.cf.  In my case I only take mails for myself, so I stuck with the per-user ~/.procmailrc.</p>
<p>No changes were needed anywhere else in the server setup, all I had to do was turn off all my thunderbird filters and enjoy immediate access to the emails via Dovecot IMAP in the morning, without upgrading any hardware.</p>
]]></content:encoded>
			<wfw:commentRss>http://warmcat.com/_wp/2007/09/06/embedded-procmail-and-dovecot/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>mac80211 Injection patches accepted in Linus git tree</title>
		<link>http://warmcat.com/_wp/2007/07/16/mac80211-injection-patches-accepted-in-linus-git-tree/</link>
		<comments>http://warmcat.com/_wp/2007/07/16/mac80211-injection-patches-accepted-in-linus-git-tree/#comments</comments>
		<pubDate>Mon, 16 Jul 2007 16:19:32 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[Embedded Linux]]></category>

		<guid isPermaLink="false">http://warmcat.com/_wp/?p=33</guid>
		<description><![CDATA[After getting on for four months, my mac80211 injection patches have been accepted by the powers-that-be and have made their way into the Linus git repo, the crucible from which vanilla kernel versions are forged, and the upstream from which all major distros are ultimately basing their kernels on.  (Edit: they are present in [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://warmcat.com/driving.png" alt="ultracompact car" align=left valign=top />After getting on for four months, my mac80211 injection patches have been accepted by the powers-that-be and have made their way into the Linus git repo, the crucible from which vanilla kernel versions are forged, and the upstream from which all major distros are ultimately basing their kernels on.  (Edit: they are present in 2.6.23-rc1 also).</p>
<p>Assuming nothing bad happens in the next few weeks leading to their being reverted (unlikely I would think, since they don&#8217;t interfere with much existing code), then a standardized driver-independent ieee80211 packet injection methodology will soon be available by default in all major distro kernels.  Currently if you want to perform packet injection, you enter into a dark underworld of individual driver patching, having to cook custom kernels and make animal sacrifices to forgotten Gods.  But now with the injection patches, for the devices with mac80211 drivers all that crap is blown away and every 2.6.23 kernel will offer the capability built-in.</p>
<p>Here are the list of mac80211 drivers and whether I have actually seen good injection.  All of the drivers are expected to work, but I don&#8217;t have all the hardware.</p>
<table>
<tr>
<td><b>mac80211 driver</b></td>
<td><b>Personally Tested</b></td>
</tr>
<tr>
<td>adm8211</td>
<td>no</td>
</tr>
<tr>
<td>bcm43xx</td>
<td>yes</td>
</tr>
<tr>
<td>iwl3945</td>
<td>yes</td>
</tr>
<tr>
<td>iwl4965</td>
<td>no</td>
</tr>
<tr>
<td>p54</td>
<td>no</td>
</tr>
<tr>
<td>rt2&#215;00</td>
<td>no (pending)</td>
</tr>
<tr>
<td>zd1211rw</td>
<td>yes</td>
</tr>
</table>
<p>I have also provided the <a href="http://penumbra.warmcat.com/_twk/tiki-index.php?page=packetspammer">Packetspammer</a> commandline applet to show how to use the injection API from userspace, this provides a simple, GPL2 tested base for making your own injection code for your own apps.  </p>
<p>Work started on it in Dec 2006 by providing the old Linux stack driver patches.  The real reason for the sustained effort is to enable <a href="http://penumbra.warmcat.com">Penumbra</a> to work &#8220;out of of the box&#8221; on not only Linux desktops and laptops but generic embedded devices as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://warmcat.com/_wp/2007/07/16/mac80211-injection-patches-accepted-in-linus-git-tree/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Bonsai code-kittens</title>
		<link>http://warmcat.com/_wp/2007/03/31/bonsai-code-kittens/</link>
		<comments>http://warmcat.com/_wp/2007/03/31/bonsai-code-kittens/#comments</comments>
		<pubDate>Sat, 31 Mar 2007 08:50:42 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[Embedded Linux]]></category>

		<guid isPermaLink="false">http://warmcat.com/_wp/?p=30</guid>
		<description><![CDATA[The last few months I have been working on the Penumbra project.  I started off patching wireless drivers in and out of the kernel tree to achieve the anonymous broadcast action that the project needs, but it became clear this would be completely unworkable for general use&#8230; getting wireless up in Linux can still [...]]]></description>
			<content:encoded><![CDATA[<p><img align=left src="http://warmcat.com/illustration-80col.png" alt="80 column limit" />The last few months I have been working on the <a href="http://penumbra.warmcat.com">Penumbra</a> project.  I started off patching wireless drivers in and out of the kernel tree to achieve the anonymous broadcast action that the project needs, but it became clear this would be completely unworkable for general use&#8230; getting wireless up in Linux can still be a struggle and hoping people will patch their driver or kernel in addition isn&#8217;t going to happen.  After trying a couple of other methods in the end I created a radiotap-based packet injection patch for the mac80211 stack (formerly dscape / d80211), and bound it together with a patch from Michael Wu that provides radiotap-based Monitor mode.  At the moment it is still in front of the linux-wireless folks and it&#8217;s not clear what the result will be.  If the patch is accepted, then the code should make it into the mainline kernel and all mac80211-based wireless drivers will work with Penumbra out of the box in the future.  The patchset provides generic radiotap monitoring injection that &#8220;just works&#8221; with libpcap both ways, so I am hoping it will get accepted without people having to form an opinion about Penumbra.</p>
<p>But one of the biggest hurdles in creating the patch was not technical, since I already had the core functionality working, but in fact the Linux kernel coding style.  In some ways the coding style fits well with my own personal style (formed over 20 years of writing C and C++), we basically use the same K&#038;R style.  There are some spacing and commenting rules that are actually better than my style and I will adopt them wholesale.  But that&#8217;s where the fun stops and the recrimination begins!</p>
<p><span id="more-30"></span><br />
The basic problem is the combination of three rules which has a terrible effect on eliminating what I consider good coding practice due to the constraints introduced by those rules.</p>
<ul>
<li>Tabs are 8 chars NO EXCEPTIONS</li>
<li>Lines are less than 80 cols NO EXCEPTIONS</li>
<li>Everything in { } is indented by a tab (except switch cases!)</li>
</ul>
<p>Now almost everything is inside a function body, so that gets you down to 72 chars already.  And if your function is doing something non-trivial, your code is probably inside a while() for a for() and there are one or more levels of if() to decide to do it or not.  Pretty soon you are writing code crushed up against the 80-col limit with only 30 chars that are usable and 50 spaces behind it.  It strongly puts me in mind of the Bonsai Kittens fake website that showed how to push kittens into bottles so they would grow into the shape of the bottle.</p>
<p>Under these abnormal circumstances, certain things become very difficult to do:</p>
<ul>
<li>\t\t\t\t\t&#8221;any kind of long &#8221; \n\t\t\t\t\t &#8220;string has to be &#8221; \n\t\t\t\t\t &#8220;artificially chopped up&#8221;</li>
<li>nested if()s may make perfect sense to explain your code logic.  But you can no longer afford them because of the tab each one adds.  So you have to invert the if() sense and use a goto (I kid you not, this is preferred due to the coding style rules)</li>
<li>I strongly prefer descriptive variable names which include type.  Type is part of the information you need to understand what that variable is when looking at it.  &#8220;nCountWaysILoveHer&#8221; tells me (now, and in 6 months when I have forgotten the code) it is an int that is counting a specific thing.  &#8220;i&#8221; or &#8220;cnt&#8221; could be anything, although &#8220;cnt&#8221; is better.  But you can&#8217;t afford a long variable name with the rules above, you can get into a situation where there is not even enough room left after the tabbing to hold just the variable name on a single line.</li>
</ul>
<p>On that last point there is some handwaving nonsense in the coding style doc for Linux that &#8220;C programmers don&#8217;t use long variable names&#8221;&#8230; well I call bullshit on that one.  The truth is that because of the other tabbing and length rules, <strong>Kernel</strong> C programmers <strong>can&#8217;t</strong> use long variable names even if they realized it was better: they ran out of room for it.</p>
<p>To be fair to the coding style doc it does have a point when talking about what to do when the indents get too much: it suggests to break the indented content out into a new function and to call through to it.  It also says that massively indented code means you were screwed anyway, because the logic was too complicated, and that can also be true.  But calling through to functions can be a very bad fit if the code you are migrating out touches many variables defined at the parent function top level.</p>
<p>I am still working through the style rules trying to see what I should take on board to replace my own style and what I have to &#8220;fake&#8221; just for kernel code, but it seems to me life would be better for everyone if they relaxed the line length to 120 chars instead of 80.</p>
]]></content:encoded>
			<wfw:commentRss>http://warmcat.com/_wp/2007/03/31/bonsai-code-kittens/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nasty Crash at Luton Airport</title>
		<link>http://warmcat.com/_wp/2007/03/04/nasty-crash-at-luton-airport/</link>
		<comments>http://warmcat.com/_wp/2007/03/04/nasty-crash-at-luton-airport/#comments</comments>
		<pubDate>Sun, 04 Mar 2007 09:03:26 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[Embedded Linux]]></category>

		<guid isPermaLink="false">http://warmcat.com/_wp/?p=29</guid>
		<description><![CDATA[
Makes no sense to have a license to Mordor for each of the hundreds of plasma displays at Luton Airport.  It sparked a conversation with my stepson about why it was chosen: presumably because the devs didn&#8217;t know anything else than Windows, they will spend the rest of their working life acting as agents [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://warmcat.com/luton-airport.jpg" alt="Plasma display at Luton Airport shows Windows BSOD" /></p>
<p>Makes no sense to have a license to Mordor for each of the hundreds of plasma displays at Luton Airport.  It sparked a conversation with my stepson about why it was chosen: presumably because the devs didn&#8217;t know anything else than Windows, they will spend the rest of their working life acting as agents for Microsoft.  This is the fruit of the Jesuit priest Ballmer&#8217;s creed of &#8220;give me a developer until he has 7 months in the industry and I will give you a Microsoft Trained Monkey&#8221;.</p>
<p>Using the same or cheaper hardware, an embedded Linux implementation would have had at least the same performance and much more flexibility.  Ogg Matroska is a patent-free high quality video solution that plays back out of the box on Fedora for example.  And if you wanted a hundred or a thousand displays your software licensing costs would stay at exactly $0.</p>
]]></content:encoded>
			<wfw:commentRss>http://warmcat.com/_wp/2007/03/04/nasty-crash-at-luton-airport/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Octotux Packaged Linux Distro</title>
		<link>http://warmcat.com/_wp/2007/01/27/octotux-packaged-linux-distro/</link>
		<comments>http://warmcat.com/_wp/2007/01/27/octotux-packaged-linux-distro/#comments</comments>
		<pubDate>Sat, 27 Jan 2007 16:18:57 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[Embedded Linux]]></category>

		<guid isPermaLink="false">http://warmcat.com/_wp/?p=27</guid>
		<description><![CDATA[For the last couple of years I have been working with the AT91RM9200 ARM9 chip from Atmel.  This is a very nice, fast, cheap CPU when combined with some SDRAM and NOR flash.  One of the bigger problems I faced getting started with it was managing the sheer amount of sources that go [...]]]></description>
			<content:encoded><![CDATA[<p>For the last couple of years I have been working with the <a href="http://www.atmel.com/dyn/products/product_card.asp?part_id=2983">AT91RM9200</a> ARM9 chip from Atmel.  This is a very nice, fast, cheap CPU when combined with some SDRAM and NOR flash.  One of the bigger problems I faced getting started with it was managing the sheer amount of sources that go into a modern Linux implementation.  Many embedded folk just generate a giant tarball which is their whole root filesystem, they don&#8217;t track what versions are where and as a result providing sources for their magic tarballs can be a pain in the ass for them.</p>
<p>I knew I didn&#8217;t want to repeat this method from the start, so I began to work towards being able to use the RPM packaging system even with my crosscompiled stuff.  Having the full RPM app and database doesn&#8217;t make sense for an Embedded system though, for example our standard AT91RM9200 platform only has 8MB of flash for all nonvolatile storage.  I found that the excellent busybox had the start of an rpm implementation already, but although the code was really well-written, the implementation was not complete enough to do anything useful: it did not keep a database and there was therefore no possibility to erase packages, for example.</p>
<p>Over a few months I added more functionality to the busybox applet, including keeping a &#8220;database&#8221; of installed RPM headers down /var/lib to emulate most of the capabilities of real RPM.  With this in place, I then went on to package all of the apps that I was interested to run on my distro.  There are numerous advantages to formalizing the management of code into packages once you accept that you will only place packaged stuff on the device.</p>
<p>Creating an RPM binary also creates a source RPM (SRPM) that is contains all of the sources and build specification for that binary, and both the binary and source are versioned.  Therefore so long as you offer the matching SRPM at the same time as you give someone the binary RPM, your GPL requirements for giving sources are solved in one stroke.</p>
<p>The patchlevel of any device can now be interrogated and used to select updates as well, in a formal manner.  You can also express the need in a package to have &#8220;required&#8221; dependent packages of specific versions, reflecting a common situation where after some release you need a library of a certain version for it to work.</p>
<p>The &#8220;cost&#8221; for this level of control over your device boil down to: no more ad-hoc building.  Even development builds are done through rpm packages.  We provide a script that will remotely install over scp and ssh the latest version of a given package from the host commandline, even one that rebuilds the package before installing it remotely, and for every single edit you can be certain the sources are captured in the SRPM.  We found a typical system is using only 100K of uncompressed data (typ 50K on jffs2) to maintain the RPM headers that make the packaging work.  That is not significant even on a box with only 8MBytes of Flash.</p>
<p>Check out the Wiki at http://octotux.org for more details and the repository which contains the packages.</p>
]]></content:encoded>
			<wfw:commentRss>http://warmcat.com/_wp/2007/01/27/octotux-packaged-linux-distro/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
