<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet href="/templates/default/atom.css" type="text/css" ?>

<feed 
   xmlns="http://www.w3.org/2005/Atom"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/">
    <link href="http://lunesu.com/index.php?/feeds/atom.xml" rel="self" title="Lunesu" type="application/atom+xml" />
    <link href="http://lunesu.com/"                        rel="alternate"    title="Lunesu" type="text/html" />
    <link href="http://lunesu.com/rss.php?version=2.0"     rel="alternate"    title="Lunesu" type="application/rss+xml" />
    <title type="html">Lunesu</title>
    <subtitle type="html">Random Notes</subtitle>
    
    <id>http://lunesu.com/</id>
    <updated>2010-08-18T12:43:15Z</updated>
    <generator uri="http://www.s9y.org/" version="1.5.2">Serendipity 1.5.2 - http://www.s9y.org/</generator>
    <dc:language>en</dc:language>

    <entry>
        <link href="http://lunesu.com/index.php?/archives/118-110V-really-means-110V.html" rel="alternate" title="&quot;110V&quot; really means 110V" />
        <author>
            <name>Lio</name>
                    </author>
    
        <published>2010-08-16T12:37:14Z</published>
        <updated>2010-08-18T12:43:15Z</updated>
        <wfw:comment>http://lunesu.com/wfwcomment.php?cid=118</wfw:comment>
    
        <slash:comments>2</slash:comments>
        <wfw:commentRss>http://lunesu.com/rss.php?version=atom1.0&amp;type=comments&amp;cid=118</wfw:commentRss>
    
            <category scheme="http://lunesu.com/index.php?/categories/3-Knowledge-Base" label="Knowledge Base" term="Knowledge Base" />
    
        <id>http://lunesu.com/index.php?/archives/118-guid.html</id>
        <title type="html">&quot;110V&quot; really means 110V</title>
        <content type="xhtml" xml:base="http://lunesu.com/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                Long story short: I've been to the US a few weeks ago and I thought I'd pick up a new Xbox 360 250GB while I was there, seeing as those are hard to find in China. I assumed its power supply would accept both 110V and 220V (like my PS3 and most modern PCs and laptops.) Well, it did not.<br />
<br />
Of course, I did not just plug it in and watch explode. I first opened up the power supply (not an easy feat, let me tell you) and only plugged it in after noticing the board inside had "250V" written on it, with a check mark next to it. Not sure what that meant though. It still blew up after I plugged it in.<br />
<br />
I already had a plan B from the moment I bought the Xbox: the power supply output 12V and 5V, much like a regular PC power supply. So I bought a (mini) ATX power supply and went online to see if I could find the pinout. <a href="http://www.google.com.hk/images?q=atx%20psu%20pinout&hl=en&um=1&ie=UTF-8&source=og&sa=N&tab=wi&biw=1746&bih=822" title="atx psu pinout">Plenty</a>. When I  plugged in the ATX power source, I measured the voltage on a few pins, but got nothing. Then I remembered the fact that an ATX power supply does not really turn on until the PC tells it to. This is done by shorting pin 14 of the ATX plug (green wire) to ground (black, any will do.) Once I did that, I got all the power I needed.<br />
<br />
The pinout on the Xbox side was harder to come by. I had found a few for the old Xbox 360, but none for the new slim model. Fortunately there were some hints on the PSU's board:<blockquote>Yellow 12V<br />
Black GND<br />
Red 5VSB<br />
Blue PS_ON<br />
Gray RSENSE</blockquote><br />
I thought I'd check what I could get away with: I connected the yellow wire from the Xbox to the yellow wire of the PSU. Same for the red wires, and black wires, matching the colors. Then, I turned on the power supply by connecting the green wire on pin 14 to a black wire. I pressed the button on the Xbox: success!<br />
<a class="serendipity_image_link"  href='http://lunesu.com/uploads/P1030006.JPG'><!-- s9ymdb:83 --><img class="serendipity_image_center" width="83" height="110"  src="http://lunesu.com/uploads/P1030006.serendipityThumb.JPG"  alt="" /></a><br />
Having the power supply turned on all the time was not something I liked though. So the next step was to get the power supply to turn on together with the Xbox. By measuring the voltage I saw the blue PS_ON wire being pulled up (~3.3V) when the Xbox wants to turn on. In order to do this, the Xbox needs some power though. This is done by the red "5VSB" wire. The "SB" stands for Stand By. This means that the red wire from the Xbox must not be attached to the red ATX wires, but to the purple wire on pin 9.<br />
<br />
<a href="http://forums.xbox-scene.com/index.php?showtopic=512276" title="ATX power supply for Xbox 360">This page </a>explained how: use a transistor or optocoupler that will connect the green ATX wire to GND when the blue Xbox wire goes up. I had no optocoupler lying around, or so I thought. I then noticed the blown up power supply on the table. There were some things on it that looked a lot like optocouplers. Sure enough:<br />
<a class="serendipity_image_link"  href='http://lunesu.com/uploads/P1030009.JPG'><!-- s9ymdb:84 --><img class="serendipity_image_center" width="110" height="52"  src="http://lunesu.com/uploads/P1030009.serendipityThumb.JPG"  alt="" /></a><br />
The datasheet for the EL817 can be found <a href="http://www.sztuofeng.com/pdf/%E4%BA%BF%E5%85%89EL817.pdf" title="EL817 datasheet">here</a>.<br />
<br />
So, pin 1 of the optocoupler (the pin near the dot) will be pulled high, to ~3.3V. We want to give the LED inside about ~1.2V, that leaves 2.1V for a resistor. At about 20mA this means we need a V/I=R 2.1/0.02= ~100 Ohm resistor. 100 Ohm = 10*10, 10 times 10 to the power 1: we need a resistor with Brown, Black, Brown rings. Luckily I found one <img src="http://lunesu.com/templates/default/img/emoticons/smile.png" alt=":-)" style="display: inline; vertical-align: bottom;" class="emoticon" /><br />
<br />
I had everything I needed:<blockquote>Yellow (Xbox) - Yellow (ATX)<br />
Red (Xbox) - Purple (ATX)<br />
Blue (Xbox) - Resistor - Optocoupler pin 1<br />
Black (Xbox) - Black (ATX)<br />
Optocoupler pin 2 - Green (ATX)<br />
Optocoupler pin 3 - Black (ATX)<br />
Optocoupler pin 4 - Black (ATX)<br />
Gray (Xbox) - unused</blockquote><br />
I had no idea what the gray RSENSE wire was for, so I just ignored it and it worked fine! Once I got everything figured out, I opened up the ATX PSU and removed all the wires I didn't use. Important: there was a brown wire that got connected to a orange (3.3V) wire IN the ATX power connector. So after cutting of the connector I had to connect the brown wire to 3.3V somewhere inside the PSU.<br />
<a class="serendipity_image_link"  href='http://lunesu.com/uploads/P1030007.JPG'><!-- s9ymdb:82 --><img class="serendipity_image_center" width="110" height="83"  src="http://lunesu.com/uploads/P1030007.serendipityThumb.JPG"  alt="" /></a><br />
And all it cost me was an ATX power supply and 1 blister. Not bad <img src="http://lunesu.com/templates/default/img/emoticons/smile.png" alt=":-)" style="display: inline; vertical-align: bottom;" class="emoticon" /><br />
<br />
<strong>UPDATE:</strong> Here's the schematic for the whole thing:<br />
<!-- s9ymdb:85 --><img class="serendipity_image_center" width="566" height="293"  src="http://lunesu.com/uploads/xbox360psu.png"  alt="" /> 
            </div>
        </content>
        
    </entry>
    <entry>
        <link href="http://lunesu.com/index.php?/archives/117-Free-memory.html" rel="alternate" title="Free memory" />
        <author>
            <name>Lio</name>
                    </author>
    
        <published>2010-07-14T13:34:30Z</published>
        <updated>2010-07-14T13:34:30Z</updated>
        <wfw:comment>http://lunesu.com/wfwcomment.php?cid=117</wfw:comment>
    
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://lunesu.com/rss.php?version=atom1.0&amp;type=comments&amp;cid=117</wfw:commentRss>
    
    
        <id>http://lunesu.com/index.php?/archives/117-guid.html</id>
        <title type="html">Free memory</title>
        <content type="xhtml" xml:base="http://lunesu.com/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                My VPS was running out of memory so I started googling to see what could be done about it. The best tip was <a href="http://forums.spry.com/cpanel-whm/1420-high-memory-usage-look-into-mysqld.html" title="High Memory Usage">this</a>:<br />
