Few new drawings

I’ve been working with a new design these past few days … I’m trying to build a portable power supply / charger for mobile usb devices. Inspired by Lady Ada’s Minty Boost, I set out to build something a bit more powerful. Perhaps I can call it the Minty XL? Alas, that is not the topic of this article. The charger is based on two “modules” which are discussed here. I felt it was a good idea to build these modules as separate units, so I can breadboard them and test out their design, before committing to have a PCB professionally fabricated for the actual charger.

The first module is a boost converter based on the National Semiconductor LM2698. This converter takes 3.6v from the batteries and boosts it to 5v. The converter should supply at least one amp and perhaps as much as 1.3 amps under ideal conditions. To test the design and layout, I’ve designed a small single sided PCB that will plug into a breadboard using a four pin header.

lm2698 boost converter schematic

National supplies the LM2698 as a mini-so8 package, so it’ll be some challenging soldering to do with an iron! Although a 4 pin header was used, there are really only 3 connections. Vi will connect to the batteries or current limiting circuit simulating batteries. Vo is the boost output, which is also indicated by an LED. Two low esr tantalum capacitors provide input and output filtering and some smaller ceramic caps provide decoupling for the IC and a filter for loop compensation. Two resistors form a voltage divider, supplying 1.25v to the feedback circuit of the chip. The coil is a two amp 7mmx7mm shielded ferrite core inductor and the switching diode is just some schottky I picked out of the Digikey catalog.

lm2698 boost converter pcb

What good is a powerful portable charger if its own batteries wear down? The second module for my project is a battery charger based on Maxim’s MAX1811 Li+ Charger. The MAX1811 is designed to be a USB powered charger, which seems a fitting complement to a portable USB charger. In fact, if you visit a dimension were conventional physics don’t apply, the device may be able to recharge itself! Anyway, the MAX1811 based circuit is very simple – the chip does all the heavy lifting of monitoring the cell health, temperature and state of charge.

max1811 usb lithium ion charger schematic

Two capacitors, neither strictly required provide filtering on the input and output of the chip. An on-board LED indicates the charging mode. When the LED is on, the charger is bulk charging the cell, up to 500mA. When the LED is off, the charger is either preconditioning the cell (for severely discharged cells), maintaining the cell, or off. I would have preferred a little more information, but hey, I like simple and this chip is that, the blocking diode is even built in!

max1811 usb lithium ion charger pcb

Thankfully Maxim supplies the MAX1811 in an so8 package, so it should be fairly easy to solder. This small circuit board also plugs into a breadboard using a three pin header. V+ supplies the charger with roughly four to six volts. B+ is the charger output to the battery, and both the battery and supply share a common ground.

Hopefully this weekend I’ll be able to fabricate these circuit-boards and will toss up a few pictures of the finished product.

Diskless Computing

Following up on the dev box upgrade article, I’ll try to describe the process of blind luck and educated guesswork that enabled my network to support “fat clients”.

My dev box had a conflict. I needed memory bandwidth and processing power, but I didn’t need local storage. Ever since a near miss on a total loss of all my development work, I had moved everything onto a central server, which performs scheduled backups, has uninterruptible power and redundant disks. This meant the dev box only needed to store the OS and the software tools I used to do my thing. This was fine when I was using the slower Pentium IV … its udma 66 hard disk was plenty fast for the kind of bandwidth that machine had to deal with. Aside from the drive being noisy, all was well. After I upgraded the box, I first tried using the old drive again. It worked OK, but I could feel it was a real bottleneck, so I went with a modern sata drive instead. This eased the bottleneck some, and it was quiet. However, it was also wasteful, 90% of the local space was never going to get used. This waste put me in conflict as to how to resolve the situation, so instead of fixing the problem, I just ignored it.

