Discuss here different C compiler set ups, and compiling executables for the ESP8266

User avatar
By smh
#49095 Hi thanks again for the response. I've got a few questions:
    - Slightly off topic, but how do you determine that the resulting code doesn't fit into iram?
    - Can you show me how you are including math.h in your code?
    - Which copy of math.h is being included, I assume it's in the open-sdk directories somewhere?
User avatar
By jcmvbkbc
#49104
smh wrote:Hi thanks again for the response. I've got a few questions:
- Slightly off topic, but how do you determine that the resulting code doesn't fit into iram?

I get this at the end of the build:
/home/jcmvbkbc/tmp/esp/esp-open-sdk/xtensa-lx106-elf/lib/gcc/xtensa-lx106-elf/4.8.5/../../../../xtensa-lx106-elf/bin/ld: blinky section `.text' will not fit in region `iram1_0_seg'
/home/jcmvbkbc/tmp/esp/esp-open-sdk/xtensa-lx106-elf/lib/gcc/xtensa-lx106-elf/4.8.5/../../../../xtensa-lx106-elf/bin/ld: region `iram1_0_seg' overflowed by 236 bytes
/home/jcmvbkbc/tmp/esp/esp-open-sdk/xtensa-lx106-elf/lib/gcc/xtensa-lx106-elf/4.8.5/../../../../xtensa-lx106-elf/bin/ld: link errors found, deleting executable `blinky'
smh wrote:- Can you show me how you are including math.h in your code?

Nothing fancy, just
Code: Select all#include <math.h>

smh wrote:- Which copy of math.h is being included, I assume it's in the open-sdk directories somewhere?

It's esp-open-sdk/xtensa-lx106-elf/xtensa-lx106-elf/include/math.h
But it doesn't matter which math.h is included, I could as well replace that include statement with function declaration as follows:
Code: Select allfloat sin(float);

and with the same result.
User avatar
By smh
#49106 Ok looks like I had a small ordering error in my Makefile. I'm getting the same result as you now.

If you don't mind some more questions..
    - Can you enlighten me on why the functions are causing the code to be too large?
    - Is there a sensible work around? #define lookup table?

Thanks for the help, much appreciated.
User avatar
By jcmvbkbc
#49107
smh wrote:Can you enlighten me on why the functions are causing the code to be too large?

It pulls a lot of support code, all with floating point math, and there's no FPU in this processor.

smh wrote:Is there a sensible work around? #define lookup table?

One possible way around, yes.
The other is moving math library to FLASH, which should be possible unless you call sin from the interrupt context. Look at the libcirom target in the open-esp-sdk Makefile, it makes a copy of the C library that goes into FLASH by default. You can do the same to produce libmirom, and when you link with that library instead of libm the image gets built successfully.