Saturday, September 29, 2012

A new MP3 player and other product placements

After the last post on that EZ Flash cartridge I bought for the GBA, this installment is another tale of rampant consumerism all about another new toy I've recently bought - a Sandisk Clip Zip MP3 player. Ah, and I also bought Batman Lego 2, which has been a great success with my eldest son. It's not a bad game, far better than the horribly bugged DS Star Wars Lego at least. Probably a bit easy for most of us older gamers. It came with this amusing Lex Luthor figure, made of tiny pieces that disappear under the sofa with surprising ease:

Lex Luthor, awwww

Speaking of consumer, I really despise the way that the word has taken over the American technology press. Nobody reads, listens or watches anything anymore - they only consume. We now consume books, consume music, consume films, consume TV shows. Consume, consume, consume. Arrrgghh! It's actually made me stop listening to the Tech News Today podcast. Heh, I feel like I ought to be writing "wake up sheeple!" at this point. You get the idea.

So then, MP3 player. Eager readers may recall that 3 years ago I got a Creative Zen Mozaic to replace another Creative model that was starting to fall apart. The Zen has been a pretty good MP3 player, it has a nice user interface and after fiddling I could use gnomad2 to transfer MP3s across to it. Sadly, what really lets it down is its on/off/lock switch.

Creative on-off-lock switch

This switch is vital. You press down to turn the device on or off, with the switch springing back to the middle when you let go, or you press it up to lock the screen, whereupon the switch clicks into place. If the screen is not locked then the backlight remains on, wasting precious battery life. As you can almost make out on that crappy photo, the button and surrounding plastic have been worn away by constant use over the years, and now the switch lever itself is below the level of the surrounding plastic, making it tricky to move. In addition, the underlying springyness part and electronic contact of the switch has become flakey - it sometimes doesn't register changes from on to off or to lock at all. This seems to be a fundamental flaw in the design of the Zen Mozaic - I already had to send one back to the manufacture after only a few months of use as its switch packed in completely - and a bit of a shame, because besides that it is a good player.

Having said all that, I have been wanting to try out Rockbox for a while now, and the Creative devices have never been supported by this interesting Free firmware for digital audio players. Some advances have been made on a couple of the newer Creative devices, but not for the older Mozaic model. Even for those it does sort-of work with, it is still early days. By comparison, the Sandisk MP3 players are very well supported. I decided to take the plunge. BTW, the Zip is rated as "unstable" by the project, but only because it lacks documentation screenshots and a couple of games are not formatted  correctly for its smaller screen. The music playing side of things works great.

I couldn't find a Sandisk Clip Zip for sale in any of the major retailers here in Madrid. They only seem to sell Apple, Samsung and Sunstech devices (big in India, apparently). The bottom has really fallen out of the MP3 player market, it seems. I ended up buying from Amazon. The UK version was surprisingly the cheapest, and with no charger included, 3pin or otherwise, it made no difference to me.

Once you buy a Zip and figure out how to get the player out of the box it comes in (pro tip: use a stanley knife, nobody is peeling that glue apart) the actual Sandisk build quality feels nastier than the Creative one. The buttons on the front face are a bit hollow-plasticky sounding, and the socket to plug in the headphones doesn't inspire confidence. It needed an ungodly shove to get the 3.5mm jack in there. I haven't dared take it out again, just in case the whole thing comes apart in my hands. On the plus side, it weighs next to nothing. Not that I exactly needed a trolley to wheel around the old Mozaic, which was itself a lightweight compared to the even older Micro, but the Zip feels like it's hollow it is that light.

