April 2009

Samuel Morse’s Birthday

Did anyone happen to visit Google today? Those who haven’t… if it isn’t too late, have a squiz now.  Update: Google have reverted back to their old logo… the one they had up is pictured below.

Google celebrating the birthday of Samuel Morse

Yeah… I saw it and said… WTF… then it hit me what I was looking at. You’d think with the number of times I’ve heard CW on the air, I’d have recognised it straight off.

Anyway… happy birthday to you Samuel, and thank-you for providing us with this wonderful low-bandwidth mode that still sees use today. One of these days, I’ll actually get around to having a QSO on this mode. 😉

– – • • •   • • • – –      • • – •   • – •   – – –   – –      • • • –   – • –   • • • • –   – –   • • •   • – • •

Embedded development

Lately I’ve been looking around at microcontrollers.

With my work with Eze Corp, I’ve gotten quite accustomed to the MSP430. It’s a nice little MCU, with a very low power drain, gcc port and is in general, quite easy to drive. At my workplace, I use a Windows XP machine to do development under MSYS, using a MSP FET-430UIF JTAG device for programming and debugging. This is not my preferred mode of development, I’d much rather be doing it on a Linux host (or at least something that properly understands POSIX)… but it’s tolerable.

For my home projects though… this isn’t an option. I do not own a Windows computer any more, and in any case, I dislike working with it at my workplace — to hell with using it in my recreation! (The reasons why are best saved for another rant at some other time. No, I’m not a free-software hippie, I have other reasons.)

There are a number of MCUs available that I’m aware of. The biggest hurdle with many of them is the requirement of some piece of hardware which is either proprietary, expensive and/or unavailable. I like the MCUs that provide a JTAG interface, since it’s a well defined protocol that allows real-time debugging of the device as well as programming. JTAG for what its worth is little more than an SPI bus at the hardware level, it’s what’s layered on top of this that differs between devices.

JTAG can be implemented via GPIO. Since a computer parallel port is merely a specialised form of GPIO port, this enables people to wire up a JTAG port to a parallel port, and bit-bang the signals. There’s a couple of issues with this approach:

  • Parallel ports (I mean real ones) are getting harder to come by, especially on portable computers (understandable on netbooks, but I don’t see why full-size laptops don’t have them…anyway)
  • Most USB Parallel cables only have the smarts to drive a printer, they don’t allow arbitrary bit-banging of data. (e.g. the PL2305. And try explaining the difference to a salesperson…)
  • USB introduces a 1~2msec latency… which stuffs up timing at high speed.

I’ve seen some programmers (for PIC and AVR chips) that use RS-232. Now these are usually specialised devices for a given range of MCUs… that’s fine… but they suffer the same problem as the parallel-port JTAG cables… that is, most modern computers don’t have RS-232 anymore for some silly reason (as I say, understandable on netbooks… but are they saying they can’t cram a mini-din8 somewhere on a 15″ laptop?!)… and the USB latency screws timing up (I suspect this is the issue with the PL2303-based adapters we have here).

That leaves me with native USB devices.

A lot of the ones used by ARM devs are based on a FTDI chip which offers UART (RS-232) and SPI… so you get a serial console and a JTAG in one unit. Nice… In addition, there’s a open framework for debugging with them, OpenOCD. I don’t have the knowledge necessary to port this across to other MCUs… I guess one hope is that a MSP430 guru might contribute an OpenOCD port, but in the short term this isn’t an option.

For many ARM devices, there’s the J-link developed by Segger.  I’ve mentioned this one in past posts.  For MSP430, TI provide their MSP FET430UIF.  Both of these devices are on the nose from a usability point of view.  Both require you to use proprietary software in order to access their device.  This is fine if you’re on a supported platform, and the tool is well maintained.

For the J-link… well, if you’re not on Windows… forget it, that’s all they support.  The advice from them is to just run a Windows computer purely to run their GDB proxy software (which costs too I might add).

TI’s tool is theoretically a little better for support… the userspace drivers are proprietary freeware… but again, if you’re not using Windows or Linux on an i386 PC, forget it.  More to the point, the Linux version doesn’t seem to get updated as often — so the only real option is Windows.  Bad luck for me and my Yeeloong.

