View Full Version : PRS-500 lbhook.sh support patch


igorsk
10-21-2006, 09:51 AM
igorsk 1 - cramfs 0 :D
Read the provided readme.txt for instructions.
Here's a sample script:
#! /bin/bash

PATH="/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games:/usr/local/sony/bin:/usr/sbin"
LD_LIBRARY_PATH="/opt/sony/ebook/application:/lib:/usr/lib:/usr/local/sony/lib:/opt/sony/ebook/lib"
export PATH LD_LIBRARY_PATH

pstree -a -c -l >/tmp/pstree.log &

and its output (retrieved with "ebook.py get /tmp/pstree.log"):
init)
|-getty) console
|-(jffs2_gcd_mtd15)
|-(jffs2_gcd_mtd16)
|-(keventd)
|-lbhook.sh) /tmp/lbhook.sh
| `-pstree) -a -c -l
|-(msbdrv_thread)
|-(mtdblockd)
|-(sdbdrv_thread)
`-tinyhttp.sh) /opt/sony/ebook/bin/tinyhttp.sh
`-tinyhttp)

gseryakov
10-21-2006, 10:12 AM
igorsk 1 - cramfs 0 :D
Read the provided readme.txt for instructions.


This is the breakthrough! Just a couple of questions to clarify.


1. dump the current Rootfs:
>ebook.py get /dev/mtd13 0x863000
...
5. upload new Rootfs:
>ebook.py pwrite "Rootfs" Rootfs.new


So Reader lets you read the flash partitions by addresses and write by names? Is there any way to read them by names?

What is the difference between cramfs from Reader and Librie? I mean - after mounting the cramfs-es.

arivero
10-21-2006, 10:39 AM
So Reader lets you read the flash partitions by addresses and write by names?
Amazed of this. I was afraid that you were going to need to dd it, and of course you can not dd if you can not to run scripts. But straight access to the partition is a bless! Moreover tiu need it, because a file by file extract is not able to recover ln files, /dev things and all these "minor" issues.

Today 01:51 PM
Did you got to sleep, igorsk ? :)


What is the difference between cramfs from Reader and Librie? I mean - after mounting the cramfs-es.
Judging from the filesystem dumps, the architecture of the aplication has changed, but it seems that the Operating System is the same. Meaning that perhaps the communication trick (console access via usb) could work straight from librie to reader without modification, and perhaps even the display utilities to upload jpg from scripts. Next steps are, in random order:

a) try for console access via USB.
b) try to show a picture in the display using command line utilities.
c) try my command line utilities for DJVU files.
d) review how to compile Andrew's "simple reader", of if it works straighforward.
e) if not console access, create a "SMS-phone" way to enter text to show it in the console. Note that the netpbm utilities, a lot of them, are included in the djvu package, and this includes some text display utility, I believe to remember.

Slava
10-21-2006, 10:55 AM
... Next steps are, in random order:

a) try for console access via USB.
b) try to show a picture in the display using command line utilities.
c) try my command line utilities for DJVU files.
d) review how to compile Andrew's "simple reader", of if it works straighforward.
e) if not console access, create a "SMS-phone" way to enter text to show it in the console.

Next step will be to copy Russian fonts to /opt/.... :)


igorsk 1 - cramfs 0 :D

Excellent :)

gseryakov
10-21-2006, 11:22 AM
Next step will be to copy Russian fonts to /opt/.... :)


Yeah! It was a Russian party from the beginning, because the Reader hack is of terrible need for Russians to drink^Wsmoke^Wread Russian books!

Slava
10-21-2006, 11:42 AM
Igor,

I wonder if it's possible to create softlinks for directories under /opt tree to updatable filesystem like /Data? It will make updating fonts and graphics much easier.

NatCh
10-21-2006, 11:46 AM
igorsk, You Da Man! You Da Man!

igorsk
10-21-2006, 11:55 AM
So Reader lets you read the flash partitions by addresses and write by names? Is there any way to read them by names?

Download /proc/mtd to see mapping between device numbers and partitions. Then you can use "ebook.py pinfo" command to get the partition info (there ain't much). You can also execute "/usr/local/sony/bin/nblsdm list" with redirection via the script hook.

What is the difference between cramfs from Reader and Librie? I mean - after mounting the cramfs-es.
You can always extract both and compare :) From what I've seen, they're almost the same - Reader has an extra SD driver but that's about it. The main difference is the reading application.

I wonder if it's possible to create softlinks for directories under /opt tree to updatable filesystem like /Data? It will make updating fonts and graphics much easier.
Probably the same trick as with /etc would work, i.e. copy files to ramdisk and remount under a subdir. However, currently the hook script runs after tinyhttp so I'm not sure if the updated fonts will be loaded.

igorsk
10-21-2006, 12:20 PM
For the brave, here's modified cramfs tools from Cygwin which I used to extract and reassemble the cramfs image. To make sure you get the same permissions in your new filesystem, use a devtable file (-d in cramfsk and -D in mkcramfs).
A few things to know to minimize a chance to brick your device:
1) Linux0 and Rootfs2 are kernel and root fs used in the recovery (update) mode. It's best not to touch them.
2) USB control is handled by switcher.so (loaded by tinyhttp) in normal mode, and by /opt0/UsbUpdater in recovery mode. So, disabling any of them will leave you without a way to control the unit via USB.
3) Using USB interface, in normal mode you cannot write flash partitions and in recovery mode you cannot read and write files.

arivero
10-21-2006, 03:49 PM
However, currently the hook script runs after tinyhttp so I'm not sure if the updated fonts will be loaded.
It can kill tinyhttp and relaunch it, in any case.

TadW
10-21-2006, 06:56 PM
igorsk 1 - cramfs 0 :D
:jester: You rock, igor!

porkupan
10-21-2006, 08:19 PM
Igor,
Just wondering, why are you dumping 0x863000 bytes of Rootfs while the actual size of the filesystem is supposed to be 0x980000? Did you try dumping the whole 0x980000 bytes?

igorsk
10-21-2006, 09:57 PM
The partition size is 0x980000. However, the actual size used by the cramfs image is 0x863000. You can check it yourself, it's specified in the second dword of the image.

porkupan
10-23-2006, 11:20 PM
Thank you, igorsk!

http://images19.fotki.com/v34/photos/3/3909/116140/reader1011-vi.jpg

NatCh
10-23-2006, 11:32 PM
Y'all did it! Excellent!

Slava
10-24-2006, 12:46 AM
Photoshop ??? :)

Thank you, igorsk!
http://images19.fotki.com/v34/photos/3/3909/116140/reader1011-vi.jpg

porkupan
10-24-2006, 10:50 AM
Photoshop ??? :)
Not at all. But it was 99.9% igorsk's research, info and tools, which made the Cyrillic font upload into the Reader possible.

A question to igorsk. I see that you made a function cksum2() in the ebook.py, but you still call cksum(), which in turn calls the standard unix/linux/cygwin cksum to calculate the CRC. Does cksum2() work, as far as you know? If it doesn't, you may want to pack cksum.exe and cygwin DLLs with ebook.py. :) I haven't had time to check it out last night - was so excited about the process (to be described later on the Russian E-Book forums (http://www.the-ebook.org/forum) with full credit to you) working.

Slava
10-24-2006, 10:52 AM
Not at all.
...
(to be described later on the Russian E-Book forums (http://www.the-ebook.org/forum) with full credit to you) working.

I was just teasing you :) Great job! I'm looking forward to your easy-to-understand description :)

igorsk
10-24-2006, 11:04 AM
A question to igorsk. I see that you made a function cksum2() in the ebook.py, but you still call cksum(), which in turn calls the unix/linux/cygwin cksum to calculate the CRC. Does cksum2() work, as far as you know? If it doesn't, you may want to pack cksum.exe and cygwin DLLs with ebook.py. :) I haven't had time to check it out last night - was so excited about the process (to be described later on the Russian E-Book forums (http://www.the-ebook.org/forum) with full credit to you) working.
Oops, I forgot to include chskum.exe. My bad -_-.
Anyway, cksum2() is way way too slow. The first time I tried uploading the new fs I left it running overnight and in the morning there was still no progress. I was already thinking that I bricked the unit, but after I stopped the script and tried the ls command, it worked just fine. Then I realized that I didn't see the actual upload request in the log - it was calculating the checksum the whole night! So I quickly rewrote it using chksum.exe and the next time the upload was finished in under a minute.
Maybe I will make a binary module for calculating it... there is already python-fchksum but it's unix-only.

P.S. I do read your forum, I just don't want to make yet another account for just one thread...

NatCh
10-24-2006, 12:45 PM
Any chance of getting a simple tool-kit or executable type approach that would allow adding fonts for the less technically agile user? :grin:

porkupan
10-24-2006, 12:48 PM
Maybe I will make a binary module for calculating it... there is already python-fchksum but it's unix-only.

Probably not worth the trouble. There is one already (http://files.ebook.googlepages.com/cksum.exe), which seems to work just fine.

porkupan
10-24-2006, 12:54 PM
Any chance of getting a simple tool-kit or executable type approach that would allow adding fonts for the less technically agile user? :grin:
Probably someone will make a batch file soon just for this purpose. The Python executables should be convertable into EXE by the above mentioned http://www.py2exe.org/, the other stuff is mostly cygwin, but can be executed at Command Line is proper DLLs are included.

TadW
10-24-2006, 01:01 PM
Someone (boroda, is that you, porkupan?) has published the updated instruction on Russian the-ebook.org. Of course I don't understand a single word. Someone care to translate? :)

Итак, описываю последовательность своих действий.

0. Прочитал и внимательно ознакомился с инструкциями Игоря Ск. (Mobileread's igorsk) по модификации Rootfs, скачал cramfs-tools.zip.

1. Выяснил размер файл-системы в partition Fsk. Для этого сначала слил 0х100 байт из /dev/mtd14 (./ebook.py get /dev/mtd14 0x100) и посмотрел значение второго 32-битного слова: 0x40A000 - это и есть размер файловой системы в partition Fsk.

2. Слил всю файл-систему из Fsk (она же /dev/mtd14, mounted on /opt) единым файлом:
$ ./ebook.py get /dev/mtd14 0x40A000

3. Разобрал полученный файл командой cramfsck (если вы залили в директорию, в которой вы оперируете, присоединенные Игорем Ск. к cramfs-tools.zip Cygwin DLLs, то вам не нужно все это делать в окне cygwin, можно просто в досовской командной строке. Сам я все делал под cygwin, но это в принципе не обязательно):
$ ./cramfsck.exe -v -x opt -d opt.dt mtd14

4. Для страховки собрал директорию обратно в единый файл и удостоверился, что MD5 чексам такая же, как у оригинала.
$ md5sum mtd14
12e8e500e0dac98f9cd89650c0510d85 *mtd14
$ ./mkcramfs -D opt.dt opt opt.fs
$ md5sum opt.fs
12e8e500e0dac98f9cd89650c0510d85 *opt.fs

5. Скопировал заранее приготовленные шрифты в директорию ./opt/sony/ebook/FONT

6. Собрал crams image командой mkcramfs
$ ./mkcramfs -D opt.dt opt opt.fs
Если кому-то лень самому заливать, корректировать и собирать имидж, вы можете его скачать отсюда (http://files.ebook.googlepages.com/opt.fs), пока Сергей не удалил.

7. Перевел ебуку в режим recovery.
$ ./ebook.py um recovery
Ридер перегрузился и приготовился получать "updates"

8. Попытался залить opt.fs:
$ ./ebook.py pwrite "Fsk" opt.fs
Поскольку эту процедуру я попытался выполнить в командной строке "ДОСа", выяснилось, что необходима команда cksum (cygwin'овский экзешник может быть добавлен в местную директорию, и будет работать, если вы залили все DLLs из cramfs-tools.zip). Когда разобрался с cksum, апдэйт файл-системы в партишн Fsk был проведен успешно.

9. Перевел Ридер в normal mode.
$ ./ebook.py um normal
программка немного ругнулась, но ебука перегрузилась и после некоторого ожидания на экране появился кружок из стрелочек, который символизирует перезагрузку контента. Кружок этот оставался на экране значительно дольше, чем обычно, и я уже начал было нервничать, но вдруг на экране появилось родное Ридеровское меню, в котором присутствовали теперь и буквы на родном языке.

10. Вот, собственно и все. Попробовал RTF - работает. Текстовый либриенный LRF еще не пробовал, попробую вечером. Не вижу причин, почему он не должен работать. Похоже, Ридер требует называть файлы исключительно латиницей (попытка загрузить на SD карту файл, названный русскими буквами - Бонч-Бруевич.rtf, окончилась неуспехом, пришлось переименовать в Bonch-Bruevich.rtf).

Шрифты Dutch801 BT и Swis721 BT с полным набором уникодов я нашел на интернете, курьер переписал с начала и до кириллицы на Courier New Bold (читается вполне нормально, но я все-таки пожалуй перепишу его каким-нибудь более приятным моноспэйсным шрифтом, если не удастся найти Courier10 BT с кириллицей). Добавлять другие шрифты я не пытался. Если вы скачаете мой имидж (http://files.ebook.googlepages.com/opt.fs), то можете разобрать его, и переписать шрифты или попробовать скорректировать их. Рендерингом Dutch кириллицы в RTF файле я остался не очень доволем (см. картинку выше). Буду очень рад, если кто-нибудь сможет помочь со шрифтами.

porkupan
10-24-2006, 01:15 PM
Someone (boroda, is that you, porkupan?) has published the updated instruction on Russian the-ebook.org. Of course I don't understand a single word. Someone care to translate? :)
Yes, boroda and porkupan are in fact the same person :kid:.

Not sure there is any value in translating the above Russian text into English. I basically reitereated in Russian the info in igorsk's readme files and the Sony Reader hacking Wiki. The sole purpose of the excersize was adding the Cyrillic support to the Reader's fonts. I did provide the link to my modified image of the Fsk (/opt) filesystem with the new fonts already built-in. I didn't uncover any new info, and I didn't find any problems with the process, described by igorsk. I was working in a cygwin environment, but all of this could be done in "DOS" Command Line window with just a bit of investigative effort. If you have the ready image, and you don't wish to unassemble and reassemble it to add or remove your own stuff, you will not really need cygwin libraries and/or environment (get the cksum.exe too).

NatCh
10-24-2006, 01:46 PM
Probably someone will make a batch file soon just for this purpose. The Python executables should be convertable into EXE by the above mentioned http://www.py2exe.org/, the other stuff is mostly cygwin, but can be executed at Command Line is proper DLLs are included.Excellent. It's so wonderful to be in the (virtual) presence of greatness. :2thumbsup

njt
10-24-2006, 02:16 PM
I for one can't wait for this... Having to use pdf for Japanese fonts is quite a bother :s.

kurochka
10-24-2006, 04:04 PM
I for one can't wait for this... Having to use pdf for Japanese fonts is quite a bother :s.

The comment about Japanese made me think whether we could install fonts with entire Unicode-defined range (a huge file but shouldn't be a problem, right?) so that one could read any language on the device? This could be great for language learners and polyglots (I've heard they do exist).

gseryakov
10-24-2006, 05:08 PM
Someone (boroda, is that you, porkupan?) has published the updated instruction on Russian the-ebook.org. Of course I don't understand a single word. Someone care to translate? :)


You'll be disappointed.


So, I am describing the sequence on what I done.

0. Read and carefully grasp instructions from Igor Sk. (Mobileread's igorsk)
on Rootfs modification, downloaded cramfs-tools.zip.

1. Figured out the size of the file system in Fsk partition.
For this first downloaded 0х100 byte from /dev/mtd14 (./ebook.py get /dev/mtd14 0x100) checked the value of the second 32-bit word: 0x40A000 -
it is the size of the filesystem of Fsk partition.

2. Downloaded all filesystem from Fsk (a.k.a. /dev/mtd14, mounted on /opt) as contiguous file:
$ ./ebook.py get /dev/mtd14 0x40A000

3. Decompressed the file with command cramfsck (it you downloaded in the current directory the DLLs from CygWin, attached by Igor Sk into cramfs-tools.zip Cygwin DLLs, then you do not need cygwin window, plain dos command line is ok. I myself have done all that in cygwin but it is not nesessary):
$ ./cramfsck.exe -v -x opt -d opt.dt mtd14

4. To be sure compressed back the directory into contiguous file and made sure MD5 checksum is as before:
$ md5sum mtd14
12e8e500e0dac98f9cd89650c0510d85 *mtd14
$ ./mkcramfs -D opt.dt opt opt.fs
$ md5sum opt.fs
12e8e500e0dac98f9cd89650c0510d85 *opt.fs

5. Copied the prepared fonts into directory
./opt/sony/ebook/FONT

6. Compressed crams image with mkcramfs command:
$ ./mkcramfs -D opt.dt opt opt.fs
If somebody is lazy to download/upload the image, change it and compres it back you can download it from отсюда (http://files.ebook.googlepages.com/opt.fs), until Sergey deleted it.

7. Swith the e-book to recovery mode
$ ./ebook.py um recovery
Reader got reloaded and was ready to receive "updates"

8. Tried to upload opt.fs:
$ ./ebook.py pwrite "Fsk" opt.fs
Because of it was done in DOS command line, it occurred that command cksum is needed (you can add the exe-file from cygwin to the current directory and everything will be ok if you took all dlls from cramfs-tools.zip). When I got through cksum, the update of filesystem of Fsk partition was name successfully.

9. Swithched Reader into normal mode:
$ ./ebook.py um normal
There were warnings but the e-book reloaded ok and after some period a circle of arrows appeared which signalize content reload. The circle stayed on the screen longe then usial and I almost started worrying but instantly the native Reader menu came to the screen with Cyrillic letters.

10. This is essentially it. Did try RTF - works fine. Text file LRF from Librie did not try yet, will do today evening. See not reason for not working. It looks like Reader needs the file names to be Latin (I did try to load to SD card a file named with Cyrillic - Бонч-Бруевич.rtf, it failed so I renamed to Bonch-Bruevich.rtf).

The fonts Dutch801 BT and Swis721 BT with full Unicode I found on the net, Courier font I rewrote from the beginning till Cyrillic with Courier New Bold (it is pretty much readable so I will rewrite it someday with some monospace font which is more pleasable, if I failed to find Courier10 BT with Cyrillic).
Did not try to add more fonts. If you downloaded my image (http://files.ebook.googlepages.com/opt.fs) you can decompress it and rewrite the fonts or correct them.
I don't like too much as the Dutch font is being rendered in RTF file (see picture above). I'd be pleased if somebody helped me with fonts.

arivero
10-24-2006, 05:23 PM
The comment about Japanese made me think whether we could install fonts with entire Unicode-defined range (a huge file but shouldn't be a problem, right?) so that one could read any language on the device? This could be great for language learners and polyglots (I've heard they do exist).

It is possible that SimpleReader, from Andrew Jennings, can be run in the Reader with only minor modifications to the keyboard input, or perhaps note. And it supports korean and japanese unicode, due to popular requests.

gseryakov
10-24-2006, 08:29 PM
It is possible that SimpleReader, from Andrew Jennings, can be run in the Reader with only minor modifications to the keyboard input, or perhaps note. And it supports korean and japanese unicode, due to popular requests.

Sue Sony. You just opened the hige China market for them.

hkabir
10-24-2006, 08:57 PM
We, who are not programmers, and don't understand a lot of things inside a program, need a exe file on windows platform so that we can also add fonts. I guess someone can help us having the same enjoyment as the programmers' are enjoying. Shouldn't we?

NatCh
10-24-2006, 09:36 PM
See post #22, hkabir: it seems the Great Ones already have something like that in mind. :)

And now, let us move the Great Ones to wrath, lest they withold their Bountiful Blessings from us. :laugh4:

porkupan
10-26-2006, 12:59 AM
Finally I got a hold of all three good Unicode fonts (Roman, Swiss and Monotype). Now we have fonts, which are essentially identical to the original packaged ones, but have full European language support. For Monotype font I had to use the Courier10 Pitch Win95 BT font, that required a slight mod to the kconfig.xml. The latest /opt cramfs image is at the same spot (http://files.ebook.googlepages.com/opt.fs). The instructions for loading the image into the device are still valid.

Slava
10-26-2006, 01:27 AM
... For Monotype font I had to use the Courier10 Pitch Win95 BT font, that required a slight mod to the kconfig.xml ...

Thank you!

It's probably good idea to add archive with those fonts and updated kconfig.xml to replace those on PC :)

njt
10-26-2006, 03:41 AM
Finally I got a hold of all three good Unicode fonts (Roman, Swiss and Monotype). Now we have fonts, which are essentially identical to the original packaged ones, but have full European language support. For Monotype font I had to use the Courier10 Pitch Win95 BT font, that required a slight mod to the kconfig.xml. The latest /opt cramfs image is at the same spot (http://files.ebook.googlepages.com/opt.fs). The instructions for loading the image into the device are still valid.
Could I trouble you to try a Japanese text with it to see if it works?

porkupan
10-26-2006, 10:54 AM
Could I trouble you to try a Japanese text with it to see if it works?
The new fonts only include Unicode sets up to Cyrillic (Latin based languages, Greek, Cyrillic based languages). There are neither Chinese nor Japanese characters there. You would have to use full Unicode fonts, i.e. Iwata (from the original Librie).

porkupan
10-26-2006, 11:02 AM
It's probably good idea to add archive with those fonts and updated kconfig.xml to replace those on PC :)
Slava,
All of that is already there. You just need to learn to use cramfsck. :vulcan: kconfig.xml is in the sony/ebook/application directory, the fonts are in the sony/ebook/FONT directory.

Upd.: Actually, I just checked - the kconfig.xml file is different on a PC vs the ebook. So you shouldn't copy one to the other. :rolleyes5 But the fonts part is similar. This is what you would need on the PC:
<ui>
<font face="Swis721 BT" href="[bbebFontPath]" engine="FreeType">
<family name="roman" uses="Dutch801 Rm BT"/>
<family name="swiss" uses="Swis721 BT"/>
<family name="modern" uses="Courier10 Win95BT"/>
<family name="script" uses="Dutch801 Rm BT"/>
<family name="decor" uses="Dutch801 Rm BT"/>
<family name="tech" uses="Courier10 Win95BT"/>
</font>
</ui>