help with cogc/SimpleIDE ?
Mark Mara
Posts: 64
When I reference _CLKFREQ in a cogc routine I get the following error message using SimpleIDE to compile the code:
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.
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.
Comments
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.
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.
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.
Use this instead: "i = *(int*) 0;"
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