Shop OBEX P1 Docs P2 Docs Learn Events
Solved: O2 and O3 fail, but Os and O1 work (CMM) — Parallax Forums

Solved: O2 and O3 fail, but Os and O1 work (CMM)

SRLMSRLM Posts: 5,045
edited 2012-12-10 14:44 in Propeller 1
I tried the attached program, and it works fine in CMM and LMM with -Os. But, when I tried CMM with -O2 and -O3, it got hung up as indicated in the following terminal dump:
Waiting for key press to start tests
Mount tests first
First mount.
Succeeded; stopping cog.
Second mount.
Succeeded.
Reading block 0 (should be a boot block)
<HANG>

Any suggestions on what the problem is?

Also, any suggestions on how to find the source of this kind of problem myself in the future?

edit: top level file is "test.nl"

Comments

  • ersmithersmith Posts: 6,054
    edited 2012-12-10 05:00
    Hmmm, that's a strange bug. Most likely there's a problem with the output of spin2cpp -- as I think you've noticed, it doesn't label variables as "volatile", and this can cause issues when communicating with PASM programs in other COGs. I don't actually have any good ideas on how to make spin2cpp do this, and I"m open to suggestions.

    In general the main difference in CMM between -Os and -O2 is that -O2 enables the use of FCACHE, which speeds things up quite a bit. This can exacerbate race conditions (such as ones caused by missing volatile).

    Eric
  • Dave HeinDave Hein Posts: 6,347
    edited 2012-12-10 06:07
    The first 4 longs of "dat" in safe_spi.cpp are used to send commands to the SPI cog. After the C code sets the command it sits in a while loop waiting for the command long to be cleared. You probably need to make "dat" volatile.
  • SRLMSRLM Posts: 5,045
    edited 2012-12-10 14:44
    That was exactly it: as soon as I made the dat sections volatile, it worked at O2 and O3.

    Now, the volatile problem has bitten me twice. Hopefully, I'll remember next time.
Sign In or Register to comment.