Shop OBEX P1 Docs P2 Docs Learn Events
Trouble running a demo in P2 mode — Parallax Forums

Trouble running a demo in P2 mode

RaymanRayman Posts: 14,665
edited 2013-04-07 09:43 in Propeller 1
Trying the demos out in P2 mode...

Got the "hello" demo running with just these steps:
add -mp2 to build
replace CNT with getcnt()
Change propeller-load argument to a P2 board (DE2-115) in Project Properties
(e.g.: -I C:/propgcc/propeller-load/ -b DE2-115 a.out -r -t -v)
But, running into trouble with the "calc" demo...
In "cmm" mode it compiles and runs but does some pretty bad math:

Enter first  number: 23
Enter second number: 23
16.000000 * 16.000000 = 256.000000


In "lmm" mode, it won't compile at all...
Here's what my command line looks like:

propeller-elf-gcc.exe -mp2 -m32bit-doubles -Dprintf=__simple_printf -Wall -o a.out -Os -mcmm -I . -fno-exceptions *.c -lm

Here's the kind of errors I'm getting:
1>Build:
1>  c:/propgcc/bin/../lib/gcc/propeller-elf/4.6.1/p2\libgcc.a(_loadfloat.o): In function `.FCfloatstart':
1>  (.text+0x10): undefined reference to `__TMP1'
1>  c:/propgcc/bin/../lib/gcc/propeller-elf/4.6.1/p2\libgcc.a(_loadfloat.o): In function `.FCadd':
1>  (.text+0x4c): undefined reference to `__TMP1'
1>  c:/propgcc/bin/../lib/gcc/propeller-elf/4.6.1/p2\libgcc.a(_loadfloat.o): In function `.FCadd':

Comments

  • ersmithersmith Posts: 6,054
    edited 2013-03-28 11:54
    Those are known bugs that have been fixed in the source tree. The CMM floating point math issue is due to a change in the way the carry flag is calculated on max and min instructions. The LMM problem was a simple missing .global.

    Are you using the latest propgcc for p2 release? I'm not sure when that was made; if you are on the latest, then I guess it's time for us to send out another!

    Eric
  • RaymanRayman Posts: 14,665
    edited 2013-03-28 11:57
    I may have messed myself up by downloading the latest version looking for the image-size thing and got P1 instead of P2...
  • RaymanRayman Posts: 14,665
    edited 2013-03-28 12:03
    Ok, I reverted to what I know is a P2 version, but I still get these errors...

    Just tried with the P2 version of calc.c and still get this error...

    BTW: Calc used to be in 2 places demos\calc and demos\forumists\jazzed\calc
    But now, demos\calc just has a makefile and no .c code...
  • jazzedjazzed Posts: 11,803
    edited 2013-03-28 12:19
    I've talked about these kinds of things briefly with David, Eric, and Andy. Also started a thread to discuss appropriate APIs for abstracting these issues some time ago. David had split propeller.h into separate files used based on the compiler mode. That helps but as you can see there are still gotchas.

    The current set of demos need to be reviewed and ported where necessary to use a common Propeller API. Some of it may have already been done, but I'm sure there is more work to do.

    I would like to see every Propeller demo work on every Propeller family chip. I'd like to help, but I'm buried in other issues.
    We might consider a re-org of demos. I chose only a few for the SimpleIDE project.

    PS. There was never any .c code in the top level demos/calc folder which was added by David. I only added the one under jazzed.
  • David BetzDavid Betz Posts: 14,516
    edited 2013-03-28 12:28
    jazzed wrote: »
    I've talked about these kinds of things briefly with David, Eric, and Andy. Also started a thread to discuss appropriate APIs for abstracting these issues some time ago. David had split propeller.h into separate files used based on the compiler mode. That helps but as you can see there are still gotchas.

    The current set of demos need to be reviewed and ported where necessary to use a common Propeller API. Some of it may have already been done, but I'm sure there is more work to do.

    I would like to see every Propeller demo work on every Propeller family chip. I'd like to help, but I'm buried in other issues.
    We might consider a re-org of demos. I chose only a few for the SimpleIDE project.

    PS. There was never any .c code in the top level demos/calc folder which was added by David. I only added the one under jazzed.
    Did I check in a demo without its source code? Sorry!
    I guess I'm going to go through the demos as soon as I get something working for XMM on the P2. Our other P2 project participants seem to be unavailable.

    Also, one should never include "propeller1.h" or "propeller2.h" directly. The correct one is included when you include "propeller.h" based on the preprocessor symbol __PROPELLER2__.
  • RaymanRayman Posts: 14,665
    edited 2013-03-28 12:36
    I got some of the P1 demos to work for P2 by adding this:

    #ifdef __PROPELLER2__
    #define CNT getcnt()
    #define INA PINA
    #define OUTA PINA
    #endif
    There's just no way all P2 demos could work on P1, but maybe you can make all P1 demos work on P2...
  • RaymanRayman Posts: 14,665
    edited 2013-03-28 13:15
    I have problems with the Dhrystone demo too... This compiles with warnings under -mlmm but doesn't run right.
    Won't compile with -mcmm...

    These are the kind of warnings:
    1>  dry.c:514:18: warning: conflicting types for built-in function 'malloc' [enabled by default]
    1>  dry.c: In function 'main':
    1>  dry.c:589:3: warning: incompatible implicit declaration of built-in function 'strcpy' [enabled by default]
    1>  c:/propgcc/bin/../lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/bin/ld.exe: propeller architecture mismatch: old = 0x00000001, new = 0x00000002, filename = dry1.o
    1>  c:/propgcc/bin/../lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/bin/ld.exe: propeller architecture mismatch: old = 0x00000003, new = 0x00000002, filename = dry2.o
    1>  c:/propgcc/bin/../lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/bin/ld.exe: propeller architecture mismatch: old = 0x00000003, new = 0x00000001, filename = _muldi3.o
    1>  c:/propgcc/bin/../lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/bin/ld.exe: propeller architecture mismatch: old = 0x00000003, new = 0x00000001, filename = _divdi3.o
    1>  c:/propgcc/bin/../lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/bin/ld.exe: propeller architecture mismatch: old = 0x00000003, new = 0x00000001, filename = _clz.o
    1>  c:/propgcc/bin/../lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/bin/ld.exe: propeller architecture mismatch: old = 0x00000003, new = 0x00000001, filename = simple_printf.o
    
  • David BetzDavid Betz Posts: 14,516
    edited 2013-03-28 13:25
    You're finding all sorts of problems! I suppose you'll be wanting TWO signed P2 boards when they come out. :-)

    Thanks for doing this testing. I'll try these myself but I can't until later. I assume you're just using the makefiles in the demo directories?
  • jazzedjazzed Posts: 11,803
    edited 2013-03-28 13:30
    Rayman wrote: »
    I got some of the P1 demos to work for P2 by adding this:

    #ifdef __PROPELLER2__
    #define CNT getcnt()
    #define INA PINA
    #define OUTA PINA
    #endif
    There's just no way all P2 demos could work on P1, but maybe you can make all P1 demos work on P2...

    LOL. Nice point. Do we have P2 specific demos yet?

    I'm not sure using the defines mentioned would be correct in all cases. There must be at least one demo that does OUTA ^= (1 << pin). That case could be different in P1/P2 depending on the value actually present on the the pin for P2. P1 keeps a shadow copy of OUTA where P2 does not. We are almost forced to use a function-like API rather than using a register-like variable.
  • RaymanRayman Posts: 14,665
    edited 2013-03-28 13:51
    Not using makefiles... Don't really want to...

    BTW: I get this error message if I try to use make:
    The procedure entry point libintl_setlocale could not be located in the dynamic link library libintl-8.dll.
  • doggiedocdoggiedoc Posts: 2,243
    edited 2013-03-28 13:55
    I can report that all the demos I have tried with the p2test build compile fine for the P1. :D
  • David BetzDavid Betz Posts: 14,516
    edited 2013-03-28 14:03
    doggiedoc wrote: »
    I can report that all the demos I have tried with the p2test build compile fine for the P1. :D
    That's great news. Can you tell me which demos you tried?

    Thanks!
    David
  • doggiedocdoggiedoc Posts: 2,243
    edited 2013-03-28 15:04
    I will give you a list when I get home. :D
  • doggiedocdoggiedoc Posts: 2,243
    edited 2013-03-29 05:24
    Here's a partial list: I'll post more as I go back through them:
    c++_toggle
    toggle.cc compiles: propeller-elf-c++ -o a.out -Os -mlmm -I . -fno-exceptions -fno-rtti toggle.cc
    
    lmm_c_toggle
    	toggle.c compiles: propeller-elf-gcc -o a.out -Os -mlmm -I . -fno-exceptions toggle.c
    
    lmm_toggle
    	toggle.c compiles: propeller-elf-gcc -o a.out -Os -mlmm -I . -fno-exceptions toggle.c
    
    
    
    
  • David BetzDavid Betz Posts: 14,516
    edited 2013-03-29 05:38
    doggiedoc wrote: »
    Here's a partial list: I'll post more as I go back through them:
    c++_toggle
    toggle.cc compiles: propeller-elf-c++ -o a.out -Os -mlmm -I . -fno-exceptions -fno-rtti toggle.cc
    
    lmm_c_toggle
    	toggle.c compiles: propeller-elf-gcc -o a.out -Os -mlmm -I . -fno-exceptions toggle.c
    
    lmm_toggle
    	toggle.c compiles: propeller-elf-gcc -o a.out -Os -mlmm -I . -fno-exceptions toggle.c
    
    
    
    
    Thanks! I'm assuming that they also run okay? :-)
  • doggiedocdoggiedoc Posts: 2,243
    edited 2013-03-29 10:00
    Sorry - didn't have a prop board handy when I compiled those. I will test them.
  • AribaAriba Posts: 2,690
    edited 2013-04-06 23:04
    Finally I also tried PropGCC with the Propeller 2 (with SimpleIDE).

    For me it looks like the Modulo operator (%) does not work correct in Prop2 mode.

    Where can I find the LMM interpreter source code for Prop2? I searched a bit in the p2test branch but it's not obvious for me where it should be.
    Thanks
    Andy
  • David BetzDavid Betz Posts: 14,516
    edited 2013-04-07 04:40
    Ariba wrote: »
    Finally I also tried PropGCC with the Propeller 2 (with SimpleIDE).

    For me it looks like the Modulo operator (%) does not work correct in Prop2 mode.

    Where can I find the LMM interpreter source code for Prop2? I searched a bit in the p2test branch but it's not obvious for me where it should be.
    Thanks
    Andy

    propgcc/gcc/gcc/config/propeller/crt0_lmm2.s
  • ersmithersmith Posts: 6,054
    edited 2013-04-07 05:38
    Ariba wrote: »
    Finally I also tried PropGCC with the Propeller 2 (with SimpleIDE).

    For me it looks like the Modulo operator (%) does not work correct in Prop2 mode.

    Where can I find the LMM interpreter source code for Prop2? I searched a bit in the p2test branch but it's not obvious for me where it should be.
    Thanks
    Andy

    As David mentioned, the LMM source is in gcc/gcc/config/propeller/. The main source is in crt0_lmm2.s, but the math routines are in kernel.ext (which is shared by CMM, XMM, and LMM). You've found a typo in the prop2 division routines: in __DIVSI_impl the lines:
        getdivq r0
        getdivq r1
    
    should read
        getdivq r0
        getdivr r1
    
    Thanks for catching this!

    Eric
  • AribaAriba Posts: 2,690
    edited 2013-04-07 08:44
    Thanks Eric and David for the link.

    This typo explains why my decimal output code not works on Prop2.

    I hope Ken has noticed that I've found a bug :smile:

    Andy
  • RaymanRayman Posts: 14,665
    edited 2013-04-07 09:25
    That's a more real bug than the things I find...
  • David BetzDavid Betz Posts: 14,516
    edited 2013-04-07 09:43
    Ariba wrote: »
    Thanks Eric and David for the link.

    This typo explains why my decimal output code not works on Prop2.

    I hope Ken has noticed that I've found a bug :smile:

    Andy
    This seems like a bad enough bug that we should issue an update quickly. I'm in the process of making a new Windows build and will upload it when the build completes. Sorry about this typo!!!
Sign In or Register to comment.