GNU GCC C compiler for PRU

I’d like to announce my hobby project for the past few months - a port of GNU GCC and Binutils to TI’s PRU. Patches and a simple example can be downloaded from https://github.com/dinuxbg/gnupru .

Please note that this is still a work in progress. But since now there is a working blinking led example, I decided others may be interested.

Disclaimers:

  1. This effort has no relation to the rumored TI C PRU compiler.
  2. This is a preliminary release, so expect bugs. If your program doesn’t run, then please be prepared to disassemble and check what the compiler/assembler/linker did.
  3. There is no C library.
  4. ABI is not yet finalized.

Regards,
Dimitar

Hi Dimitar,

I’d like to get in touch with you, could I PM you ?

I’d like to announce my hobby project for the past few months - a port of GNU GCC and Binutils to TI’s PRU. Patches and a simple example can be downloaded from https://github.com/dinuxbg/gnupru .

Please note that this is still a work in progress. But since now there is a working blinking led example, I decided others may be interested.

Thank you, thank you!

Disclaimers:

  1. This effort has no relation to the rumored TI C PRU compiler.

Said rumored compiler is at http://software-dl.ti.com/codegen/non-esd/downloads/beta.htm

  1. This is a preliminary release, so expect bugs. If your program doesn’t run, then please be prepared to disassemble and check what the compiler/assembler/linker did.
  2. There is no C library.
  3. ABI is not yet finalized.

If you can make the ABI compatible, that would be really cool.

I’d like to announce my hobby project for the past few months - a port of GNU GCC and Binutils to TI’s PRU. Patches and a simple example can be downloaded from https://github.com/dinuxbg/gnupru .

Please note that this is still a work in progress. But since now there is a working blinking led example, I decided others may be interested.

Thank you, thank you!

Disclaimers:

  1. This effort has no relation to the rumored TI C PRU compiler.

Said rumored compiler is at http://software-dl.ti.com/codegen/non-esd/downloads/beta.htm

  1. This is a preliminary release, so expect bugs. If your program doesn’t run, then please be prepared to disassemble and check what the compiler/assembler/linker did.
  2. There is no C library.
  3. ABI is not yet finalized.

If you can make the ABI compatible, that would be really cool.

Can you share this compatible ABI? If I have the specification and it is easy to modify GCC, then I could do it. I’ll have to change the ABI anyway - current one is not optimal for using the hardware multiplication instruction.

FYI, the current GCC PRU ABI was inspired by Nios2 and looks roughly like this:
Regno Name
0-3 r0-r3 Register Arguments. Rest of arguments are saved on stack.
4-5 r4-r5 Return Location. Allows 64bit value return without involving the stack.
6-16 r6-r16 Caller Saved Registers
17-26 r17-r26 Callee Saved Registers
27 r27 ra Return Address
28 r28 sp Stack Pointer
29 r29 fp Frame Pointer. Usually omitted and used as a general-purpose register.
30 r30 Special I/O register. Not used by compiler.
31 r31 Special I/O register. Not used by compiler.

I couldn’t find a description of TI’s PRU C ABI. Can somebody help by publicly posting it?

If TI PRU C ABI turns out to be secret, then what do you think GCC PRU ABI should look like?

Thanks,
Dimitar

I couldn't find a description of TI's PRU C ABI. Can somebody help by
publicly posting it?

If TI PRU C ABI turns out to be secret, then what do you think GCC PRU ABI
should look like?

Right now, based on my internal queries, the ABI doesn't have a hard
specification. The readme does contain the calling convention and type
size/alignment. I'm looking to see if additional aspects of the ABI
can be solidified. If you have some specific decisions you'd like to
standardize upon, please share those so we can drive as much
interoperability as is reasonable and quickly become aware of points
of incompatibility.

I'd like to announce my hobby project for the past few months - a port of
GNU GCC and Binutils to TI's PRU. Patches and a simple example can be
downloaded from GitHub - dinuxbg/gnupru: GCC and Binutils port for the TI PRU I/O processor .

Please note that this is still a work in progress. But since now there is a
working blinking led example, I decided others may be interested.

Disclaimers:
1. This effort has no relation to the rumored TI C PRU compiler.
2. This is a preliminary release, so expect bugs. If your program doesn't
run, then please be prepared to disassemble and check what the
compiler/assembler/linker did.
3. There is no C library.
4. ABI is not yet finalized.

Tried building it on a Mac. Not sure if you are interested, but here's
the last bit of the error I got when making a quick pass (clone and
run build.sh):

