Memories, Dreams and Refractions: Network Products Part I

In 1981 Business Application Systems was making a version of the BASPort portable operating system (private labeled VOS) for SCI Systems, a corporation based in Huntsville Alabama. That spring BAS agreed to sell the portion of BAS developing VOS to SCI.

Flash back to the 1960s when the integration of components for the Saturn V Instrument Unit was taking place in an IBM facility in Huntsville Alabama. SCI, then called Space Craft Incorporated, had created two of the boxes to be bolted into the IU. My father was the engineer responsible for determining that those boxes worked properly (backed up at a less technical level by NASA engineers). In the course of working with SCI employees my dad got a good feel for the SCI corporate culture as strongly formed by the asshole who ran it by the name of Olin King. Dad’s reports left me with a crystal clear judgement about whether I’d jump off a bridge or work for SCI.

So when news of SCI acquiring us was sprung I started shopping for a new job. By what I now consider to be one of the biggest coincidences that I’ve never experienced, a month or two after the acquisition Bob Nichols and Steve Schleimer approached me about joining their new startup Network Products that was chartered to make data communications equipment. I jumped at it. Working with Steve again was going to be simply sublime, as he’d been my mentor at Data General (he authored the virtual machine of the commercial language system I worked on). And Bob and I had got along pretty well at BAS (Bob wrote the commercial system’s compiler). Steve had left Data General where he was a software architect and developer of Data General’s Fountainhead project while Bob had already left BAS. Also joining us were Steve Hafele, a hardware design engineer also from Fountainhead and Steve Chewning, an ex-HP hardware design engineer.

Babymux

To be continued.

Trouble in Arduino Paradise

(This is another article I wrote a year or more ago but never got around to publishing until now)

I’ve been helping an ecologist make a “compass bearing data logger” using an Arduino Uno. Actually, I’ve been doing most of the implementation while Erik has defined the requirements based on his many years doing field work with other logging tools. (It is pure joy to have crisp requirements so you know your solution happens to match the problem at hand!) Erik picked the Uno and it seemed like an excellent choice because it was very easy for him to combine bits and pieces from Adafruit to create a solution. We quickly became aware of off the shelf software libraries that either come with the Arduino IDE or that are available as add-ons from the main Arduino repositories to support the hardware. At the start of the project it seemed unimaginable to exhaust the Uno’s memory capacity with such a simple application. Does that sound familiar?

After getting about 98% of the functionality in place the IDE still reported only about 24 kilobytes of text usage along side the Uno’s 32 kilobyte capacity figure. But after the addition of the last hundred or so lines of C++ the system became unstable. It wasn’t unstable in the usual sense that the new code didn’t work right the first time. (My batting average up to that point had been excellent, but there had been a number of surprises.) The system was unstable in the sense that only the first sliver of initialization code was executing, but it was executing over and over forever. The CPU was reseting after just a little bit of the application code had executed.

When I was much younger I might have thrashed with this a long time, struggling to determine what broken code fragment I’d added somehow explained the failure. Instead I got out the machete and gutted the bodies of several functions until the overall code size was similar to what it had been the last time the system had run properly. Sure enough, it ran properly again. Replacing stub code with full function bodies in various combinations proved that it was simply the amount of code involved that caused the instability. I should point out that this program has very little “variable” storage in relation to the Uno’s 2kb of RAM. That is, it has maybe a dozen scalar variables, one small character array for building file pathnames, and a couple of objects to do with the clock/calendar and compass chips and the SPI interface to the SD card used for the actual data logging. Also, there are no recursive routines and very few local variables and very shallow call nesting, so stack demands are trivial too. In short, the bad magic was to do with undiagnosed overflow of “something” to do with the amount of text (machine instructions produced by the C++ compiler).

Except that C semantics require initialized string constants to be put into the data segment, and this has to be mutable, and therefore in RAM vs flash memory. Duh. So I was overflowing RAM, causing the stack to walk over the top of variable storage as it nested during routine calls.

The trouble in paradise is that in my world it’s just not acceptable that overflow of a statically allocated memory segment would go unnoticed by the tool chain. In my world this kind of misbehavior forces the Arduino IDE into the “piece of sh*t” bucket and I’m only persevering with this tool chain now for the sake of Erik’s target user group being able to make this logger with user-friendly tools. The Arduino IDE is fantastically user-friendly for making an Arduino blink LEDs. Going much beyond that in my experience has given appreciation for the “get what you paid for” adage.

