Saturday, September 29, 2012

Workaround

In the waning summer days since my last blog update I suffered two crushing laptop failures.  Although neither laptop is completely dead, both are pretty much useless to me in their current state.  First, my ancient PIII thinkpad decided it would only run for 3 minutes before an abrupt shutdown.  Very frustrating.  I can just barely open all the windows needed for openwrt coding and then, bam, it's done.  A mere 2 days later the NVIDIA graphics chip fritzed out on my old Dell 620 (the one with the IZ2S development VM).  The poor thing still boots and runs, but I can't see what it's doing.  I'm gonna try to  dismantle it someday and reflow the solder to the graphics chip.  But that won't likely happen for a long time, if ever...

So now I'm down to an early EeePC netbook and a bunch of zipits.  That's just barely enough to workaround my laptop problem, but it'll have to do.  Since I was fresh off a successful rockbox build on the openwrt zipit, I figured that I might as well soldier on with that compiler and see what else it could do.  Unfortunately I tend to work much faster with a real keyboard.  The EeePC keyboard is extremely cramped but I can still sorta touch type without too much pain.  So the first thing I did was to build all the SDL libs on the netbook.   Now I can tinker on the EeePC first, before committing to work on the zipit.

Around the time of the laptop meltdown I managed to convince slug to rebuild the SDL library on his jffs and drop DirectFB to save a whole bunch of space.  I'm thinking a small build of the links browser would be a much better use of the precious jffs space.  But anyhow, he got it working only to discover he needed a way to do the splash screen without DirectFB.  So I poked around and found imgv, already in the openwrt packages.  It uses SDL for the graphics and has some nice features, but was lacking a command line interface that would allow it to run a timed splash screen.  I couldn't imagine an easier project to practice with the native compiler on the zipit.  In almost no time we had a working SDL splash screen and slideshow program, and slug made us a new rc12 jffs with plenty of room to grow.

Then walrus45 followed up on my imgv work and pointed out there was also a zgv openwrt package that could use some lovin.  Once upon a time I took a stab at building zgv for IZ2S because of the spiffy thumbnail image selector, but never got it to do much of anything.  For some reason, this time it was easy.  I just configged it to use SDL instead of svgalib, tweaked the fileselector to fit better in 320x240, and miraculously it all seems to work.  I still gotta get my changes worked up into an openwrt patch for github and the official packages.  Then maybe I'll try and build it with the native compiler on an IZ2S zipit.


You can fit up to 8 thumbnails on screen with the current set of hacks.  Originally it was limited to 2 thumbnails at 320x240, which (as you could imagine) was not terribly useful.  Here it is, zoomed to fullscreen on an old cell phone picture of the dog.  I haven't yet played with the slideshow feature to see how it compares to imgv.


Speaking of beagles...   Also around this time beaglebreath resurfaced and got me going again on the gpio code.  We eventually worked out that the kernel needed a small patch to enable the CIF camera gpios for use in sysfs.  Mozzwald supplied the patch, Slug whipped up a new kernel and voila, the gpios were working.  I managed to build some gpio testing hardware (no solder required ;) and beaglebreath got his weather sensor working on his openwrt zipit.  I'd still like to see if picoc can handle the timing requirements, because I think it'd be cool to have a full gpio prototyping setup on a zipit with no SD card.
 Here's my solder-free gpio test rig.  It's a bit unwieldy but I needed a way to include the pull up resistor to make the open collector gpio pins work.  The three clips on teeny tiny pins of the zipit connector had a habit of falling off whenever I tried to type a gpio sysfs command on the zipit.

Next up, maybe I'll get back to work on the flipclock.  I noticed that dronz recently added a fancy new timezone script to the the goodie bag.  Perhaps I'll try and fold the clock into gmu, with an internet radio scanner based on a shoutcast website that walrus45 pointed out.  Apparently this page works in the links browser, without javascript, although I don't have it working yet.  I tried to set it up via the links menu.  I went to setup>associations, selected "Add" to create a new association for the audio, and then created a new association with these settings:

  "Label":  shoutcast-pls
  "Content-Types(s)":  audio/x-scpls
  "program":  mpg123 -C@ %

I also unchecked something about X-Windows.  It didn't work at first, so I went back to the setup menu and picked "Save Options".  That seemed to do the trick.  Now I need to figure out how to control it better.  For example, Alsa Mixer lets me change the volume, but its a challenge to get there.


Here's the goodies (not much, really):

A zgv executable for openwrt (I still need to update the patches on github)
An imgv ipk for openwrt.

Thursday, September 13, 2012

Bedtime Stories

Thanks to some nice folks at CMU, the zipit can now read aloud to me at night.  Apparently things have come a long ways since the eighties when I toiled away in a lab down the hall from the speech guys.  I sorta remember the speech recognition software at that time had some difficulty with my central New England speech patterns.  Or maybe that was a scene from a movie... I can hardly remember it was so long ago.


Anyhow, the flite text to speech system and the accompanying Bard Storyteller epub reader appear to be a perfect fit for the zipit.  If you don't like the "kal16" voice you can set Bard to scroll lazily through the document (still hands free) instead of reading aloud.  That's a step up from my cheesy links2 based ereader.  The only issue I've run into so far is the poor rendering quality of the pictures at the 320x240 resolution of the zipit.  I might take a stab at fixing that someday.

