Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Readers > Amazon Kindle > Kindle Developer's Corner

Notices

Reply
 
Thread Tools Search this Thread
Old 11-21-2016, 01:40 AM   #1
scolby33
Junior Member
scolby33 began at the beginning.
 
Posts: 7
Karma: 10
Join Date: Nov 2011
Device: Kindle, iPhone
Weather Kindle: packaging advice needed

Hello! I've created a cool program (hack?) for my old K4NT and need some advice on packaging it up for easier installation by others.

You can see all the details here on Github, but, in a nutshell, it downloads the weather forecast for your area over Wi-Fi and displays it on the Kindle, all without any external server--the Kindle does all the work!

I have a semi-reasonable installation process worked out, but I'd like to package up the whole thing as an Update_whatever.bin and perhaps make sure it works on other Kindles than just the K4NT.

I also need advice on how to set the LD_LIBRARY_PATH automatically--if I symlink the binaries I need to /usr/bin (like I see things like USBNetwork doing), how do they know to find their .so's in /usr/mnt/whatever/lib? Will this require re-compiling the binaries?

Finally, I'd like to add KUAL compatibility, which doesn't look to be too difficult, but any advice on potential landmines would be welcome.
scolby33 is offline   Reply With Quote
Old 11-21-2016, 09:33 AM   #2
knc1
Ex-Helpdesk Addict
knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.
 
knc1's Avatar
 
Posts: 12,235
Karma: 12451893
Join Date: Feb 2012
Location: Central Texas
Device: No PW2, KV, KOA
Display the rpath entry in the USB net elf binaries - that is how it happens.
LD_LIBRARY_PATH changing is not required.

You do not need to re-compile your binaries, you can use patchelf to change the library path.
patchelf is posted here, both for x86 and armel.

Use the most recent KindleTool from the snapshot thread, that does the packaging.
Be certain to RTFM on KindleTool.

There is no such thing as KUAL compatibility - if the target is executable on armel (or S360), it is compatible.

The K4 was the last Kindle to NOT use X11 in the 'main' OS (K4 'diags' runs X11).
The K4 was a transition device in a lot of ways.
So get your application running on one of the firmware 5.x devices next.
(This is Amazon sales week - a good time to buy. The KT3 (unlighted screen) is the cheapest and includes Bluetooth support. The PW3 (front lit screen) is the best deal for the money. The others are for the "Bragging Rights" people.)

It is an "after market add-in".
'Hack' is a four letter word, this is a public forum, be nice.
(For an explanation, click link in my signature.)

Last edited by knc1; 11-21-2016 at 09:56 AM.
knc1 is offline   Reply With Quote
Old 11-23-2016, 06:01 PM   #3
scolby33
Junior Member
scolby33 began at the beginning.
 
Posts: 7
Karma: 10
Join Date: Nov 2011
Device: Kindle, iPhone
Thanks for the info about patchelf! I managed to get pngcrush working, but not rsvg-convert:

Code:
$ patchelf --set-rpath /mnt/us/weather/lib rsvg-convert
$ patchelf --set-rpath /mnt/us/weather/lib pngcrush
$ readelf -d rsvg-convert | grep RUNPATH
 0x0000001d (RUNPATH)                    Library runpath: [/mnt/us/weather/lib]
$ readelf -d pngcrush | grep RUNPATH
 0x0000001d (RUNPATH)                    Library runpath: [/mnt/us/weather/lib]
It turns out that all of pngcrush's shared libraries are already in /usr/lib, but I was able to confirm that it was searching the RUNPATH by touching one of the libraries in my lib folder and getting an error:

Code:
# pngcrush --qf -c 0 img/error.png img/e.png
pngcrush: error while loading shared libraries: /mnt/us/weather/lib/libpng12.so.0: file too short
However, no matter what I've tried, I can't get rsvg-convert to search it's RUNPATH:

Code:
# rsvg-convert
rsvg-convert: error while loading shared libraries: libgsf-1.so.114: cannot open shared object file: No such file or directory
# ls /mnt/us/weather/lib | grep libgsf
libgsf-1.so.114
Any hints or ideas about what's happening?

Last edited by scolby33; 11-23-2016 at 06:03 PM.
scolby33 is offline   Reply With Quote
Old 11-23-2016, 06:28 PM   #4
knc1
Ex-Helpdesk Addict
knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.
 
knc1's Avatar
 
Posts: 12,235
Karma: 12451893
Join Date: Feb 2012
Location: Central Texas
Device: No PW2, KV, KOA
Use the information found in this thread:
http://www.mobileread.com/forums/sho...86&postcount=6
And before/after - I was inventing the ARMhf on Kindle as I went along.

