View Single Post
Old 04-18-2012, 09:53 PM   #1
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
Arrow geekmaster's simple guide to tcc (tinycc)

UPDATE: New v1.6 adds fixes for libpthread library problems on v3.3 and v5.1.0 kindle firmware. As we discover new problems with kindle firmware (more broken loadable libraries), we will add fixes for them to new tcc package versions downloadable in this first post. [v1.6a removes include.tar.gz file that did not belong in v1.6].

I successfully built and ran a modified version of dithermatron.c (demo.c included in the install package) on my DX, K3, and K5(touch), like this:
1) download and extract kindle-tcc-1.3.tar.gz (below) to /mnt/us (USB drive)
2) install: "/mnt/us/tcc/install"
3) compile: "tccmake demo"
4) run: "./demo"
5) Watch the kindle draw square and round tubes on its eink screen.


For original dithermatron.c and other fun little kindle C programs, go here:


For the simple "monolithic" programs I usually write, this download package provides all I need. For programs that use extended library functions, you might need to link to some libraries too.

For details and other good tips about using tcc, read this (the download link on that page is dead, so that download is attached below):


History and tech notes:
Spoiler:
UPDATE: New v1.5 same as v1.3 but also includes all MISSING header files for codesourcery arm-linux-gcc cross-compiler, and all linux header files for kindle 5.0.0 gpl source code (including the eink header files used in my C demo programs). The install program also adds a symlink for the math library if it is missing (at least in firmware v3.3). The v1.4 package had problems because it replaced v1.3 header files with "broken" headers from the amazon gpl source code. This v1.5 restores the "good" headers that were in v1.3.

UPDATE: Okay... I downgraded the headers to 5.0.0 and they are "broken" too. Comparing to 5.1.0, there were only about a dozen headers that changed. In the tcc 1.3 package I only added MISSING headers from 5.0.0, keeping the codesourcery and tinycc versions. I will copy the headers from v1.3 on top of the v1.4 package and release that as v1.5. Why does amazon have to make using their gpl source code so difficult?

UPDATE: New v1.4 contains broken v5.1.0 headers (this comes as no surprise due to other v5.1.0 screwups). I will downgrade the headers to 5.0.x. Meanwhile I re-uploaded v1.3, and I included the tutorial downloads that now have a download dead link in the referenced offsite tcc tutorial page.

UPDATE: New v1.4 same as v1.3 but also includes all header files for codesourcery arm-linux-gcc cross-compiler, and all linux header files for kindle 5.1.0 gpl source code (including the eink header files used in my C demo programs). The install program also adds a symlink for the math library if it is missing (at least in firmware v3.3).

Version 1.3 update that works on the K4(mini) and K5(touch). It "bind mounts" a tcc-compatible replacement libc.so loader script while compiling with the tccmake script.

The kindle-tcc-1.6a.tar.gz file attached below contains lrizzo's tcc build downloaded from his website (after fixing his bad download URL), and the tcc include folder downloaded from the tinycc arm source repository, and the include folder from amazon gpl source code version 5.0.0. I also added install and uninstall scripts, and a "bind mount" replacement libc.so loader script that allows tcc to work on the k4 and k5. To use the replacement libc.so, just compile with the tccmake script, or copy the "bind mount" command from that script file for you own use. To make this fun and easy to test, this package also includes the demo.c program mentioned above.

NOTE: Earlier kindle models might need DIFFERENT header files (such as for framebuffer support) from an earlier version of the firmware source code. I do NOT use these in my code. I prefer to COPY individual definitions from kindle version-specific include files to my source program. Also, for incompatible version-specific libraries, I like to add "-static" to my build, so that the library code I need is included inside my compiled program executable file, making it work on all the kindle models (at the expense of a larger executable file).

Be aware that although this compiler is convenient, and great for small utility programs, more complex programs such as my dithermatron and cosmegg demos run several times faster when cross-compiled with arm-linux-gcc (from CodeSourcery) than they do with this compiler, so I like to do a final cross-build for a fast executable to include with my demo programs. But for fast development and testing directly on the kindle, this tcc compiler is GREAT! You can always recompile with cross-tools later. And even when compiled with tcc, my C demo programs are much faster than my /bin/sh demo programs.

Enjoy and learn!
Attached Files
File Type: gz tcctut1.0.tar.gz (22.8 KB, 692 views)
File Type: gz kindle-tcc-1.5.tar.gz (4.50 MB, 685 views)
File Type: gz kindle-tcc-1.6a.tar.gz (4.49 MB, 871 views)

Last edited by geekmaster; 09-30-2012 at 11:34 AM. Reason: more awesomized :D
geekmaster is offline   Reply With Quote