Lately, I had been playing around with virtualization on my file server. It had also been upgraded recently, and was flush with diskspace and bandwidth. One of the fruits of my virtualization experimentation was Windows on Linux. Now I’m not talking emulation like Wine or Crossover or whatever else there is… I’m talking about a complete virtual machine living inside the memory of my server (which runs a flavor of Redhat Enterprise Linux called Centos). This gave me ideas, wild and crazy ideas! If I ran linux as the host os on my dev box, I could boot it off the network, and then run Windows XP as a guest, in a virtual machine!

The first steps were easy:

1) My network is ‘managed’ by a ‘lill router, the WRT54G, running some great firmware called DD-WRT. DD-WRT gives your $50 router $5000 worth of software features and a real nice interface to manage it all with. I configured my router, which was already playing the role of dhcp and local dns, to act as a bootp server as well.

2) Bootp works hand-in-hand with a file serving daemon called TFTP. The router can run tftp, but it’s storage is limited and I don’t feel like doing an SD Card Upgrade, so I gave the tftpd role to my network fileserver. After a quick “yum install tftpd” and an edit to “/etc/xinetd.d/tftp” I was all set.

3) Pxelinux.0 is a network boot image of sorts. It is built on syslinux, which is a microscopic distribution commonly used for booting heavier versions of linux. You see it used to boot almost every linux distro’s install cd and live cd. This special file is used to search out a configuration file on the tftp server that tells it where to find a kernel. It first tries various combinations of the client MAC address, followed by various other hexadecimal numbers and finally gives up and looks for a config named “default”. This lets you pass along different configurations to different computers or groups of computers.

4) Find a victim distribution. Ubuntu linux appears to be wildly popular right now. I’ve been running it for a few months on my laptop and I think it’s nice. One benefit of popularity is lots of people try lots of things, and some of them write about it on the interweb. So because there was a lot to read on diskless ubuntu, I stuck with that distribution. The recommended method is to install a local copy of the OS, mount your nfs root, and copy everything over. Instead, I just opened a new virtual machine on the server, installed ubuntu there, and then copied everything over. This allowed me to tweak and experiment to my heart’s content, without troubling a physical machine with lots of reboots and such. Three simple commands did the job; “mount -tnfs -onolock , “cp -ax /. /mnt/.” and “cp -ax /dev/. /mnt/dev/.”. I think the /dev part is redundant, since 2.6 uses devfs but I’m not a big guru on linux.

5) Copy that kernel and bring its ramdisk too. For whatever reason, the kernel needs a crutch to help it get going. On a disk based system, the crutch (ramdisk) might contain drivers to enable the kernel to work with a raid controller or a funky filesystem. On a diskless system, the ramdisk contains drivers for the network card and a basic dhcp client and tcp/ip stack. So bootp loads syslinux. Syslinux loads the ramdisk and the kernel, and setups up some things for the kernel. Then the kernel gets executed and sets up a bunch more stuff and then starts up init. Once init is up and running, things take off and the pretty soon you’re at the gdm greeter. You do need to rebuild the ramdisk, since the default is for a local disk boot. Changing one line in the initfs config file from boot=local to boot=nfs is all that’s needed, then just rerun the script that generates the initrd.

Now the job gets a little more interesting.
6) Configuration confusion. If you have a few systems sharing a single nfsroot, they’ll step on each others toes. I don’t plan to run a huge number of hosts, more than likely it’ll just be one. But, I wanted to learn some tricks anyway. First, the system hostname is very important to a lot of linux services. There didn’t appear to be an easy way to setup the hostname based on information from the DHCP server. I don’t know if there is a proper way to do this, and asking for help on a linux forum is generally an exercise in futility. Anyway, I came up with a script that init runs early on startup that sets the hostname from dhcp and dns information. It should work fine for any network that has local dns of its own IP addresses. The other config file to worry about is xorg.conf. Luckily, Xorg is smart, and reading the man page for xorg.conf, it shows that X will look in various places for various combinations of a config file name. The option that made the most sense for my setup was /usr/etc/X11/xorg.conf.hostname … so I nuked the original /etc/X11/xorg.conf and created a new one custom for each host (I’d been using a laptop to test this with before moving to the desktop). Now each host has its own X configuration specific for the display and video card. Lastly, the diskless howto’s recommend / recommend against mounting various directories on a ramdisk called tmpfs. I have some mounted that way, and others are shared. This will require more study if I use this knowledge in a bigger enviroment.

