View Single Post
Old 09-17-2012, 04:30 PM   #658
Kai771
Just a Noob
Kai771 can program the VCR without an owner's manual.Kai771 can program the VCR without an owner's manual.Kai771 can program the VCR without an owner's manual.Kai771 can program the VCR without an owner's manual.Kai771 can program the VCR without an owner's manual.Kai771 can program the VCR without an owner's manual.Kai771 can program the VCR without an owner's manual.Kai771 can program the VCR without an owner's manual.Kai771 can program the VCR without an owner's manual.Kai771 can program the VCR without an owner's manual.Kai771 can program the VCR without an owner's manual.
 
Kai771's Avatar
 
Posts: 140
Karma: 162610
Join Date: Aug 2011
Device: Kindle 3
Noob 2 Noob - KindlePDFViewer Development Guide

Now that I managed to properly compile kindlepdfviewer, I thought I should write a guide about it while my memory is still fresh. The developers had plans of writing DEVELOPMENT.TXT - see https://github.com/hwhw/kindlepdfviewer/issues/62, but they never did, and there isn't much info in the wiki too, so, as a thank you to them for their efforts and their help I'm writing this guide in hope that in absence of other info someone might find it helpful, at least until something better comes along.

Let me start by saying that what you are about to read isn't the only way. There are always multiple ways of doing the same thing. I can't cover them all, even if I knew them (which I don't). This text will be just one way - not necessarily correct way - but the way that works, described step by step, in as much detail as I can, that anyone should be able to follow and achieve the same results.

For this way, you will need 32-bit Linux installed. To save you from reading the previous posts, the reason is because other people reported problems with using 64-bit Linux and compiling for kindle (twobob), even if compiling in emulation mode (tigran). So to avoid all that, we will use 32-bit Linux, specifically Ubuntu 12.04 LTS Desktop 32-bit (you can download iso image here: http://www.ubuntu.com/download/desktop). If you feel really adventurous, you can use Linux Mint 13 "Maya" - Cinnamon (32-bit) (you can download iso here: http://www.linuxmint.com/edition.php?id=105)

Note: I'm kidding about the adventurous part. These two distros are the ones I tested. Other distros should also work, especially those based on Ubuntu or Debian (other might have different commands for installing packages), but I can't guarantee it since I never tried. So if you're following this guide, please pick one of the above.

If you're running Windows, 64-bit Linux, or some other distro - I suggest you install VirtualBox and install Ubuntu or Linux Mint in Virtual Machine. Creating the virtual machine should be outside the scope of this guide, but since I'm the one recommending it, I guess I'll have to cover it at least briefly. So, here it goes:

- Start Oracle VM VirtualBox Manager
- click New, then Next
- Enter Name (for example "Ubuntu VM"), select Operating System: Linux, Version: Ubuntu. Click Next
- If your real computer has more than 2GB of RAM, move the slider to 1024. If not, leave it at 512. Click Next.
- Leave Start-up Disk and Create new hard disk selected. Just click Next.
- Leave VDI (VirtualBox Disk Image) selected. Just click Next.
- Leave Dynamically allocated selected. Just click Next.
- again, leave default values untouched. Just click Next. Then click Create, then Create again.
- click on the Ubuntu VM on the left, then click Settings
- Click Storage on the left. Then in the middle click on CD icon under IDE Controller. Then on the CD icon near the right edge of the window, next to IDE Secondary Master. Select Choose a Virtual CD/DVD Disk File... and select Ubuntu-12.04-deskto-i386.iso. Click OK.
- Click again on Ubuntu VM on the left, and then click Start. The Virtual Machine will start booting. Follow instructions on screen to install Ubuntu as you would on a real computer.

If anyone's wondering, I'm running Windows 7 64-bit, and Ubuntu 12.04 32-bit under VirtualBox.


You'll also need a GitHub account. So if you don't have one, go to github.com and create it. If you have problems with creating github account, you can find help here: https://help.github.com/articles/sig...github-account. Log in to GitHub, and go here: https://github.com/hwhw/kindlepdfviewer/. Click on Fork. Wait until it's done, and then you can sign out.



Now, if you just installed Ubuntu with default settings (or Linux Mint), you'll need to install some more packages. On your Ubuntu box, open terminal and type:

Code:
$ sudo apt-get install git subversion g++ lua5.1 cmake libsdl1.2-dev
and wait untill all packages are installed.

Then type:

Code:
$ git config --global user.name "kai771"
$ git config --global user.email "kai771@somewhere.com"
$ git clone https://github.com/kai771/kindlepdfviewer.git
(kai771 is my username - you type your own). When it's done, type:

Code:
$ cd kindlepdfviewer
$ git remote add upstream https://github.com/hwhw/kindlepdfviewer.git
$ make fetchthirdparty
$ EMULATE_READER_W=600 EMULATE_READER_H=800 EMULATE_READER=1 make thirdparty kpdfview
Wait a long time. This will compile kindlepdfreader in emulation mode, so it can be run on your PC. You can start reader typing the following command:

Code:
$./reader.lua test
To keep things simple, I suggest you put your pdf files in test folder too. You can now edit various .lua files using text editor, and test them using the above command. When you're satisfied with your changes of .lua files, you can transfer them to your kindle, copying them over the files of your regular kindlepdfviewer installation. To push commits, send pull requests etc. refer to the git help (at least read https://help.github.com/articles/fork-a-repo).


Cross-Compile
If you want to make installation package for kindle, you'll need the cross-compile toolchain. You have two options here: let's call them controversial and mainstream . I'll cover controversial first, since that option worked first for me. However, I recommend you use mainstream, especially if you have trouble finding the file needed for controversial.

Update: As of 2012-10-03, KindlePDFViewer's Makefile went through extensive changes. It might not be possible to build it successfully using Controversial Way anymore. Preferred ToolChain is Code Sourcery/Mentor Graphics 2012.03. Follow the instructions for Mainstream way, but use newer version. Version 2007q3 will still work, but 2012.03 is preferred.


Controversial Way

I call this way controversial because of the file you'll need - it seems it can't be freely distributed, probably because it contains kindle libraries and headers that are under copyright (my guess - I don't know for sure). The name of the file you need is x-tools-glibc2.5-gcc4.2.4.tar.gz, and it's 45,741,995 bytes long. You shouldn't have much trouble finding it.


With that file in your home dir, type this:

Code:
$ cd ~
$ tar xzvf x-tools-glibc2.5-gcc4.2.4.tar.gz
$ cd x-tools-glib2.5
$ sudo mv arm-kindle-linux-gnueabi /usr/local
Edit your .profile and add this line at the end:
Code:
PATH="/usr/local/arm-kindle-linux-gnueabi/bin:$PATH"
Relog. Now you have all you need to make a package that will install on kindle. To do so, type this:

Code:
$ cd kindlepdfviewer
$ make clean cleanthirdparty
$ make thirdparty kpdfview customupdate HOST=arm-kindle-linux-gnueabi
Wait a long time, and you'll have your very own kindlepdfviewer-xxxxxxx.zip that you can put in customupdates folder on your kindle and press Shift-Shift-I to install (assuming you're using launchpad).


Mainstream Way

We'll use Code Sourcery/Mentor Graphics toolchain here. Go to http://www.mentor.com/embedded-software/codesourcery, and click "Download Lite Edition". In the "ARM processors" section, click on "Download the GNU/Linux Release". Fill in the form with your Name and e-mail, and click "Get Lite!". You'll receive an e-mail with a link to download page. On the download page, click on "Sourcery CodeBench Lite 2012.03-57", and then on "IA32 GNU/Linux TAR". You'll download the file arm-2012.03-57-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2. Put that file in your home dir, and then type:

Code:
$ cd ~
$ tar xvf arm-2012.03-57-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
$ sudo mv arm-2012.03 /opt
Edit your .profile and add this line at the end:

Code:
PATH="/opt/arm-2012.03/bin:$PATH"
Relog. Now you have all you need to make a package that will install on kindle. To do so, type this:

Code:
$ cd kindlepdfviewer
$ make clean cleanthirdparty
$ make thirdparty kpdfview customupdate
Wait a long time, and you'll have your very own kindlepdfviewer-xxxxxxx.zip that you can put in customupdates folder on your kindle and press Shift-Shift-I to install (assuming you're using launchpad).




Update: The following is already fixed, so you don't need to do it anymore. I'm still leaving it so people would know what tigran refered to in his next message
Note: at the time of testing all this, it failed in the end because README.TXT file is not there anymore, and there's README.md file instead. If this happens to you, type
Code:
$ cp README.md README.TXT
and then
Code:
$ make customupdate HOST=arm-kindle-linux-gnueabi
Update 2:
Tigran reports that it also works on FC17 64-bit version. See his posts http://www.mobileread.com/forums/sho...&postcount=680 and http://www.mobileread.com/forums/sho...&postcount=682

Last edited by Kai771; 10-04-2012 at 05:37 AM. Reason: New TC version
Kai771 is offline   Reply With Quote