ESP8266 Developer Zone The Official ESP8266 Forum 2015-01-28T10:37:52+08:00 https://bbs.espressif.com:443/feed.php?f=7&t=159 2015-01-28T10:37:52+08:00 2015-01-28T10:37:52+08:00 https://bbs.espressif.com:443/viewtopic.php?t=159&p=581#p581 <![CDATA[Re: how to use sprintf??标准C函数不支持?]]> Statistics: Posted by jyesp — Wed Jan 28, 2015 10:37 am


]]>
2015-01-27T15:00:36+08:00 2015-01-27T15:00:36+08:00 https://bbs.espressif.com:443/viewtopic.php?t=159&p=572#p572 <![CDATA[Re: how to use sprintf??标准C函数不支持?]]>
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 !

Statistics: Posted by ESP_Faye — Tue Jan 27, 2015 3:00 pm


]]>
2015-01-27T11:49:29+08:00 2015-01-27T11:49:29+08:00 https://bbs.espressif.com:443/viewtopic.php?t=159&p=570#p570 <![CDATA[Re: how to use sprintf??标准C函数不支持?]]> #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

Statistics: Posted by jyesp — Tue Jan 27, 2015 11:49 am


]]>
2015-01-27T09:34:22+08:00 2015-01-27T09:34:22+08:00 https://bbs.espressif.com:443/viewtopic.php?t=159&p=568#p568 <![CDATA[how to use sprintf??标准C函数不支持?]]> 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

Statistics: Posted by jyesp — Tue Jan 27, 2015 9:34 am


]]>