<blockquote>SSH into the system with putty or some other ssh utility<br />
vi /etc/my.cnf<br />
at the end of the section that starts with [mysqld] you want to add the following lines to turn off support for innodb and bdb.<br />
<br />
skip-innodb<br />
skip-bdb<br />
<br />
restart mysql with '/etc/init.d/mysql restart'</blockquote><br />
My my.cnf happened to be in /etc/mysql/my.cnf, but after restart mysqld was using 80MB less memory! Before you do this though, make sure you don't have any tables using innodb or bdb. 
            </div>
        </content>
        
    </entry>
    <entry>
        <link href="http://lunesu.com/index.php?/archives/116-Well,-that-took-long-enough....html" rel="alternate" title="Well, that took long enough..." />
        <author>
            <name>Lio</name>
                    </author>
    
        <published>2010-06-23T13:33:27Z</published>
        <updated>2010-06-23T13:33:27Z</updated>
        <wfw:comment>http://lunesu.com/wfwcomment.php?cid=116</wfw:comment>
    
        <slash:comments>1</slash:comments>
        <wfw:commentRss>http://lunesu.com/rss.php?version=atom1.0&amp;type=comments&amp;cid=116</wfw:commentRss>
    
    
        <id>http://lunesu.com/index.php?/archives/116-guid.html</id>
        <title type="html">Well, that took long enough...</title>
        <content type="xhtml" xml:base="http://lunesu.com/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                New in Windows 7: select some files in explorer and press SHIFT + RIGHT-CLICK on the selection. Lo and behold, a secret option appears: "Copy As Paths"!<br />
<br />
Similarly, SHIFT + RIGHT-CLICK on a folder offers "Open command window here" and "Open in new process." The things you learn when you work at MS. 
            </div>
        </content>
        
    </entry>
    <entry>
        <link href="http://lunesu.com/index.php?/archives/115-China-Mobile-SIMs-explained.html" rel="alternate" title="China Mobile SIMs explained" />
        <author>
            <name>Lio</name>
                    </author>
    
        <published>2010-05-15T08:51:50Z</published>
        <updated>2010-05-26T11:46:01Z</updated>
        <wfw:comment>http://lunesu.com/wfwcomment.php?cid=115</wfw:comment>
    
        <slash:comments>4</slash:comments>
        <wfw:commentRss>http://lunesu.com/rss.php?version=atom1.0&amp;type=comments&amp;cid=115</wfw:commentRss>
    
    
        <id>http://lunesu.com/index.php?/archives/115-guid.html</id>
        <title type="html">China Mobile SIMs explained</title>
        <content type="xhtml" xml:base="http://lunesu.com/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                A <a href="http://lunesu.com/index.php?/archives/114-New-phone-number.html#c1835" title="Jose">reader</a> (!) complained about not being able to get GPRS to work with China Mobile. Although I'm in no way an expert on the subject, I think I know enough to make a useful remark, or two..<br />
