Where is the time machine?

Gentoo July 11th, 2007

After several times unsuccessful hibernation, the JFS file system is screwed up by the forceful shutdown. There are some directories with weired access control in the portage, that cause the fsck.jfs exit abnormally. Eventually, I decided to clean up this morning using the ultimate way: format.

I did a full stage4 backup first, and then format the disk and tried to recover from the stage4 tar ball. Oops, here is an fatal error. It looks like the backup met some errors then exited with a success message. That is really not funny.

Anyway, I had a backup one week ago, it is old since I update the system everyday, yes, that is the typical Gentoo users’ behavior. But wait, I just got the second half of the split stage4 tar ball, where is the first half?

Where is the time machine?

HOWTO display Chinese in Creative ZenMicro using Amarok

Desktop, Gentoo June 25th, 2007

Creative is less creative in building software, that is why so many users are asking how to display Chinese character in Creative ZenMicro using either Windows Media Player or Creative MediaSource. But this company really build solid hardware, and I could resist the temptation of ZenMicro RED 5G (refurbished) 49$ with free shipping from Outpost. So I got another one and found the same annoyance happened to Amarok 1.4.6. Amarok is open sourced, that leave the door open for me to dig into the problem.

According to the solution,

1. Go to your Control Panel
2. Select Regional and Language Options
3. Go to the Advanced tab
4. See the Language for Non-Unicode programs
5. Select Chinese PRC
6. The system will prompt you to restart.

it looks like the Creative ZenMicro uses the GB2312 code page to display Chinese. So the first move to solve this problem is to convert the ID3 tag to GB2312 before the track is downloaded to the device:

// $TOPSRC/amarok/src/mediadevice/njb/track.cpp
    QTextCodec *codec = QTextCodec::codecFromName(“GB2312″);
    // orig: NJB_Songid_Addframe( songid, NJB_Songid_Frame_New_Title( m_bundle.title().utf8() ) );
    NJB_Songid_Addframe( songid, NJB_Songid_Frame_New_Title( codec->fromUnicode(m_bundle.title()) ) );

Good news is the old messy code disappeared, the bad news is we have new messy code. It is worthy understanding how the device stores the information and how libnjb is designed for the developers. So I sent an email to the libnjb developers, and got the reply from Linus Walleij in a short period:

The Zen Micro like all Zens use UCS2 as internal representation. However
the libnjb library uses UTF-8 as input/output format if requested, so it
shouldn’t matter.
… …
It is however very important that the client calls the libnjb function
NJB_Set_Unicode() with the UTF-8 flag, in order for it to work. Else
libnjb will assume encoding is in ISO8859-1 and drop a lot of information
by making approximations and mangling chinese totally. The call should be
made before any other initialization

I combed the Amarok’s source code, and found the bug, Amarok’s developers setup the Unicode after call the NJB_Discover, it may be too late. Once we move that function call earlier, it works. You can download this patch here, and if you are a Gentoo user, here is the ebuild. Check out this HOWTO if you are not clear how to setup the portage overlay.

Further reading showed that the problem is caused by the transport layer from Creative which is built without Unicode support, that drops the ball, and Windows user could do nothing but request Creative to rebuild the code with Unicode; or they can use libnjb derived application, such as NomadSync(not tested yet).

Update Some Chinese characters are missing without a hint, like 一, 言, no idea which cause the bug. If you are using Creative ZenMicro, could you help to test it in Windows and leave a comment here?

Upgrade to 2.6.20

Gentoo June 21st, 2007

After several months’ waiting, kernel 2.6.20 with suspend2 patch finally come into x86 branch. The upgrade is quite smooth except some bumps.

According to the experience of building the poor man’s wireless network, some exotic errors may happen if the .config is copied direct from kernel 2.6.18, so I went though all the configuration using make menuconfig. Read the rest of this entry »

Poor man’s wireless network

Gentoo, Network May 28th, 2007

If you would rather take a longer route to setup your wireless network, instead of the shortcut, rushing to Circuit City to get one wireless AP/router, please tight your seat belt and follow my guidance, and keep it in mind: your miles may vary.

I happen to have one Pentium III Gentoo box as my file server, and one Encore ENLWI-G Wireless G PCI Adapter, how about setup a wireless network for my Dell 700m laptop, so I can surf the web, write blog in the bed?

Drive it with caution

First, we need to find an appropriate driver for this card, as many short-sighted vendors, Marvell does not ship native driver for non-Windows platform, the good news is we have the ndiswrapper to rescue.

For unknown reason, ndiswrapper keeps crashing in gentoo-sources-2.6.17-r8, so I just copy the .config and update the kernel to gentoo-sources-2.6.20-r8, that is proven to be a disastrous decision[1].

Slow down, acrossing the bridge

Bridge seems to make more sense than any other approaches, the Gentoo box would bridge 802.11 wireless network and 802.3 ethernet with the following advantage:

  • Less hassle in the server side: enable 802.1d Ethernet Bridging support in the kernel, and emerge bridge-utils in the userland, done.
  • Transparent to the users: the wireless network is the extension of the ethernet, as if the users are connected to wireless router.

I am following this HOWTO, and here is the sample configuration of /etc/conf.d/net:

bridge_br0=( “eth0″ “wlan0″)

config_eth0=( null )
config_wlan0=( null )

