Shop OBEX P1 Docs P2 Docs Learn Events
propeller-elf-gcc compilation on Jetson TK1 — Parallax Forums

propeller-elf-gcc compilation on Jetson TK1

I am attempting to compile my C source code for the Propeller Activity Board on a Jetson TK1 (armv7l) running Ubuntu 12.04. In my case, I need to forgo using the GUI/SimpleIDE, so I am trying to compile from the command line. I figured the Raspberry Pi (armv6) SimpleIDE binaries might compatible with the TK1 but I have run into some strange stuff.

First off, this is the source for the SimpleIDE I installed. Running "simpleide" won't work because of a Qt incompatibility. I don't care because the whole point is to not use the GUI. After this, from /opt/parallax/bin I can run propeller-elf-gcc, propeller-load, etc. Using ELF and binary files created by actually running SimpleIDE on my Mac using the following source code, propeller-load on the TK1 works correctly. My program runs and the serial terminal output is correct. Therefore I assume the issue must be with the compiler: propeller-elf-gcc. The source is as follows...
#include <stdio.h>
#include <propeller.h>
#include "fdserial.h"

fdserial *term;

int main(void)
{

    simpleterm_close();
    term = fdserial_open(31,30,0,115200);

    int n = 1;
    while(1) {
        waitcnt(CLKFREQ/10+CNT);
	      dprint(term, "%d",n);
        n++;
    }
    return 0;
}

My shell script to invoke propeller-elf-gcc and propeller-load is as follows.
#!/bin/bash

export PATH=/opt/parallax/bin:$PATH

propeller-elf-gcc -Wall -v \
	-I . -L . \
    -I ~/Desktop/Simple-Libraries-master/Learn/Simple\ Libraries/TextDevices/libfdserial \
	-L ~/Desktop/Simple-Libraries-master/Learn/Simple\ Libraries/TextDevices/libfdserial/cmm \
    -I ~/Desktop/Simple-Libraries-master/Learn/Simple\ Libraries/TextDevices/libsimpletext \
	-L ~/Desktop/Simple-Libraries-master/Learn/Simple\ Libraries/TextDevices/libsimpletext/cmm \
	-o hello.elf -Os -mcmm -m32bit-doubles -fno-exceptions -std=c99 -ffunction-sections -fdata-sections -Wl,--gc-sections hello.c -lsimpletext -lfdserial -lm

propeller-load -Dreset=dtr -I ~/Desktop/SimpleIDE/propeller-gcc/propeller-load/ -b ACTIVITYBOARD -e hello.elf

The verbose output during compilation...
Using built-in specs.
COLLECT_GCC=propeller-elf-gcc
COLLECT_LTO_WRAPPER=/opt/parallax/libexec/gcc/propeller-elf/4.6.1/lto-wrapper
Target: propeller-elf
Configured with: ../../propgcc/gcc/configure --target=propeller-elf --prefix=/opt/parallax --disable-nls --disable-libssp --disable-lto --disable-shared --with-pkgversion=propellergcc_v1_0_0_2344 --with-bugurl=http://code.google.com/p/propgcc/issues
Thread model: single
gcc version 4.6.1 (propellergcc_v1_0_0_2344) 
COLLECT_GCC_OPTIONS='-Wall' '-v' '-I' '.' '-L.' '-I' '/home/ubuntu/Desktop/Simple-Libraries-master/Learn/Simple Libraries/TextDevices/libfdserial' '-L/home/ubuntu/Desktop/Simple-Libraries-master/Learn/Simple Libraries/TextDevices/libfdserial/cmm' '-I' '/home/ubuntu/Desktop/Simple-Libraries-master/Learn/Simple Libraries/TextDevices/libsimpletext' '-L/home/ubuntu/Desktop/Simple-Libraries-master/Learn/Simple Libraries/TextDevices/libsimpletext/cmm' '-o' 'hello.elf' '-Os' '-mcmm' '-m32bit-doubles' '-fno-exceptions' '-std=c99' '-ffunction-sections' '-fdata-sections'
 /opt/parallax/libexec/gcc/propeller-elf/4.6.1/cc1 -quiet -v -I . -I /home/ubuntu/Desktop/Simple-Libraries-master/Learn/Simple Libraries/TextDevices/libfdserial -I /home/ubuntu/Desktop/Simple-Libraries-master/Learn/Simple Libraries/TextDevices/libsimpletext -imultilib cmm/short-doubles hello.c -quiet -dumpbase hello.c -mcmm -m32bit-doubles -auxbase hello -Os -Wall -std=c99 -version -fno-exceptions -ffunction-sections -fdata-sections -o /tmp/ccVWQmis.s
