Register Guidelines E-Books Today's Posts Search

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

Notices

Reply
 
Thread Tools Search this Thread
Old 08-02-2025, 07:29 PM   #1
smbgaiden
Junior Member
smbgaiden rocks like Gibraltar!smbgaiden rocks like Gibraltar!smbgaiden rocks like Gibraltar!smbgaiden rocks like Gibraltar!smbgaiden rocks like Gibraltar!smbgaiden rocks like Gibraltar!smbgaiden rocks like Gibraltar!smbgaiden rocks like Gibraltar!smbgaiden rocks like Gibraltar!smbgaiden rocks like Gibraltar!smbgaiden rocks like Gibraltar!
 
Posts: 7
Karma: 100000
Join Date: Jul 2025
Device: none
[Release] TinyC - TCC for armhf hard float

Okay, sorted through all the issues. Attached is a release of the TCC program that runs on Kindles with hard float. This was built from the open source TCC mob branch and assembled with other contents and sometimes with changes as described below.

INSTALLATION
Prerequisites: A jailbroken Kindle. Said Kindle on a higher SW version that uses hardfloat. A way to transfer this package to the Kindle. A way to have a terminal on the kindle.

Spoiler:

Jailbreak - search this forum, not this post.
Checking hardfloat: Go to terminal and run ldd /bin/ls and look for armhf in the libraries it loads.
Transfer to Kindle: Use USB from Computer to kindle or SCP.
Terminal on kindle: Kterm, or SSH from USBNetLite. (setting up usbnetlite and ssh on colorsoft was a little painful).


Same installation routine as geekmaster's package, so copying verbatim but only changing the package name.
1) download and extract kindlehf-tcc-1.0-0928.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.


FILE CONTENTS
The file contains the following, structured as name followed by description:
1) tcc - The program which was newly built for arm hard float using kox toolkit from tcc mob branch sources with changes
From geekmaster's package, some with changes
2) tccmake - a convenience makefile
3) install - script to install it so you can just run tcc or tccmake from anywhere
4) uninstall - script to undo the installation of tcc and tccmake
5) tcc.libc.so - C Library helper to address full path to libc
6) tcc.libpthread.so - C Library helper to address full path to libc
7) demo - executable demo program of dithermatron (screenshot from colorsoft attached)
8) demo.c - the source of the program, so your installation can be quickly tested by compiling it
9) lib directory and contents - C runtime initialization objects.
10) include (stdarg.h and stddef.h, i think) - the root include of kox lacked these, so i grabbed from here
From kox toolkit:
11) include directory (except the two files above) - So tcc has heads to reference for compilations

History, Changes, and Tech Notes
Spoiler:
History:
1.0 based on mob branch tiny c TCC version 0.928rc

Changes:
None. Initial package.

Tech Notes
This describes what was changed after pulling from other packages.
1) tccmake - Removed the -I, because I forced tcc to look at /mnt/us/tcc/include without needing explicit instruction. If your project uses other include directories, you'll need -I
2) install - commented out interactions with /usr/lib, such as cd to there and copying CRT to there, because I forced tcc to find crt in /mnt/us/tcc/lib
3) uninstall - like install, it removes consideration of /usr/lib
4) demo - executable working on hard float, compiled from updated demo.c, see below
5) demo.c - Now also does color! Randomly selects background, box, and ball to be red, green, or blue. Although they have a random color, they'll never share a color. See screenshot attached at the bottom.
a) Use eips_v2 if available
b) For color (my colorsoft v1, maybe others) update the screen more frequently
c) When using eips v1. Make it silent, in case it wants to write feedback or errors
d) Restructure code to absorb changes related with color and above, but ensure it runs in B&W (tested on a PW gen 11)
6) C runtime initialization objects. The crt1.o was recreated by disassembling geekmaster's through objdump, tweaking into compilable assembly, verifying no thumb code and no soft float attempts are made, and then assembling using the armhf TCC compiler. crti.o was copied over and used as both crti.o and crtn.o since it lacks any exports.
10) stdarg.h and stddef.h, i think, from geekmaster's package were added to the root of include/ because programs wouldn't compile without it.


FINAL NOTES
TCC is a single pass compiler, so you can get much faster code with GCC. However, it is small and is fairly easy to build, so it's good to put on a jailbroken kindle and execute directly on it. It has some support for debugging, since kindle has gdb. Just put -g option into your makefile. Sometimes things get a little weird in gdb though.

Not implemented: If you come across the tcc -run option or programmatically embedding C into your program to on the fly compile and executing it, well that's unfortunately not going to work on this. Maybe later. I did not compile libtcc1.a. Even if libtcc1.a is compiled and put somewhere, I probably broke the loader for it to ensure I could get this functional, so it will likely need a new tcc executable along with the libtcc1.a. Maybe will do this change by making tcc on kindlehf compile for kindlehf and remove the kox toolkit from the equation.
Attached Thumbnails
Click image for larger version

