How to hack a Sony Reader

Amazon’s Kindle receives plenty of publicity, but it’s only available in the US. Book buffs elsewhere have to content themselves with other e-book readers, of which one of the most popular is the Sony Reader. The PRS-505 is available from High Street stores like John Lewis and Waterstones, making it one of the more visible devices at the moment.

Sony's PRS-505: eminently hackable, thanks to its Linux foundations

It’s also comparatively easy to tweak and hack, thanks to the way it’s designed. The core operating system is MontaVista Linux, and though the speed of response of the e-ink screen and the lack of a full keyboard means that you can’t really use it as a general purpose computer, there is a fair bit that you can do with it.

Some is simple customisation: you can change the fonts, icons and logos, or add your name and contact details to the About screen, for example. Buttons can be reassigned, or disabled too, so if you prefer to shut the Reader down rather then send it to sleep, then you can add that function to an easily accessible key, instead of having to work through a few menus to find it.

It’s actually possible to go a lot further than that. The reader is controlled using JavaScript and XML, and there are even applications such as dictionaries and Sudoku that can be run from an SD card.

When a memory card is inserted in the reader, it’s scanned by the operating system. As well as looking for books, the folder /Sony Reader/software is checked for an autorun.xml file.

Activated with XML and JavaScript

This file defines functions for things like button presses and controls the skin elements that will appear on the display, all through JavaScript. It can also launch applications. According to the service manual, it can be used to load a diagnostic test too – and it’s by using this mechanism that you can start to customise your reader.

Universal Flasher

When you plug your Reader in over USB, you don’t see much in the way of control files. There’s a /tmp folder, a folder for Digital Editions, and a database folder, below which you’ll find the various media – images, music and e-books that are on the Reader – and a few XML files related to them.

The Universal Flasher is simple – just press 5 and then 6 to customise the firmware on your Sony Reader

What you won’t see are any of the files that control how the Reader behaves. For that, you need Universal Flasher, which is available from the MobileRead forums. Unzip it, and you’ll have a collection of files that’s designed to be copied onto an SD card, together with an autorun.xml that allows you to flash your Reader with updated firmware.

For the most basic customisations – such as controlling different button functions – that firmware incorporates more XML files. For example, the current UK firmware for the PRS-505 is version 1.2.00.18050. The Universal Flasher kit includes a directories for each model and firmware supported, called files.{model}.{firmware}. Within that, the /opt/sony/ebook/application/resources folder contains a file called applicationStart.xml and another folder, /scripts, which contains main.xml. It’s in these two files that the bulk of customisation for the reader is done. You can also replace some of the image files for the reader, by placing them in the scripts folder, changing the icon set, for example.

When you insert an SD card containing all the files from the flasher kit into the Reader, you’ll be presented with a menu that allows you to flash a new firmware, or make a copy of the existing one.

So, customising button functions is a matter of editing the applicationStart.xml or main.xml files in the folder for your Reader’s version of firmware, copying the whole lot to an SD card, plugging it in and picking the right option from the menu.

As well as the Flasher itself, download the originals.zip file, which contains the unmodified scripts and images from the reader. Icon customisations are perhaps one of the easiest: the file kBookIcon.png contains most of the icons used in navigating round the Reader, while kBookAssets.png contains the ‘Reader’ logo and some other symbols.

Changing graphics

To see how things work, let’s start with a very simple customisation. At the top left of the kBookAssets.png image is the word ‘Reader’ which appears on the main screen. Although you can put your name and other information on the About screen, people will have to hunt for it. So, we’ll replace the Reader logo with some contact details.

You need to create an image that’s 210 pixels across, and 70 high, with a black background.

The new logo should be 210 x 70 pixels, with a black background and white text, to match the existing screens

We’ve put the name of the reader, and a PO Box address, in case it’s found and someone wants to post it back. You can put whatever you want in there, but remember there’s limited space. Now, open kBookAssets.png, and paste the new image into the top left, over the word ‘Reader’. Save the file and then copy it into the appropriate place for your reader’s model and firmware, in the folder where you extracted the Universal Flasher.

For a UK 505 with the latest firmware that’s:
files.505.1.2.00.18050/opt/sony/ebook/application/resources/scripts.

Paste the new image into the top left of kBookAssets.png

