Saturday, February 4, 2012

Starting Over, Again.

In my previous blog entry I mentioned a bunch of goodies and ideas provided by dronz just as I was going to press with the blog post.  It took a lot longer than I expected, but I think I've finally got most of it incorporated into a new jffs base.  Originally I expected to break it into a bunch of additions, but as I rummaged through the goodies I realized much of it really belonged in the base jffs package.  So it had to be small.  The first thing I noticed was a proliferation of upxed executables from the original IZ2S and EZ2S systems that simply access a GPIO line to the zipit LEDs and buttons and such.  I figured these presented a perfect opportunity to roll them all into a single multi-call binary (mbc) executable and really save some space.  I was even hoping to toss in the IZ2S power button and screenblanker demons since they access the same GPIOs.

It actually turned out to make the most sense to create 2 mcb executables and leave the demons alone.  The static linked demons were the most efficient with memory at runtime, and don't take up all that much disk space.  Especially considering all the other savings I was getting from the two mcbs.   You can see the two static linked daemons in this htop screenshot, using a mere 16K of resident (RES) memory each while running.
The shared versions use significantly more RES memory, although there is the possibility that some of that will be recovered by sharing (SHR) with more programs running.  Here you can see the shared version of the screenblanker on the blue line with the two original static daemons on the two lines below.
I'm also starting to rethink upx.  It imposes a 4k runtime memory penalty, which is not so bad, but it also starts it's disk compression 4k or so behind the builtin (gzip?) compression on the jffs.  Now upx seemed to win somewhat in my minimal testing on the fairly large busybox and rockbox executables, but it's really hard to be sure when working on a live jffs because you never know when the jffs garbage collection will kick in and throw off all the numbers.  I really prefer to just make the executables tiny and let the jffs compress them.  Here's a shot of the original IZ2S daemons using 4k more memory after being upxed.
To make matters more difficult for me, the original IZ2S daemons were built in an earlier scratchbox environment that's a bit more frugal than the one I'm using.  I've experimented with dietlibc and musl libc to see if I could duplicate some of that frugality with the mcb executables, but the gcc wrapper used by my scratchbox environment conflicts with the gcc wrappers used by dietlibc and musl, to that's gonna take some serious work to get any sort of results.  Oh well.

Anyhow, the new additions from dronz also included some upxed helper utilities such as tee, clear, and date to pull in more functionality such as timezone, and hex passphrase management from the EZ2S network setup scripts.  I set about recompiling tiny shared lib versions of those, as well as replacing the large static sed, grep, and ntpdate programs from IZ2S with dynamic builds of minised, ugrep, and ntpclient for a rather large savings of several hundred K on the jffs.  I also threw in a new setup-tz.sh script to help get a /etc/TZ file generated after a fresh jffs install.

Now if you're off the wifi grid with your zipit, you can still set the time and date either interactively or on the command line with the new date utility.  Simply type date MMDDhhmmYYYY with the appropriate Month, Day, hours, minutes, and Year on the command line, or run /mnt/ffs/bin/date -i to do it interactively.

Also amongst the new goodies were some additions for better sound out of rockbox, however since I'd already ditched the massive alsactl utility in favor of the smaller amixer program these required some changes to the rockbox script to make them work.  I modified things to use amixer and it seems ok now, saving and restoring sound settings in the rockbox script.  I also renamed the original  /mnt/ffs/share/rockbox/eqs/Default.cfg file to Rockbox.cfg and switched to the dronz "hifi" Default.cfg file.  This apparently gets you better sound than the original default eq settings.  However I'm not positive how to activate the eq settings.  If I had to guess, I'd say go into the Settings/Sound/Equalizer menu and select Enable, then Browse to pick the Default config file.

By the way, dronz points out that you can save gobs of space on the jffs by deleting codecs you don't use from the /mnt/ffs/lib/rockbox/codecs directory.  He's got better ears than I, so he deletes the MP3 codec file mpa.codec.  I'd probably go the other way and delete most of the others...

Since I was now committed to remaking the base system I decided to throw in some more font support for the Western European characters.  The /mnt/ffs/share/fonts/erusfont.psf console font has slightly larger glyphs and is thus a bit more legible than the default font.  It may also have more unicode glyphs than the default font.  Feel free to edit the font loading line of the Zcovery script to suit your preference.   You can also load the /mnt/ffs/etc/eurokeymap.kmap instead of the default keymap.kmap.  This keymap provided by dronz allows you to use special key combos to type uincode text with the zipit keyboard.  I had trouble with this in the bash shell on IZ2S (maybe I'm missing some language setting environment variables) but it works pretty well in the busybox sh shell on the jffs.  I also couldn't get the eurokeymap to work in the e3 editor.  However the nano editor handle the unicode typing so I'm providing a separate package for that with a slightly smaller build than the statically linked IZ2S nano executable.

If you wish, you can add more fonts.  I recommend installing non .gz versions of the fonts on the jffs because the base system won't load .gz fonts and the jffs uses gzip compression anyhow, so the file size is effectively the same.

Finally, there's also a set of replacement kernel modules from dronz that you can use to enable auto-repeating keys, so you don't wear out your thumbs quite as fast.

Whew!  That's a big post.  Here's the goods, starting with the new base.  Follow the instructions from the earlier post to install it.
iz2jffs-base-v2.tar.bz2
Oops.  Apparently the new timezone script leaves you at a blank screen.  Here's the fix: tz-iz2s.zip.

The mini Rockbox is now a separate install after the base.
rockbox-391-jffs.tar.bz2
Dronz says:  You can save some space by replacing the default cabview theme with this 4k theme and the 14-Terminus-Bold.fnt font from the rockbox font pack (or this slimmer version of the font Lat15-TerminusBold14.zip).

Here's the typematic keyboard goodies from dronz. 

And the smaller (shared lib) nano editor.

This loadkeys program can be used in IZ2S to convert keymaps to the binary .kmap format used on by the jffs base.

Oh yeah, here's the updated naim IM client that uses the still functioning OSCAR protocol.  I still couldn't tell if it works though...

The handy IZ2S busybox update is still available in here.

And I still need to wrap up the final version of the source code for the IZ2S mcbs...
Here's the nearly final version of iz2s-pwr-src.tgz just in case i lose track of this...



8 comments:

  1. Instead of the 14-Terminus-Bold.fnt font from the rockbox font pack,
    use the 12-Profont.fnt from this pack, it is only 4K vs the 139K of the Terminus.
    The CenterArt theme displays time & date.

    ReplyDelete
    Replies
    1. Yes. CenterArt was designed around the 14 point terminus font with the box and line drawing glyphs, just like the ncurses interfaces I've been tinkering with. I tried a few other fonts but didn't find anything suitable. The 12 point Profont allows longer song titles, and it saves a lot of jffs space over terminus. But may be harder to read in a moving car. :) It also lacks the line glyphs used for the divider lines and volume bar, and I don't yet know how to modify the .fnt format files.

      Even so, all of the important information is there (including the time & date). If you can tone down the colors so they don't burn out my retinas, I might just go with it and demote the cabbie theme to an add on pack.

      Delete
    2. Hmmm. Maybe I *can* add the line glyphs: http://www.rockbox.org/wiki/CreateFonts

      That doesn't look too difficult. To make it work I really only need to dig up a 14x8 fixed width font with just the line glyphs and the latin-1 character set.

      Delete
    3. It gets even easier. There's already a handy font converter executable available here. http://www.rockbox.org/wiki/RockboxFontConvertor

      Delete
  2. Wow ! A 4K rockbox font challenge! :D

    ReplyDelete
    Replies
    1. Yeah, it was tougher than it shoulda been. I quickly found a tiny 2K Lat-15-TerminusBold14.psf console font file with all the goodies on my Linux Mint PC. But then I had to find the magic --iso10646 setting to make psf2bdf convert it in a way that retained the unicode table. That ends up making a 23K rockbox font file, but it's mostly empty space so it still compresses back up to 2K on the jffs.

      Actually it turns out the original rockbox terminus font also contains a lot of empty space and compresses to just under 6K with built in compression on the jffs. I'd say it wasn't really worth it for 4k, but I did learn a bit more about unicode and fonts and things.

      Delete
  3. Thanks to your infos, I learn a lot, too.
    A guy from the rockbox team converted linux fonts:
    asher.dk/rockbox/fonts/ , but I can't understand
    his unicode way....A very few of all his fonts
    displays correctly in my theme.

    ReplyDelete
  4. The sbs and wps files use the unicode box glyphs: http://en.wikipedia.org/wiki/Box-drawing_character and the bullet, sun chars.
    You can find them by running "od -c -t x1 file.sbs". Look for 3 byte utf-8 sequences like e280a2 which is the unicode bullet character u+2022. Google "unicode e280a2" to see it.
    Anyhow, the 2022 is a hex number that tells you which 128 character codepage the glyph is on. The psf font files just jam all the glyphs into two pages and have a table to map to the real pages. The bdf fonts must not have a map because they want the entire page, even if you only have one char like the bullet on that page. Hence the big file with lots of empty characters. The rockbox utility converts from BDF so it keeps all the empty characters.
    You could probably put the box glyphs in the lower 32 ASCII characters, and make a tiny rockbox font file, but then you'd have to rewrite the sbs and wps files.
    There, that should help me remember next time I have to work with unicode...

    ReplyDelete