In particular, see the following post (#7) for a worked example of how to get the dynamic loader to report the paths it is searching.

You are not using ARMhf (although you may have copied one by accident) but all the utilities and debugging process is the same as I used in that thread.
knc1 is offline   Reply With Quote
Old 11-23-2016, 07:17 PM   #5
scolby33
Junior Member
scolby33 began at the beginning.
 
Posts: 7
Karma: 10
Join Date: Nov 2011
Device: Kindle, iPhone
I got it! The difference between RPATH and RUNPATH was the issue, and the most recent version of patchelf seems to greatly prefer the latter...I couldn't ever get it to set RPATH.

librsvg-2 needs libgsf-1, so I just patched librsvg's RUNPATH and everything works great now.

Is it typical practice to patch all the binaries and shared libraries, or only those that complain?

I haven't been able to find documentation on this, but from looking at examples, the Kindle runs the file "install.sh" when unpacking an update?

Last edited by scolby33; 11-23-2016 at 07:21 PM.
scolby33 is offline   Reply With Quote
Old 11-23-2016, 08:58 PM   #6
knc1
Ex-Helpdesk Addict
knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.
 
knc1's Avatar
 
Posts: 12,235
Karma: 12451893
Join Date: Feb 2012
Location: Central Texas
Device: No PW2, KV, KOA
IIRC - Yes it does.
The dummy update package is suppose to be the worked example.

Another thing which is possible with patchelf -
Make the entire application behave like a Windows application -
Put both the executable and all the required libraries that are not already in /lib, /usr/lib in the same directory.
Include:
$ORIGIN
Exactly like the above including the '$' first in rpath (note that patchelf is actually setting runpath, they just kept the original terminology).

Then, just like the Windows dynamic loader, ld.so will first search the directory that holds the executable.

You can also use paths relative to $ORIGIN -
Here is what one example looks like (cvm - the Kindle's Java VM):
Code:
Dynamic section at offset 0xab4 contains 30 entries:
  Tag        Type                         Name/Value
 0x00000001 (NEEDED)                     Shared library: [libpthread.so.0]
 0x00000001 (NEEDED)                     Shared library: [libjli.so]
 0x00000001 (NEEDED)                     Shared library: [libdl.so.2]
 0x00000001 (NEEDED)                     Shared library: [libc.so.6]
 0x0000000e (SONAME)                     Library soname: [lib.so]
 0x0000000f (RPATH)                      Library rpath: [$ORIGIN/../lib/arm/jli:$ORIGIN/../lib/arm]
Note that it has an soname, even though it is called as an executable.
That is to allow external, dynamically loaded, libraries call back into it.
You can see that it also uses libdl (the dynamic library loader).
So it also loads other libraries ('plugins' in some languages) -
All-in-all, probably one tricky bit of coding in that application, that is about as complex as an ELF format file can get.

- - - -

I am not intentionally feeding you bits and pieces of the answer -
I am only remembering bits and pieces at any one time -
Age does that -
There are members of this site older than myself, but very few of them.

Last edited by knc1; 11-25-2016 at 01:44 AM.
knc1 is offline   Reply With Quote
Old 11-25-2016, 05:10 PM   #7
iXPert12
Junior Member
iXPert12 began at the beginning.
 
Posts: 1
Karma: 10
Join Date: Nov 2016
Device: Kindle PW1
Wow. Actually i was working on this too, based on cathay4t's kindle-weather github page and Niluje's python libs. As for dependencies for pngcrush and rsvg-convert , i renamed the libs using their symlink name and copied them into /usr/lib/ as a temporary solution. Then i modified the weather svg to match PW1 resolution.
I got stuck at the power management. I didn't want to keep my kindle usb connected all the time, so i wanted a solution to create a loop that wakes up kindle every 30-60 minutes and updates the weather and then put it to sleep/low power mode. After a lot of investigations, i found https://github.com/snowtechblog/avakindle that may give a solution using rtcwake. But i put on hold this project for now.

Last edited by iXPert12; 11-25-2016 at 05:14 PM.
iXPert12 is offline   Reply With Quote
Old 11-25-2016, 06:30 PM   #8
knc1
Ex-Helpdesk Addict
knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.
 
knc1's Avatar
 
Posts: 12,235
Karma: 12451893
Join Date: Feb 2012
Location: Central Texas
Device: No PW2, KV, KOA
Quote:
Originally Posted by iXPert12 View Post
Wow. Actually i was working on this too, based on cathay4t's kindle-weather github page and Niluje's python libs. As for dependencies for pngcrush and rsvg-convert , i renamed the libs using their symlink name and copied them into /usr/lib/ as a temporary solution. Then i modified the weather svg to match PW1 resolution.
I got stuck at the power management. I didn't want to keep my kindle usb connected all the time, so i wanted a solution to create a loop that wakes up kindle every 30-60 minutes and updates the weather and then put it to sleep/low power mode. After a lot of investigations, i found https://github.com/snowtechblog/avakindle that may give a solution using rtcwake. But i put on hold this project for now.
Do not modify the Amazon image, you are asking for trouble.
Set the library search path (rpath) in your executable to give the path to your libraries.

PS:
You can find the original development of avakindle in this forum.
I guess this is just another example of running out of bytes when it came to giving credit where credit is due.
knc1 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Waterproof Kindle cover - advice needed! JasmineHatchaway Amazon Kindle 7 02-24-2015 08:30 AM
Reality Check/Advice needed: Kindle or Kobo MiguelATF Which one should I buy? 38 01-21-2015 10:07 PM
Kindle HDX 7 Advice and a little help needed... kico42 Kindle Fire 1 08-04-2014 08:21 AM
Kindle 4 NT battery advice needed Beginner-reader Amazon Kindle 6 01-26-2013 02:49 PM
More advice needed by Canadian Re: Kindle verbose Amazon Kindle 13 03-25-2009 05:36 PM


All times are GMT -4. The time now is 07:40 AM.


MobileRead.com is a privately owned, operated and funded community.