.
.
.
gcc -DHAVE_CONFIG_H -I.
-I/Users/jason/workspace/gnupru/src/binutils-gdb/ld -I.
-I/Users/jason/workspace/gnupru/src/binutils-gdb/ld -I../bfd
-I/Users/jason/workspace/gnupru/src/binutils-gdb/ld/../bfd
-I/Users/jason/workspace/gnupru/src/binutils-gdb/ld/../include -g -O2
-DENABLE_PLUGINS
-DLOCALEDIR="\"/Users/jason/bin/pru-gcc/share/locale\"" -W -Wall
-Wstrict-prototypes -Wmissing-prototypes -Wshadow -Werror -g -O2 -MT
ldlex-wrapper.o -MD -MP -MF .deps/ldlex-wrapper.Tpo -c -o
ldlex-wrapper.o
/Users/jason/workspace/gnupru/src/binutils-gdb/ld/ldlex-wrapper.c
-Wno-error
libtool: link: gcc -dynamiclib -o .libs/libldtestplug.0.dylib
.libs/libldtestplug_la-testplug.o -lz -Wl,-no_pie -install_name
/nowhere/libldtestplug.0.dylib -compatibility_version 1
-current_version 1.0 -Wl,-single_module
mv -f .deps/ldlang.Tpo .deps/ldlang.Po
LIB_PATH='' /bin/sh
/Users/jason/workspace/gnupru/src/binutils-gdb/ld/genscripts.sh
"/Users/jason/workspace/gnupru/src/binutils-gdb/ld"
"/Users/jason/bin/pru-gcc/lib" "/Users/jason/bin/pru-gcc"
"/Users/jason/bin/pru-gcc" x86_64-apple-darwin12.5.0 pru-unknown-none
pru "pruelf" "/usr/local/lib /lib /usr/lib" no no pruelf "pru"
libtool: link: (cd ".libs" && rm -f "libldtestplug.dylib" && ln -s
"libldtestplug.0.dylib" "libldtestplug.dylib")
libtool: link: ar rc .libs/libldtestplug.a libldtestplug_la-testplug.o
libtool: link: ranlib .libs/libldtestplug.a
In file included from
/Users/jason/workspace/gnupru/src/binutils-gdb/ld/ldlex-wrapper.c:26:
ldlex.c: In function ‘yy_scan_buffer’:
ldlex.c:3822: warning: declaration of ‘base’ shadows a global declaration
/Users/jason/workspace/gnupru/src/binutils-gdb/ld/ldlang.h:508:
warning: shadowed declaration is here
libtool: link: ( cd ".libs" && rm -f "libldtestplug.la" && ln -s
"../libldtestplug.la" "libldtestplug.la" )
/Users/jason/workspace/gnupru/src/binutils-gdb/ld/genscrba.sh: line 6:
/Users/jason/workspace/gnupru/src/binutils-gdb/ld/emultempl/pruelf.em:
No such file or directory
make[4]: *** [epruelf.c] Error 1
make[4]: *** Waiting for unfinished jobs....
rm -f ld.pod
mv -f .deps/ldlex-wrapper.Tpo .deps/ldlex-wrapper.Po
make[3]: *** [all-recursive] Error 1
make[2]: *** [all] Error 2
make[1]: *** [all-ld] Error 2
make: *** [all] Error 2

I'll try again on an ARM/Linux board next, but the Mac was handy at
the time. Might look a bit more at where pruelf.em gets created, but
didn't know if it might simply be missing from the patch as the other
.em files all seem to be under source control and not generated.

Jason, I reproduced your error by switching to bash as default shell. On my debian PC the default dash shell silently “drops” the error code from the failed source command. I’m working on a fix.

I pushed the build fix to the master branch. You should now be able to build your toolchain, make the LED example, and see the blinking led.

Now the bad news. I tried a bit more complex example but it failed (see the md5-example branch on github). I’m on to chasing why MD5 generation differs between ARM and x86_64 hosts on one hand and PRU target on the other hand.

Regarding the ABI. I tried to download TI’s compiler to see its readme, but it asked for registration and accepting some EULA. I’d rather not spend my free time reading legalese, so until I see TI’s ABI description in an open Wiki, it remains secret to me :slight_smile:

I’ll try to propose a GCC PRU ABI in the next couple of days. I’m very keen to hear comments from community.

Regards,
Dimitar

Response I got...

It will be soon ...

The external documentation keeps getting delayed, but it is almost
complete. Once it is published it will be available directly from the
wiki with no EULA.

Also, the next PRU compiler release will not require a EULA. It will
be a TSPA release.

(TSPA means no EULA ahead of download, just a download. This next big
release would likely be toward the end of next year. The wiki in
discussion is http://processors.wiki.ti.com)

end of ** 2015 ** ??? The chip will likely be obsolete by then! Yikes, why
such a huge delay?

Not that I really think this is such a catastrophe, it is not so bad to do very
low-level tasks in the PRU assembler, where you are totally conscious of
every machine cycle.

Jon

The C compiler is already publicly available (http://elinux.org/Ti_AM33XX_PRUSSv2#C_Compiler), just currently requires a EULA. The documentation required for sharing the calling conventions, however, should be posted much sooner.

The MD5 example has been fixed. I had forgotten to update binutils after changing the Return Address register number.

I started taking notes for the new calling convention on https://github.com/dinuxbg/gnupru/wiki . I’ll wait a couple of weeks to gather comments before commencing with the implementation.

Regards,
Dimitar