![]() |
#1 |
Junior Member
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7
Karma: 100000
Join Date: Jul 2025
Device: none
|
TinyC TCC for armhf hard float
Hi All,
Either looking for help or anyone that's interested in providing TinyC tcc (https://www.mobileread.com/forums//s...d.php?t=175834) and (https://www.mobileread.com/forums/sh...d.php?t=106537) for Kindles executable on Kindles that use hard float? I checked in with the latest here also, but none worked on the colorsoft kindle with hard float: https://www.mobileread.com/forums/sh...&postcount=113 So I came up with a plan. 1. Cross compile with the kox toolchain. Success. Helloworld (and others) cross compiled and executed successfully on colorsoft. 2. Get TCC cross compiling from amd64 linux to arm32 hf. Failed. see below. 3. This would be taking the package from 2 and compiling to execute on arm and compile for arm once step 2 succeeds... For 2, what was done 1. Grabbed almost latest branch of tcc from mob (latest has an error with atomic) 2. ./configure --enable-cross --disable-static 2a. I tried w/o the disable-static part also and same result 3. Makefile generated 4. make cross-arm 5. arm-tcc was generated. observed VFP was used and HARDFLOAT also 6. made hello.c as a traditional printf...return 0 program 7. compiled with arm-tcc taking note to a. not use stdlib b. not use stdinc c. add kox inc dir d. add kox lib dir e. manually include the kox crt* objects f. manually include the kox libc, ld-linux-armhd, libc_nonshared, libs along with the hello.o and link together with arm-tcc 8. transfer hello compiled and linked program to the colorsoft 9. executed it and observed: the printf statement worked. then illegal instruction error SIGILL (happened regardless of the disable-static flag from the configure step, as expected) 10. ran it under gdb on kterm on the colorsoft. wow, they have gdb on it! 11. observed the error was not in the hello code region, but in the ld-linux-armhd region. Not expecting their lib to have an illegal instruction, so suspecting the configure or make flags are improper for this target OR something bad about the ABI OR the libs I linked pulled in manually have some incompatibility with each other and or the colorsoft. Any ideas for other things to try, or anyone see directly what error was made and can point out the error? |
![]() |
![]() |
![]() |
#2 |
Junior Member
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7
Karma: 100000
Join Date: Jul 2025
Device: none
|
Update for any future readers. Step 2 is working now. Compiling helloworld from amd64 linux via tcc arm eabihf compiler produces an exe that does not crash.
The problem was 7e. That caused intermixed thumb and arm code. TCC is arm only and likely doesn't fix up calls to and from thumb, so either stuff gets misaligned, some registers get neglected, or the thumb arm switch doesn't get toggled. I don't know, but i do know the solution is to avoid arm thumb intermixed. aso i dumped crt1.o from the aforementioned thread package and made a crt1.s to replace the stuff that was added on 7e and removed the 7e stuff. next step is to use kox to cross compile this cross compiling tcc to run on armhf. |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Junior Member
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7
Karma: 100000
Join Date: Jul 2025
Device: none
|
Continue the discussion with myself
![]() tldr; tcc works on armhf for armhf on a Kindle Colorsoft now. There's some kludges in tccmake, but they work. People that know dev env better than me can fix that up, if they so wish. Did: 1. modified the toolsets on linux x64 to replace the gcc compiler/linker with the kox compiler/linker 2. Fixed up some of the definitions in the headers and/or config (i forget now, but could diff them since I usually copy dir before large changes) 3. ran make cross-arm 4. copied the arm-tcc to the kindle 5. copied the aforementioned tcc package (especially the geekmaster one) to have header include directory, to have the tcc.libc.so and libpthread.so, and to have the tccmake command/script 6. compiled helloworld.c along with crt1.s with arm-tcc on my kindle with my kludges 6a. -nostdlib used because i couldn't figure out how to get it to find my crt1.o even though in same directory. 6b. -nostdinc because it made me feel better 6c. -I to the place I unpacked aforementioned include headers 6d. -L/lib 6e. put my crt1.s as another object with helloworld.c, later i just compiled it to .o and use that. 7. executed it and verified it worked Okay, that's an easy program that has few function calls, so I used geekmaster's demo.c dithermatron program compiled from kindle for kindle. Also, this one I wanted to use tccmake instead of the full arm-tcc sentence on cmdline. 1. Make a tcc directory at /mn/us/tcc 2. copy rename arm-tcc to /mnt/us/tcc as tcc 3. copy the tccmake, demo.c, and tcc.lib* to /mnt/us/tcc 4. ./tccmake demo 5. Error, unresolved stuff. This pulls in a dependency for __aeabi_idiv, which is not in libc. -> cd /lib grep for that symbol and found in /lib/libgcc_s.so.1. Adding -lgcc to tccmake did not work, was not found. Adding a tcc.libgcc.so with the tcc.libgcc.so and GROUP or tcc.libgcc_s.so and GROUP did not work. Therefore, I just add /lib/libgcc_s.so.1 to tccmake tcc line. 6. run command 4 again, and it made it through! This SEGFAULTED, like the other thread earlier referenced years ago. But I want to see if this is a compiler or program bug. 7. add -g into the building sentence of tccmake 8. gdb demo 9. Find the instruction and corresponding function it crashes on. 10. Notice there's an out of bounds write in something that looks like: fb0[ math stuff] = a lot of math stuff to calculat X, Y offsets and use a dither color. 11. Add a guard before the fb if math stuff > fs*MY then do not write to fb0 12. Build it again Result: see stuff moving across screen, but not so smoothly due to the skipped fb0 writes I guess. I think tcc on kindle color soft for kindle colorsoft works now. But I think headers from kox are needed instead of the old headers used from the aforementioned thread packages. Also, I don't really want to debug the math for the setpx function and caller, so will leave that as is. Also ahead, in case anyone wants this thing, could probably package it up as the trailblazers did in past incarnations and make a new post here for downloading it. |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
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 |
Ripping Debian ARMhf packages for the Kindle | knc1 | Kindle Developer's Corner | 0 | 07-21-2014 08:55 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 |