I didn't spend much time with the Zip's stock original firmware (OF) - pretty much just long enough to confirm that the Zip turned on and played tracks correctly. Interestingly the OF lets you choose whether to use the device in MSC or MTP mode - that's massive storage, or media transfer protocol. The Mozaic had this partly built in, but only let you use up to 2Gb as regular storage, not the whole device.
MSC means the device is seen as a regular mounted disk and is typically what USB drives and cameras use. After you finish transferring files, you have to remember to unmount the device so that you don't lose any partially written data. MTP has a more proprietary history, being a Microsoft invention that up until recently was not a standard. In recent Ubuntus at least MTP has been quite well supported. It has the advantage of not needing to unmount after transferring files, and on really modern devices the software on the device itself can still read and write to the storage even if the computer it is connected to wants to do the same. With traditional MSC only one "thing" can use the drive at a time. This is one reason why newer Android versions have switched to MTP over having a mounted drive visible on external computers.

All that said, I tried MTP on the Sandisk, and though Gnomad2 recognized it, it gave a funny error ("-1" not recognized or something). And transferring a file with a "?" in the name cause the Sandisk to lock up! Ulp. So I quickly reverted to regular MSC mode. Besides, Rockbox mostly installs as regular files on the player's drive, so having it in regular USB mode would be an advantage there.

Installing Rockbox is really, really easy! I was expecting it to be a crazy ordeal involving partition tables or something. You do have to download the OF, since the Rockbox installer patches this to boot either the OF or the Rockbox code when you turn the device on, but apart from that you literally just plug the Zip in, start the installer, and click "Install". When you unplug the gizmo it says "updating firmware" for a minute or so, then reboots into the Rockbox UI!

Rockbox is Free Software. And like a lot of Free Software, it has a user interface that is rather "designed by programmers". This means you can do tons of things, it has a million options and tweaks, and everything is consistent with the model the programmers had. But it is initially overwhelming and looks a little bare-bones. You can see a couple of the default screens on this blog post. The Zip has a smaller screen than the Zen Mozaic, but the Zip OF had a fair amount of gratuitous bells and whistles. It "looked nicer" than Rockbox, I think you could say. However, one immediately irritating thing Rockbox fixes that the OF did was to rebuild its MP3 database index every time you unplugged the thing from the USB. Every f-ing time! The whole database! This took several minutes - the sandisk forum response is "buy a charger", or (hilariously) "it must be the antivirus software you have". Ha ha.

I use my MP3 player for 3 things: listening to music at work, listening to podcasts on my daily commute, and listening to music before falling asleep at night. For the music-at-work thing, I think things will be OK. I like the fact that Rockbox aggressively switches off the backlight and does so even without being locked. Having to constantly lock/unlock the Zen to get the backlight off is probably what wrecked the switch in the end.

For the daily commute, podcast support is improved over the Zen. First off, the bookmarks are created automatically when you stop a track and automatically resume (or asks you) if you play the same track. On the Zen you have to manually create bookmarks, and manually select them from the bookmark menu. Secondly, you can set the "skip length", so that instead of skipping to the next track when you press ">>" it can skip any number of seconds. I have this set to 30 seconds, which is perfect for skipping the otherwise-great Ubuntu UK Podcast's incredibly irritating and remarkably unfunny "Tomorrow’s Technology Today" segment, for example. Or for skipping adverts, I don't always want to "consume" these.

When I plug the MP3 in before going to bed, I set a sleep timer for 15 minutes. That way if I doze off, it doesn't play all night and waste the battery. On the Zen this could be placed on a shortcut and was easy to enable or disable. When set to "off" that was it, the sleep was off. When it was set to "15 minutes" it reset to 15 minutes each time you switched it back on.

