Bluish Coder

Programming Languages, Martials Arts and Computers. The Weblog of Chris Double.


Writing your own MP3 player firmware

The S1 MP3 Player (or 's1mp3' as it is commonly known as) is a generic type of MP3 that is used and branded by a number of manufacturers. It uses a chip that is firmware updatable, where the firmware is written in Z80 machine code. A number of people have written third party tools allowing writing and running their own code on the MP3 player. The S1MP3 website and wiki has lots of details about this.

A program originally announced on the mailing list called loadram is used to upload Z80 code while the player sits on the 'upload new firmware' screen. This code is run, and can return back to the player. Not much seems to be known about the MP3 players yet but it is possible to write text to the LED screen on some models.

The manufacturers firmware updates can be 'unarchived', and they contain the Z80 binary programs that are run from the firmware menu. For example, the program to run the sound recorder is called RECORDER.AP. This can be replaced by your own Z80 program, repacked into the firmware and updated to the player. From then on, selecting 'Record' from the MP3 player menu will run your new program.

What interests me about this is it gives a small portable reprogrammable device. And hopefully something I can leverage Factor's interactive development system. I wrote an 8080 emulator to play the original Space Invaders arcade game written in Factor. 8080 and Z80 are quite similar. In fact I used Z80 assembler syntax in the 8080 emulator implementation.

It wouldn't be hard to base a Z80 emulator on top of this to allow testing programs to run on the MP3 player. And to write a Z80 assembler in Factor that generated the binaries to upload to the device. 'loadram' was Linux based and has been recently ported to Windows. It uses libusb to communicate with the player. By adding libusb wrappers to Factor it would be possible to assemble and upload directly to the player from a Factor environment - and it should work on Windows, Linux and Mac OS X.

I put together a quick wrapper around libusb and added it to my repository:

darcs get

This has been tested to work on Linux and Mac OS X. I'll try adding a nice Factor wrapper around the alien definitions and get 'loadram' ported.

Note that to implement the alien wrappers I had to modify Factor's alien C structure wrappers to accept arrays of characters. The patch for this is in my repository but may not necessarily be pulled by Slava into the main Factor repository. I need to tidy it up and work on it before that might happen.

Once libusb is working and loadram is ported I'll try getting the Z80 emulator and disassembler going.

If you're looking for suitable players, Dick Smith Electronics in New Zealand, has at least two models that work. The first is their DSE branded 128MB MP3 player, model number A2439. This is a very basic model and is quite cheap. It has a black and white LCD screen which can be written too using the S1MP3 open source code.

Another model they have is the AStone Samba AV MP4 player. This has a colour OLED display and can play video and pictures - on its very tiny screen. Calling it an MP4 player is a bit of a stretch. It can't actually play MP4's. You use their client software to convert videos in other formats to an AMV format which has awful quality (not that it matters on the tiny screen) but otherwise works ok. The downside of this player is it seems that there is no known way of writing to the colour OLED displays yet.

What sort of things could be written to run on the MP3 players? I'm not sure yet but it'll be an interesting 'spare time' project to play with.


This site is accessable over tor as hidden service mh7mkfvezts5j6yu.onion, or Freenet using key: