i want to print the chip id use sprintf,but compile error??why ?ths standard c function no support??
uint32 chip_id=system_get_chip_id();
char buffer_str[20]={0};
sprintf(buffer_str,"chip_id");
uart0_sendStr(buffer_str);
the complie info is blew..
xt-xcc -Os -g -O2 -Wpointer-arith -Wundef -Werror -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -D__ets__ -DICACHE_FLASH -I include -I ./ -I ../../rom/include -I ../../include/ets -I ../include -I ./ -I ../../include -I ../../include/eagle -o .output/eagle/debug/obj/user_main.o -c user_main.c
user_main.c: In function 'user_init':
user_main.c:70:2: error: incompatible implicit declaration of built-in function 'sprintf' [-Werror]
sprintf(buffer_str,"chip_id");
^
cc1: all warnings being treated as errors
make[1]: *** [.output/eagle/debug/obj/user_main.o] Error 1
make[1]: Leaving directory `/mnt/Share/esp8266/v093/esp_iot_sdk_v0.9.3/app_at/user'
make: *** [.subdirs] Error 2
+ '[' 2 == 0 ']'
+ echo 'make error'
make error
how to use sprintf??标准C函数不支持?
Re: how to use sprintf??标准C函数不支持?
Postby jyesp » Tue Jan 27, 2015 11:49 am
add
#include <stdio.h>
codee
sprintf(buffer_str,"sprintf test\n");
uart0_sendStr(buffer_str);
the complie ok!
but sprintf(buffer_str,"sprintf test=%d\n",chip_id); compile fail??? so bad !!!O(∩_∩)O
uint32 chip_id=system_get_chip_id();
char buffer_str[20]={0};
//sprintf(buffer_str,"chip_id=%d");
sprintf(buffer_str,"sprintf test\n");
sprintf(buffer_str,"sprintf test=%d\n",chip_id);
uart0_sendStr(buffer_str);
the info blew:
DICACHE_FLASH -I include -I ./ -I ../../rom/include -I ../../include/ets -I ../include -I ./ -I ../../include -I ../../include/eagle user_main.c
make[1]: Leaving directory `/mnt/Share/esp8266/v093/esp_iot_sdk_v0.9.3/app_at/user'
make[1]: Entering directory `/mnt/Share/esp8266/v093/esp_iot_sdk_v0.9.3/app_at/user'
xt-xcc -Os -g -O2 -Wpointer-arith -Wundef -Werror -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -D__ets__ -DICACHE_FLASH -I include -I ./ -I ../../rom/include -I ../../include/ets -I ../include -I ./ -I ../../include -I ../../include/eagle -o .output/eagle/debug/obj/user_main.o -c user_main.c
xt-ar ru .output/eagle/debug/lib/libuser.a .output/eagle/debug/obj/user_main.o
make[1]: Leaving directory `/mnt/Share/esp8266/v093/esp_iot_sdk_v0.9.3/app_at/user'
make[1]: Entering directory `/mnt/Share/esp8266/v093/esp_iot_sdk_v0.9.3/app_at/driver'
make[1]: Leaving directory `/mnt/Share/esp8266/v093/esp_iot_sdk_v0.9.3/app_at/driver'
xt-xcc -L../lib -nostdlib -T../ld/eagle.app.v6.ld -Wl,--no-check-sections -u call_user_start -Wl,-static -Wl,--start-group -lc -lgcc -lhal -lphy -lpp -lnet80211 -llwip -lwpa -lmain -ljson -lupgrade user/.output/eagle/debug/lib/libuser.a driver/.output/eagle/debug/lib/libdriver.a -Wl,--end-group -o .output/eagle/debug/image/eagle.app.v6.out
/opt/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: .output/eagle/debug/image/eagle.app.v6.out section `.text' will not fit in region `iram1_0_seg'
/opt/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/libc.a(freer.o):(.literal+0x1c): undefined reference to `_sbrk_r'
/opt/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/libc.a(freer.o): In function `_malloc_trim_r':
C:\build\build\RC-2010.1\lxinnovation\delivery\lx106\104196\xbuild\Target-libs\newlib\xtensa-elf\newlib\libc\stdlib/\build\tree\RC-2010.1_kuma\p4root\Xtensa\Target-libs\newlib\newlib\libc\stdlib/mallocr.c:3309: undefined reference to `_sbrk_r'
C:\build\build\RC-2010.1\lxinnovation\delivery\lx106\104196\xbuild\Target-libs\newlib\xtensa-elf\newlib\libc\stdlib/\build\tree\RC-2010.1_kuma\p4root\Xtensa\Target-libs\newlib\newlib\libc\stdlib/mallocr.c:3351: undefined reference to `_sbrk_r'
C:\build\build\RC-2010.1\lxinnovation\delivery\lx106\104196\xbuild\Target-libs\newlib\xtensa-elf\newlib\libc\stdlib/\build\tree\RC-2010.1_kuma\p4root\Xtensa\Target-libs\newlib\newlib\libc\stdlib/mallocr.c:3327: undefined reference to `_sbrk_r'
/opt/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/libc.a(makebuf.o):(.literal+0x8): undefined reference to `_fstat_r'
/opt/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/libc.a(makebuf.o): In function `__smakebuf':
C:\build\build\RC-2010.1\lxinnovation\delivery\lx106\104196\xbuild\Target-libs\newlib\xtensa-elf\newlib\libc\stdio/\build\tree\RC-2010.1_kuma\p4root\Xtensa\Target-libs\newlib\newlib\libc\stdio/makebuf.c:52: undefined reference to `_fstat_r'
/opt/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/libc.a(mallocr.o): In function `_malloc_r':
C:\build\build\RC-2010.1\lxinnovation\delivery\lx106\104196\xbuild\Target-libs\newlib\xtensa-elf\newlib\libc\stdlib/\build\tree\RC-2010.1_kuma\p4root\Xtensa\Target-libs\newlib\newlib\libc\stdlib/mallocr.c:2152: undefined reference to `_sbrk_r'
C:\build\build\RC-2010.1\lxinnovation\delivery\lx106\104196\xbuild\Target-libs\newlib\xtensa-elf\newlib\libc\stdlib/\build\tree\RC-2010.1_kuma\p4root\Xtensa\Target-libs\newlib\newlib\libc\stdlib/mallocr.c:2189: undefined reference to `_sbrk_r'
/opt/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/libc.a(stdio.o):(.literal+0x0): undefined reference to `_read_r'
/opt/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/libc.a(stdio.o):(.literal+0x4): undefined reference to `_write_r'
/opt/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/libc.a(stdio.o):(.literal+0x8): undefined reference to `_lseek_r'
/opt/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/libc.a(stdio.o):(.literal+0xc): undefined reference to `_close_r'
/opt/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/libc.a(stdio.o): In function `__sread':
C:\build\build\RC-2010.1\lxinnovation\delivery\lx106\104196\xbuild\Target-libs\newlib\xtensa-elf\newlib\libc\stdio/\build\tree\RC-2010.1_kuma\p4root\Xtensa\Target-libs\newlib\newlib\libc\stdio/stdio.c:47: undefined reference to `_read_r'
/opt/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/libc.a(stdio.o): In function `__swrite':
C:\build\build\RC-2010.1\lxinnovation\delivery\lx106\104196\xbuild\Target-libs\newlib\xtensa-elf\newlib\libc\stdio/\build\tree\RC-2010.1_kuma\p4root\Xtensa\Target-libs\newlib\newlib\libc\stdio/stdio.c:84: undefined reference to `_write_r'
C:\build\build\RC-2010.1\lxinnovation\delivery\lx106\104196\xbuild\Target-libs\newlib\xtensa-elf\newlib\libc\stdio/\build\tree\RC-2010.1_kuma\p4root\Xtensa\Target-libs\newlib\newlib\libc\stdio/stdio.c:76: undefined reference to `_lseek_r'
/opt/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/libc.a(stdio.o): In function `__sseek':
C:\build\build\RC-2010.1\lxinnovation\delivery\lx106\104196\xbuild\Target-libs\newlib\xtensa-elf\newlib\libc\stdio/\build\tree\RC-2010.1_kuma\p4root\Xtensa\Target-libs\newlib\newlib\libc\stdio/stdio.c:103: undefined reference to `_lseek_r'
/opt/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/libc.a(stdio.o): In function `__sclose':
C:\build\build\RC-2010.1\lxinnovation\delivery\lx106\104196\xbuild\Target-libs\newlib\xtensa-elf\newlib\libc\stdio/\build\tree\RC-2010.1_kuma\p4root\Xtensa\Target-libs\newlib\newlib\libc\stdio/stdio.c:120: undefined reference to `_close_r'
/opt/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/libc.a(sysfstat.o): In function `fstat':
C:\build\build\RC-2010.1\lxinnovation\delivery\lx106\104196\xbuild\Target-libs\newlib\xtensa-elf\newlib\libc\syscalls/\build\tree\RC-2010.1_kuma\p4root\Xtensa\Target-libs\newlib\newlib\libc\syscalls/sysfstat.c:12: undefined reference to `_fstat_r'
collect2: error: ld returned 1 exit status
make: *** [.output/eagle/debug/image/eagle.app.v6.out] Error 1
+ '[' 2 == 0 ']'
+ echo 'make error'
make error
#include <stdio.h>
codee
sprintf(buffer_str,"sprintf test\n");
uart0_sendStr(buffer_str);
the complie ok!
but sprintf(buffer_str,"sprintf test=%d\n",chip_id); compile fail??? so bad !!!O(∩_∩)O
uint32 chip_id=system_get_chip_id();
char buffer_str[20]={0};
//sprintf(buffer_str,"chip_id=%d");
sprintf(buffer_str,"sprintf test\n");
sprintf(buffer_str,"sprintf test=%d\n",chip_id);
uart0_sendStr(buffer_str);
the info blew:
DICACHE_FLASH -I include -I ./ -I ../../rom/include -I ../../include/ets -I ../include -I ./ -I ../../include -I ../../include/eagle user_main.c
make[1]: Leaving directory `/mnt/Share/esp8266/v093/esp_iot_sdk_v0.9.3/app_at/user'
make[1]: Entering directory `/mnt/Share/esp8266/v093/esp_iot_sdk_v0.9.3/app_at/user'
xt-xcc -Os -g -O2 -Wpointer-arith -Wundef -Werror -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -D__ets__ -DICACHE_FLASH -I include -I ./ -I ../../rom/include -I ../../include/ets -I ../include -I ./ -I ../../include -I ../../include/eagle -o .output/eagle/debug/obj/user_main.o -c user_main.c
xt-ar ru .output/eagle/debug/lib/libuser.a .output/eagle/debug/obj/user_main.o
make[1]: Leaving directory `/mnt/Share/esp8266/v093/esp_iot_sdk_v0.9.3/app_at/user'
make[1]: Entering directory `/mnt/Share/esp8266/v093/esp_iot_sdk_v0.9.3/app_at/driver'
make[1]: Leaving directory `/mnt/Share/esp8266/v093/esp_iot_sdk_v0.9.3/app_at/driver'
xt-xcc -L../lib -nostdlib -T../ld/eagle.app.v6.ld -Wl,--no-check-sections -u call_user_start -Wl,-static -Wl,--start-group -lc -lgcc -lhal -lphy -lpp -lnet80211 -llwip -lwpa -lmain -ljson -lupgrade user/.output/eagle/debug/lib/libuser.a driver/.output/eagle/debug/lib/libdriver.a -Wl,--end-group -o .output/eagle/debug/image/eagle.app.v6.out
/opt/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: .output/eagle/debug/image/eagle.app.v6.out section `.text' will not fit in region `iram1_0_seg'
/opt/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/libc.a(freer.o):(.literal+0x1c): undefined reference to `_sbrk_r'
/opt/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/libc.a(freer.o): In function `_malloc_trim_r':
C:\build\build\RC-2010.1\lxinnovation\delivery\lx106\104196\xbuild\Target-libs\newlib\xtensa-elf\newlib\libc\stdlib/\build\tree\RC-2010.1_kuma\p4root\Xtensa\Target-libs\newlib\newlib\libc\stdlib/mallocr.c:3309: undefined reference to `_sbrk_r'
C:\build\build\RC-2010.1\lxinnovation\delivery\lx106\104196\xbuild\Target-libs\newlib\xtensa-elf\newlib\libc\stdlib/\build\tree\RC-2010.1_kuma\p4root\Xtensa\Target-libs\newlib\newlib\libc\stdlib/mallocr.c:3351: undefined reference to `_sbrk_r'
C:\build\build\RC-2010.1\lxinnovation\delivery\lx106\104196\xbuild\Target-libs\newlib\xtensa-elf\newlib\libc\stdlib/\build\tree\RC-2010.1_kuma\p4root\Xtensa\Target-libs\newlib\newlib\libc\stdlib/mallocr.c:3327: undefined reference to `_sbrk_r'
/opt/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/libc.a(makebuf.o):(.literal+0x8): undefined reference to `_fstat_r'
/opt/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/libc.a(makebuf.o): In function `__smakebuf':
C:\build\build\RC-2010.1\lxinnovation\delivery\lx106\104196\xbuild\Target-libs\newlib\xtensa-elf\newlib\libc\stdio/\build\tree\RC-2010.1_kuma\p4root\Xtensa\Target-libs\newlib\newlib\libc\stdio/makebuf.c:52: undefined reference to `_fstat_r'
/opt/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/libc.a(mallocr.o): In function `_malloc_r':
C:\build\build\RC-2010.1\lxinnovation\delivery\lx106\104196\xbuild\Target-libs\newlib\xtensa-elf\newlib\libc\stdlib/\build\tree\RC-2010.1_kuma\p4root\Xtensa\Target-libs\newlib\newlib\libc\stdlib/mallocr.c:2152: undefined reference to `_sbrk_r'
C:\build\build\RC-2010.1\lxinnovation\delivery\lx106\104196\xbuild\Target-libs\newlib\xtensa-elf\newlib\libc\stdlib/\build\tree\RC-2010.1_kuma\p4root\Xtensa\Target-libs\newlib\newlib\libc\stdlib/mallocr.c:2189: undefined reference to `_sbrk_r'
/opt/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/libc.a(stdio.o):(.literal+0x0): undefined reference to `_read_r'
/opt/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/libc.a(stdio.o):(.literal+0x4): undefined reference to `_write_r'
/opt/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/libc.a(stdio.o):(.literal+0x8): undefined reference to `_lseek_r'
/opt/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/libc.a(stdio.o):(.literal+0xc): undefined reference to `_close_r'
/opt/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/libc.a(stdio.o): In function `__sread':
C:\build\build\RC-2010.1\lxinnovation\delivery\lx106\104196\xbuild\Target-libs\newlib\xtensa-elf\newlib\libc\stdio/\build\tree\RC-2010.1_kuma\p4root\Xtensa\Target-libs\newlib\newlib\libc\stdio/stdio.c:47: undefined reference to `_read_r'
/opt/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/libc.a(stdio.o): In function `__swrite':
C:\build\build\RC-2010.1\lxinnovation\delivery\lx106\104196\xbuild\Target-libs\newlib\xtensa-elf\newlib\libc\stdio/\build\tree\RC-2010.1_kuma\p4root\Xtensa\Target-libs\newlib\newlib\libc\stdio/stdio.c:84: undefined reference to `_write_r'
C:\build\build\RC-2010.1\lxinnovation\delivery\lx106\104196\xbuild\Target-libs\newlib\xtensa-elf\newlib\libc\stdio/\build\tree\RC-2010.1_kuma\p4root\Xtensa\Target-libs\newlib\newlib\libc\stdio/stdio.c:76: undefined reference to `_lseek_r'
/opt/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/libc.a(stdio.o): In function `__sseek':
C:\build\build\RC-2010.1\lxinnovation\delivery\lx106\104196\xbuild\Target-libs\newlib\xtensa-elf\newlib\libc\stdio/\build\tree\RC-2010.1_kuma\p4root\Xtensa\Target-libs\newlib\newlib\libc\stdio/stdio.c:103: undefined reference to `_lseek_r'
/opt/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/libc.a(stdio.o): In function `__sclose':
C:\build\build\RC-2010.1\lxinnovation\delivery\lx106\104196\xbuild\Target-libs\newlib\xtensa-elf\newlib\libc\stdio/\build\tree\RC-2010.1_kuma\p4root\Xtensa\Target-libs\newlib\newlib\libc\stdio/stdio.c:120: undefined reference to `_close_r'
/opt/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/libc.a(sysfstat.o): In function `fstat':
C:\build\build\RC-2010.1\lxinnovation\delivery\lx106\104196\xbuild\Target-libs\newlib\xtensa-elf\newlib\libc\syscalls/\build\tree\RC-2010.1_kuma\p4root\Xtensa\Target-libs\newlib\newlib\libc\syscalls/sysfstat.c:12: undefined reference to `_fstat_r'
collect2: error: ld returned 1 exit status
make: *** [.output/eagle/debug/image/eagle.app.v6.out] Error 1
+ '[' 2 == 0 ']'
+ echo 'make error'
make error
Re: how to use sprintf??标准C函数不支持?
Postby ESP_Faye » Tue Jan 27, 2015 3:00 pm
Yes, esp_iot_sdk could not use #include <stdio.h>
Because our ram is limited , lib c is too large for us ..
You could use the api defined in "osapi.h" , please try "os_sprintf"
Thanks for your interest in ESP8266 !
Because our ram is limited , lib c is too large for us ..
You could use the api defined in "osapi.h" , please try "os_sprintf"
Thanks for your interest in ESP8266 !
Who is online
Users browsing this forum: No registered users and 83 guests
Login
Newbies Start Here
Are you new to ESP8266?
Unsure what to do?
Dunno where to start?
Start right here!
Latest SDK
Documentation
Complete listing of the official ESP8266 related documentation release by ESPRESSIF!
Must read here!
- All times are UTC+08:00
- Top
- Delete all board cookies
About Us
Espressif Systems is a fabless semiconductor company providing cutting-edge low power WiFi SoCs and wireless solutions for wireless communications and Internet of Things applications. We are the manufacturer of ESP8266EX.