Cog memory model, printf of a static string versus a buffer.
Martin_H
Posts: 4,051
The program below compiles just fine in cog memory model, but if you uncomment the BREAK_IT the program gets all kinds of undefined symbols. However, to my eye printf of a static string or a char buffer should be the same. I don't get it.
/** * @file HelloWorld.c * This is the main HelloWorld program start point. */ #include <stdio.h> #include <propeller.h> // Uncomment this to break the cog memory model build. //#define BREAK_IT 1 /** * Cog memory model hellow world program */ int main(void) { int x; char buff[16]; while(true) { // copy hellow world to the buffer. strcpy(buff, "Hello World"); #ifndef BREAK_IT // print a static string printf("Hello World\n"); #else // print a buffer printf(buff); #endif } return 0; }
Comments
The only undefined symbol I see (when compiling either with or without BREAK_IT) is "true"; if I change while(true) to while(1) both versions seem to compile OK, although the static string one is smaller (as expected).
Eric
c:/users/a231861/propgcc/bin/../lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/bin/ld.exe: region `cog' overflowed by 22716 bytes
Note that if I switch from COG to LMM the error goes away. So I think this is an issue with cog memory model. I'm just surprised such a trivial change pulled in so much code.