cJSON, Makefile or RAM Issues?
Posted: Tue Apr 25, 2017 5:29 am
Hey there,
So I'm trying to implement JSON into my esp8266 code by using cJSON.h and cJSON.c and have encountered some issues. At first I got a few errors saying that there was undefined references to the functions used in cJSON even though I had the cJSON.h and -.c files in the correct locations. cJSON.h was also included in my code. This error seems to occur every time I try to compile multiple .c files and because of this I figured that the issue must lie within the makefile and so I modified the makefile to include the cJSON files.
This is the modified makefile:
After modifying the makefile I got a different set of errors starting with "....'.text' will not fit in 'iram1_0_seg ". At this point I'm not sure if my makefile was incorrectly modified or the ram is actually completely filled.
These are the errors received after modifying the makefile:
Can anyone enlighten on what i might be doing wrong and how i can fix it?
So I'm trying to implement JSON into my esp8266 code by using cJSON.h and cJSON.c and have encountered some issues. At first I got a few errors saying that there was undefined references to the functions used in cJSON even though I had the cJSON.h and -.c files in the correct locations. cJSON.h was also included in my code. This error seems to occur every time I try to compile multiple .c files and because of this I figured that the issue must lie within the makefile and so I modified the makefile to include the cJSON files.
This is the modified makefile:
Code: Select all
CC = xtensa-lx106-elf-gcc
CFLAGS = -I. -mlongcalls $(addprefix -I ,$(INCLUDE1)) $(addprefix -I ,$(INCLUDE2)) $(addprefix -I ,$(INCLUDE3)) $(addprefix -I ,$(INCLUDE4))
LDLIBS = -nostdlib -Wl,--start-group -lmain -lnet80211 -lwpa -llwip -lpp -lphy -lc -Wl,--end-group -lgcc -ljson
LDFLAGS = -Teagle.app.v6.ld
INCLUDE1 := include
INCLUDE2 := driver_lib/driver
INCLUDE3 := include/json
INCLUDE4 := driver_lib/include/driver
vpath %.h $(INCLUDES)
vpath %.c $(INCLUDE2)
vpath %.h $(INCLUDE3)
vpath %.h $(INCLUDE4)
pushButton-0x00000.bin: pushButton
esptool.py elf2image $^
pushButton: pushButton.o cJSON.o
pushButton.o: pushButton.c
cJSON.o: cJSON.c
flash: pushButton-0x00000.bin
esptool.py write_flash 0 pushButton-0x00000.bin 0x10000 pushButton-0x10000.bin
clean:
rm -f pushButton pushButton.o pushButton-0x00000.bin pushButton-0x10000.bin
After modifying the makefile I got a different set of errors starting with "....'.text' will not fit in 'iram1_0_seg ". At this point I'm not sure if my makefile was incorrectly modified or the ram is actually completely filled.
These are the errors received after modifying the makefile:
Code: Select all
xtensa-lx106-elf-gcc -Teagle.app.v6.ld pushButton.o cJSON.o -nostdlib -Wl,--start-group -lmain -lnet80211 -lwpa -llwip -lpp -lphy -lc -Wl,--end-group -lgcc -ljson -o pushButton
/opt/Espressif/esp-open-sdk/xtensa-lx106-elf/lib/gcc/xtensa-lx106-elf/4.8.5/../../../../xtensa-lx106-elf/bin/ld: pushButton section `.text' will not fit in region `iram1_0_seg'
/opt/Espressif/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 13368 bytes
cJSON.o:(.literal+0xc): undefined reference to `malloc'
cJSON.o:(.literal+0x14): undefined reference to `free'
cJSON.o:(.literal+0x38): undefined reference to `pow'
cJSON.o:(.literal+0x7c): undefined reference to `floor'
cJSON.o: In function `parse_number':
cJSON.c:(.text+0x46e): undefined reference to `pow'
cJSON.o: In function `print_number':
cJSON.c:(.text+0x71e): undefined reference to `floor'
cJSON.o:(.data+0x0): undefined reference to `malloc'
cJSON.o:(.data+0x4): undefined reference to `free'
/opt/Espressif/esp-open-sdk/xtensa-lx106-elf/lib/gcc/xtensa-lx106-elf/4.8.5/../../../../xtensa-lx106-elf/lib/libc.a(lib_a-svfprintf.o):(.literal+0x10): undefined reference to `_malloc_r'
/opt/Espressif/esp-open-sdk/xtensa-lx106-elf/lib/gcc/xtensa-lx106-elf/4.8.5/../../../../xtensa-lx106-elf/lib/libc.a(lib_a-svfprintf.o): In function `_svfprintf_r':
/opt/Espressif/esp-open-sdk/crosstool-NG/.build/src/newlib-2.0.0/newlib/libc/stdio/vfprintf.c:733: undefined reference to `_malloc_r'
/opt/Espressif/esp-open-sdk/xtensa-lx106-elf/lib/gcc/xtensa-lx106-elf/4.8.5/../../../../xtensa-lx106-elf/lib/libc.a(lib_a-svfiprintf.o):(.literal+0x0): undefined reference to `_realloc_r'
/opt/Espressif/esp-open-sdk/xtensa-lx106-elf/lib/gcc/xtensa-lx106-elf/4.8.5/../../../../xtensa-lx106-elf/lib/libc.a(lib_a-svfiprintf.o):(.literal+0x4): undefined reference to `_free_r'
/opt/Espressif/esp-open-sdk/xtensa-lx106-elf/lib/gcc/xtensa-lx106-elf/4.8.5/../../../../xtensa-lx106-elf/lib/libc.a(lib_a-svfiprintf.o): In function `__ssprint_r':
/opt/Espressif/esp-open-sdk/crosstool-NG/.build/src/newlib-2.0.0/newlib/libc/stdio/vfprintf.c:234: undefined reference to `_malloc_r'
/opt/Espressif/esp-open-sdk/crosstool-NG/.build/src/newlib-2.0.0/newlib/libc/stdio/vfprintf.c:245: undefined reference to `_realloc_r'
/opt/Espressif/esp-open-sdk/crosstool-NG/.build/src/newlib-2.0.0/newlib/libc/stdio/vfprintf.c:249: undefined reference to `_free_r'
/opt/Espressif/esp-open-sdk/xtensa-lx106-elf/lib/gcc/xtensa-lx106-elf/4.8.5/../../../../xtensa-lx106-elf/lib/libc.a(lib_a-svfiprintf.o): In function `_svfiprintf_r':
/opt/Espressif/esp-open-sdk/crosstool-NG/.build/src/newlib-2.0.0/newlib/libc/stdio/vfprintf.c:733: undefined reference to `_malloc_r'
collect2: error: ld returned 1 exit status
<builtin>: recipe for target 'pushButton' failed
make: *** [pushButton] Error 1
Can anyone enlighten on what i might be doing wrong and how i can fix it?