config_br0=( “192.168.15.144 netmask 255.255.255.0 broadcast 192.168.15.255″ )
routes_br0=( “default gw 192.168.15.1″ )
depend_br0() {
        need net net.eth0 net.wlan0
}

modules_wlan0=(“iwconfig”)
mode_wlan0=“Ad-hoc”
essid_wlan0=“hippo”
channel_wlan0=“3″
key_hippo=“0123456789″

To have net.wlan0, net.br0 services:

cp /etc/init.d/net.eth0 /etc/init.d/net.wlan0
ln -s /etc/init.d/net.lo /etc/init.d/net.br0
rc-update add net.eth0 default
rc-update add net.wlan0 default
rc-update add net.br0 default

Restart the desktop, in laptop, set the ESSID to hippo with key[2], then dhcpcd wlan0, try to ping the bridge, then the router. Oops, although we get the correct IP from the top-level ADSL router(192.168.15.1), and get the replay from the bridge, we fail to connect to any other hosts. I have tried different combinations of bridge and netfilter, and eventually found Bridging Mini-HOWTO:

Q: Machines on one side cannot ping the other side!
A: …
# Did you put the interfaces into promiscuous mode? (issue the ifconfig command. The PROMISC flag should be on for both interfaces.)

ndiswrapper does not support promiscuous mode, it is most likely that the incoming packages are not forwarded to the eth0 interface. But how come the dhcpcd works? If you have further explanation, please drop a message in the comment.

Next Services, 240 Miles

NEXT SERVICES, 240 MILES

It seems we are going to have a long way to go, if eth0 and wlan0 works solely, we can always use iptables to forward the packages.

Unfortunately, iptables always complained that the kernel is not setup correctly, though I strictly followed The Gentoo Home Router Guide, searched the forums, and found the trick is to start the kernel configuration from the scratch to unleash the hidden options. //sigh

The succeeding setting is quite straightforward, just setup one sub networks in each NIC in the desktop, then use iptables to forward/NAT the packages between the them. Check this post:

# /etc/conf.d/net:
config_eth0=( “192.168.15.133 netmask 255.255.255.0 broadcast 192.168.15.255″ )
routes_eth0=( “default via 192.168.15.1″ )
dns_servers_eth0=( “192.168.15.1″ )

modules_wlan0=(“iwconfig”)
config_wlan0=(“10.0.0.1 netmask 255.255.255.0 broadcast 10.0.0.255″)
mode_wlan0=“Ad-hoc”
essid_wlan0=“hippo”
adhoc_essid_wlan0=“hippo”
channel_wlan0=“3″
key_hippo=“0123-4567-89 enc open”

# Setup the IP forwarding and iptables:
# turn on forwarding
echo “1″ > /proc/sys/net/ipv4/ip_forward # ip_forward needed in kernel

# setup iptables
iptables -F
iptables -A FORWARD -i eth0 -o wlan0 -m state –state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

#Serialize the setting in the configuration files:
/etc/init.d/iptables save

# Add/uncomment these lines in /etc/sysctl.conf:
net.ipv4.ip_forward = 1
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.all.rp_filter = 1

To eliminate the burden of ifconfig/ipconfig, we may run a DHCP relay service in the router, one of lightweight dhcp/dns implementations is dnsmasq. Here is the sample /etc/dnsmasq.conf:

domain-needed
bogus-priv
interface=wlan0
dhcp-range=10.0.0.3,10.0.10,12h

The network architecture is as:

Router


Troubleshooting

[1] The menuconfig is screwed up by the old configuration, to show all the options, it is suggested to configure the kernel from the scratch.

[2] When laptop joins the Ad-hoc wireless network, the desktop may not discover the newcomer, so we have to explicitly set the ESSID of desktop again. I am not quite sure whether this is required by Ad-hoc network or the flaw of the device driver.

Zen is less Creative in software

Gentoo May 25th, 2007

I have been allured by the Creative ZenMicro for its relative high-finite sound quality and cost efficiency, last but not the least, the free PlayForSure DRM WMA service provided by Arlington County library. Eventually, I got a refurbished white Creative ZenMicro.

It works as a charm with Amarok in my Gentoo Linux, you even don’t bother to rebuild the kernel since libnjb works in the user land. Still two things bother me: the Chinese Id3v2 tag support and MTP support. After checking their web site, I start the nightmare to upgrade the firmware.

According to their knowledge base, the firmware upgrade utility only works on Windows XP with SP1 and explicitly Windows Media Player 10. What the hell of this? Does Creative Lab have a special promotion for Windows XP sale? Unfortunately, I have one Windows Vista Business and one Windows 2000 Professional. I downloaded almost 100M software and install them in my two Windows platform, failed, fair enough. I just wondered how the Windows user could stand such a bloated software just for music transfer.

Thanks for my roommate, he has one Windows XP Home, one Windows XP Professional as the playgrounds. Unfortunately, the firmware upgrade still failed without any error message, the application just hang there, no response. I eventually call the Creative Labs. The reception felt sorry about my situation, and offered me to replace the device if I would like to pay the shipping, round trip, via either FedEx or UPS. And she was so kind to remind me I should do this ASAP in the one month’s warranty.

What a crappy company!

UPDATE: Creative refund the full price with tax at the end since Creative ZenMicro is out of stock.