On Rockbox it works a little differently and has 2 options and a "start/cancel" button. One option controls the default time, and the other determines if the timer should reset when you switch the Zip back on again. This is actually not that helpful, and I couldn't seen any way to make it so that you could have it either off, or on-and-always-resetting-on-reboot - you always have to fiddle with 2 options. e.g. if you have reset-on-start "on", but cancel the timer, then rebooting will start the timer again. You have to go in and press "cancel" again, which is 3 menus deep and can't be placed in a shortcut. But at night, you want the timer on if you reboot (because you haven't fallen asleep and want to restart the player for another 15 mins).

So my first hack-on-the-code patch was to make it work more like the Zen. I added 0 minutes to the list of default times, and if you select that it cancels the timer. Now, when I turn the Zip on for the commute, I set the timer to 0 minutes. And at night, I set the timer to 15 minutes. The "set default time" option can be placed on a shortcut, which means there's no need to dive deep into the options every time.

A bit of RTFMing revealed that you can hide entries on the main menu. This makes it a little less overwhelming, and I immediately got rid of the options I knew I'd never use, like FM radio and voice recorder. It's a shame that this is not more configurable - on the Zen you can hide menu items and "pull up" sub-menu items into the top menu, but I don't think the Rockbox code is really designed in a way to allow this level of flexibility. Another customization I made was on the "database" menu, which is the Rockbox name for where all the track filtering options are, like list songs by artist, album, genre, etc. This is really overloaded with zany selections I'll never use. I mean "order by composer" as a main menu item? Really? The database menu navigation configuration is a plain text file, and is easy to hack up to something a bit easier to manage - of course the devs recommend not doing this. But I'm a professional, don't try this at home :-) I even added the podcast menu item mentioned on the wiki.

As you can see on those images, I've set the text to resemble the classic green-on-black that is well known for being the greatest combination.

One acronym that comes up time and time again on the Rockbox Wiki but took me a while to find out what it meant is "WPS". WPS is short for the "While Playing Screen", which is the screen shown while a track is playing.

On device screenshot

There are dozens of skins for this screen, as well as the rest of Rockbox. You can mix and match skins. I found the default WPS skin a little hard to read, and a simpler design with big letters works better on the small screen. Here the functionality over looks of Rockbox trumps the Zen WPS. In less pixels, the custom screens manage to pack in a lot more info, such as bitrate, file type, genre, and the clever "next track" text.
Rockbox playlists are just text files! This is something I've always wanted on the Zen, since creating "complex" playlists on the device is fiddly, and Gnomad2 is not much better. Now I can create a list of tracks using find and edit that list in Vim, the text editor of champions. For example, to create a list of all the Super Furry Animals tracks, I can now do the obvious...

cd /media/SANSA\ CLIPZ/Playlists/
find ../MUSIC/Super\ Furry\ Animals/ -type f | sed 's/^\.\.//g' | sort > SFA.m3u8

Then in Vim move the lines around to get all the albums in chronological order. Doing that any other way always caused me to miss out on some tracks, like forgetting the Ice Hockey Hair EP or something. No danger now. Here, go and watch this '96 performance of "Something for the Weekend" on Later with Jools Holland and be nostalgic.

What else? Oh, I've been saying "MP3" in this post, but the Zip with Rockbox also plays .ogg files too. And .flac, and a million other formats - including video game formats like MOD, SID and NSF. The Zen was limited to MP3 and some Windows-specific codecs that nobody uses. One thing that using MSC rather than MTP does really force you to do is make sure that your MP3 ID3 tags are all correct. I used tagtool to fix file names, and id3v2 to get rid of empty or rubbish ID3 tags that transferring the files off my Zen had created. After that, it turns out that the FAT32 file format can't handle some "special" characters, including ?, : and ". I used a line like this in bash to fix the mess ups for each unsupported character:

find . -name '*:*'  | while read file ; do mv "$file"  "${file//:/_}"; done

Then there's all the "under the hood" stuff that Rockbox improves over most things - battery level that seems really accurate (the Zen only ever seemed to have 3 stages: 100%, 75%, 0%), random number generator for shuffling tracks that puts Nethack to shame, loads of equalizer knobs and buttons, etc, etc.

Compiling and testing custom versions of Rockbox is pretty similar to GBA development, except that instead of an emulator the Rockbox authors have created a simulator. Here you build the source for a native (e.g. x86) version of the source code, and executing the resulting binary simulates the device running on your computer in its own little window. This makes testing custom menus and firmware builds a lot easier, since there's no need to copy stuff across, uplug, and reboot. Once you want to test on the real thing, you need to use a GCC cross-compiler for ARM. Unlike devkitARM, which is distributed in binary form to quickly get you up and running, there's a "" script that downloads, patches and compiles a suitable version of GCC and associated tools. This takes a while, but Just Works (or at least it did for me). After that, you run an autotools-like "configure" script and choose the device you want to build from the list of dozens, then run "make" to build the source code for your player.

