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-12-2010, 02:24 PM   #1
lrizzo
Member
lrizzo can tie a knot in a cherry stem with his or her tonguelrizzo can tie a knot in a cherry stem with his or her tonguelrizzo can tie a knot in a cherry stem with his or her tonguelrizzo can tie a knot in a cherry stem with his or her tonguelrizzo can tie a knot in a cherry stem with his or her tonguelrizzo can tie a knot in a cherry stem with his or her tonguelrizzo can tie a knot in a cherry stem with his or her tonguelrizzo can tie a knot in a cherry stem with his or her tonguelrizzo can tie a knot in a cherry stem with his or her tonguelrizzo can tie a knot in a cherry stem with his or her tonguelrizzo can tie a knot in a cherry stem with his or her tongue
 
Posts: 23
Karma: 22222
Join Date: Oct 2010
Device: kindle3
tiny C compiler on the kindle

I have prepared a version of the Tiny C compiler (tcc) that can run on the Kindle.
You can find it at http://info.iet.unipi.it/~luigi/kindle/#TCC-for-Kindle

For those who don't know, tcc is a single, small binary that can compile and runs C code on the fly. The only serious impairment (common to all C compilers) is that you often need a ton of headers to build anything useful;
however, i am preparing a workaround which allows you to put all the definitions in a single file and ignore errors for missing headers.

For those who want to give it a try -- the tarball contains the compiler, tcc, and some tiny objects (crt*.o) which you should put in /usr/lib (they are not needed if you just want to run code on the fly).
Then edit your favourite hello world program and run it with
tcc -run helloworld.c
lrizzo is offline   Reply With Quote
Old 11-12-2010, 02:32 PM   #2
NiLuJe
BLAM!
NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.
 
NiLuJe's Avatar
 
Posts: 4,643
Karma: 4440239
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW & PW2
Nice! .

I'll stick with my usual full fledged cross toolchain, but, still, it might be nice for on-the-fly very small C utils .
NiLuJe is online now   Reply With Quote
Old 11-12-2010, 06:29 PM   #3
kindle3zeng
Enthusiast
kindle3zeng once ate a cherry pie in a record 7 seconds.kindle3zeng once ate a cherry pie in a record 7 seconds.kindle3zeng once ate a cherry pie in a record 7 seconds.kindle3zeng once ate a cherry pie in a record 7 seconds.kindle3zeng once ate a cherry pie in a record 7 seconds.kindle3zeng once ate a cherry pie in a record 7 seconds.kindle3zeng once ate a cherry pie in a record 7 seconds.kindle3zeng once ate a cherry pie in a record 7 seconds.kindle3zeng once ate a cherry pie in a record 7 seconds.kindle3zeng once ate a cherry pie in a record 7 seconds.kindle3zeng once ate a cherry pie in a record 7 seconds.
 
Posts: 35
Karma: 1566
Join Date: Nov 2010
Device: kindle 3wifi
Quote:
Originally Posted by NiLuJe View Post
Nice! .

I'll stick with my usual full fledged cross toolchain, but, still, it might be nice for on-the-fly very small C utils .
could you share me where you got your cross toolchain? I've tried several cross toolchain, either of them worked.
scratchbox-toolchain and sourcecody doesn't compile the simple helloworld
the cross-compiler coming with ubuntu did compile, but it produced a segment fault on kindle at frame_dummy().
kindle3zeng is offline   Reply With Quote
Old 11-12-2010, 07:03 PM   #4
NiLuJe
BLAM!
NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.
 
NiLuJe's Avatar
 
Posts: 4,643
Karma: 4440239
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW & PW2
@kindle3zeng: I use a cross (right now, with an i686 GNU/Linux host) toolchain built using the crosstool-ng tool.

The actual config/shell history of the current build I'm using is detailed in the kindle-x-tc.tar.gz archive attached here.