GNU C (propellergcc_v1_0_0_2344) version 4.6.1 (propeller-elf)
	compiled by GNU C version 4.6.3, GMP version 5.0.2, MPFR version 3.0.1, MPC version 0.9
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/opt/parallax/lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/sys-include"
#include "..." search starts here:
#include <...> search starts here:
 .
 /home/ubuntu/Desktop/Simple-Libraries-master/Learn/Simple Libraries/TextDevices/libfdserial
 /home/ubuntu/Desktop/Simple-Libraries-master/Learn/Simple Libraries/TextDevices/libsimpletext
 /opt/parallax/lib/gcc/propeller-elf/4.6.1/include
 /opt/parallax/lib/gcc/propeller-elf/4.6.1/include-fixed
 /opt/parallax/lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/include
End of search list.
GNU C (propellergcc_v1_0_0_2344) version 4.6.1 (propeller-elf)
	compiled by GNU C version 4.6.3, GMP version 5.0.2, MPFR version 3.0.1, MPC version 0.9
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 2d66887c08bf480da448e6ad7c490bae
COLLECT_GCC_OPTIONS='-Wall' '-v' '-I' '.' '-L.' '-I' '/home/ubuntu/Desktop/Simple-Libraries-master/Learn/Simple Libraries/TextDevices/libfdserial' '-L/home/ubuntu/Desktop/Simple-Libraries-master/Learn/Simple Libraries/TextDevices/libfdserial/cmm' '-I' '/home/ubuntu/Desktop/Simple-Libraries-master/Learn/Simple Libraries/TextDevices/libsimpletext' '-L/home/ubuntu/Desktop/Simple-Libraries-master/Learn/Simple Libraries/TextDevices/libsimpletext/cmm' '-o' 'hello.elf' '-Os' '-mcmm' '-m32bit-doubles' '-fno-exceptions' '-std=c99' '-ffunction-sections' '-fdata-sections'
 /opt/parallax/lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/bin/as -lmm -cmm -o /tmp/cc4F1eAJ.o /tmp/ccVWQmis.s
COMPILER_PATH=/opt/parallax/libexec/gcc/propeller-elf/4.6.1/:/opt/parallax/libexec/gcc/propeller-elf/4.6.1/:/opt/parallax/libexec/gcc/propeller-elf/:/opt/parallax/lib/gcc/propeller-elf/4.6.1/:/opt/parallax/lib/gcc/propeller-elf/:/opt/parallax/lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/bin/
LIBRARY_PATH=/opt/parallax/lib/gcc/propeller-elf/4.6.1/cmm/short-doubles/:/opt/parallax/lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/lib/cmm/short-doubles/:/opt/parallax/lib/gcc/propeller-elf/4.6.1/:/opt/parallax/lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/lib/
COLLECT_GCC_OPTIONS='-Wall' '-v' '-I' '.' '-L.' '-I' '/home/ubuntu/Desktop/Simple-Libraries-master/Learn/Simple Libraries/TextDevices/libfdserial' '-L/home/ubuntu/Desktop/Simple-Libraries-master/Learn/Simple Libraries/TextDevices/libfdserial/cmm' '-I' '/home/ubuntu/Desktop/Simple-Libraries-master/Learn/Simple Libraries/TextDevices/libsimpletext' '-L/home/ubuntu/Desktop/Simple-Libraries-master/Learn/Simple Libraries/TextDevices/libsimpletext/cmm' '-o' 'hello.elf' '-Os' '-mcmm' '-m32bit-doubles' '-fno-exceptions' '-std=c99' '-ffunction-sections' '-fdata-sections'
 /opt/parallax/libexec/gcc/propeller-elf/4.6.1/collect2 -mpropeller -o hello.elf /opt/parallax/lib/gcc/propeller-elf/4.6.1/cmm/short-doubles/spinboot.o /opt/parallax/lib/gcc/propeller-elf/4.6.1/cmm/short-doubles/_crt0.o /opt/parallax/lib/gcc/propeller-elf/4.6.1/cmm/short-doubles/_crtbegin.o -L. -L/home/ubuntu/Desktop/Simple-Libraries-master/Learn/Simple Libraries/TextDevices/libfdserial/cmm -L/home/ubuntu/Desktop/Simple-Libraries-master/Learn/Simple Libraries/TextDevices/libsimpletext/cmm -L/opt/parallax/lib/gcc/propeller-elf/4.6.1/cmm/short-doubles -L/opt/parallax/lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/lib/cmm/short-doubles -L/opt/parallax/lib/gcc/propeller-elf/4.6.1 -L/opt/parallax/lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/lib --gc-sections /tmp/cc4F1eAJ.o -lsimpletext -lfdserial -lm -lgcc --start-group -lc -lgcc --end-group -lgcc /opt/parallax/lib/gcc/propeller-elf/4.6.1/cmm/short-doubles/_crtend.o