Testing a custom build - once you have alread installed via the installation tool - involves copying your "rockbox.sansa" file onto the USB-mounted partition for your device. You don't even have to overwrite the original rockbox.sansa file that is on there. You can call it "custom.sansa", and run it from the File menu just once to test how it goes. When you're happy with the fix, overwrite the original file and you're done. The current firmware detects it has been replaced and reboots automatically.

There you have it. Rockbox. Totally recommended. Simple to install on supported devices, highly tweakable, easy to hack on, and has loads of useful features. Who thought MP3 players could do so much? :-)

Wednesday, September 19, 2012

EZ Flash IV For GBA

I've always used an ancient GBA flash cartridge that needed a parallel port connection to work. Since it is virtually impossible to buy a new laptop with a parallel printer port, I decided to buy a new flash cart that worked via USB. This will save me digging out my old Windows 98 laptop.

The idea is that you copy the ".gba" files onto the microSD card using whatever method you like. I plugged it into a card adapter and plugged that into the port on the side of my laptop. Hilariously Linux managed to mount the card read-only, which was quickly followed by a lot of searching for what could be the cause of the "mount: block device /dev/sdc1 is write-protected, mounting read-only" message. Turns out I had the lock switch in the "locked" position, making the card read only. Durrr..

The build quality of the cartridge is pretty bad, sadly. The shell is a couple of bits of plastic with a slot for its own micro SD card adapter. The microSD fits snugly into the adapter, a bit too snugly initially as I had to give it a fair old shove to get it in there. The adapter then fits equally as tightly into the cartridge itself. Once it's in you need to apply a little too much force to get the adapter out again. I'm worried something will give sooner rather than later.

On a phat DS: everything seems to work. I didn't realise this at first, but the cartridge boots up into DS mode, from where you can select GBA games from the menu and they boot in GBA mode.

On a GBA SP: everything works too, though my "GBA Rogue" port didn't launch :-( I tried a new build of PocketBeeb I've been semi-working on and that did boot on the GBA and DS, so I think perhaps it is a problem with really old homebrew. I also tried an English-patched ROM of Fire Emblem 6, and that worked too. Launching large games takes a while though - I guess this is because they get copied from the microSD onto internal RAM that the actual GBA reads. When I say a while, it takes maybe 10-20 seconds.

The cart boots up into Chinese on the GBA the first time you run it, which threw me a bit. The fourth option down changes the language to English though. One thing I'm not sure about is what the point of overwriting the flashcard "NOR RAM" is - I think this is similar to the old-style GBA carts, but all it seems to do is corrupt the main menu.

Saving seems to work OK too.

Ah, just tried Powder 117 on the DS - it doesn't boot there, but it did boot on the GBA SP. So there are some compatibility problems with homebrew games it seems. Unless Powder does something odd on start up, like checking the hardware type, causing a crash (I don't think it does though). I might try building it from source with a newer devkitARM, see if that fixes things.

All in all, not too bad. Better than having to use the smaller capacity, slower and obsolete parallel-port based flash cartridge that's for sure. Being able to load multiple GBA files is a bonus - the only way to do that on the old cartridge was using pogoshell (on Linux), FTP-ing the file over to the Windows 98 machine, then writing the ROM there with the special software. "Clumsy" is the word.

This new cart was a little pricey mind, costing €35 with a 2Gb card - although the older GBA cart I cost me more back in 2001 I'm pretty sure - but nowadays you don't have much choice about where to buy this stuff. I got this one from and it took about 2 weeks to arrive from Hong Kong to here in Spain with the free shipping option.

Here is a link to the latest firmware