<br />
The problem with China Mobile is that they have two kinds of SIM cards: 神州行 ShenZhouXing, also known as EasyOwn, versus 动感地带 DongGanDiDai also known as M-Zone.<br />
<ul><li/>ShenZhouXing/EasyOwn are most popular and you can buy them in every kiosk. However, they don't support GPRS, only WAP. There's an android app called <a href="http://code.google.com/p/cmwrap/" title="CMWrap">CMWRAP</a> that tries to mimic GPRS by tunneling all traffic over WAP. I've used this for a while and it works, but it's not very stable, so be careful.<br />
<br />
<li/>M-Zone supports GPRS and EDGE. Even 3G, but China Mobile's 3G standard is not UMTS or HSDPA, but some other TD-SCDMA standard, which is not supported by most phones that originate from abroad. For what it's worth, I thought EDGE worked quite well, to be honest. When using 3G, China's internet connection is probably the limiting factor.</ul><br />
There are two ways to tell which card you have. First of all, the actual SIM cards are of a different color. ShenZhouXing SIMs are green, whereas M-Zone are orange. Also, when you turn on your phone (at least with Android) it should popup a message saying what SIM you have. For example, my phone shows something like 没错！我是动感地带！"Not Bad! I'm M-Zone!" <br />
<br />
Apart from being able to use GPRS, receiving calls with M-Zone is FREE, contrary to ShenZhouXing where you pay when you pick up the phone. Note that M-Zone does require you to subscribe to some kind of package deal, which means some money will be subtracted at the beginning of each month. The cheapest package is about 11 RMB, if I remember correctly, and includes local (Beijing only) minutes, short messages and 20MB of traffic.<br />
<br />
If you currently have a ShenZhouXing SIM, you can change it into an M-Zone SIM by going to your local China Mobile office (real CM office, not just any reseller.) Bring your passport and the PUK code of the ShenZhouXing SIM. The PUK code is written on the bank-card-shaped piece of plastic that used to contain the SIM card. The change will active from the beginning of the next month.<br />
<br />
Hope this helps. 
            </div>
        </content>
        
    </entry>
    <entry>
        <link href="http://lunesu.com/index.php?/archives/114-New-phone-number.html" rel="alternate" title="New phone number" />
        <author>
            <name>Lio</name>
                    </author>
    
        <published>2010-05-11T11:41:20Z</published>
        <updated>2010-05-15T09:02:31Z</updated>
        <wfw:comment>http://lunesu.com/wfwcomment.php?cid=114</wfw:comment>
    
        <slash:comments>3</slash:comments>
        <wfw:commentRss>http://lunesu.com/rss.php?version=atom1.0&amp;type=comments&amp;cid=114</wfw:commentRss>
    
    
        <id>http://lunesu.com/index.php?/archives/114-guid.html</id>
        <title type="html">New phone number</title>
        <content type="xhtml" xml:base="http://lunesu.com/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                A few days ago I've moved to Shanghai and, since using a Beijing phone number in Shanghai is expensive, I decided to get a new phone number. I've decided to go with <a href="http://www.chinaunicom.com.cn/" title="China Unicom (CN)">China Unicom</a>, because their 3G standard is the same as the rest of the world's, so now I finally have 3G! (Although, youtube is still blocked, but at least Android 2.1 supports VPN now.)<br />
<br />
To get my new Shanghai phone number, add 3410941632 to my old phone number <img src="http://lunesu.com/templates/default/img/emoticons/wink.png" alt=";-)" style="display: inline; vertical-align: bottom;" class="emoticon" /> 
            </div>
        </content>
        
    </entry>
    <entry>
        <link href="http://lunesu.com/index.php?/archives/112-Converting-mailbox-format-from-mbox-to-Maildir.html" rel="alternate" title="Converting mailbox format from mbox to Maildir" />
        <author>
            <name>Lio</name>
                    </author>
    
        <published>2010-04-29T00:43:03Z</published>
        <updated>2010-05-07T01:41:32Z</updated>
        <wfw:comment>http://lunesu.com/wfwcomment.php?cid=112</wfw:comment>
    
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://lunesu.com/rss.php?version=atom1.0&amp;type=comments&amp;cid=112</wfw:commentRss>
    
    
        <id>http://lunesu.com/index.php?/archives/112-guid.html</id>
        <title type="html">Converting mailbox format from mbox to Maildir</title>
        <content type="xhtml" xml:base="http://lunesu.com/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                The default mailbox format used by postfix and dovecot is the mbox format. This basically boils down to a single file per user in <em>/var/mail/</em> with all mails concatenated, one after the other. (Mail in folders other than inbox are stored in ~/mail/)<br />