Propeller Version 1 on /dev/ttyUSB0
Loading hello.elf to EEPROM via hub memory
                                          
9208 bytes sent
Verifying RAM ... OK
Programming EEPROM ... OK
Verifying EEPROM ... OK

But when I run this version, a single, non-alphanumeric byte gets spit out to the terminal followed by nothing else. The version compiled on the Mac, loaded on by the TK1, instead spits out two non-alphanumeric values and then starts the count correctly. Just for comparison, the working binary is 9212 bytes in size.

The Simple Libraries I am using were retrieved here.

As far as I can tell, the only strange thing about the compilation output is...
ignoring nonexistent directory "/opt/parallax/lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/sys-include"

I cannot find any reference to a "sys-include" folder on the TK1, nor my Mac. Does anyone know where this comes from?

Soon I will build from source both libfdserial and libsimpletext on the TK1. I've only used the included .a files up until now and I feel that I am running out of places to look for the source of this problem. Simplifying the source even further be removing dependence on those two libs and simply printing with printf builds just fine on the TK1, so I am stumped.

Any insight at all is greatly appreciated.




Comments

  • I've looked over your message a couple times, and it all does seem correct to me. Given that, I'm throwing the following idea out there as a random guess not because I think it will actually work:

    I have a server that watches the PropGCC repository and builds a new tarball on every commit. You can download the latest version for Raspberry Pi from this link: http://david.zemon.name:8111/repository/download/PropGCC5_Gcc4rpi/1644:id/propellergcc-alpha_v1_9_0-gcc4-rpi.tar.gz?guest=1 (I agree with your reasoning about armv6 binaries being compatible with armv7: they should be).

    I think I recall that the ABI changed with this newer version of PropGCC, so you'll need new static libraries for Simple. You can either compile them yourself, pull only the source you need and build it as part of your project, or you can grab a zip of PropWare of use the libSimple.a libraries from it: http://david.zemon.name:8111/repository/download/PropWare_Develop/1794:id/PropWare-3.0.0.162-Generic-propware.zip?guest=1
  • Thank you, David. I decided to take a step back and try to get this all to work on my Raspberry Pi3 B. To my surprise, it doesn't work there either! I can build and run a simplified example of hello.c that uses printf instead of fdserial and it works fine on both the Pi and TK1. It's only when I use the ELF file with links to the Simple Libraries that it fails to produce something that runs correctly.

    I have tried the latest version of the binaries for the Pi that you linked. As a side note, I did not use anything from the second download link because it doesn't seem to contain the Simple Libraries (libfdserial and libsimpletext) that I need.

    No new luck using the new binaries, even after using them to rebuild the latest release of libfdserial and libsimpletext from source.

    At this point, I'm convinced that the problem is with the Simple Libraries as, without them, everything works just fine. I just can't seem to find any mention of someone having a similar issue, even with the Pi.

    I think the (dis)similarity in gdb output for the different cases is interesting. For the simplified hello.c version they look relatively similar but for the one with fdserial the differences seem very odd.
    
    #### Mac - simplified hello.c (without fdserial)
    
    (gdb) disassemble main
    Dump of assembler code for function main:
          0x000007f8 <+0>:	if_ae            waitcnt	0x98, 0xc <__sys_mbox+4> nr
          0x000007fc <+4>:	if_nc_or_nz      wrbyte	0x200, #430 
          0x00000800 <+8>:	if_a             <unrecognized instruction>
          0x00000804 <+12>:	if_nc_and_z      waitpeq	0x540, 0x774 wz
          0x00000808 <+16>:	if_c_and_z       rdlong	0x1c <pbase+12>, 0x7c4 <___init+25> 
          0x0000080c <+20>:	if_c             rdbyte	0x6e0, #16 
          0x00000810 <+24>:	if_c_eq_z        wrword	0x7f0 <L_loopend+14>, #0 
          0x00000814 <+28>:	if_c_and_nz      hubop	0x1e0, 0xc8 wz
          0x00000818 <+32>:	if_ae            shl	0x63c, #8 wz
          0x0000081c <+36>:	if_c_eq_z        wrlong	0xc <__sys_mbox+4>, 0x40 
          0x00000820 <+40>:			nop
    
    ### Raspberry Pi - simplified hello.c (without fdserial)
    
    (gdb) disassemble main
    Dump of assembler code for function main:
          0x000000b8 <+0>:     if_ae           waitcnt 0x98 <L_loop+7>, 0xc <__sys_mbox+4> nr
          0x000000bc <+4>:     if_nc_or_z      wrbyte  0x200 <__serial_putchar+24>, #430
          0x000000c0 <+8>:     if_a            <unrecognized instruction>
          0x000000c4 <+12>:    if_nc_and_z     waitpeq 0x540 <__fmt_octal+6>, 0x774 <__dofmt+313> wz
          0x000000c8 <+16>:    if_c_and_z      rdlong  0x1c <pbase+12>, 0x7c4 <__dofmt+393>
          0x000000cc <+20>:    if_c            rdbyte  0x6e0 <__dofmt+165>, #16
          0x000000d0 <+24>:    if_c_eq_z       ror     0x7f0 <__itoa_prec+40>, #0 nr
          0x000000d4 <+28>:    if_c_and_nz     hubop   0x1e0 <__serial_tx+60>, 0x2c wz
          0x000000d8 <+32>:    if_ae           shl     0x63c <__dofmt+1>, #8 wz
          0x000000dc <+36>:    if_e            rdbyte  0x20c <__serial_putchar+36>, #16
          0x000000e0 <+40>:                    nop
    
    #### Mac - hello.c (with fdserial)
    
    (gdb) disassemble main
    Dump of assembler code for function main:
          0x000007f8 <+0>:  if_ae             waitcnt  0x98, 0xc <__sys_mbox+4> nr
          0x000007fc <+4>:  if_c_eq_z         absneg   0x190, 0x1b4 wz, nr
          0x00000800 <+8>:                    wrlong   0xc <__sys_mbox+4>, #1 wz
          0x00000804 <+12>: if_c_and_z        <unrecognized instruction>
          0x00000808 <+16>:       nop
          0x0000080c <+20>: if_a              rev   0x400, 0x4 <__clkmode> nr
          0x00000810 <+24>: if_nc_or_nz       xor   0x620, #8 
          0x00000814 <+28>: if_c_and_nz       cmpx  0x0 <start>, 0x0 <start> wc
          0x00000818 <+32>: if_c              waitpeq  0x414, #161 wc, wr
          0x0000081c <+36>: if_nc_and_z       <unrecognized instruction>
          0x00000820 <+40>:       nop
          0x00000824 <+44>: if_ne             ror   0xcc, #504 wc
          0x00000828 <+48>: if_ae             wrlong   0x420, 0x3c0 
          0x0000082c <+52>: if_c_and_nz       subsx 0x8 <__sys_mbox>, 0x31c wc, nr
          0x00000830 <+56>: if_nc_or_z        <unrecognized instruction>
          0x00000834 <+60>: if_nc_and_z       muxnz 0x610, 0x18 <pbase+8> wz, wc, nr
          0x00000838 <+64>:       nop
    
    ### Raspberri Pi - hello.c (with fdserial)
    
    (gdb) disassemble main
    Dump of assembler code for function main:
          0x000000b8 <+0>:     if_ae           waitcnt 0xb4 <L_loopend+17>, 0x40c <__dosprnt+160> nr
          0x000000bc <+4>:     if_nc_or_z      wrbyte  0x0 <start>, #430
          0x000000c0 <+8>:     if_be           rdbyte  0xc <__sys_mbox+4>, #0
          0x000000c4 <+12>:    if_c_and_z      <unrecognized instruction>
          0x000000c8 <+16>:                    nop
          0x000000cc <+20>:    if_a            <unrecognized instruction>
          0x000000d0 <+24>:    if_c            <unrecognized instruction>
          0x000000d4 <+28>:    if_c_and_nz     cmpx    0x8 <__sys_mbox>, 0x32c <_writeStr+28> wc
          0x000000d8 <+32>:    if_c            waitpeq 0x414 <__dosprnt+168>, #161 wc, wr
          0x000000dc <+36>:    if_nc_and_z     <unrecognized instruction>
          0x000000e0 <+40>:                    nop
          0x000000e4 <+44>:    if_nc_or_z      <unrecognized instruction>
          0x000000e8 <+48>:    if_ae           wrlong  0x420 <__dosprnt+180>, 0x3c0 <__dosprnt+84>
          0x000000ec <+52>:    if_nc_or_nz     negnz   0x5b8 <_float2string+152>, 0x440 <__dosprnt+212> wz, wc, nr
          0x000000f0 <+56>:    if_a            add     0x420 <__dosprnt+180>, 0xb8 <main> nr
          0x000000f4 <+60>:    if_nc_or_nz     rdbyte  0x6fc <_float2string+476>, #257 ---Type <return> to 
    
    simplified hello.c - runs just fine when compiled from both Pi and TK1
    
    #include <stdio.h>
    #include <propeller.h>
    
    int main(void)
    {
        int n = 1;
        while(1) {
            waitcnt(CLKFREQ/10+CNT);
    	printf("%d\n",n);
            n++;
        }
        return 0;
    }
    
  • I'm afraid that all of those disassemblies are bogus (the "<unrecognized instruction>" clinches this, but the high proportion of conditional instructions was also a clue). It almost looks like gdb has gotten confused about whether the code was compressed (CMM) or not.

    Getting back to the original problem, I have heard that some of the Simple Libraries have trouble with new PropGCC versions (which is one reason, I think, that the official PropGCC release is so old). I don't know any more details, though.
  • Sorry to hear you're still not having any luck.
    Falimond wrote: »
    I have tried the latest version of the binaries for the Pi that you linked. As a side note, I did not use anything from the second download link because it doesn't seem to contain the Simple Libraries (libfdserial and libsimpletext) that I need.

    When I compile the Simple libraries, I put all of the different objects into a single static archive: libSimple.a. Look for a library by that name in the second download and try linking against that. So long as you link with "-Wl,--gc-sections", you should get the same size binary because the files in the library were compiled with "-ffunction-sections -fdata-sections". A few bytes difference will of course be expected because the compiler is different.
    ersmith wrote: »
    Getting back to the original problem, I have heard that some of the Simple Libraries have trouble with new PropGCC versions (which is one reason, I think, that the official PropGCC release is so old). I don't know any more details, though.

    I did some work a while ago to pinpoint at least one of those problems, and I haven't been able to find it again in either the PropGCC or Simple Libraries issue trackers on GitHub. Perhaps I talked through the issue in a forum thread here... not sure.

    Anyway, what's weird to me (and the reason I don't understand this problem in the first place) is that Falimond used the PropGCC and Simple libraries shipped with SimpleIDE in his original post. Those should have been compatible. It makes sense that his second test - new version of PropGCC + old version of Simple libs - failed because that seems to be the same problem I (supposedly) documented a while ago. But his first test... that's just weird :(.
Sign In or Register to comment.