But the other trouble is that it appears that some combination of Linux, the USB library “RXTX”, and the Arduino IDE are conspiring to ruin my system’s uptime record. If I had a nickle for every time a failure to do with the USB connection between the IDE and my Uno has forced a reboot I could buy another several TI MSP430 Launchpads. More on this here.

 

 

Raspberry Pi with little SD cards

If you have an old SD card that’s less than the 2gb needed to run the blessed Raspbian (Debian Wheezy) Linux distro made for the RPi, or like me, you had a 4gb SD card but a bad spot turned it into an 870mb SD card, fear not. If you’ve got a thumb drive you can trivially carry on. Here’s how.

First thing is to copy the image file to both devices with commands like this, after:

1) BEING SURE you substitute your /dev/paths and

2) Unmounting the card and/or thumb drive before copying images over the top of them

sudo dd if=2012-07-15-wheezy-raspbian.img of=/dev/sdk ; **>>MY<<** thumb drive

sudo dd if=2012-07-15-wheezy-raspbian.img of=/dev/sdi ; **>>MY<<**SD card

If the SD card was 64mb or better, then you should have an intact copy of the FAT filesystem on the front of your card, and if you have a current Linux system it automagically mounted . If not, mount it with something like mount -t vfat /dev/sdi1 /somepath and then cd into /somepath (or the actual filesystem typically under /media).

Edit cmdline.txt to look like this:

dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/sda2 rootfstype=ext4 elevator=deadline rootwait

Then cd out of this filesystem and umount it, put the card into your Raspberry Pi and the thumb drive into one of it’s USB sockets (or a hub socket) and power it up. The command line above will tell the system on the SD card to mount the root filesystem on the thumbdrive instead of trying to use the (uncopied or corrupt/incomplete) 2nd partition of the SD card.

 

Goals for my Raspberry Pi computers

I have two Raspberry Pi boards now, and both seem to be finding a long term role. The first I’ve been using for some time as a PC at Splat Space meetings. Connected to the meeting room’s LAN, a mouse, keyboard, and USB-based hard drive, this RP makes a usable stand-alone Linux system for keeping up with email and the like. A fellow Splat Spacer is making a case for this RP with his 3D printer (thanks, Geoff!). Instead of hauling all the pieces and parts and plugging them together for every meeting, I intend to strap the RP, hard drive, USB hub, etc to the back of the monitor. A wireless bridge is needed, too. I still have several left over from when our broadband was via Starband and I was my next door neighbor’s ISP.  This RP is named kludge-pc.

The other RP is destined to live on my home LAN. The original charter I had in mind for it when I ordered it in February was as a low power, battery-backed “overseer” to monitor the various bits and bobs in the house and make available clues as to what’s right or wrong with things. I especially want it to be able to diagnose common failure modes, such as when the wireless repeater gets unplugged for the sake of the vacuum cleaner and then we all wonder what happened to the Internet connection. But since deciding on this job for it, I’ve since realized we badly need a local caching DNS server to make today’s URL-heavy web content less painful to access. Before we could get broadband at this house in the boondocks, I ran an autodial modem-based LAN, and a DNS server was key to making it tolerable. The problem with that (bind-based) setup was that it had to be highly available, and apart from it becoming painful to reboot while others were using computers in the house, I begrudged the watts of electricity. I can’t use my main Linux system because I can’t guarantee it being up all the time (of all things the Arduino development IDE is capable of killing it: more on that in another post.) But a 3.5 watt board like the Raspberry Pi will be perfect. Finally, the GPIO on this board in combination with the Adafruit Linux distro will naturally tie into various monitoring functions, such as how many hours a day the water pumps are actually running. The obvious name for this RP will be eye.

Raspberry Pi round two

I ordered a Raspberry Pi in late February, soon after the gate opened, but didn’t get it until late May. My vendor Newark opened the gate again, this time with a quantity ten limit, on July 5th and I put in for 10 more as a group buy for fellow Splatspace enthusiasts. Newark published “late August” delivery as they were opening the gate, gave us a crazy 162 day lead time right after the order was put in, then pulled it back to August 16. The 10 new boards arrived yesterday, three weeks after the order and three weeks ahead of schedule. They were triple-boxed and this weekend we’ll be testing each one before sending it on to its new home.