Shop OBEX P1 Docs P2 Docs Learn Events
help with cogc/SimpleIDE ? — Parallax Forums

help with cogc/SimpleIDE ?

Mark MaraMark Mara Posts: 64
edited 2013-11-06 17:15 in Learn with BlocklyProp
When I reference _CLKFREQ in a cogc routine I get the following error message using SimpleIDE to compile the code:

theEnd (1).jpg


However, the cogc code in the cog_c_toggle demo references _CLKFREQ and builds fine If I use the make file that comes with the demo. What do I need to change in SimpIDE so it can resolve _CLKFREQ?

Thanks for your help.
1024 x 107 - 38K

Comments

  • SRLMSRLM Posts: 5,045
    edited 2013-11-06 06:52
    Can you post the full program so that we can try it out?

    It looks like --gc-sections isn't working correctly in cogc mode. It's something that I haven't tested (I've only done CMM and LMM). There should be an option somewhere in SimpleIDE compile options to turn off --gc-sections as a short term solution.
  • jazzedjazzed Posts: 11,803
    edited 2013-11-06 09:44
    #include <propeller.h>

    SRLM the -gc-sections .boot problem will be fixed with propeller-gcc in the SimpleIDE 0-9-44+ package.
  • SRLMSRLM Posts: 5,045
    edited 2013-11-06 11:17
    jazzed wrote: »
    #include <propeller.h>

    SRLM the -gc-sections .boot problem will be fixed with propeller-gcc in the SimpleIDE 0-9-44+ package.

    Sounds good. I suppose you've tested -gc-sections in the other modes besides CMM and LMM? I don't know how to use anything else so I haven't tried it yet.

    You know what might be handy with SimpleIDE (or the PropGCC compiler?) is if it could detect these common errors (this and PhiPi's) and suggest fixes. Maybe a PropGCC Lint program would be the answer.
  • Mark MaraMark Mara Posts: 64
    edited 2013-11-06 13:13
    I think that the error is caused by something stupid that I am doing, a PropGCC Lint would be great. Rather than post the code that was giving me the problems I deleted everything I could and still have it compile, which is what I should have done in the first place. Now the reference does not create an error. I have posted the the code with the problem. If you comment out line 42 in cogA.cogc the error will go away. I will start adding stuff back until it breaks, but if someone had the time to take a look at my code I would really appreciate it.

    The code is a little cogc program that watches a byte of shared memory then updates the Parallax Digital IO board via the serial interface. The reference to _CLKFREQ (line 42 cogA.cogc) does nothing I just wanted to see if I could access it for a different project.


    test.zip 764.4K
  • jazzedjazzed Posts: 11,803
    edited 2013-11-06 13:36
    The issue is that CLKFREQ lives in HUB RAM and can't be "shared" between COGC and normal C code.

    Use this instead: "i = *(int*) 0;"
  • Mark MaraMark Mara Posts: 64
    edited 2013-11-06 13:45
    Thanks for the explanation. A little more please - Could you elaborate as to what " *(int*) 0;" does?
  • jazzedjazzed Posts: 11,803
    edited 2013-11-06 13:53
    Mark Mara wrote: »
    Thanks for the explanation. A little more please - Could you elaborate as to what " *(int*) 0;" does?
    HUB location 0 is where the clock frequency is kept. The *(int*) cast says take the value from the address, where (int*) specifies that the following item is the address. The * before (int*) says take the value.
  • ersmithersmith Posts: 6,032
    edited 2013-11-06 17:15
    jazzed wrote: »
    The issue is that CLKFREQ lives in HUB RAM and can't be "shared" between COGC and normal C code.

    Actually that's not quite accurate. Most variables can be shared between COGC and normal C code if they are in HUB memory (see for example the "togglecount" variable in the cog_c_toggle example). There is an argument that programs *shouldn't* share variables as a matter of style, but the linker normally allows it.

    The problem is that CLKFREQ is a special case, being declared in the .boot section rather than .data, and our linker scripts seem to have a bug with that. It's funny that nobody has noticed it before. Thanks for catching this, Mark!

    Steve's suggested workaround of using *(int *)0 is a good one, since CLKFREQ is defined to always be located at address 0 of the HUB memory (which is why it is in the special .boot section which is causing us problems).

    Eric
Sign In or Register to comment.