Here it is reading a relaxing bedtime story acquired from the archives at Project Gutenberg.  I feel sleepy already...

For some reason the name and the sound quality of the kal16 voice made me think of "Karel the Robot", the intro to programming book used at CMU way back in the early eighties.  Or maybe it was just that story.  I don't know.

I put the zipit patches for this on github, so pretty soon now the nightly build should generate some official ipk files.  I really wish git would make that easier, instead of giving me trouble every single time I try use it...  Meanwhile, here are some openwrt ipk packages that work for me.

bard_0.7-1_pxa.ipk
flite_1.5.5-1_pxa.ipk 
libzip_0.10.1-1_pxa.ipk

Sunday, September 9, 2012

More of the Same

Yet another month of very light blogging.  And once again, I did actually accomplish a few things that I just simply haven't yet managed to write about.

I was lurking around on the zipit IRC channel lamenting the apparent demise of some zipit sites (and locating the backups on google and in the wayback archives) when beaglebreath mentioned he was looking to move some of his weather monitoring gpio code over to openwrt from z2sid.  Now z2sid comes with a native compiler, but openwrt is where most of the action is these days.  So I thought, hey! openwrt has a package with the PicoC small C interpreter.  Maybe that could handle it.  You only need to read and write some files in sysfs to work the gpios for the weather sensor. Based on my experience with PicoC on IZ2S I figured that'd be easy.  Of course reality gets in the way.  Openwrt had PicoC, but it was on an old version of PicoC, just before the file IO support was added.  Figures. I bumped it up to the latest version on the zipit openwrt github, and then added a tiny patch to convince openwrt to build it.  I had to switch some of beaglebreath's file IO routines to use stdio instead of fcntl.  But with that small change it seems to work for me.  However it's still unclear if it can actually handle the IO for the sensor.

At this point I decided to try a real native compiler instead of the C interpreter in PicoC.  I started with tcc because it's tiny.  It seems to work, sort of.  But I got stuck trying to link anything against uclibc.  Without a libc, file IO would probably be a challenge.  So I revisited the self contained aboriginal linux gcc that worked so well on IZ2S.  Because openwrt is eabi I was able to use the arm5l compiler which is quite reasonable for the arm5tel processor on the zipit.  I built a few hello.c progams, which worked, but the weather sensor program gave the same results as PicoC.  Hmm, maybe we're using the wrong source, or perhaps the sysfs works differently on the openwrt kernel than it does on z2sid.  Since I don't have my own weather sensor I'll have to dig up a logic analyzer someday and watch the IO lines to verify once and for all if PicoC can do it.  I still believe...

Meanwhile, I opted for a real challenging test of the native compiler.  Rockbox!  I got it to build way back in February with the buildroot cross compiler setup from openwrt, but it ran like crap so I gave up on it.

This time I compiled it on the zipit with the native compiler, but wouldn't link against the openwrt SDL shared lib.  Possibly because the libs are stripped?  I don't know.  I gotta swap in the unstripped libs someday and see what happens.  Anyhow, I still had nagging doubts that maybe the previous performance problems could've been fixed with my buffer patched SDL from IZ2S.  So I compiled the IZ2S SDL and salsa code on the openwrt zipit and static linked rockbox against it.  That was a bit of a chore, and the rockbox executable is now about 300K bigger, but it runs nice and smooth.  I had to fetch perl, some perl modules, and coreutils-install packages from the openwrt package repository to work through the rockbox build and install process.  I also created a 32MB swapfile needed to compile a few of the codecs.  Otherwise the build was fairly straightforward, if somewhat tedious.  I even compiled a pile of plugins.  Rockblox, anyone?

I still wonder if the performance problems with the cross-compiled rockbox could be fixed by installing a replacement SDL like I did on IZ2S.  Someday, maybe...

The apps on my openwrt zipit are now looking a whole lot more like my IZ2S zipit apps. 




Here's the goodies.  I updated these from the betas so now all the codecs are included, as well as a gmenu2x icon, and the key bindings on the rockblox and bubbles plugins have been fixed up.
rockbox-wrt-r3.9.1.tgz
rocks-wrt-r3.9.1.tgz

I finally managed to link against the shared libSDL using the unstripped libs from my openwrt staging-area.  So I upxed the smaller rockbox.bin down to just under 280K if you want to try and fit it on the jffs.  But it does sometimes skip when it first starts up.
rockbox-wrt-shared-upxed-r9.1.1.tgz

I also created a rockbox wrapper script with dronz' bass and treble setting settings.

RockboxWrtJffsInst.sh will set you up to use it when you boot from the jffs. This may not be required if you're using the overlay scripts.  I haven't tried them yet.


The updated PicoC is available from the openwrt package repository.

Here are some interesting PicoC links:
PicoC enhanced for a commercial PLC
PicoC robot code documentation

There might be something wrong with the openwrt gdb package so I compiled it on the zipit just in case.

gdb-wrt.tgz