Int declaration location difference makes .text/hub overflow. Why?
pmrobert
Posts: 674
I have two ints, x1 & y1 that, if globally declared, give the following error message when compiled. If I declare them in their own local cog function everything is fine.
Here's a partial but specific section of the compiler output:
Batch file that compiles and loads:
Compiler output:
Thanks to all in advance..... -Mike
Here's a partial but specific section of the compiler output:
c:/program files (x86)/simpleide/propeller-gcc/bin/../lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/bin/ld.exe: lmm/PGCCEFI.elf section `.text' will not fit in region `hub' c:/program files (x86)/simpleide/propeller-gcc/bin/../lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/bin/ld.exe: region `hub' overflowed by 15024 bytesHere's the code that causes the overflow message - x1 & y1 are declared on lines 27 & 28. If I comment them out of the main section and declare them on lines 83 & 84, in the cog they're actually active in, all is good. I would like to know what I'm doing wrong - similar use of global vars for debug/dev purposes in other GCC platforms hasn't been a problem. I'm surely hope it's just some rule that I've tripped over. I use ints hirpm and hiload (declared in lines 35,36, modified in lines 100 & 112 in the cog code and displayed in main code in 71 & 72) in a very similar manner and they work without issue. I did try declaring x1 & y1 volatile and unsigned - no change. If I declare them global, the .text section of the program grows by ~15K no matter what. I included the full compiler output as I'm using EditPlus, not SimpleIDE. The batch file I'm running is included in another code section below.
#include "simpletools.h" // Include simpletools library //#include "fdserial.h" // Include Full Duplex Serial library #define reboot() __builtin_propeller_clkset(0x80) // For LMM cog 160 bytes declared as int // Add enough for stack & calcs unsigned int stack[(160 + (50 * 4)) / 4]; // Initialize the arrays //int verpm[] = {500,1000,1500,2000,2500,3000,3500,4000,4500,5000,5500,6000,6500,7000,7500,8000,8500,9000,9500,10000}; volatile unsigned int verpm[20]; //int veload[] = {20,25,30,35,40,45,50,55,60,75,80,85,90,95,100,110,115,120,125,130}; unsigned int veload[20]; unsigned int vetable[20][20]; volatile unsigned int rpm,load; unsigned int baseaddr = 40000; //EEPROM Adress unsigned int veresult; volatile unsigned int verpmsize = (sizeof(verpm)/4); unsigned int veloadsize = (sizeof(veload)/4); unsigned int cog2; //Candidates for moving declarations to interp cog - here now for debug purposes. //signed int x1; //signed int y1; int x1; // Here there be dragons int y1; // More dragons here..... //volatile int x1; //volatile int y1; //Debug vars volatile int hirpm; volatile int hiload; // Function prototype void interp(void *par); // Cog 0 starts here int main() { for ( int i = 0; i < 20; i++ ) { verpm[i]=ee_getInt(baseaddr+2000+(i*4)); veload[i]=ee_getInt(baseaddr+2080+(i*4)); print("Loaded verpm[%2d] : %5d from EEPROM Address %x ",i,verpm[i],baseaddr+2000+(i*4)); print("Loaded veload[%2d]: %5d from EEPROM Address %x\n",i,veload[i],baseaddr+2080+(i*4)); for (int i2 = 0; i2 < 20; i2++) { vetable[i][i2]=ee_getInt(baseaddr+(i*80)+(i2*4)); } } //serial *SPORT = fdserial_open(31, 30, 0, 115200); print("\n\n =->FIN<-=\n"); cog2 = cogstart(&interp, NULL, stack, sizeof(stack)); // Start interp cog while(1) { for ( rpm = 0, load = 0; rpm < 12000; rpm=rpm+500,load=load+10 ) { pause(500); print("**************\n"); print("RPM - %d\n",rpm); print("LOAD - %d\n",load); //print("SizeofRpm - %d\n",verpmsize-1); print("hirpm: %d\n",hirpm); print("hiload: %d\n",hiload); print("**************\n"); } } } void interp(void *par) { //int x1; // These work fine when declared here //int y1; // and here..... while(1) { // Sanity check of rpm & load, make sure in bounds of table edges if (rpm > verpm[verpmsize-1]) rpm = verpm[verpmsize-1]; else if(rpm < verpm[0]) rpm = verpm[0]; if (load > veload[veloadsize-1]) load = veload[veloadsize-1]; else if(load < veload[0]) load = veload[0]; // Done with Sanity check of rpm & load, make sure in bounds of table edges // Get highest index into rpmtable for(x1 = 19; x1+1 > 0; x1--) { if(rpm > verpm[x1]) { hirpm = verpm[x1]; break; } } // Done with Get highest index into rpmtable // Get highest index into loadtable for(y1 = 19; y1+1>0; y1--) { if(load > veload[y1]) { hiload = veload[y1]; break; } } pause(300); // Done with Get highest index into loadtable } }
Batch file that compiles and loads:
propeller-elf-gcc -v -I . -L . -I %1/SimpleLibraries/Utility/libsimpletools -L %1/SimpleLibraries/Utility/libsimpletools/lmm/ -I %1/SimpleLibraries/TextDevices/libsimpletext -L %1/SimpleLibraries/TextDevices/libsimpletext/lmm/ -I %1/SimpleLibraries/Protocol/libsimplei2c -L %1/SimpleLibraries/Protocol/libsimplei2c/lmm/ -I %1/SimpleLibraries/TextDevices/libfdserial -L %1/SimpleLibraries/TextDevices/libfdserial/lmm/ -o lmm/%2.elf -Os -mlmm -Wall -m32bit-doubles -fno-exceptions -std=c99 -save-temps %2.c -lm -lsimpletools -lsimpletext -lsimplei2c -lfdserial -lm -lsimpletools -lsimpletext -lsimplei2c -lm -lsimpletools -lsimpletext -lm -lsimpletools -lm rem propeller-load -v -s %1\lmm\%2.elf propeller-load -v -e -r %1\lmm\%2.elf
Compiler output:
---------- Compile C Source ---------- Using built-in specs. COLLECT_GCC=propeller-elf-gcc COLLECT_LTO_WRAPPER=c:/program files (x86)/simpleide/propeller-gcc/bin/../libexec/gcc/propeller-elf/4.6.1/lto-wrapper.exe Target: propeller-elf Configured with: ../../propgcc/gcc/configure --target=propeller-elf --prefix=/opt/parallax --disable-nls --disable-libssp --disable-lto --disable-shared --with-pkgversion=propellergcc_v1_0_0_2162 --with-bugurl=http://code.google.com/p/propgcc/issues : (reconfigured) ../../propgcc/gcc/configure --target=propeller-elf --prefix=/opt/parallax --disable-nls --disable-libssp --disable-lto --disable-shared --with-pkgversion=propellergcc_v1_0_0_2162 --with-bugurl=http://code.google.com/p/propgcc/issues Thread model: single gcc version 4.6.1 (propellergcc_v1_0_0_2162) COLLECT_GCC_OPTIONS='-v' '-I' '.' '-L.' '-I' 'C:\PropGCC_EFI/SimpleLibraries/Utility/libsimpletools' '-LC:\PropGCC_EFI/SimpleLibraries/Utility/libsimpletools/lmm/' '-I' 'C:\PropGCC_EFI/SimpleLibraries/TextDevices/libsimpletext' '-LC:\PropGCC_EFI/SimpleLibraries/TextDevices/libsimpletext/lmm/' '-I' 'C:\PropGCC_EFI/SimpleLibraries/Protocol/libsimplei2c' '-LC:\PropGCC_EFI/SimpleLibraries/Protocol/libsimplei2c/lmm/' '-I' 'C:\PropGCC_EFI/SimpleLibraries/TextDevices/libfdserial' '-LC:\PropGCC_EFI/SimpleLibraries/TextDevices/libfdserial/lmm/' '-o' 'lmm/PGCCEFI.elf' '-Os' '-mlmm' '-Wall' '-m32bit-doubles' '-fno-exceptions' '-std=c99' '-save-temps' c:/program files (x86)/simpleide/propeller-gcc/bin/../libexec/gcc/propeller-elf/4.6.1/cc1.exe -E -quiet -v -I . -I C:\PropGCC_EFI/SimpleLibraries/Utility/libsimpletools -I C:\PropGCC_EFI/SimpleLibraries/TextDevices/libsimpletext -I C:\PropGCC_EFI/SimpleLibraries/Protocol/libsimplei2c -I C:\PropGCC_EFI/SimpleLibraries/TextDevices/libfdserial -imultilib short-doubles -iprefix c:\program files (x86)\simpleide\propeller-gcc\bin\../lib/gcc/propeller-elf/4.6.1/ PGCCEFI.c -mlmm -m32bit-doubles -std=c99 -Wall -fno-exceptions -Os -fpch-preprocess -o PGCCEFI.i ignoring nonexistent directory "c:\program files (x86)\simpleide\propeller-gcc\bin\../lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/sys-include" ignoring duplicate directory "c:/program files (x86)/simpleide/propeller-gcc/lib/gcc/../../lib/gcc/propeller-elf/4.6.1/include" ignoring duplicate directory "c:/program files (x86)/simpleide/propeller-gcc/lib/gcc/../../lib/gcc/propeller-elf/4.6.1/include-fixed" ignoring nonexistent directory "c:/program files (x86)/simpleide/propeller-gcc/lib/gcc/../../lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/sys-include" ignoring duplicate directory "c:/program files (x86)/simpleide/propeller-gcc/lib/gcc/../../lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/include" #include "..." search starts here: #include <...> search starts here: . C:\PropGCC_EFI/SimpleLibraries/Utility/libsimpletools C:\PropGCC_EFI/SimpleLibraries/TextDevices/libsimpletext C:\PropGCC_EFI/SimpleLibraries/Protocol/libsimplei2c C:\PropGCC_EFI/SimpleLibraries/TextDevices/libfdserial c:\program files (x86)\simpleide\propeller-gcc\bin\../lib/gcc/propeller-elf/4.6.1/include c:\program files (x86)\simpleide\propeller-gcc\bin\../lib/gcc/propeller-elf/4.6.1/include-fixed c:\program files (x86)\simpleide\propeller-gcc\bin\../lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/include End of search list. COLLECT_GCC_OPTIONS='-v' '-I' '.' '-L.' '-I' 'C:\PropGCC_EFI/SimpleLibraries/Utility/libsimpletools' '-LC:\PropGCC_EFI/SimpleLibraries/Utility/libsimpletools/lmm/' '-I' 'C:\PropGCC_EFI/SimpleLibraries/TextDevices/libsimpletext' '-LC:\PropGCC_EFI/SimpleLibraries/TextDevices/libsimpletext/lmm/' '-I' 'C:\PropGCC_EFI/SimpleLibraries/Protocol/libsimplei2c' '-LC:\PropGCC_EFI/SimpleLibraries/Protocol/libsimplei2c/lmm/' '-I' 'C:\PropGCC_EFI/SimpleLibraries/TextDevices/libfdserial' '-LC:\PropGCC_EFI/SimpleLibraries/TextDevices/libfdserial/lmm/' '-o' 'lmm/PGCCEFI.elf' '-Os' '-mlmm' '-Wall' '-m32bit-doubles' '-fno-exceptions' '-std=c99' '-save-temps' c:/program files (x86)/simpleide/propeller-gcc/bin/../libexec/gcc/propeller-elf/4.6.1/cc1.exe -fpreprocessed PGCCEFI.i -quiet -dumpbase PGCCEFI.c -mlmm -m32bit-doubles -auxbase PGCCEFI -Os -Wall -std=c99 -version -fno-exceptions -o PGCCEFI.s GNU C (propellergcc_v1_0_0_2162) version 4.6.1 (propeller-elf) compiled by GNU C version 4.6.2, GMP version 5.0.2, MPFR version 3.0.1, MPC version 0.9 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 GNU C (propellergcc_v1_0_0_2162) version 4.6.1 (propeller-elf) compiled by GNU C version 4.6.2, GMP version 5.0.2, MPFR version 3.0.1, MPC version 0.9 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: b164ade464d31b01e5f340d6fe7b3f00 COLLECT_GCC_OPTIONS='-v' '-I' '.' '-L.' '-I' 'C:\PropGCC_EFI/SimpleLibraries/Utility/libsimpletools' '-LC:\PropGCC_EFI/SimpleLibraries/Utility/libsimpletools/lmm/' '-I' 'C:\PropGCC_EFI/SimpleLibraries/TextDevices/libsimpletext' '-LC:\PropGCC_EFI/SimpleLibraries/TextDevices/libsimpletext/lmm/' '-I' 'C:\PropGCC_EFI/SimpleLibraries/Protocol/libsimplei2c' '-LC:\PropGCC_EFI/SimpleLibraries/Protocol/libsimplei2c/lmm/' '-I' 'C:\PropGCC_EFI/SimpleLibraries/TextDevices/libfdserial' '-LC:\PropGCC_EFI/SimpleLibraries/TextDevices/libfdserial/lmm/' '-o' 'lmm/PGCCEFI.elf' '-Os' '-mlmm' '-Wall' '-m32bit-doubles' '-fno-exceptions' '-std=c99' '-save-temps' c:/program files (x86)/simpleide/propeller-gcc/bin/../lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/bin/as.exe -lmm -o PGCCEFI.o PGCCEFI.s COMPILER_PATH=c:/program files (x86)/simpleide/propeller-gcc/bin/../libexec/gcc/propeller-elf/4.6.1/;c:/program files (x86)/simpleide/propeller-gcc/bin/../libexec/gcc/;c:/program files (x86)/simpleide/propeller-gcc/bin/../lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/bin/ LIBRARY_PATH=c:/program files (x86)/simpleide/propeller-gcc/bin/../lib/gcc/propeller-elf/4.6.1/short-doubles/;c:/program files (x86)/simpleide/propeller-gcc/bin/../lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/lib/short-doubles/;c:/program files (x86)/simpleide/propeller-gcc/bin/../lib/gcc/propeller-elf/4.6.1/;c:/program files (x86)/simpleide/propeller-gcc/bin/../lib/gcc/;c:/program files (x86)/simpleide/propeller-gcc/bin/../lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/lib/ COLLECT_GCC_OPTIONS='-v' '-I' '.' '-L.' '-I' 'C:\PropGCC_EFI/SimpleLibraries/Utility/libsimpletools' '-LC:\PropGCC_EFI/SimpleLibraries/Utility/libsimpletools/lmm/' '-I' 'C:\PropGCC_EFI/SimpleLibraries/TextDevices/libsimpletext' '-LC:\PropGCC_EFI/SimpleLibraries/TextDevices/libsimpletext/lmm/' '-I' 'C:\PropGCC_EFI/SimpleLibraries/Protocol/libsimplei2c' '-LC:\PropGCC_EFI/SimpleLibraries/Protocol/libsimplei2c/lmm/' '-I' 'C:\PropGCC_EFI/SimpleLibraries/TextDevices/libfdserial' '-LC:\PropGCC_EFI/SimpleLibraries/TextDevices/libfdserial/lmm/' '-o' 'lmm/PGCCEFI.elf' '-Os' '-mlmm' '-Wall' '-m32bit-doubles' '-fno-exceptions' '-std=c99' '-save-temps' c:/program files (x86)/simpleide/propeller-gcc/bin/../libexec/gcc/propeller-elf/4.6.1/collect2.exe -mpropeller -o lmm/PGCCEFI.elf c:/program files (x86)/simpleide/propeller-gcc/bin/../lib/gcc/propeller-elf/4.6.1/short-doubles/spinboot.o c:/program files (x86)/simpleide/propeller-gcc/bin/../lib/gcc/propeller-elf/4.6.1/short-doubles/_crt0.o c:/program files (x86)/simpleide/propeller-gcc/bin/../lib/gcc/propeller-elf/4.6.1/short-doubles/_crtbegin.o -L. -LC:\PropGCC_EFI/SimpleLibraries/Utility/libsimpletools/lmm/ -LC:\PropGCC_EFI/SimpleLibraries/TextDevices/libsimpletext/lmm/ -LC:\PropGCC_EFI/SimpleLibraries/Protocol/libsimplei2c/lmm/ -LC:\PropGCC_EFI/SimpleLibraries/TextDevices/libfdserial/lmm/ -Lc:/program files (x86)/simpleide/propeller-gcc/bin/../lib/gcc/propeller-elf/4.6.1/short-doubles -Lc:/program files (x86)/simpleide/propeller-gcc/bin/../lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/lib/short-doubles -Lc:/program files (x86)/simpleide/propeller-gcc/bin/../lib/gcc/propeller-elf/4.6.1 -Lc:/program files (x86)/simpleide/propeller-gcc/bin/../lib/gcc -Lc:/program files (x86)/simpleide/propeller-gcc/bin/../lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/lib PGCCEFI.o -lm -lsimpletools -lsimpletext -lsimplei2c -lfdserial -lm -lsimpletools -lsimpletext -lsimplei2c -lm -lsimpletools -lsimpletext -lm -lsimpletools -lm -lgcc --start-group -lc -lgcc --end-group -lgcc c:/program files (x86)/simpleide/propeller-gcc/bin/../lib/gcc/propeller-elf/4.6.1/short-doubles/_crtend.o c:/program files (x86)/simpleide/propeller-gcc/bin/../lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/bin/ld.exe: lmm/PGCCEFI.elf section `.text' will not fit in region `hub' c:/program files (x86)/simpleide/propeller-gcc/bin/../lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/bin/ld.exe: region `hub' overflowed by 15024 bytes collect2: ld returned 1 exit status Output completed (0 sec consumed) - Normal Termination
Thanks to all in advance..... -Mike
Comments
In SimpleIDE, right click on a file in the project manager and select Show Map File.
Or use this on the command line:
propeller-elf-gcc -Xlinker -Map=somefile.map somefile.c
And here's the compilation:
With this version it works. I'm not sure what to conclude from this. Just another data point I guess.
Edit: I've added the map file, just in case.
-Mike
-Mike
-Mike
You can use iprint() now to save around 2KB instead of the floating point enabled print() function.
The format specifier documentation is in the code now, but hasn't made it to the html doc set yet. A new release is planned soon.
Function printf (and friends) is for programming environments where we don't have to live in a straight-jacket.
Floating point is still there. We just encountered a small issue with using fpu_cog.c (in the release branch), and had to remove it for now. If you like, you can manually add fpu_cog.c into your project and get the benefits of it.