<br />
Mail stored in the Maildir format uses 1 file per mail. Accessing individual mails is faster, but because there are many small files, the disk space overhead is bigger.<br />
<br />
The mbox format is fairly simple and compact, but has a couple of problems. For one, being a single flat file it's easy to append new incoming mails, but it's not straightforward to remove a mail from the middle of the file. Another problem that I've noticed in Thunderbird 3 is that sometimes two mails would appear to be combined. I'd suddenly see another mail's attachments appearing on a mail without attachments. I'm not sure whether this is a problem with Thunderbird, dovecot, or perhaps a corrupt mbox file?<br />
<br />
The steps:<br />
<ol><li/>Before we start the conversion exit your mail client. <br />
<br />
<li/>You should also stop postifx to prevent mail being delivered to the wrong mailbox during conversion: <em>sudo /etc/init.d/postfix stop</em><br />
<br />
<li/>The easiest way to convert the mailbox format is to let dovecot do it for us. Make the following changes to <em>/etc/dovecot/dovecot.conf</em>: <blockquote>mail_location = maildir:~/Maildir<br />
mail_plugins = convert<br />
convert_mail = mbox:~/mail:INBOX=/var/mail/%u</blockquote>(Search for the settings and change them.)<br />
<br />
<li/>Apply the changes by restarting dovecot: <em>sudo /etc/init.d/dovecot restart</em><br />
<br />
<li/>Now start your mail client. Dovecot will convert the mailbox at login, so this might take a while. Also, chances are the client will start to download all mail again. (There seem to be <a href="http://wiki.dovecot.org/Migration/MailFormat" title="Converting dovecot mail storage format">some scripts</a> that can prevent this.)<br />
<br />
<li/>Before we start postfix, edit <em>/etc/postfix/main.cf</em> to tell it where to deliver the mail: <em>home_mailbox = Maildir/</em><br />
<br />
<li/>Restart postfix: <em> sudo /etc/init.d/postfix start</em></ol> 
            </div>
        </content>
        
    </entry>
    <entry>
        <link href="http://lunesu.com/index.php?/archives/111-How-long-is-one-month.html" rel="alternate" title="How long is one month?" />
        <author>
            <name>Lio</name>
                    </author>
    
        <published>2010-04-26T03:16:53Z</published>
        <updated>2010-04-26T06:59:33Z</updated>
        <wfw:comment>http://lunesu.com/wfwcomment.php?cid=111</wfw:comment>
    
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://lunesu.com/rss.php?version=atom1.0&amp;type=comments&amp;cid=111</wfw:commentRss>
    
    
        <id>http://lunesu.com/index.php?/archives/111-guid.html</id>
        <title type="html">How long is one month?</title>
        <content type="xhtml" xml:base="http://lunesu.com/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                Depends who you ask:<br />
<blockquote>mysql> select "2010-01-31" + INTERVAL 1 MONTH;<br />
+---------------------------------+<br />
| "2010-01-31" + INTERVAL 1 MONTH |<br />
+---------------------------------+<br />
| 2010-02-28                      |<br />
+---------------------------------+<br />
1 row in set (0.25 sec)</blockquote><br />
<blockquote>php > print date("Y-m-d",strtotime("2010-01-31 +1 month"));<br />
2010-03-03</blockquote><br />
<blockquote>sqlite> select date('2010-01-31',"+1 month");<br />
2010-03-03</blockquote>I'm siding with PHP/sqlite on this one. 
            </div>
        </content>
        
    </entry>
    <entry>
        <link href="http://lunesu.com/index.php?/archives/110-QingHai-memorial-day.html" rel="alternate" title="QingHai memorial day" />
        <author>
            <name>Lio</name>
                    </author>
    
        <published>2010-04-21T14:17:54Z</published>
        <updated>2010-04-21T14:17:54Z</updated>
        <wfw:comment>http://lunesu.com/wfwcomment.php?cid=110</wfw:comment>
    
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://lunesu.com/rss.php?version=atom1.0&amp;type=comments&amp;cid=110</wfw:commentRss>
    
    
        <id>http://lunesu.com/index.php?/archives/110-guid.html</id>
        <title type="html">QingHai memorial day</title>
        <content type="xhtml" xml:base="http://lunesu.com/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                <div class="serendipity_imageComment_left" style="width: 110px"><div class="serendipity_imageComment_img"><a class="serendipity_image_link"  href='http://lunesu.com/uploads/elong-bw.png'><!-- s9ymdb:81 --><img class="serendipity_image_left" width="110" height="67"  src="http://lunesu.com/uploads/elong-bw.serendipityThumb.png"  alt="" /></a></div><div class="serendipity_imageComment_txt">elong.com</div></div><div class="serendipity_imageComment_left" style="width: 110px"><div class="serendipity_imageComment_img"><a class="serendipity_image_link"  href='http://lunesu.com/uploads/xinhua-bw.png'><!-- s9ymdb:78 --><img class="serendipity_image_left" width="110" height="67"  src="http://lunesu.com/uploads/xinhua-bw.serendipityThumb.png"  alt="" /></a></div><div class="serendipity_imageComment_txt">xinhuanet.com</div></div><div class="serendipity_imageComment_left" style="width: 110px"><div class="serendipity_imageComment_img"><a class="serendipity_image_link"  href='http://lunesu.com/uploads/airchina-bw.png'><!-- s9ymdb:79 --><img class="serendipity_image_left" width="110" height="67"  src="http://lunesu.com/uploads/airchina-bw.serendipityThumb.png"  alt="" /></a></div><div class="serendipity_imageComment_txt">airchina.com.cn</div></div><div class="serendipity_imageComment_left" style="width: 110px"><div class="serendipity_imageComment_img"><a class="serendipity_image_link"  href='http://lunesu.com/uploads/csair-bw.png'><!-- s9ymdb:80 --><img class="serendipity_image_left" width="110" height="67"  src="http://lunesu.com/uploads/csair-bw.serendipityThumb.png"  alt="" /></a></div><div class="serendipity_imageComment_txt">csair.com</div></div> 
            </div>
        </content>
        
    </entry>
    <entry>
        <link href="http://lunesu.com/index.php?/archives/109-Android-2.1,-here-we-go.html" rel="alternate" title="Android 2.1, here we go" />
        <author>
            <name>Lio</name>
                    </author>
    
        <published>2010-04-21T08:54:15Z</published>
        <updated>2010-04-23T02:58:08Z</updated>
        <wfw:comment>http://lunesu.com/wfwcomment.php?cid=109</wfw:comment>
    
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://lunesu.com/rss.php?version=atom1.0&amp;type=comments&amp;cid=109</wfw:commentRss>
    
    
        <id>http://lunesu.com/index.php?/archives/109-guid.html</id>
        <title type="html">Android 2.1, here we go</title>
        <content type="xhtml" xml:base="http://lunesu.com/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                I've had it. I've been waiting since November last year for an official firmware update from HTC for my HTC Hero. Since then the update has been postponed numerous times and all the while I see these reports from people using leaked Android 2.1 ROMs. Now, it appears the official update will come in May, but I'm done waiting!<br />