For what it’s worth, I do not understand why these things need to be proprietary… it’s a flipping programming cable.  Just moves data from one end to the other.  If they need to load firmware into the RAM of the chip being programmed, fine… but why can’t this be an ELF binary or something that just gets picked up by OpenOCD (or equivalent) and stuffed down the wire?

Devices like the Rabbit Semiconductor series of microcontrollers drive me insane with their non-standard nonsense… they decided to chuck many years of C history down the gurgler and invent their own “wannabe C”. #include <foo.h>? Nah… don’t be silly, we’ll just stuff everything into .lib files and #use them. Urgh!

I’d love to know what low-end microcontrollers exist that don’t exhibit the proprietary nonsense that is outlined above. 8 or 16 bits wide… I like ARM, but I’m not needing something that flashy. I like the low current drain of MSP430, and the fact they use gcc… which I guess pushes me in the direction of AVR and maybe PIC, but I’d be interested in other options. Cheap is important too, I don’t have a lot of cash for expensive tools or chips.

The other thing in the favour of AVR/PIC MCUs, is that there’s a local shop that I can buy them from — no need to order on-line. Farnell and RS have a wide variety, but I have to purchase from their website, which is awkward for me.

The applications I’d have in mind? Well, one idea is a more modern version of my headlamp… some of these MCUs draw less power than the 74HC14 chip used in that project (a few mA in standby mode) and would offer more functionality. Other applications include small controllers for amateur radio projects (not SDR though).

I’m really interested to know what controllers are out there, which are open-source friendly. Once I have a clear picture of what’s on offer, I can look more closely at my applications.

Recovering a braindead DSL-504 router

This is mainly for my own reference… but may be useful to others, so I’ll publish it here.  We have two routers, one which we keep as a spare, is a D-Link DSL-504 (not a 504T… and not a Generation II) 4-port ethernet switch and router.

Recently, I noticed the unit was not firing up — the status LED remained off, and I could not remember what the IP address was for the life of me (I had changed it from its default, and had disabled the DHCP server).  As it turned out… it didn’t have one, the flash memory had become corrupt, and so it was not booting.

These routers have a RS-232 serial port on the back for a console, to which you plug in a plain 9-pin serial extension lead (not a null-modem) and hook up your favourite serial terminal program.  The unit spits out its messages at 9600 baud 8n1.  In the above scenario, you will notice the bootloader (PP boot) complain that there is “no ATMOS image present” or some such message, and it’ll drop you to a prompt.

Firstly, you’ll need the flash image to load back in.  You get that from the D-Link Australia website, just go to their support section and look up DSL-504.  You’ll find the firmware under the downloads, it comes in a 3MB ZIP file, when you decompress this, there’ll be a .bin file inside — this is your image.

There are two ways to stuff this image back into the device.  The most obvious is the way D-Link tell you to… that is… enter xmodem at the prompt, then upload it using the Xmodem protocol.  Slow… it takes about 30mins.  There is a faster way.

These routers are capable of booting off a network in much the same manner as a SGI workstation… that is… obtaining an IP address via BOOTP, then downloading the above image via TFTP.  The concept is exactly the same.  Set up your boot server as per the Gentoo/MIPS handbook — you won’t need the special kernel parameters… but the host setting will look identical.  Just place the .bin file you obtained earlier in your TFTP root directory, and point the filename parameter at it.  If you don’t know your router’s MAC address, type tftp and it’ll tell you, then reset the router.

Once all the settings are in, and the daemons are started… turn to your terminal emulator, and issue the tftp command. It’ll immediately download the image and boot it, should take a few seconds. It’ll tell you to type quit to boot, do this.

When it prompts for a password, just press ENTER… the password is blank (not “private” as D-Link will have you believe).

Upon booting, type config save to store the settings… Don’t make the mistake I made at this point — I tried mucking with the settings via serial console and had to start over (the webserver kept giving me a blank page). If you need to, isolate it from your network at this point, just plug in a machine with a web browser.

If you decide to muck around, and have to reset it… at the prompt, type flashfs wipe followed by restart, and you’ll be back to step 1.

From here, you should be able to visit the router’s homepage and configure it as if pulled straight out of the box.