7) Get virtual. Installing VMWare Player was pretty straight forward… pretty much you just answer all the questions with the default “yes”. VMWare is a little buggy over nfs for some reason, and I need to sort that out since I can’t have the virtual machine crashing and failing to start. I built a windows xp pro virtual machine on my fileserver, which runs VMWare Server, and then I just open that machine on the dev box using vmplayer. I was happy to see Windows XP boot up just fine, and it actually saw the usb devices I had connected to the host machine. Drivers for my HP Printer installed and work great. Sound was broken at first, since vmplayer uses OSS, which my linux distro uses ALSA … there’s a quick and easy fix that involves loading an alsa-oss emulator library prior to starting vmware. Presto, sounds are mixed in just fine with the hosts sounds now.

8) Get busy. The main task of reading datasheets and drawing schematics I will do natively in Linux. Windows XP is there pretty much for running my pic programmer and compiler. The windows guest os mounts its smb shares off the file server as normal, and is actually pretty responsive.

Overall, this was a great project. I learned a great deal, of which I might be able to reuse for some of my educational customers. I haven’t done any concrete testing, but I’m pretty sure this diskless system is as fast or faster than a single drive system would be. The connection from client to server is over gigabit eithernet, and the server is running a multidrive RAID array. The last network benchmarks I ran yielded writes of 32meg/sec and reads of 60meg/sec.

Dev Computer Upgrade

My project for this past weekend was to get my development machine up and running, after being in a state of ‘upgrade’ since pretty much July.

The old box was 2nd generation Pentium IV (mpga 478, 400fsb) 1.6ghz, with a gigabyte of rambus and a tired old pata hard disk. The machine served well for 90% of the tasks asked of it, as drawing schematics and reading datasheets is not very tasking work. However, when it came time to prepare the pcb layouts for photo-lithography, the graphic files were huge (300mb+), and the poor p4 just swamped under the strain. So, I had planned to upgrade my ‘gaming rig’ that summer, and was going to move the old gamer up there to work off it. The old gamer however, had other plans, and decided to be unstable after it was retired. So, I just abandoned the entire project for months. Later in the fall, Newegg had a special, to clear out the now obsolete Athlon64 socket 939 chips. You get a cheap board and a cheap chip for $89, shipped free! So I grabbed two; elitegroup kn1 lite and athlon64 3400+. The kn1 lite isn’t that bad, it has the nvidia ultra4 chipset, a pci express x16 slot, plenty of ram slots and other connectors. The 3400+ is nice, running at 2.2 ghz, it also supports powernow and will scale down to 1 ghz when idle.

Specs:
CPU: Athlon 64 3400+ socket 939
RAM: 2GB Corsair XMS PC3200
Mainboard: Elitegroup KN1 Lite
Video: Biostar GeForce 6200
Drive: Hitachi “Deathstar” 250g sata

So I built my new dev box and it was nice, and quiet too, like most of the athlon64’s I’ve built. Not wanting to suffer the pain of a tired old pata drive, I built the new box with a 250g sata drive pulled from the old gamer. After I had loaded all my software, I had used about 6gig of the 250. This little fact had started another project, my quest for diskless computing.

The box ran great! XP booted in under 30 seconds. There was copious ram and bandwidth for dealing with pcb layout panelizing. Only one thing continued to gnaw at me; and that was wasting a huge drive on a box that didn’t need local storage. Sure, I could have bought a smaller drive, but that didn’t make sense … a 40g sata drive costs over $1/gb compared to the $0.40/gb I paid for the 250. I was conflicted, and that led me to ignore the computer. So, without a dev workstation, I had an excuse to not do any development work. Then I finally decided to give diskless computing a try!