<br />
As we speak I'm installing <a href="http://www.villainrom.co.uk/viewtopic.php?f=23&t=94" title="VillainROM 5.22">Villainrom 5.22</a>, which appears to be the <a href="http://android.modaco.com/content/htc-hero-hero-modaco-com/306106/poll-only-best-2-1-rom/" title="Android 2.1 ROM Poll">most popular 2.1 ROM</a> out there. Unfortunately it's not that straightforward to update your ROM and the necessary information is scattered among several forums and posts. Below is a list of the steps that I did to get 2.1 on my HTC Hero. Basically there are two kinds of updates: flash images and update packages. Flash images have the extension <em>.img</em> and are flashed using the command <em>flash_image</em> from the android shell. To install an update package you put the package as <em>update.zip</em> on the sdcard and reboot the phone into recovery mode. From there you can install the update package.<br />
<br />
<strong>Flash a new Radio ROM</strong><br />
I've read somewhere on the <a href="http://forum.xda-developers.com/forumdisplay.php?f=508" title="XDA HTC Hero forum">XDA Hero forum</a> (sorry, can't remember the post) that the newer ROMs need a newer Radio ROM as well, so I've decided to flash a new radio ROM first. I suggest you make a backup first (step 2+3) and flash the Radio ROM afterwards.<br />
<br />
I've downloaded version <a href="http://forum.xda-developers.com/showpost.php?p=4594434" title="HTC Hero Radios">63.18.55.06JU_6.35.09.26</a> and put it on my sdcard as <em>update.zip</em> using the USB cable and enabling USB mass storage. I've shutdown my phone and then, while keeping the <em>home </em>key pressed, turned it on again. My phone booted into the recovery mode, displaying a menu from where I selected <strong>flash sdcard:update.zip</strong>.<br />
<br />
<strong>Flash a new Recovery boot loader</strong><br />
The first step went well but I really should have created a backup <em>before</em> flashing the new radio. Better late than never, I suppose. I booted into the recovery mode again and selected <em>backup</em> but I instead of a backup I got an error message: <em>error running rom backup. backup not performed.</em> First thought: update the recovery image.<br />
<br />
I've downloaded <a href="http://rapidshare.com/files/360227978/recovery-RA-hero-v1.6.2.img" title="HTC Hero recovery image 1.6.2">recovery-RA-hero-v1.6.2.img</a> and followed the steps in <a href="http://forum.xda-developers.com/showthread.php?t=561124" title="[Recovery ROM] [07-Mar-2010] RA-hero-v1.6.2 ">this post</a>, using adb (android debug bridge):<br />
<blockquote>adb shell reboot bootloader<br />
fastboot boot recovery-RA-hero-v1.6.2.img<br />
adb shell mount /sdcard<br />
adb push recovery-RA-hero-v1.6.2.img /sdcard/recovery-RA-hero-v1.6.2.img<br />
adb shell flash_image recovery /sdcard/recovery-RA-hero-v1.6.2.img<br />
adb shell reboot</blockquote><br />
<br />
<strong>Make a Nandroid backup</strong><br />
Reboot into the (new) recovery mode and selected <em>nand backup</em>. There was also a <em>nand + ext</em> and <em>BART backup </em>options, but I don't quite know what each does, so I ignored them <img src="http://lunesu.com/templates/default/img/emoticons/smile.png" alt=":-)" style="display: inline; vertical-align: bottom;" class="emoticon" /> After backup move all the contents of the sdcard to your PC. (The sdcard will be wiped in the next step.) Note that the nandroid backup does not backup the contents of your sdcard. <br />
<br />
<strong>Wipe all data</strong><br />
From Android version 1.5 to 2.1 is a big step so I followed XDA poster's advice and wiped all the data from my phone before flashing the new firmware. Boot into recovery (if not already done) and select each of the following options from the recovery menu:<br />
<blockquote>Wipe Data/Factory Reset<br />
Wipe Dalvik cache<br />
Wipe SD</blockquote><br />
<br />
<strong>Flash the new ROM</strong><br />
I opted to go for the VillainROM 5.2 (aka 5.22) You can get it <a href="http://www.villainrom.co.uk/viewtopic.php?f=23&t=94" title="VillainROM 5.2">here</a>. The trick is the same: download the file and put it on the sdcard as <em>update.zip</em>. Then, boot into recovery mode and flash the zip from the sdcard. Reboot. Rinse. Repeat.<br />
<br />
This should have done the trick. Note that the first time the phone boots it might take a while for all the components to initialize, so go easy on your phone. <br />
<br />
Another great guide is found <a href="http://forum.xda-developers.com/showthread.php?t=645253" title="newbie guide">here</a>.<br />
<br />
And I've just got word that the official 2.1 has been postponed <em>yet again </em>until June. Now I'm really glad I've decided to go for the leaked 2.1. 
            </div>
        </content>
        
    </entry>
    <entry>
        <link href="http://lunesu.com/index.php?/archives/108-Converting-my-mobile-phone-into-an-IR-remote-control,-part-3.html" rel="alternate" title="Converting my mobile phone into an IR remote control, part 3" />
        <author>
            <name>Lio</name>
                    </author>
    
        <published>2010-04-15T10:05:26Z</published>
        <updated>2010-04-19T00:19:39Z</updated>
        <wfw:comment>http://lunesu.com/wfwcomment.php?cid=108</wfw:comment>
    
        <slash:comments>2</slash:comments>
        <wfw:commentRss>http://lunesu.com/rss.php?version=atom1.0&amp;type=comments&amp;cid=108</wfw:commentRss>
    
    
        <id>http://lunesu.com/index.php?/archives/108-guid.html</id>
        <title type="html">Converting my mobile phone into an IR remote control, part 3</title>
        <content type="xhtml" xml:base="http://lunesu.com/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                After confirming the signal and still failing to turn on my TV, I figured my Panasonic Viera TV was using a different protocol from the RC5 that I had initially implemented. I tried to decode the protocol by pointing my remote at the IR sensor attached to the O-scope, but I was unable to get a complete code on the scope:<br />
