04-18-2012, 09:53 PM
Всё гениальное просто.
Join Date: Nov 2011
Location: Щедрость не имеет пределов.
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:
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!
Last edited by geekmaster; 09-30-2012 at 11:34 AM.
Reason: more awesomized :D