Name:	dithermatron.png
Views:	16
Size:	228.8 KB
ID:	217234  
Attached Files
File Type: gz kindlehf-tcc-1.0-0928.tar.gz (1.60 MB, 6 views)
smbgaiden is offline   Reply With Quote
Old 08-04-2025, 02:42 AM   #2
smbgaiden
Junior Member
smbgaiden rocks like Gibraltar!smbgaiden rocks like Gibraltar!smbgaiden rocks like Gibraltar!smbgaiden rocks like Gibraltar!smbgaiden rocks like Gibraltar!smbgaiden rocks like Gibraltar!smbgaiden rocks like Gibraltar!smbgaiden rocks like Gibraltar!smbgaiden rocks like Gibraltar!smbgaiden rocks like Gibraltar!smbgaiden rocks like Gibraltar!
 
Posts: 7
Karma: 100000
Join Date: Jul 2025
Device: none
Fixed two things. Is it possible to edit the original post and attachment?

The fixes were:
1. The crt i used was not compatible, it messed up argc and argv in main. Therefore, i debugged the registers and memory at the start of execution to find argc and argv then modified the assembly, compiled it, put on the kindle and it worked well. More description down bottom.

2. Since above, it unlocked the ability to compile tcc with tcc directly on the kindle. Used that ability to troubleshoot why tcc -run - was not working and it was due to a missing object. Built that object, placed on kindle, and verified tcc can on the fly build and execute now.

I'll upload a new package after learning if editing is possible, outgrow I'll put in a new reply in this thread.

before fix 1,
int main(int arg, char * argv[])
was impossible to use argc and argv since they were sourced from the wrong location in the crt that's used in the package. This made a tcc built on kindle unworkable since all the options and code needs to come in through argv
smbgaiden is offline   Reply With Quote
Advert
Old 08-04-2025, 11:12 AM   #3
j.p.s
Grand Sorcerer
j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.
 
Posts: 5,799
Karma: 103362673
Join Date: Apr 2011
Device: pb360
It is possible for members to edit their own posts and manage attachments.

Over the years many anti-spam measures have had to be put into place, especially for new members. If you are being affected by this and don't want to wait for time and total posts to increase, you can open a thread in the Feedback forum. After the moderators review your posting history they might grant your request.
j.p.s is offline   Reply With Quote
Old Today, 12:55 AM   #4
smbgaiden
Junior Member
smbgaiden rocks like Gibraltar!smbgaiden rocks like Gibraltar!smbgaiden rocks like Gibraltar!smbgaiden rocks like Gibraltar!smbgaiden rocks like Gibraltar!smbgaiden rocks like Gibraltar!smbgaiden rocks like Gibraltar!smbgaiden rocks like Gibraltar!smbgaiden rocks like Gibraltar!smbgaiden rocks like Gibraltar!smbgaiden rocks like Gibraltar!
 
Posts: 7
Karma: 100000
Join Date: Jul 2025
Device: none
@j.p.s thank you for the response! I'll wait it out and then merge this post with the top post when the time comes.

Release 1.1 is here with three improvements. It can even compile its own code to make a tcc which will then successfully compile programs, but that's far from needed for most use cases, just a nice anecdote.

1. tccmake no longer mounts and unmounts libraries.
2. Command line arguments now work with programs compiled by tcc. int main(int argc, const char * argv[]) are sent to main properly.
3. tcc -run works now

Details:
Spoiler:

1. tccmake was simplified. There's now the two needed linker defined libs, libc & libpthread, directly placed in the tcc directory instead of mounted to /usr/lib. They're also not going to be unmounted each time, since they've not been mounted. The tcc include path by default will look in its own directory for these two files which point to the real libraries. You can see the loading by invoking with ./tcc -vvv in your build.

2.The crt1.o I used from the prior package incorrectly addressed for the argc and argv parameters before calling main. I used gdb at _start to find them. Noticed they're passed into _start in r1 and r2, so just made a little edit to store them off in other registers and then use the arm calling convention to move them into the proper registers immediately before calling main.I left the rest of the init code untouched, which seems to address handling the stack pointer and incorrectly finding argc and argv.

3. Added arm-runmain.o to the tcc directory, so the tcc -run command will work. Have a try:

From SSH or command line in kterm:
Code:
echo -e '#include <stdio.h> \n void main(){ puts("Hey there!\\n");}' | tcc -run -
Yes, please keep the last dash without any character following it. That's to tell tcc to read off of stdin. Also unsure if there's any utility for this, but it's neat to me and now it works.
Attached Files
File Type: gz kindlehf-tcc-1.1-0928.tar.gz (1.61 MB, 1 views)
smbgaiden is offline   Reply With Quote
Old Today, 01:44 PM   #5
HenriHenry
Enthusiast
HenriHenry began at the beginning.
 
Posts: 25
Karma: 10
Join Date: Jun 2025
Device: Kindle PW5
works perfectly, thanks!
To edit your post, log in, go to your post, and look at the bottom right near ">quote"
HenriHenry is offline   Reply With Quote
Advert
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
TinyC TCC for armhf hard float smbgaiden Kindle Developer's Corner 2 07-28-2025 12:38 AM
Screensavers hack for armhf firmwares qqqqqqqqqqqz Kindle Developer's Corner 0 05-20-2025 05:25 AM
ARMhf on the Kindle(s) knc1 Kindle Developer's Corner 83 07-16-2017 09:34 AM
The operator >> is undefined for the argument type(s) float, float twobob Kindle Developer's Corner 10 09-05-2012 12:50 PM
tcc on iriver Story HD jmseight iRiver Story 2 05-02-2012 02:23 AM


All times are GMT -4. The time now is 04:40 PM.


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