<br />
<!-- s9ymdb:77 --><img class="serendipity_image_center" width="332" height="91"  src="http://lunesu.com/uploads/oscope3.png"  alt="" /><br />
<br />
It's immediately apparent however that the Panasonic IR protocol uses space modulation, where the spaces between the pulses are used to differentiate a 1 from a 0. But since I was not able to get a picture of a complete code, I still didn't know what signal I should create to turn my TV on! Fortunately, the <a href="http://lirc.sourceforge.net/remotes/" title="LIRC remote control database">LIRC remote control database</a> had an entry for just <a href="http://lirc.sourceforge.net/remotes/panasonic/N2QAYB000239" title="N2QAYB000239 remote control protocol">my remote</a> and I could confirm that the bits from the picture above are indeed a match for Panasonic's standby button.<br />
<br />
Above: .....000001000000001011110010......<br />
From LIRC: Power = 0x0100BCBD = ....00<strong>000001000000001011110010</strong>111101<br />
<br />
Now to change my code to write the right signal. Be right back...<br />
<br />
<strong>UPDATE: </strong>OK, so I actually got it to work using the audio out from my PC! I had to create a 72Khz wav to make it work. For some reason a 36Khz wouldn't work, but simply doubling the frequency (and duplicating all values) did the trick. Unfortunately, neither the 36Khz nor the 72Khz wav worked when played on my android mobile phone. In fact, the music player failed to load the 72Khz wav completely. Checking the LEDs with a digital camera when playing any loud wav file I could not see the LEDs light up the way they did when attached to my PC's audio out. Not enough power? Does the phone do some smart "ear piece present" check? More for tomorrow... 
            </div>
        </content>
        
    </entry>
    <entry>
        <link href="http://lunesu.com/index.php?/archives/107-Its-alive!.html" rel="alternate" title="It's alive!" />
        <author>
            <name>Lio</name>
                    </author>
    
        <published>2010-04-15T08:08:08Z</published>
        <updated>2010-04-15T08:12:15Z</updated>
        <wfw:comment>http://lunesu.com/wfwcomment.php?cid=107</wfw:comment>
    
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://lunesu.com/rss.php?version=atom1.0&amp;type=comments&amp;cid=107</wfw:commentRss>
    
    
        <id>http://lunesu.com/index.php?/archives/107-guid.html</id>
        <title type="html">It's alive!</title>
        <content type="xhtml" xml:base="http://lunesu.com/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                (Continued from below.)<br />
<br />
It works! I've attached the O-scope to an IR sensor (TSOP31238, 38Khz) which also demodulates the signal, and the demodulated signal is correct! This proves that using the 2 LED trick works fine, and it further proves that a 38Khz sensor will also demodulate a 36KHz signal!<br />
<br />
<!-- s9ymdb:76 --><img class="serendipity_image_center" width="524" height="188"  src="http://lunesu.com/uploads/oscope2.png"  alt="" /> 
            </div>
        </content>
        
    </entry>
    <entry>
        <link href="http://lunesu.com/index.php?/archives/106-Converting-my-mobile-phone-into-an-IR-remote-control.html" rel="alternate" title="Converting my mobile phone into an IR remote control" />
        <author>
            <name>Lio</name>
                    </author>
    
        <published>2010-04-15T03:39:36Z</published>
        <updated>2010-04-15T03:39:36Z</updated>
        <wfw:comment>http://lunesu.com/wfwcomment.php?cid=106</wfw:comment>
    
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://lunesu.com/rss.php?version=atom1.0&amp;type=comments&amp;cid=106</wfw:commentRss>
    
    
        <id>http://lunesu.com/index.php?/archives/106-guid.html</id>
        <title type="html">Converting my mobile phone into an IR remote control</title>
        <content type="xhtml" xml:base="http://lunesu.com/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                I had this silly idea a few weeks back: to simply attach an LED to an 3,5" audio jack and make a mobile phone application with which you can control all your devices, simply by playing a generated sound file.<br />