Now, find a blank SD card and copy everything in the Universal Flasher folder to the root directory of the card, then slot it into the Sony Reader. When the display appears, press 5 to create an image from the files on the SD card. Once the image has been created, press 6 to flash it to the Reader; after a pause, it will reboot, and you’ll see the new logo at the top of the main screen. Replacing the icons and fonts is done in a similar way – files you put on the card replace those already on the Reader.

After flashing, our Reader has a return address visible on the main screen.

You can add text to some of the screens on the Reader, and control how they appear, by editing those XML files. For example, when you select Settings from the main menu, followed by About, you’ll see the various copyrights and logos. The information on this page comes from the main.xml file, which is in the scripts folder.

Open it in a text editor and look for the tag that starts

<group id="ABOUT_GROUP"

Just below is a <records> tag with individual <record> elements, all of which contain the text that appears on the screen. Each has a ‘kind’ attribute: types 0 and 1 have additional information added, based on authorisations for Sony’s store and Adobe DRM. If you want to add your own name and address, the simplest way is just to edit one of the other options, leaving the ‘kind’ attribute set to -1. For example:

Again, save the XML file, copy it into the appropriate folder on an SD card for your Reader’s firmware, flash, and you’ll see the new text appear on the About menu.

Calibre – using a Sony Reader with Mac and Linux

The software that’s supplied by Sony is Windows only, but that doesn’t limit the reader to just PC users. An open source tool called Calibre is available for Linux, Mac OS X and Windows. As well as providing tools for managing your library of documents, it can also fetch websites and format them for the reader, and convert documents between formats.

Calibre can manage Sony Readers and other devices, on Mac, Linux and Windows

If you want to use DRM books, such as those sold by Waterstone’s eStore and you use a Mac, you’ll need to register for an Adobe ID first, then spend some time on a PC with the Digital Editions software installed. Use that to authorise your reader with the ID, but don’t transfer any books – the Mac version of Digital Editions can’t authorise the Reader.

Once the authorisation is done, you don’t need a PC any more. You can use the same ID in Digital Editions on the Mac, and use Calibre to transfer the DRM-protected ePub files from the Digital Editions folder on to your Reader.

More tweaks

You’re not limited to simply altering the text that appears on some of the screens - you can actually add additional functions, though this is where things start to become somewhat less straightforward.

For a simple tweak, look at the applicationStart.xml file. You’ll see definitions near the top for the different keys, for example:

Assigning a global built-in function to one of these keys is achieved by changing the value of the do parameter. A popular tweak uses the long press on the centre of the navigation button to shut the Reader down, though you could equally choose to use it to much the audio. Just change the do= value to doDeviceShutdown or doMute if you prefer.

More complex customisations tend to rely on adding extra code in the main.xml file. Look through, and you’ll see that there’s a group tag for the different screens, as for the About screen that we tinkered with earlier. The <code> tag allows you to define specific functions for that page, each within its own <function> tag.

Look, for example, at the PAGE_GROUP, where you’ll find a function with the id “pageChanged” which updates the bottom of the screen with the current page of the current book. A similar function is found in menus.

And another popular hack adds a clock to the bottom of the screen. A call to this.shd_clock() is added at the bottom of “pageChanged”. Then, a new function shd_clock is defined, using a function tag, which starts like this:

It goes on to checks the preferences for clock display, and shows the time in the appropriate format, each time the page is changed. A companion function on the About screen uses the 0 key to toggle the clock display between off, 12 and 24 hour. It begins by using doDigit, then checking if the 0 key was pressed, and setting a preferences option appropriately.

Tweaks made easy

Rather than reproduce all the code here – which is essentially JavaScript wrapped in XML – the best way to learn is by looking at it in detail. The MobileRead forums include a development corner for the Sony Readers, where you can find lots of hacks. And, more usefully, you can find a way to apply many of these without having to get your hands dirty using XML or programming in JavaScript.

PRS Customizer lets you tweak your Reader by ticking a few checkboxes

PRS Customizer is a tool for Windows, Mac OS X and Linux which makes it much much simpler to apply some of the common customisations to your Reader.

All you have to do is tick the options you require, fill in any details you want for personalising the About screen, and then click the Customize button. A folder called sdcard will be populated with all the files necessary to re-flash your reader, including a copy of the Universal Flasher, so you don’t even need to download that separately. There are three alternative icon sets included with PRS Customizer, if you want a change from the Sony ones, and don’t fancy creating some yourself from scratch.

Alternative icon sets are included with PRS Customizer

If you want to find out more about the reader, the forums at MobileRead are well worth exploring, and you can also download some of the additional applications that have been written to run from the SD card slot. ®