<?xml version="1.0" encoding="iso-8859-1" ?>
<rss version="2.0"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:content="http://purl.org/rss/1.0/modules/content/"
  xmlns:wfw="http://wellformedweb.org/CommentAPI/"
  >

 <channel>
  <title><![CDATA[Natulte::Blog]]></title>
  <link>http://natulte.net/index.php/blog</link>
  <description><![CDATA[]]></description>
  <copyright>Copyright 2009, David Anderson</copyright>
  <language>fr</language>
  <generator>Zwe v2.6-angela, http://zwe.bulix.org</generator>
  <pubDate>Mon, 21 Dec 2009 14:01:24 +0100</pubDate>
  <dc:creator>David Anderson</dc:creator>
  <item>
   <title><![CDATA[How to write a good changelog]]></title>
   <link>http://natulte.net/index.php/blog/555</link>
   <description>
I've just read through the Python 3.1 changelog, and it has encouraged me to write up something that I've wanted to say for a while, but never quite got round to: dear open source developer, please write good changelogs for your project.What do I mean by changelogs? Historically, the term has meant something akin to "Our version control system sucks, we need to keep track of logical changes by hand". This leads to a "changelog" that looks something like this:



1999-03-24  Stan Shebs  address@removed

	* configure.host (mips-dec-mach3*): Use mipsm3, not mach3.
	
	Attempt to sort out SCO-related configs.  

	* configure.host (i[3456]86-*-sysv4.2*): Use this instead of
	i[3456]86-*-sysv4.2MP and i[3456]86-*-sysv4.2uw2*.
	(i[3456]86-*-sysv5*): Recognize this.

	* configure.tgt (i[3456]86-*-sco3.2v5*, i[3456]86-*-sco3.2v4*):
	Recognize these.




If you're like any developer not involved with the project, that changelog entry is a complete parse error. You have no idea what the actual change is, whether you should care, whether the change was cosmetic or semantic... A compiler analogy would be that if the version control logs are machine code, this is a barely decorated disassembly.

Humans generally don't want to read a disassembly of version control logs. They want to know what changed at a higher, human level, units of change that can be grokked in terms of new tools available to them, new syntax, new libraries, what they need to change in their data to ensure compatibility...

A good changelog doesn't just disassemble version control logs. It presents an executive summary of a whole slew of changes, in terms that make it clear why I, the end user, should be giving a damn.

Thanks for your attention.
   </description>
   <author><![CDATA[David Anderson]]></author>
   <category><![CDATA[English]]></category>
   <category><![CDATA[Geek]]></category>
   <guid>http://natulte.net/index.php/blog/555</guid>
   <pubDate><![CDATA[Mon, 21 Dec 2009 14:01:24 +0100]]></pubDate>
   <dc:creator><![CDATA[David Anderson]]></dc:creator>
   <content:encoded><![CDATA[<p>
I've just read through the Python 3.1 changelog, and it has encouraged me to write up something that I've wanted to say for a while, but never quite got round to: dear open source developer, please write good changelogs for your project.<br /><br />What do I mean by changelogs? Historically, the term has meant something akin to &quot;Our version control system sucks, we need to keep track of logical changes by hand&quot;. This leads to a &quot;changelog&quot; that looks something like this:</p>

<div class="cmd">
<pre>
1999-03-24  Stan Shebs  address@removed

	* configure.host (mips-dec-mach3*): Use mipsm3, not mach3.
	
	Attempt to sort out SCO-related configs.  

	* configure.host (i[3456]86-*-sysv4.2*): Use this instead of
	i[3456]86-*-sysv4.2MP and i[3456]86-*-sysv4.2uw2*.
	(i[3456]86-*-sysv5*): Recognize this.

	* configure.tgt (i[3456]86-*-sco3.2v5*, i[3456]86-*-sco3.2v4*):
	Recognize these.
</pre>
</div>
<p></p>
<p>
If you're like any developer not involved with the project, that changelog entry is a complete parse error. You have <strong>no idea</strong> what the actual change is, whether you should care, whether the change was cosmetic or semantic... A compiler analogy would be that if the version control logs are machine code, this is a barely decorated disassembly.</p>
<p>
Humans generally don't want to read a disassembly of version control logs. They want to know what changed at a higher, human level, units of change that can be grokked in terms of new tools available to them, new syntax, new libraries, what they need to change in their data to ensure compatibility...</p>
<p>
A good changelog doesn't just disassemble version control logs. It presents an executive summary of a whole slew of changes, in terms that make it clear why I, the end user, should be giving a damn.</p>
<p>
Thanks for your attention.</p>
   ]]></content:encoded>
   <wfw:commentRss>http://natulte.net/index.php/blog/rss/555/comments</wfw:commentRss>
  </item>

  <item>
   <title><![CDATA[Wtf, seriously]]></title>
   <link>http://natulte.net/index.php/blog/556</link>
   <description>