<br />
So when I was in Shenzhen the other day I decided to buy an audio jack and some IR LEDs to keep myself busy in the hotel room. I attached a LED to the audio jack and played some mp3 on full volume. By using my phone's digital camera to look at the LED I could see it clearly light up, so at least the voltage of the audio out was high enough to drive a LED.<br />
<br />
First problem I've encountered: the RC5 signal (and many other IR protocols) is modulated at 36Khz and there's no way my PC, let alone my mobile phone, will play a 36Khz tone. I slept on this for a few nights and suddenly had an idea: I use two LEDs! One will shine on a positive signal and the other on a negative signal. This way I'll be able to get the LEDs to flash up to a <em>theoretic </em>frequency of 44.1Khz. In practice this limit is lower because audio-out has a high pass (and low pass) filter, but with some luck I'll be able to get a decent 18Khz AC signal to achieve the required 36Khz modulation.<br />
<br />
I quickly wrote a program (in <a href="http://digitalmars.com/d/" title="D Programming Language">D</a>, of course) to generate a .wav file with a modulated RC5 signal to turn TVs on or off. The RC5 signal consists of 14 data bits, each data bit is sent as two modulated bits: a data bit 1 is sent as 01 (a pause followed by the modulated signal) and a data bit 0 is sent as 10 (signal followed by a pause.) <br />
<br />
Unfortunately, when I played this generated .wav file and held my laptop in front of my TV, nothing happened. In order to debug this, I bought a cheap O-scope on <a href="http://taobao.com/" title="Taobao online store">taobao</a>: only 350 RMB! Below you'll see the IR signal with the 14 bits:<br />
<br />
<!-- s9ymdb:75 --><img class="serendipity_image_center" width="581" height="148"  src="http://lunesu.com/uploads/oscope.png"  alt="RC5 signal" /><br />
<br />
The signal appears to be correct, so there must be something else wrong. Are the modulated pulses too wide, not wide enough? Is my TV <strong>not </strong>using the RC5 protocol? <br />
<br />
To be continued...<br />
 
            </div>
        </content>
        
    </entry>
    <entry>
        <link href="http://lunesu.com/index.php?/archives/105-The-D-Programming-Language.html" rel="alternate" title="The D Programming Language" />
        <author>
            <name>Lio</name>
                    </author>
    
        <published>2010-04-13T09:14:07Z</published>
        <updated>2010-04-15T01:59:53Z</updated>
        <wfw:comment>http://lunesu.com/wfwcomment.php?cid=105</wfw:comment>
    
        <slash:comments>1</slash:comments>
        <wfw:commentRss>http://lunesu.com/rss.php?version=atom1.0&amp;type=comments&amp;cid=105</wfw:commentRss>
    
    
        <id>http://lunesu.com/index.php?/archives/105-guid.html</id>
        <title type="html">The D Programming Language</title>
        <content type="xhtml" xml:base="http://lunesu.com/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                <a class="serendipity_image_link"  href='http://lunesu.com/uploads/DforBLUG1.odp'><!-- s9ymdb:73 --><img class="serendipity_image_left" width="110" height="83"  src="http://lunesu.com/uploads/DforBLUG.serendipityThumb.png"  alt="" /></a>You can get the slides of my presentation <a href="http://lunesu.com/uploads/DforBLUG1.odp" title="DforBLUG" target="_blank">here</a>. Feel free to leave comments below. 
            </div>
        </content>
        
    </entry>
    <entry>
        <link href="http://lunesu.com/index.php?/archives/104-LinkStation-playing-music!.html" rel="alternate" title="LinkStation playing music!" />
        <author>
            <name>Lio</name>
                    </author>
    
        <published>2010-03-19T06:02:40Z</published>
        <updated>2010-03-20T01:14:20Z</updated>
        <wfw:comment>http://lunesu.com/wfwcomment.php?cid=104</wfw:comment>
    
        <slash:comments>2</slash:comments>
        <wfw:commentRss>http://lunesu.com/rss.php?version=atom1.0&amp;type=comments&amp;cid=104</wfw:commentRss>
    
            <category scheme="http://lunesu.com/index.php?/categories/3-Knowledge-Base" label="Knowledge Base" term="Knowledge Base" />
    
        <id>http://lunesu.com/index.php?/archives/104-guid.html</id>
        <title type="html">LinkStation playing music!</title>
        <content type="xhtml" xml:base="http://lunesu.com/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                Inspired by this page on <a href="http://buffalo.nas-central.org/wiki/Add_a_USB_sound_card" title="Add a USB sound card">NAS-Central</a>, I ordered a <a href="http://item.taobao.com/item_detail.jhtml?item_id=50334a3c57df67f334cf4d7b70b6d67c&x_id=db1" title="USB 5.1声卡">USB sound card on TaoBao</a> (15 RMB including delivery!) and plugged it into my <a href="http://lunesu.com/index.php?/archives/96-Heh.html" title="Open stock LinkStation">LinkStation</a>. A quick <em>dmesg</em> showed that the device was detected, but not recognized.<br />
