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: 13,477
Karma: 26012492
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW, PW2, PW5; Kobo H2O, Forma, Elipsa, Sage, C2E
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 offline   Reply With Quote
Advert
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: 13,477
Karma: 26012492
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW, PW2, PW5; Kobo H2O, Forma, Elipsa, Sage, C2E
@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 offline   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
Advert
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: 13,477
Karma: 26012492
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW, PW2, PW5; Kobo H2O, Forma, Elipsa, Sage, C2E
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 offline   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
Carpe diem, c'est la vie.
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: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
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):
https://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
Carpe diem, c'est la vie.
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: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
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
Carpe diem, c'est la vie.
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: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
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
Old 04-15-2018, 09:26 PM   #12
jmiller099
Junior Member
jmiller099 began at the beginning.
 
Posts: 1
Karma: 10
Join Date: Apr 2018
Device: PW2
Quote:
Originally Posted by geekmaster View Post
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):
https://www.mobileread.com/forums/sh...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.

Many thanks to you and lrizzo for this! Some quick feedback.

Downloaded the geekmaster package with the highest version number.

tccmake of demo.c and then executing it seg fault.

tccmake of my helloworld was okay. So then I went a little more complex and tried an eightball app my friend wrote and it was successful. Then I really pushed it by trying my eslisten program which uses pthread. To my surprise stat and fstat weren't available as unfindable by the linker. Pulling the libs to my computer and dumpobj it was confirmed as truth.

Then, after seeing what linaro's cross compiler did with those function calls via hex editing the binary and searching stat came to know about __xstat and __fxstat. After doing the needful, it successfully ran!

tldr; if you have to use stat, then use __xstat(3, filename, &statstruct); and if fstat then use __fxstat(3, filehandle, &statstruct);
jmiller099 is offline   Reply With Quote
Old 04-16-2018, 08:52 AM   #13
knc1
Going Viral
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: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
Did you notice you are posting to an eight year old thread?
Did it occur to you that there might have been changes/updates/corrections to tinyc in the past eight years?

Translation:
Mostly you are wasting your time by not using what is current.
Posting in a current thread (which you create, they are cheap here) what you find the current situation to be.
knc1 is offline   Reply With Quote
Old 04-16-2018, 10:44 AM   #14
nasser
Evangelist
nasser ought to be getting tired of karma fortunes by now.nasser ought to be getting tired of karma fortunes by now.nasser ought to be getting tired of karma fortunes by now.nasser ought to be getting tired of karma fortunes by now.nasser ought to be getting tired of karma fortunes by now.nasser ought to be getting tired of karma fortunes by now.nasser ought to be getting tired of karma fortunes by now.nasser ought to be getting tired of karma fortunes by now.nasser ought to be getting tired of karma fortunes by now.nasser ought to be getting tired of karma fortunes by now.nasser ought to be getting tired of karma fortunes by now.
 
nasser's Avatar
 
Posts: 475
Karma: 445678
Join Date: Feb 2010
Device: Too many..
@jmiller099: demo.c doesn't work on PW1, PW2... but works OK on PW3, KT3! Maybe the code needs to be tweaked to suit the 1024x758 resolution.

@knc1:The version here is 0.9.25. The mainstream version was bumped up to 0.9.27 in Dec-17.
nasser is offline   Reply With Quote
Reply

Tags
tcc, tinycc

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 Greg Anos 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 02:42 AM.


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