Shop OBEX P1 Docs P2 Docs Learn Events
PropGCC Propeller 2 Bug Fixes - and your chance for first-release Propeller hardware! - Page 3 — Parallax Forums

PropGCC Propeller 2 Bug Fixes - and your chance for first-release Propeller hardware!

135

Comments

  • potatoheadpotatohead Posts: 10,261
    edited 2013-03-18 08:10
    It's 64 bit now. You can do one getcnt and get the lower 32 bits. If you do two in a row, you get all 64.
  • RaymanRayman Posts: 14,640
    edited 2013-03-18 08:33
    Ok, here's another question... I see there's a new "SUBCNT" instruction. I tried using it like this, but it doesn't work:
    #include "cog.h"
    #include <stdint.h>
    #include <string.h>
    static __inline__ uint32_t subcnt(void)
    {
        uint32_t value;
        __asm__ volatile (
            "subcnt %[_value]"
        : /* outputs */
            [_value] "=r" (value)
        : /* no inputs */
        : /* no clobbered registers */
        );
        return value;
    }
    
    int main(void)
    {
        int n = 1;
        while(1) {
            //waitcnt(CLKFREQ/10+getcnt());
            getcnt();
            while(subcnt()<(CLKFREQ/10));
            printf("Hello World %d\n", n);
            n++;
        }
        return 0;
    }
     
    

    I'm trying to use the "SUBCNT" instruction, but it seems to not work right...
    It looks like subcnt is giving me something like GETCNT instead...
  • Ken GraceyKen Gracey Posts: 7,392
    edited 2013-03-18 08:37
    jazzed wrote: »
    Seems to me this thread is drifting into the unnecessarily complicated zone.

    Knowledge of Makefiles and building Propeller-GCC are not required for testing.

    I have several PropGCC programs and I don't think I've even encountered a Makefile yet. And if I had, they didn't bother me and I didn't know what they were anyway. I'm just writing simple C examples, compiling them and downloading using one of the available memory models.
  • David BetzDavid Betz Posts: 14,516
    edited 2013-03-18 08:37
    Rayman wrote: »
    Ok, here's another question... I see there's a new "SUBCNT" instruction. I tried using it like this, but it doesn't work:
    #include "cog.h"
    #include <stdint.h>
    #include <string.h>
    static __inline__ uint32_t subcnt(void)
    {
        uint32_t value;
        __asm__ volatile (
            "subcnt %[_value]"
        : /* outputs */
            [_value] "=r" (value)
        : /* no inputs */
        : /* no clobbered registers */
        );
        return value;
    }
    
    int main(void)
    {
        int n = 1;
        while(1) {
            //waitcnt(CLKFREQ/10+getcnt());
            getcnt();
            while(subcnt()<(CLKFREQ/10));
            printf("Hello World %d\n", n);
            n++;
        }
        return 0;
    }
     
    

    I'm trying to use the "SUBCNT" instruction, but it seems to not work right...
    It looks like subcnt is giving me something like GETCNT instead...

    Shouldn't you be passing a parameter into subcnt()? I think it subtracts its argument from the counter and returns the result. I've never used it though so I may be wrong.
  • RaymanRayman Posts: 14,640
    edited 2013-03-18 08:47
    I was going off of the "PreliminaryFeatureList-v2.0" pdf:




    Subtracts the system count value when the GETCNT instruction was last executed from the current system count value. Results are stored in the register referenced by "D (0-511)".






    Seems like it should automatically give the difference between current CNT and CNT from last time you used Getcnt...
  • David BetzDavid Betz Posts: 14,516
    edited 2013-03-18 08:51
    Rayman wrote: »
    I was going off of the "PreliminaryFeatureList-v2.0" pdf:




    Subtracts the system count value when the GETCNT instruction was last executed from the current system count value. Results are stored in the register referenced by "D (0-511)".






    Seems like it should automatically give the difference between current CNT and CNT from last time you used Getcnt...

    Okay, I haven't used it so I may be mistaken. Here is what the current instruction set document says:
    Get CNTL minus D into D. If another SUBCNT is executed in the next clock cycle
    by the same task, it gets CNTH minus D minus carry from previous SUBCNT into D.
    In either case, the logical not of the MSB of the D result (not the carry) goes
    into C, indicating by C=1 if CNTL (or CNT) has exceeded the original D value(s).
  • RaymanRayman Posts: 14,640
    edited 2013-03-18 08:57
    Okay, then looks like I'm looking at old documentation... Can you point me to the "current instruction set document"?

    BTW: I did just get the toggle.side example working on my DE0 and verified 1 Hz coming out of P0.
    Just changed CNT to getcnt() and OUTA to PINA
  • David BetzDavid Betz Posts: 14,516
    edited 2013-03-18 08:59
    Rayman wrote: »
    Okay, then looks like I'm looking at old documentation... Can you point me to the "current instruction set document"?

    BTW: I did just get the toggle.side example working on my DE0 and verified 1 Hz coming out of P0.
    Just changed CNT to getcnt() and OUTA to PINA
    Try looking at the most recent message in this thread:

    http://forums.parallax.com/showthread.php/144432-The-unofficial-P2-documentation-project/page14
  • RaymanRayman Posts: 14,640
    edited 2013-03-18 10:16
    Thanks. New question... Any chance pong can work?

    More generally, can we get video going with one cog like is done in the pong.side example?
  • David BetzDavid Betz Posts: 14,516
    edited 2013-03-18 10:20
    David Betz wrote: »
    I just realized that even this thread is probably not really current. I know Chip posted some additional documentation recently including the 3D texture features. I'm not sure where that document is. Maybe someone else will post a link to that doc.
  • David BetzDavid Betz Posts: 14,516
    edited 2013-03-18 10:21
    Rayman wrote: »
    Thanks. New question... Any chance pong can work?

    More generally, can we get video going with one cog like is done in the pong.side example?
    I suspect Eric's one COG Pong could be made to work although he would be the best one to answer that.
  • RaymanRayman Posts: 14,640
    edited 2013-03-18 10:54
    Related question/issue: Just tried "hello.side" with CNT replaced by getcnt() again. Works in LMM and CMM modes. But, in cog mode, it gives a slew of errors...
    Any idea why that is? Should it work?
  • David BetzDavid Betz Posts: 14,516
    edited 2013-03-18 10:56
    Rayman wrote: »
    Related question/issue: Just tried "hello.side" with CNT replaced by getcnt() again. Works in LMM and CMM modes. But, in cog mode, it gives a slew of errors...
    Any idea why that is? Should it work?
    I'm not sure what the code for the hello.side demo looks like but I imagine it must use printf which is unlikely to work in COG mode due to the limited size of COG memory. Sorry I can't be more help. I never use SimpleIDE. I'm a command line guy and besides I'm attached to BBEdit on the Mac for doing my source code editing.
  • RaymanRayman Posts: 14,640
    edited 2013-03-18 11:04
    I don't think this is a SimpleIDE issue, but it probably is related to using printf... Here is the code:
    /*
     * This is a non-traditional hello demo for Propeller-GCC.
     * The demo repeats printing every 100ms with the iteration.
     * It uses waitcnt instead of sleep so it will fit in a COG.
     */
    #include <stdio.h>
    #include <propeller.h>
    int main(void)
    {
        int n = 1;
        while(1) {
            waitcnt(CLKFREQ/10+getcnt());
            printf("Hello World %d\n", n);
            n++;
        }
        return 0;
    }
    

    It talks about using waitcnt instead of sleep so it will fit in a cog... It does work with P1 in cog mode...
  • David BetzDavid Betz Posts: 14,516
    edited 2013-03-18 11:08
    Rayman wrote: »
    I don't think this is a SimpleIDE issue, but it probably is related to using printf... Here is the code:
    /*
     * This is a non-traditional hello demo for Propeller-GCC.
     * The demo repeats printing every 100ms with the iteration.
     * It uses waitcnt instead of sleep so it will fit in a COG.
     */
    #include <stdio.h>
    #include <propeller.h>
    int main(void)
    {
        int n = 1;
        while(1) {
            waitcnt(CLKFREQ/10+getcnt());
            printf("Hello World %d\n", n);
            n++;
        }
        return 0;
    }
    

    It talks about using waitcnt instead of sleep so it will fit in a cog... It does work with P1 in cog mode...
    What kind of errors do you get?

    Edit: By the way, I didn't mean to imply that it was a SimpleIDE problem. It's just that I think SimpleIDE has its own set of demos and I'm not familiar with them.
  • jazzedjazzed Posts: 11,803
    edited 2013-03-18 11:12
    Rayman wrote: »
    ....
    It talks about using waitcnt instead of sleep so it will fit in a cog... It does work with P1 in cog mode...

    I'm sure David will provide an example where it works without SimpleIDE.
  • RaymanRayman Posts: 14,640
    edited 2013-03-18 11:16
    Here are the first few lines of errors... Maybe there is no "Simple printf" for P2 version?

    Project Directory: E:/Parallax/Propeller/GCC/hello/
    Ignoring "Simple printf" flag in COG mode program.
    propeller-elf-gcc.exe -o a.out -O0 -mcog -I . -fno-exceptions -mp2 Hello_P2.c
    c:/propgcc/bin/../lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/lib/crt0_cog2.o: In function `r0':
    (.text+0x0): relocation truncated to fit: R_PROPELLER_DST against symbol `sp' defined in .text section in c:/propgcc/bin/../lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/lib/crt0_cog2.o
    c:/propgcc/bin/../lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/lib/crt0_cog2.o: In function `r1':
    (.text+0x4): relocation truncated to fit: R_PROPELLER_DST against symbol `r0' defined in .text section in c:/propgcc/bin/../lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/lib/crt0_cog2.o
    c:/propgcc/bin/../lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/lib/crt0_cog2.o: In function `r1':
    (.text+0x4): relocation truncated to fit: R_PROPELLER_SRC against symbol `sp' defined in .text section in c:/propgcc/bin/../lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/lib/crt0_cog2.o
    c:/propgcc/bin/../lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/lib/crt0_cog2.o: In function `r2':
  • David BetzDavid Betz Posts: 14,516
    edited 2013-03-18 11:24
    Rayman wrote: »
    Here are the first few lines of errors... Maybe there is no "Simple printf" for P2 version?

    Project Directory: E:/Parallax/Propeller/GCC/hello/
    Ignoring "Simple printf" flag in COG mode program.
    propeller-elf-gcc.exe -o a.out -O0 -mcog -I . -fno-exceptions -mp2 Hello_P2.c
    c:/propgcc/bin/../lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/lib/crt0_cog2.o: In function `r0':
    (.text+0x0): relocation truncated to fit: R_PROPELLER_DST against symbol `sp' defined in .text section in c:/propgcc/bin/../lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/lib/crt0_cog2.o
    c:/propgcc/bin/../lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/lib/crt0_cog2.o: In function `r1':
    (.text+0x4): relocation truncated to fit: R_PROPELLER_DST against symbol `r0' defined in .text section in c:/propgcc/bin/../lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/lib/crt0_cog2.o
    c:/propgcc/bin/../lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/lib/crt0_cog2.o: In function `r1':
    (.text+0x4): relocation truncated to fit: R_PROPELLER_SRC against symbol `sp' defined in .text section in c:/propgcc/bin/../lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/lib/crt0_cog2.o
    c:/propgcc/bin/../lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/lib/crt0_cog2.o: In function `r2':
    Might be something like that. I just tried this with the current top of tree propgcc code and get the same errors. I don't think it's a simple_printf problem because that is entirely written in C and should compile fine for the P2.
  • RaymanRayman Posts: 14,640
    edited 2013-03-18 11:43
    Does this count as a bug? (Ken might be looking...)
  • David BetzDavid Betz Posts: 14,516
    edited 2013-03-18 12:10
    Rayman wrote: »
    Does this count as a bug? (Ken might be looking...)
    Yes, I'm sure it does! Thanks for reporting it. :-)
  • ersmithersmith Posts: 6,052
    edited 2013-03-18 14:52
    Rayman wrote: »
    Thanks. New question... Any chance pong can work?

    More generally, can we get video going with one cog like is done in the pong.side example?

    pong would need changes to the video initialization (some of the registers have changed between P1 and P2) and possibly to the video display code. I suspect it's not a big deal to make the changes, but haven't looked. In general a one cog video example can certainly be done on P2 (in fact on the final chip it will be much easier than on P1!).

    Eric
  • ersmithersmith Posts: 6,052
    edited 2013-03-18 15:01
    David Betz wrote: »
    Might be something like that. I just tried this with the current top of tree propgcc code and get the same errors. I don't think it's a simple_printf problem because that is entirely written in C and should compile fine for the P2.

    -mcog and -mp2 aren't compatible yet. We only have one linker script for -mp2, and that's for LMM mode, which is why the linker was upset about the relocations. I think we can re-use the P1 linker script for P2; I'll look into it.

    Eric
  • jazzedjazzed Posts: 11,803
    edited 2013-03-18 15:14
    If I recall correctly the original intent of this thread was to ensure P1 code is not broken.

    Ken did mention P2, but that is still a work in progress.

    Early testing is fine within bounds, but we don't seem to know what *should* work yet.

    Since David is in charge of the P2 effort, I'll stay out of the way on p2test.

    I don't want a branch or merge on the default tree until after the upcoming release though.
  • David BetzDavid Betz Posts: 14,516
    edited 2013-03-18 15:22
    jazzed wrote: »
    If I recall correctly the original intent of this thread was to ensure P1 code is not broken.

    Ken did mention P2, but that is still a work in progress.

    Early testing is fine within bounds, but we don't seem to know what *should* work yet.

    Since David is in charge of the P2 effort, I'll stay out of the way on p2test.

    I don't want a branch or merge on the default tree until after the upcoming release though.
    Yes, the main goal was to verify that we hadn't broken anything for P1 so that we could justify merging the p2test branch back into the default branch but we certainly want bug reports for P2 as well. As you say, there are likely to be many but they all need to be fixed.
  • RaymanRayman Posts: 14,640
    edited 2013-03-18 15:24
    I think I tested cmm mode and it seemed to work. Was that a fluke or should both cmm and lmm be working at this point?
  • David BetzDavid Betz Posts: 14,516
    edited 2013-03-18 15:24
    ersmith wrote: »
    -mcog and -mp2 aren't compatible yet. We only have one linker script for -mp2, and that's for LMM mode, which is why the linker was upset about the relocations. I think we can re-use the P1 linker script for P2; I'll look into it.

    Eric
    That's odd. I could have sworn that I ran COG mode programs before. In fact, the multi-cog demo uses -mcog and it runs on the DE2-115 board although it also uses -r so I guess it doesn't try to link in any runtime code.
  • Ken GraceyKen Gracey Posts: 7,392
    edited 2013-03-18 19:05
    David Betz wrote: »
    Yes, I'm sure it does! Thanks for reporting it. :-)

    Yes, we'll be applying a fairly wide interpretation of what constitutes a bug. Nice job, Rayman!
  • RaymanRayman Posts: 14,640
    edited 2013-03-19 06:55
    Just noticed that the "Hello" demo I started with here isn't in the new propgcc demo folder... I think jazzed wrote it, but I don't know where I downloaded it from...
    Maybe demos used to be a seperate download from propgcc? Anyway, seems to me that if you're going to include some demos in propgcc that a hello world one should be in there...
  • ersmithersmith Posts: 6,052
    edited 2013-03-19 07:05
    Rayman wrote: »
    I think I tested cmm mode and it seemed to work. Was that a fluke or should both cmm and lmm be working at this point?

    Yes, you're right, CMM works on P2 as well. The same linker script is used for LMM and CMM (they both reside in hub memory). But COG and XMM don't quite work yet. I think getting COG to work should be very easy. XMM will be a bit more effort, but I think David is looking into this.

    Eric
  • David BetzDavid Betz Posts: 14,516
    edited 2013-03-19 07:11
    ersmith wrote: »
    Yes, you're right, CMM works on P2 as well. The same linker script is used for LMM and CMM (they both reside in hub memory). But COG and XMM don't quite work yet. I think getting COG to work should be very easy. XMM will be a bit more effort, but I think David is looking into this.

    Eric
    I think -mcog works for generating code to be loaded into another COG. I use it in my multi-cog demo. What doesn't work is using -mcog to generate a standalone program. As Eric says, that requires a different linker script. I can look at that later if Eric hasn't already fixed it by then. He's pretty fast! :-)
Sign In or Register to comment.