<br />
The NAS-Central page mentions that some kernel modules are needed to get USB audio to work, but of course, the device does not have these modules by default. After googling for a few hours I still could not find any precompiled modules that matched my LinkStation's kernel version, 2.6.22. I decided to jump in and try to compile the modules myself.<br />
<br />
So how do you compile kernel modules? <br />
<br />
Well, first of all you'll need the correct kernel sources, but that's easy: <a href="http://opensource.buffalo.jp/gpl_storage.html" title="Buffalo NAS sources">Buffalo provides them</a>. Download the <em>linux-*</em> package that matches your NAS.<br />
<br />
Now you need a compiler. Turns out Buffalo uses CodeSourcery so we best stick to that as well. Get the pre-compiled cross-compilation toolchain <a href="http://www.codesourcery.com/sgpp/lite/arm/releases/2005q3-2" title="CodeSourcery cross-compilation toolchain">here</a>. Select "ARM GNU/linux" and the operating system that you will use for building. No need to download the toolchain source.<br />
<br />
Before we can compile the modules we need a kernel configuration file. Some Buffalo source packages seem to include it (the file is called <em>.config</em> and is hidden because of the leading dot) but the one I downloaded did not include one. Copy this file into the root of the folder where you've extracted the Buffalo sources. This .config file most likely has all support for audio disabled so we'll enable it by adding <em>CONFIG_SND=m</em> (or check whether there's a <em>CONFIG_SND</em> present and change that to <em>=m</em>). The 'm' tells the make file to build it as a separately loadable module, instead of building it into the kernel. (Since I didn't want to change the stock kernel, I had to build loadable modules instead.)<br />
<br />
Now the good part starts: <em>make modules</em><br />
<br />
The make file should notice the new CONFIG_SND directive and ask you about the specific sound related modules. Make sure you answer 'm' to all of 'em. You don't need them all, but figuring which you need/don't need is too much work.<br />
<br />
When make is done we need to 'install' the modules, but not in our host/build system of course! Use the INSTALL_MOD_PATH directive to copy the built modules into a separate folder: <em>make modules_install INSTALL_MOD_PATH=/tmp/MyModules</em><br />
<br />
When done, copy all the files from /tmp/MyModules/lib/modules/2.6.22.7ownkernel/kernel/sound (recursive) to your NAS. Now comes another the tricky part: loading the needed modules. The module you <strong>need</strong> is <em>snd-usb-audio</em> and <em>snd-pcm-oss</em>, but before this one will need you'll have to load a couple of others. The normal way this is done is to move the modules into the NAS's kernel folder and issue a <em>depmod -a</em> to update the module dependecies and a <em>modprobe snd-usb-audio</em> to load the module with its dependencies. I did it the wrong way: using <em>insmod</em> to load each module by hand, and trying to figure out the order in which to load them by trial-and-error. Eventually, <em>insmod snd-usb-audio.ko</em> loaded without complaints.<br />
<br />
Last step: create the device nodes. As per the NAS-Central page:<blockquote>cd /dev<br />
addgroup audio<br />
mknod -m 660 mixer c 14 0 ; chgrp audio mixer<br />
mknod -m 660 mixer1 c 14 16 ; chgrp audio mixer1<br />
mknod -m 660 dsp c 14 3 ; chgrp audio dsp<br />
mknod -m 660 dsp1 c 14 19 ; chgrp audio dsp1<br />
</blockquote><br />
I am now able to stream music using mpg123, madplay, mpd (all installable using ipkg.)<br />
<br />
The sound quality of that 15 RMB sound card sucks though <img src="http://lunesu.com/templates/default/img/emoticons/sad.png" alt=":-(" style="display: inline; vertical-align: bottom;" class="emoticon" /><br />
<br />
Here's the final <a href="http://lunesu.com/uploads/config.bz2" title="config.bz2" target="_blank">.config</a> file I used to build the sound modules. 
            </div>
        </content>
        
    </entry>
    <entry>
        <link href="http://lunesu.com/index.php?/archives/103-My-first-published-Android-app!.html" rel="alternate" title="My first published Android app!" />
        <author>
            <name>Lio</name>
                    </author>
    
        <published>2010-03-11T14:51:47Z</published>
        <updated>2010-03-12T02:20:25Z</updated>
        <wfw:comment>http://lunesu.com/wfwcomment.php?cid=103</wfw:comment>
    
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://lunesu.com/rss.php?version=atom1.0&amp;type=comments&amp;cid=103</wfw:commentRss>
    
            <category scheme="http://lunesu.com/index.php?/categories/3-Knowledge-Base" label="Knowledge Base" term="Knowledge Base" />
    
        <id>http://lunesu.com/index.php?/archives/103-guid.html</id>
        <title type="html">My first published Android app!</title>
        <content type="xhtml" xml:base="http://lunesu.com/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                <!-- s9ymdb:69 --><img class="serendipity_image_right" width="195" height="195"  src="http://lunesu.com/uploads/qrcode.png"  alt="BeijingAir qr code" />I've just finished my first app and have published it on the market! The app is very simple: it shows the current air quality in Beijing, as measured by the US Embassy. Scan the QR Code on the right and my app will pop up in the market app.<br />
<br />
(<a href="http://code.google.com/p/bjair/" title="BeijingAir project page">project page on Google code</a>) 
            </div>
        </content>
        
    </entry>

</feed>