Unless you build against glibc 2.5 (which I don't), you may have to use some trickery to avoid pulling more recent GLIBC_* symbols on some projects.
NiLuJe is online now   Reply With Quote
Old 11-13-2010, 09:58 AM   #5
curstpriest
Confused
curstpriest shares his or her toyscurstpriest shares his or her toyscurstpriest shares his or her toyscurstpriest shares his or her toyscurstpriest shares his or her toyscurstpriest shares his or her toyscurstpriest shares his or her toyscurstpriest shares his or her toyscurstpriest shares his or her toyscurstpriest shares his or her toyscurstpriest shares his or her toys
 
curstpriest's Avatar
 
Posts: 402
Karma: 5538
Join Date: Oct 2010
Location: Bay Area
Device: Kindle DXG
that and it might take like 10 hours to compile some stuff =X
curstpriest is offline   Reply With Quote
Old 11-13-2010, 02:20 PM   #6
kindle3zeng
Enthusiast
kindle3zeng once ate a cherry pie in a record 7 seconds.kindle3zeng once ate a cherry pie in a record 7 seconds.kindle3zeng once ate a cherry pie in a record 7 seconds.kindle3zeng once ate a cherry pie in a record 7 seconds.kindle3zeng once ate a cherry pie in a record 7 seconds.kindle3zeng once ate a cherry pie in a record 7 seconds.kindle3zeng once ate a cherry pie in a record 7 seconds.kindle3zeng once ate a cherry pie in a record 7 seconds.kindle3zeng once ate a cherry pie in a record 7 seconds.kindle3zeng once ate a cherry pie in a record 7 seconds.kindle3zeng once ate a cherry pie in a record 7 seconds.
 
Posts: 35
Karma: 1566
Join Date: Nov 2010
Device: kindle 3wifi
Quote:
Originally Posted by NiLuJe View Post
@kindle3zeng: I use a cross (right now, with an i686 GNU/Linux host) toolchain built using the crosstool-ng tool.

The actual config/shell history of the current build I'm using is detailed in the kindle-x-tc.tar.gz archive attached here.

Unless you build against glibc 2.5 (which I don't), you may have to use some trickery to avoid pulling more recent GLIBC_* symbols on some projects.
Thanks for your tips.
I compiled a toolchain with glibc with crosstool-ng. and right now I am trying to compile one with the glibc 2.5 from amazon.
kindle3zeng is offline   Reply With Quote
Old 11-13-2010, 03:39 PM   #7
NiLuJe
BLAM!
NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.
 
NiLuJe's Avatar
 
Posts: 4,643
Karma: 4440239
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW & PW2
Note that you can probably pretty much replicate the Kindle toolchain (gcc 4.1.2/glibc 2.5/Linux 2.6.22) with ct-ng if you enable the 'deprecated' option, no need to build it manually from amazon's tarballs.

And, unless you intend to build a whole lot of crap, you'll probably be good to go with a recent TC. I haven't yet hit a real TC related ABI mismatch showstopper with what I built so far.

And I'm really, really not a fan of using a 3.5 years old TC, so I'm glad I haven't had to use a GCC 4.1 based TC .

Granted, with a kindle-like (ie. old) TC, at least you'll be mostly 100% sure it will run without issue on the Kindle, which is not really the case with my current TC, but, hey, where's the fun in that? .

Last edited by NiLuJe; 11-13-2010 at 03:46 PM.
NiLuJe is online now   Reply With Quote
Old 04-18-2012, 08:22 PM   #8
jmseight
Zealot
jmseight knows the difference between 'who' and 'whom'jmseight knows the difference between 'who' and 'whom'jmseight knows the difference between 'who' and 'whom'jmseight knows the difference between 'who' and 'whom'jmseight knows the difference between 'who' and 'whom'jmseight knows the difference between 'who' and 'whom'jmseight knows the difference between 'who' and 'whom'jmseight knows the difference between 'who' and 'whom'jmseight knows the difference between 'who' and 'whom'jmseight knows the difference between 'who' and 'whom'jmseight knows the difference between 'who' and 'whom'
 
Posts: 130
Karma: 10000
Join Date: Mar 2012
Device: Kindle 3G, Kindle Touch 3G, iRiver Story HD, Sony Reader
Hi,

I got hello world to run, but only once, and then get illegal instruction the second time.

Also, do you have the header files?

Thanks,
James
jmseight is offline   Reply With Quote
Old 04-18-2012, 09:06 PM   #9
geekmaster
Всё гениальное просто.
geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.
 
geekmaster's Avatar
 
Posts: 5,066
Karma: 6789001
Join Date: Nov 2011
Location: Щедрость не имеет пределов.
Device: *.*
I packaged up lrizzo's tcc build, with the tinycc headers and the amazon gpl 5.0.0 headers, plus I added install and uninstall scripts, and a tccmake script to add the header include path and bind-mount a tcc-compatible replacement libc.so loader script needed to use this on newer kindles. I also include a demo.c program in the package, so it is ready to compile and test immediately after installing.
geekmaster's simple guide to tcc (tinycc):
http://www.mobileread.com/forums/sho...d.php?t=175834

Although my demos run several times faster when compiled with a cross-toolchain, using tinycc (tcc) on the device is a LOT easier for development and testing, then doing a full cross-build for final distribution.


Last edited by geekmaster; 04-20-2012 at 12:36 AM.
geekmaster is offline   Reply With Quote
Old 04-18-2012, 09:25 PM   #10
geekmaster
Всё гениальное просто.
geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.
 
geekmaster's Avatar
 
Posts: 5,066
Karma: 6789001
Join Date: Nov 2011
Location: Щедрость не имеет пределов.
Device: *.*
The tcc download link link at lrizzo's web page linked above is missing a tilde ('~') character. You can get his program packaged with an installer and with everything you need to use it on all eink kindles, at the link provided in my previous post above.


Last edited by geekmaster; 04-20-2012 at 01:16 AM.
geekmaster is offline   Reply With Quote
Old 04-20-2012, 04:51 PM   #11
geekmaster
Всё гениальное просто.
geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.
 
geekmaster's Avatar
 
Posts: 5,066
Karma: 6789001
Join Date: Nov 2011
Location: Щедрость не имеет пределов.
Device: *.*
Quote:
Originally Posted by curstpriest View Post
that and it might take like 10 hours to compile some stuff =X
Actually, tcc compiles MUCH faster than gcc, but the resulting code is not as fast. It took me 12 hours to compile X11 on my K3 using gcc from the debian arm distro, but I suspect with tcc it would only be 2 or 3 hours (based on experience comparing the x86 versions of tcc and gcc).
geekmaster 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
Compiler Notes On James Branch Cabell Ralph Sir Edward Reading Recommendations 0 01-20-2010 11:18 AM
Kindle helps tiny e-book market bookwormfjl News 7 04-04-2008 04:46 PM
Kindle boosts tiny e-book market Kingston Amazon Kindle 0 04-04-2008 02:13 PM
iLiad How can I use iRex's cross-compiler toolchain? yokos iRex Developer's Corner 8 12-11-2006 06:53 PM
iLiad iLiad cross-compiler toolchain available from iRex Matthijs iRex Developer's Corner 16 10-29-2006 02:25 PM


All times are GMT -4. The time now is 07:42 PM.


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