Ever get cold-called on your phone by a Ghanan 419 scammer? I just did.

What the fuck. Seriously.
   </description>
   <author><![CDATA[David Anderson]]></author>
   <category><![CDATA[English]]></category>
   <guid>http://natulte.net/index.php/blog/556</guid>
   <pubDate><![CDATA[Sun, 14 Jun 2009 03:42:59 +0200]]></pubDate>
   <dc:creator><![CDATA[David Anderson]]></dc:creator>
   <content:encoded><![CDATA[<p>
Ever get cold-called on your <strong>phone</strong> by a Ghanan 419 scammer? I just did.</p>
<p>
What the fuck. Seriously.</p>
   ]]></content:encoded>
   <wfw:commentRss>http://natulte.net/index.php/blog/rss/556/comments</wfw:commentRss>
  </item>

  <item>
   <title><![CDATA[Don't panic]]></title>
   <link>http://natulte.net/index.php/blog/554</link>
   <description>
It's Towel Day. Know where your towel is, and remember Douglas.

Heading out to California for a week or so. My towel is in my travel bag. Where is yours?
   </description>
   <author><![CDATA[David Anderson]]></author>
   <category><![CDATA[English]]></category>
   <category><![CDATA[Life]]></category>
   <guid>http://natulte.net/index.php/blog/554</guid>
   <pubDate><![CDATA[Mon, 25 May 2009 05:08:20 +0200]]></pubDate>
   <dc:creator><![CDATA[David Anderson]]></dc:creator>
   <content:encoded><![CDATA[<p>
It's <a href="http://www.towelday.org">Towel Day</a>. Know where your towel is, and remember Douglas.</p>
<p>
<em>Heading out to California for a week or so. My towel is in my travel bag. Where is yours?</em></p>
   ]]></content:encoded>
   <wfw:commentRss>http://natulte.net/index.php/blog/rss/554/comments</wfw:commentRss>
  </item>

  <item>
   <title><![CDATA[New times, new skin]]></title>
   <link>http://natulte.net/index.php/blog/552</link>
   <description>
Sam graciously presented me today with a new CSS stylesheet for my Zwe blog. It really was time for a bit of a change, as the previous stylesheet was starting to show its age after many upgrades and changes to the underlying engine. Hope you like it. I certainly do.

Thanks Sam!
   </description>
   <author><![CDATA[David Anderson]]></author>
   <category><![CDATA[English]]></category>
   <guid>http://natulte.net/index.php/blog/552</guid>
   <pubDate><![CDATA[Sun, 22 Mar 2009 00:33:10 +0100]]></pubDate>
   <dc:creator><![CDATA[David Anderson]]></dc:creator>
   <content:encoded><![CDATA[<p>
<a href="http://bulix.org">Sam</a> graciously presented me today with a new CSS stylesheet for my <a href="http://zwe.bulix.org/">Zwe</a> blog. It really was time for a bit of a change, as the previous stylesheet was starting to show its age after many upgrades and changes to the underlying engine. Hope you like it. I certainly do.</p>
<p>
Thanks Sam!</p>
   ]]></content:encoded>
   <wfw:commentRss>http://natulte.net/index.php/blog/rss/552/comments</wfw:commentRss>
  </item>

  <item>
   <title><![CDATA[Sport]]></title>
   <link>http://natulte.net/index.php/blog/551</link>
   <description>
Dear diary,

Yesterday, I played Wii Sports for 5 hours. Today, I have aches in muscles I'd forgotten I had.

That was fun.
   </description>
   <author><![CDATA[David Anderson]]></author>
   <category><![CDATA[English]]></category>
   <category><![CDATA[Life]]></category>
   <guid>http://natulte.net/index.php/blog/551</guid>
   <pubDate><![CDATA[Mon, 02 Feb 2009 11:21:18 +0100]]></pubDate>
   <dc:creator><![CDATA[David Anderson]]></dc:creator>
   <content:encoded><![CDATA[<p>
Dear diary,</p>
<p>
Yesterday, I played Wii Sports for 5 hours. Today, I have aches in muscles I'd forgotten I had.</p>
<p>
That was fun.</p>
   ]]></content:encoded>
   <wfw:commentRss>http://natulte.net/index.php/blog/rss/551/comments</wfw:commentRss>
  </item>

  <item>
   <title><![CDATA[Permanence]]></title>
   <link>http://natulte.net/index.php/blog/550</link>
   <description>
Nothing hammers home the sense that your life has settled down for a while like signing a 1-year mobile phone contract that says "I'll be staying here at least a year".
   </description>
   <author><![CDATA[David Anderson]]></author>
   <category><![CDATA[English]]></category>
   <category><![CDATA[Français]]></category>
   <category><![CDATA[Life]]></category>
   <guid>http://natulte.net/index.php/blog/550</guid>
   <pubDate><![CDATA[Wed, 07 Jan 2009 15:01:33 +0100]]></pubDate>
   <dc:creator><![CDATA[David Anderson]]></dc:creator>
   <content:encoded><![CDATA[<p>
Nothing hammers home the sense that your life has settled down for a while like signing a 1-year mobile phone contract that says &quot;I'll be staying here at least a year&quot;.</p>
   ]]></content:encoded>
   <wfw:commentRss>http://natulte.net/index.php/blog/rss/550/comments</wfw:commentRss>
  </item>

  <item>
   <title><![CDATA[Levels of abstraction]]></title>
   <link>http://natulte.net/index.php/blog/549</link>
   <description>
I promise, I can explain. It started out rather simply, then got a little out of hand. A week or so later, I'm still having an immense amount of fun.

It all started when Google gave me an awesome Christmas present: An HTC Dream. It's a very shiny mobile phone, and what's more, it's an unlocked developer edition. It's hacking time!

This is where things get a bit complicated. Lemme take you through the reasoning.My first idea when I saw this beast was to try to get emulators running on it. A phone is nice, but a phone that can play vintage games is even better. I decided on playing with the Sega Genesis first, as I have rather fond memories of Sonic the Hedgehog.

First obstacle: Android (the open source OS that Google develops) currently can run only Java code. There is currently no open source Genesis emulator written in Java. Most of them are written in C, or in extreme cases, even in x86 assembler. There is currently no official way to execute native code on the android phone. I'd like to make this software available to everyone.

I therefore need to write a Genesis emulator in Java.

Okay, that should be simple. The Genesis is a relatively old console, so it can't be too elaborate. I mean, it's no PS3. All I need is an emulator for the CPU, a decoder for the ROM format, and some audio and graphics hookups within Android, and I should be good to go.

Well, first, the Genesis has three processors. A Motorola 68000 CPU, a Z80 sound processor, and a custom made graphics processor. Let's start with the 68k CPU. Apparently, there is no well known open source Java emulator for the 68k.

I therefore need to write a Motorola 68k emulator in Java.

But Java sucks. I mean, it's obviously a successful language, but I find no pleasure at all programming in Java. It is pure pain without an IDE on the level of Eclipse or Netbeans, and those IDEs aggravate me in various ways. The the the language language language is is is way way way too too too verbose verbose verbose (verbose verbose).

Plus, after consulting the 68k specs and sampling a few C implementations, it looks like an extremely repetitive task: most opcodes have around 20 variants, depending on addressing modes and various flag bits. It would be very tedious to implement this by hand, not only because it'd be in Java, but because it'd be even more mind numbing and uninteresting. However, the kinds of variants that are needed are quite amenable to be described at a high level, leaving the repetitive task of actual implementation to a program. And I can use a language that I enjoy for that, say, Python.

I therefore need to write a Motorola 68k emulator generator in Python.

After a bit of prototyping, I came to the conclusion that implementing this in Python would also be rather tedious, for a variety of reasons. First, I started off badly by writing a generator that goes straight from high level description language to a Java source code string, mushing several levels of abstraction together. Second, the description needed to generate the variants quickly lead me to combinatorial explosions, or to independent components that began interacting with each other in hilarious ways. Not good.

Plus, one day, when Android does have a supported way of running native code, I'd probably want an emulator in C or C++, running on the CPU directly, instead of under the Dalvik virtual machine. At which point all my work will have been for nothing.

I therefore need something of an emulator compiler, that parses the high level description into an execution tree for the opcode implementations, which a code generator then translates into a variety of output languages, such as Java, C++ or Brainfuck.

Python is nice, but I don't think that writing compilers is one of its fortes, despite what the PyPy folks appear to think. Manipulating the code representations is cumbersome at best, and the divide between the living Python code and the dead data it manipulates is rather wide. Manipulating code as data and vice versa is one of the often described merits of the Lisp family of programming languages. I've been wanting to get back to Common Lisp as a language and poke around with it more, and it feels like the ideal language in which to build a compiler. What could be more code-as-data-as-code than a program that takes apart a description of a program and puts it back together again in another form?

I therefore need to write an m68k emulator compiler in Common Lisp, at first targeting the Java programming language, and later possibly other languages.

And that is how, a week after Google gives me a mobile phone, I find myself writing Common Lisp code, for a compiler that compiles a lisp-like language into Java code, that will be compiled into Dalvik VM bytecode, running on an ARM-based embedded system, which when executed will emulate a Motorola 68000 CPU.

I feel like I've just had a Wikipedia attack. You know, that thing where you go to Wikipedia to look up something very specific, say how Tesla coils can be used to play music, and end up three hours later reading through an analysis of 14th century persian battle tactics, with no idea how you got there. That's kinda how I felt when I came up for air yesterday and looked back. "So, I got a phone... And now I'm writing a compiler... I'm pretty sure I have a good reason..."

Oh, and the emulator compiler is starting to work. I was very rusty in Common Lisp, but in a couple of days of hacking and prototyping, I'm starting to get somewhere. I can already generate the implementation of the simplest variant of the 68k ADD opcode. The "source" looks like this, with comments added



(instruction
   ;; Instruction name, with variant information.
   "add_dreg_to_dreg"

   ;; The description of the meaning of the 16 bits of the opcode.
   ((:literal 4 #b1101)      ; 4 constant bits, with the given binary value
    (output-register 3 dest) ; The output register, whose number is coded
                             ; over 3 bits. Its value is available in the
                             ; 'dest' variable.
    (:literal 6 #010000)     ; More constant bits, describing the addressing mode.
    (input-register 3 src))  ; Input register, similar declaration to dest.

   ;; How to perform this operation, in a subset of Common Lisp.
   (setf dest (+ src dest)))




The above instruction definition produces an opcode object that contains two things: information for the instruction decoder, so that it can identify this instruction, and the intermediate representation of the implementation of that instruction:



;; The constant bit values in the opcode, and the mask to test them,
;; for the instruction decoder.
(debug-print-opcode-mask the-above-opcode-object)

--&gt; Output: 1101---010000---

;; The intermediate representation of the implementation.
(opcode-ast the-above-opcode-object)

--&gt; (LET ((SRC (REGISTER-VALUE :DATA
                               (VM-OPCODE-BITS 3 0)))
          (DEST (WRITABLE-REGISTER-VALUE :DATA
                                         (VM-OPCODE-BITS 3 9))))
      (SETF DEST (+ DEST SRC)))




This opcode can then be fed to the Java code generator, to produce the output implementation:



(java-gen-opcode the-above-opcode-object)

--&gt; public static void op_add_dreg_to_dreg(unsigned short opcode) {
      unsigned long src = mDataRegisters[(opcode &gt;&gt; 0) &amp; 0x7];
      unsigned long dest = mDataRegisters[(opcode &gt;&gt; 9) &amp; 0x7];
      dest = dest + src;
      mDataRegisters[(opcode &gt;&gt; 9) &amp; 0x7] = dest;
    }




There is still a lot to be done. For one, the ADD opcode is supposed to update the CPU's state flags with information about the result of the addition. After that, the addressing modes other than to/from a numbered register must be supported. Implementing more opcodes will surely bring more things that need to be implemented.

Once a solid base is laid, a higher-still level of description must be layered on, so that all the variants of an instruction are produced from a single implementation definition. Once all that is done, a C++ backend would be nice. And why not attempt to generalize the compiler infrastructure, so as to support the compilation of emulators other than m68k CPUs?

By the time I get anywhere near that, I suspect that it will have become possible to easily write and release native code for Android, making all of my efforts unnecessary. But I don't care, this is damn fun!

Some people are of the opinion that I should get my head examined.
   </description>
   <author><![CDATA[David Anderson]]></author>
   <category><![CDATA[English]]></category>
   <category><![CDATA[Geek]]></category>
   <guid>http://natulte.net/index.php/blog/549</guid>
   <pubDate><![CDATA[Mon, 29 Dec 2008 06:43:36 +0100]]></pubDate>
   <dc:creator><![CDATA[David Anderson]]></dc:creator>
   <content:encoded><![CDATA[<p>
I promise, I can explain. It started out rather simply, then got a little out of hand. A week or so later, I'm still having an immense amount of fun.</p>
<p>
It all started when Google gave me an awesome Christmas present: An <a href="http://en.wikipedia.org/wiki/Google_phone">HTC Dream</a>. It's a very shiny mobile phone, and what's more, it's an unlocked developer edition. It's hacking time!</p>
<p>
This is where things get a bit complicated. Lemme take you through the reasoning.<br /><br />My first idea when I saw this beast was to try to get emulators running on it. A phone is nice, but a phone that can play vintage games is even better. I decided on playing with the Sega Genesis first, as I have rather fond memories of Sonic the Hedgehog.</p>
<p>
First obstacle: Android (the open source OS that Google develops) currently can run only Java code. There is currently no open source Genesis emulator written in Java. Most of them are written in C, or in extreme cases, even in x86 assembler. There is currently no official way to execute native code on the android phone. I'd like to make this software available to everyone.</p>
<p>
I therefore need to write a Genesis emulator in Java.</p>
<p>
Okay, that should be simple. The Genesis is a relatively old console, so it can't be too elaborate. I mean, it's no PS3. All I need is an emulator for the CPU, a decoder for the ROM format, and some audio and graphics hookups within Android, and I should be good to go.</p>
<p>
Well, first, the Genesis has three processors. A Motorola 68000 CPU, a Z80 sound processor, and a custom made graphics processor. Let's start with the 68k CPU. Apparently, there is no well known open source Java emulator for the 68k.</p>
<p>
I therefore need to write a Motorola 68k emulator in Java.</p>
<p>
But Java sucks. I mean, it's obviously a successful language, but I find no pleasure at all programming in Java. It is pure pain without an IDE on the level of Eclipse or Netbeans, and those IDEs aggravate me in various ways. The the the language language language is is is way way way too too too verbose verbose verbose (verbose verbose).</p>
<p>
Plus, after consulting the 68k specs and sampling a few C implementations, it looks like an extremely repetitive task: most opcodes have around 20 variants, depending on addressing modes and various flag bits. It would be very tedious to implement this by hand, not only because it'd be in Java, but because it'd be even more mind numbing and uninteresting. However, the kinds of variants that are needed are quite amenable to be described at a high level, leaving the repetitive task of actual implementation to a program. And I can use a language that I enjoy for that, say, Python.</p>
<p>
I therefore need to write a Motorola 68k emulator generator in Python.</p>
<p>
After a bit of prototyping, I came to the conclusion that implementing this in Python would also be rather tedious, for a variety of reasons. First, I started off badly by writing a generator that goes straight from high level description language to a Java source code string, mushing several levels of abstraction together. Second, the description needed to generate the variants quickly lead me to combinatorial explosions, or to independent components that began interacting with each other in hilarious ways. Not good.</p>
<p>
Plus, one day, when Android does have a supported way of running native code, I'd probably want an emulator in C or C++, running on the CPU directly, instead of under the Dalvik virtual machine. At which point all my work will have been for nothing.</p>
<p>
I therefore need something of an emulator compiler, that parses the high level description into an execution tree for the opcode implementations, which a code generator then translates into a variety of output languages, such as Java, C++ or Brainfuck.</p>
<p>
Python is nice, but I don't think that writing compilers is one of its fortes, despite what the PyPy folks appear to think. Manipulating the code representations is cumbersome at best, and the divide between the living Python code and the dead data it manipulates is rather wide. Manipulating code as data and vice versa is one of the often described merits of the Lisp family of programming languages. I've been wanting to get back to Common Lisp as a language and poke around with it more, and it feels like the ideal language in which to build a compiler. What could be more code-as-data-as-code than a program that takes apart a description of a program and puts it back together again in another form?</p>
<p>
I therefore need to write an m68k emulator compiler in Common Lisp, at first targeting the Java programming language, and later possibly other languages.</p>
<p>
And that is how, a week after Google gives me a mobile phone, I find myself writing Common Lisp code, for a compiler that compiles a lisp-like language into Java code, that will be compiled into Dalvik VM bytecode, running on an ARM-based embedded system, which when executed will emulate a Motorola 68000 CPU.</p>
<p>
I feel like I've just had a Wikipedia attack. You know, that thing where you go to Wikipedia to look up something very specific, say <a href="http://en.wikipedia.org/wiki/Tesla_coil#Popularity">how Tesla coils can be used to play music</a>, and end up three hours later reading through an analysis of 14th century persian battle tactics, with no idea how you got there. That's kinda how I felt when I came up for air yesterday and looked back. &quot;So, I got a phone... And now I'm writing a compiler... I'm pretty sure I have a good reason...&quot;</p>
<p>
Oh, and the emulator compiler is starting to work. I was very rusty in Common Lisp, but in a couple of days of hacking and prototyping, I'm starting to get somewhere. I can already generate the implementation of the simplest variant of the 68k <tt>ADD</tt> opcode. The &quot;source&quot; looks like this, with comments added</p>

<div class="cmd">
<pre>
(instruction
   ;; Instruction name, with variant information.
   &quot;add_dreg_to_dreg&quot;

   ;; The description of the meaning of the 16 bits of the opcode.
   ((:literal 4 #b1101)      ; 4 constant bits, with the given binary value
    (output-register 3 dest) ; The output register, whose number is coded
                             ; over 3 bits. Its value is available in the
                             ; 'dest' variable.
    (:literal 6 #010000)     ; More constant bits, describing the addressing mode.
    (input-register 3 src))  ; Input register, similar declaration to dest.

   ;; How to perform this operation, in a subset of Common Lisp.
   (setf dest (+ src dest)))
</pre>
</div>
<p></p>
<p>
The above instruction definition produces an opcode object that contains two things: information for the instruction decoder, so that it can identify this instruction, and the intermediate representation of the implementation of that instruction:</p>

<div class="cmd">
<pre>
;; The constant bit values in the opcode, and the mask to test them,
;; for the instruction decoder.
(debug-print-opcode-mask the-above-opcode-object)

--&gt; Output: 1101---010000---

;; The intermediate representation of the implementation.
(opcode-ast the-above-opcode-object)

--&gt; (LET ((SRC (REGISTER-VALUE :DATA
                               (VM-OPCODE-BITS 3 0)))
          (DEST (WRITABLE-REGISTER-VALUE :DATA
                                         (VM-OPCODE-BITS 3 9))))
      (SETF DEST (+ DEST SRC)))
</pre>
</div>
<p></p>
<p>
This opcode can then be fed to the Java code generator, to produce the output implementation:</p>

<div class="cmd">
<pre>
(java-gen-opcode the-above-opcode-object)

--&gt; public static void op_add_dreg_to_dreg(unsigned short opcode) {
      unsigned long src = mDataRegisters[(opcode &gt;&gt; 0) &amp; 0x7];
      unsigned long dest = mDataRegisters[(opcode &gt;&gt; 9) &amp; 0x7];
      dest = dest + src;
      mDataRegisters[(opcode &gt;&gt; 9) &amp; 0x7] = dest;
    }
</pre>
</div>
<p></p>
<p>
There is still a lot to be done. For one, the <tt>ADD</tt> opcode is supposed to update the CPU's state flags with information about the result of the addition. After that, the addressing modes other than to/from a numbered register must be supported. Implementing more opcodes will surely bring more things that need to be implemented.</p>
<p>
Once a solid base is laid, a higher-still level of description must be layered on, so that all the variants of an instruction are produced from a single implementation definition. Once all that is done, a C++ backend would be nice. And why not attempt to generalize the compiler infrastructure, so as to support the compilation of emulators other than m68k CPUs?</p>
<p>
By the time I get anywhere near that, I suspect that it will have become possible to easily write and release native code for Android, making all of my efforts unnecessary. But I don't care, this is damn <em>fun</em>!</p>
<p>
Some people are of the opinion that I should get my head examined.</p>
   ]]></content:encoded>
   <wfw:commentRss>http://natulte.net/index.php/blog/rss/549/comments</wfw:commentRss>
  </item>

  <item>
   <title><![CDATA[Black box says yes]]></title>
   <link>http://natulte.net/index.php/blog/548</link>
   <description>
This just in: following the discovery of the "diagnostic LED" of my black box, it took mere minutes to home in on the bug and eradicate it.

It's alive! ALIVE I SAY!

Oh, what was the bug? Let's just say that when you check, in the code of a driver, whether you properly told the power management driver to power up the chip you're driving, it would be wise to also check the code of the power management driver to make sure the power-up code is right. Because a chip with no power ain't gonna be driven nowhere.

In other news, powering up random peripherals unrelated to what you want to drive doesn't work either. No, really.
   </description>
   <author><![CDATA[David Anderson]]></author>
   <category><![CDATA[English]]></category>
   <category><![CDATA[Geek]]></category>
   <guid>http://natulte.net/index.php/blog/548</guid>
   <pubDate><![CDATA[Tue, 18 Nov 2008 04:10:09 +0100]]></pubDate>
   <dc:creator><![CDATA[David Anderson]]></dc:creator>
   <content:encoded><![CDATA[<p>
This just in: following the discovery of the &quot;diagnostic LED&quot; of my black box, it took mere minutes to home in on the bug and eradicate it.</p>
<p>
It's alive! ALIVE I SAY!</p>
<p>
Oh, what was the bug? Let's just say that when you check, in the code of a driver, whether you properly told the power management driver to power up the chip you're driving, it would be wise to also check the code of the power management driver to make sure the power-up code is right. Because a chip with no power ain't gonna be driven nowhere.</p>
<p>
In other news, powering up random peripherals unrelated to what you want to drive doesn't work either. No, really.</p>
   ]]></content:encoded>
   <wfw:commentRss>http://natulte.net/index.php/blog/rss/548/comments</wfw:commentRss>
  </item>

  <item>
   <title><![CDATA[Debugging the NXT startup: a binary printf()]]></title>
   <link>http://natulte.net/index.php/blog/547</link>
   <description>
(Warning: very nerdy rant about very geeky topic ahead)

Debugging a NXT that crashes during the bootup sequence is hard. Before the main AVR link comes up, there is no way to even get any sound. I've already done debugging by sound: during the early stages of NxOS a couple of years back, I would debug by playing bytes I wanted to check as morse-code-like dits and daas, one bit at a time, over the brick's speaker. It's extremely basic, but it's how I got the display driver to work.

But debugging a crash before the sound driver is in a working state is hard. You have a large binary black box. Either it boots and the sound driver works, in which case you don't have a problem, or it doesn't and you only get The Beep Of Death, the sound of the coprocessor periodically blipping the speaker to say "Your OS is screwed, I'm not playing any more".

Just now, attempting to debug one such crash, I discovered something interesting. If I initialize the sound controller and start an infinite loop of playing a tone, for some reason the pitch of the Beep Of Death changes by a few kHz for 2 beeps, then returns to its regular pitch.

This gives me a more basic equivalent of the morse code byte "printer": if the tone changes, I know that the brick booted at least up to the point of my infinite loop. If it doesn't, I know it crashed before that point. It's an audio diagnostic LED that tells me either "I managed to initialize the kernel up until this point", or "Nope, the crash occurs before execution gets to the bruteforce sound loop".

Therefore, by moving the sound loop around in the init code, I should be able to zero in on the exact crash site. The initialization black box is no longer completely black. A little information leaks out. Instead of "Everything works/doesn't work", I now have "Everything works/doesn't work up to the following intermediate point of my choosing".

And, sometimes, when debugging embedded systems without proper hardware debugging hardware, that tiny insignificant diagnostic LED is the difference between hope and despair.
   </description>
   <author><![CDATA[David Anderson]]></author>
   <category><![CDATA[English]]></category>
   <category><![CDATA[Geek]]></category>
   <guid>http://natulte.net/index.php/blog/547</guid>
   <pubDate><![CDATA[Tue, 18 Nov 2008 03:36:50 +0100]]></pubDate>
   <dc:creator><![CDATA[David Anderson]]></dc:creator>
   <content:encoded><![CDATA[<p>
(Warning: very nerdy rant about very geeky topic ahead)</p>
<p>
Debugging a NXT that crashes during the bootup sequence is hard. Before the main AVR link comes up, there is no way to even get any sound. I've already done debugging by sound: during the early stages of NxOS a couple of years back, I would debug by playing bytes I wanted to check as morse-code-like dits and daas, one bit at a time, over the brick's speaker. It's extremely basic, but it's how I got the display driver to work.</p>
<p>
But debugging a crash before the sound driver is in a working state is hard. You have a large binary black box. Either it boots and the sound driver works, in which case you don't have a problem, or it doesn't and you only get The Beep Of Death, the sound of the coprocessor periodically blipping the speaker to say &quot;Your OS is screwed, I'm not playing any more&quot;.</p>
<p>
Just now, attempting to debug one such crash, I discovered something interesting. If I initialize the sound controller and start an infinite loop of playing a tone, for some reason the pitch of the Beep Of Death changes by a few kHz for 2 beeps, then returns to its regular pitch.</p>
<p>
This gives me a more basic equivalent of the morse code byte &quot;printer&quot;: if the tone changes, I know that the brick booted at least up to the point of my infinite loop. If it doesn't, I know it crashed before that point. It's an audio diagnostic LED that tells me either &quot;I managed to initialize the kernel up until this point&quot;, or &quot;Nope, the crash occurs before execution gets to the bruteforce sound loop&quot;.</p>
<p>
Therefore, by moving the sound loop around in the init code, I should be able to zero in on the exact crash site. The initialization black box is no longer completely black. A little information leaks out. Instead of &quot;Everything works/doesn't work&quot;, I now have &quot;Everything works/doesn't work <em>up to the following intermediate point of my choosing</em>&quot;.</p>
<p>
And, sometimes, when debugging embedded systems without proper hardware debugging hardware, that tiny insignificant diagnostic LED is the difference between hope and despair.</p>
   ]]></content:encoded>
   <wfw:commentRss>http://natulte.net/index.php/blog/rss/547/comments</wfw:commentRss>
  </item>

  <item>
   <title><![CDATA[Airports of the world, take notice]]></title>
   <link>http://natulte.net/index.php/blog/546</link>
   <description>
Singapore International Airport rocks.

The shopping and restaurant center in the international corridor is bigger than the main commercial zone of many so-called international airports.

For 5 euros, you can grab a delightful hot shower, sheer nirvana after 10 hours of flying. For 15 euros you can enjoy a day in the ambassador lounge, complete with complimentary refreshments, a complimentary bed to nap, complimentary gym, complimentary showers, and free internet access.

Oh, yeah, the internet access. Get this. Free broadband wifi internet access for the whole airport. Yes, you read that right: airport; wifi; broadband; free. All in the same sentence. Until now I thought airports were a "pick three of these four" deals, but it does appear that at least one airport in the world does get it.

I'm only here for six hours or so until my flight on to Zurich, but I will long remember Singapore International Airport as the first airport that was not only bearable to dwell in for 6 hours, but actually pleasant. And that's just the international corridor, I dare not imagine the awesomeness of the rest of the place. Whoever runs this joint, bravo.
   </description>
   <author><![CDATA[David Anderson]]></author>
   <category><![CDATA[English]]></category>
   <category><![CDATA[Life]]></category>
   <guid>http://natulte.net/index.php/blog/546</guid>
   <pubDate><![CDATA[Sat, 01 Nov 2008 02:59:11 +0100]]></pubDate>
   <dc:creator><![CDATA[David Anderson]]></dc:creator>
   <content:encoded><![CDATA[<p>
Singapore International Airport rocks.</p>
<p>
The shopping and restaurant center in the <em>international corridor</em> is bigger than the <em>main</em> commercial zone of many so-called international airports.</p>
<p>
For 5 euros, you can grab a delightful hot shower, sheer nirvana after 10 hours of flying. For 15 euros you can enjoy a day in the ambassador lounge, complete with complimentary refreshments, a complimentary bed to nap, complimentary gym, complimentary showers, and free internet access.</p>
<p>
Oh, yeah, the internet access. Get this. Free broadband wifi internet access for the whole airport. Yes, you read that right: airport; wifi; broadband; free. All in the same sentence. Until now I thought airports were a &quot;pick three of these four&quot; deals, but it does appear that at least one airport in the world <em>does</em> get it.</p>
<p>
I'm only here for six hours or so until my flight on to Zurich, but I will long remember Singapore International Airport as the first airport that was not only bearable to dwell in for 6 hours, but actually pleasant. And that's just the international corridor, I dare not imagine the awesomeness of the rest of the place. Whoever runs this joint, bravo.</p>
   ]]></content:encoded>
   <wfw:commentRss>http://natulte.net/index.php/blog/rss/546/comments</wfw:commentRss>
  </item>

 </channel>
</rss>
