Eclipse CDT -- ESP8266 -- espressif hello_world_cpp example -
i have been using arduino ide esp8266 coding, move little more powerful environment. i'm making first foray eclipse cdt environment mingw gcc toolchain.
edit -- have eclipse c arduino plugin installed: https://marketplace.eclipse.org/content/eclipse-c-ide-arduino
however, on first attempt project working, i'm running lot of issues trying compiled , linked. i've chosen hello_world_cpp example espressif sdk. i've corrected number of issues i've run into, can't seem figure out how past linking problem below. output copied below after main project code.
can guys give pointers on might start looking on problem? looks i'm missing library, life of me can't find library contains missing functions. let me know if there's further information useful.
here main cpp file:
/* hello world c++ demo */ #include <ets_sys.h> #include <osapi.h> #include <os_type.h> #include <gpio.h> #define delay 1000 /* milliseconds */ // ============================================================================================= // c includes , declarations // ============================================================================================= extern "c" { #include "driver/uart.h" #include <user_interface.h> void *pvportmalloc( size_t xwantedsize ); void vportfree( void *pv ); void *pvportzalloc(size_t size); // declare lib methods extern int ets_uart_printf(const char *fmt, ...); void ets_timer_disarm(etstimer *ptimer); void ets_timer_setfn(etstimer *ptimer, etstimerfunc *pfunction, void *parg); void ets_timer_arm_new(etstimer *ptimer,uint32_t milliseconds, bool repeat_flag, bool); #define os_malloc pvportmalloc #define os_free vportfree #define os_zalloc pvportzalloc }//extern "c" // ============================================================================================= // these methods shall defined anywhere. // required c++ compiler // ============================================================================================= void *operator new(size_t size) { return os_malloc(size); } void *operator new[](size_t size) { return os_malloc(size); } void operator delete(void * ptr) { os_free(ptr); } void operator delete[](void * ptr) { os_free(ptr); } extern "c" void __cxa_pure_virtual(void) __attribute__ ((__noreturn__)); extern "c" void __cxa_deleted_virtual(void) __attribute__ ((__noreturn__)); extern "c" void abort() { while(true); // enter infinite loop , reset wdt } void __cxa_pure_virtual(void) { abort(); } void __cxa_deleted_virtual(void) { abort(); } // ============================================================================================= // example class. show global objects shall initialyzed user // (see user_init method) // ============================================================================================= class { int a; int b; public: a() : a(5) , b(6) { } a( int k, int m ) : a(k) , b(m) { } void print() { ets_uart_printf( "a = %d, b = %d\n", a, b ); } }; // ============================================================================================= // global objects // ============================================================================================= local os_timer_t hello_timer; a; // ============================================================================================= // pointers constructors of global objects // (defined in linker script eagle.app.v6.ld) // ============================================================================================= extern void (*__init_array_start)(void); extern void (*__init_array_end)(void); // initialyzer of global objects static void do_global_ctors(void) { void (**p)(void); (p = &__init_array_start; p != &__init_array_end; ++p) (*p)(); } // ============================================================================================= // user code // ============================================================================================= local void icache_flash_attr hello_cb(void *arg) { static int counter = 0; ets_uart_printf("hello world #%d!\r\n", counter++); a.print(); } /****************************************************************************** * functionname : user_rf_cal_sector_set * description : sdk reversed 4 sectors, used rf init data , paramters. * add function force users set rf cal sector, since * don't know sector free in user's application. * sector map last several sectors : abbbcddd * : rf cal * b : @ parameters * c : rf init data * d : sdk parameters * parameters : none * returns : rf cal sector *******************************************************************************/ extern "c" uint32 icache_flash_attr user_rf_cal_sector_set(void) { enum flash_size_map size_map = system_get_flash_size_map(); uint32 rf_cal_sec = 0; switch (size_map) { case flash_size_4m_map_256_256: rf_cal_sec = 128 - 8; break; case flash_size_8m_map_512_512: rf_cal_sec = 256 - 5; break; case flash_size_16m_map_512_512: case flash_size_16m_map_1024_1024: rf_cal_sec = 512 - 5; break; case flash_size_32m_map_512_512: case flash_size_32m_map_1024_1024: rf_cal_sec = 1024 - 5; break; default: rf_cal_sec = 0; break; } return rf_cal_sec; } extern "c" void icache_flash_attr user_rf_pre_init(void) { } extern "c" void icache_flash_attr user_init(void) { do_global_ctors(); // configure uart uart_init(bit_rate_115200, bit_rate_115200); ets_uart_printf("system init...\r\n"); // set timer send message // os_timer_disarm(etstimer *ptimer) os_timer_disarm(&hello_timer); // os_timer_setfn(etstimer *ptimer, etstimerfunc *pfunction, void *parg) os_timer_setfn(&hello_timer, (os_timer_func_t *)hello_cb, (void *)0); // void os_timer_arm(etstimer *ptimer,uint32_t milliseconds, bool repeat_flag) os_timer_arm(&hello_timer, delay, 1); ets_uart_printf("system init done.\r\n"); }
and build output:
19:44:02 **** rebuild of configuration default project hello_world_cpp **** info: internal builder used build gcc -i../include "-ic:\\espressif\\esp8266_sdk\\include" -o2 -g -wall -c -fmessage-length=0 -o "driver\\uart.o" "..\\driver\\uart.c" in file included c:\espressif\esp8266_sdk\include/ets_sys.h:12:0, ..\driver\uart.c:12: ..\driver\uart.c: in function 'uart_config': c:\espressif\esp8266_sdk\include/eagle_soc.h:250:38: warning: suggest parentheses around arithmetic in operand of '|' [-wparentheses] & (~(periphs_io_mux_func<<periphs_io_mux_func_s)) \ ^ c:\espressif\esp8266_sdk\include/eagle_soc.h:50:98: note: in definition of macro 'write_peri_reg' #define write_peri_reg(addr, val) (*((volatile uint32_t *)ets_uncached_addr(addr))) = (uint32_t)(val) ^~~ ..\driver\uart.c:36:9: note: in expansion of macro 'pin_func_select' pin_func_select(periphs_io_mux_gpio2_u, func_u1txd_bk); ^~~~~~~~~~~~~~~ in file included ..\driver\uart.c:12:0: c:\espressif\esp8266_sdk\include/ets_sys.h:61:5: warning: implicit declaration of function 'ets_isr_attach' [-wimplicit-function-declaration] ets_isr_attach(ets_uart_inum, (func), (void *)(arg)) ^ ..\driver\uart.c:39:9: note: in expansion of macro 'ets_uart_intr_attach' ets_uart_intr_attach(uart0_rx_intr_handler, &(uartdev.rcv_buff)); ^~~~~~~~~~~~~~~~~~~~ in file included c:\espressif\esp8266_sdk\include/ets_sys.h:12:0, ..\driver\uart.c:12: c:\espressif\esp8266_sdk\include/eagle_soc.h:250:38: warning: suggest parentheses around arithmetic in operand of '|' [-wparentheses] & (~(periphs_io_mux_func<<periphs_io_mux_func_s)) \ ^ c:\espressif\esp8266_sdk\include/eagle_soc.h:50:98: note: in definition of macro 'write_peri_reg' #define write_peri_reg(addr, val) (*((volatile uint32_t *)ets_uncached_addr(addr))) = (uint32_t)(val) ^~~ ..\driver\uart.c:41:9: note: in expansion of macro 'pin_func_select' pin_func_select(periphs_io_mux_u0txd_u, func_u0txd); ^~~~~~~~~~~~~~~ ..\driver\uart.c:44:5: warning: implicit declaration of function 'uart_div_modify' [-wimplicit-function-declaration] uart_div_modify(uart_no, uart_clk_freq / (uartdev.baut_rate)); ^~~~~~~~~~~~~~~ ..\driver\uart.c: in function 'uart0_tx_buffer': ..\driver\uart.c:163:9: warning: implicit declaration of function 'uart_tx_one_char' [-wimplicit-function-declaration] uart_tx_one_char(buf[i]); ^~~~~~~~~~~~~~~~ in file included ..\driver\uart.c:12:0: ..\driver\uart.c: in function 'uart_init': c:\espressif\esp8266_sdk\include/ets_sys.h:67:5: warning: implicit declaration of function 'ets_isr_unmask' [-wimplicit-function-declaration] ets_isr_unmask((1<<inum)) ^ c:\espressif\esp8266_sdk\include/ets_sys.h:76:5: note: in expansion of macro 'ets_intr_enable' ets_intr_enable(ets_uart_inum) ^~~~~~~~~~~~~~~ ..\driver\uart.c:182:5: note: in expansion of macro 'ets_uart_intr_enable' ets_uart_intr_enable(); ^~~~~~~~~~~~~~~~~~~~ in file included ..\driver\uart.c:13:0: c:\espressif\esp8266_sdk\include/osapi.h:13:26: warning: implicit declaration of function 'ets_install_putc1' [-wimplicit-function-declaration] #define os_install_putc1 ets_install_putc1 ^ ..\driver\uart.c:185:5: note: in expansion of macro 'os_install_putc1' os_install_putc1((void *)uart1_write_char); ^~~~~~~~~~~~~~~~ g++ "-ic:\\espressif\\esp8266_sdk\\include\\" -i../include -o2 -g -wall -c -fmessage-length=0 -o "user\\user_main.o" "..\\user\\user_main.cpp" g++ -lc:/mingw/msys/1.0/lib "-lf:\\espressif\\lib" -o hello_world_cpp "driver\\uart.o" "user\\user_main.o" c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: skipping incompatible f:\espressif\lib/libgcc.a when searching -lgcc c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: skipping incompatible f:\espressif\lib\libgcc.a when searching -lgcc c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: skipping incompatible f:\espressif\lib/libgcc.a when searching -lgcc c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: skipping incompatible f:\espressif\lib\libgcc.a when searching -lgcc driver\uart.o: in function `uart_config': c:\espressif\examples\esp8266\hello_world_cpp\default/../driver/uart.c:39: undefined reference `uartdev' c:\espressif\examples\esp8266\hello_world_cpp\default/../driver/uart.c:39: undefined reference `ets_isr_attach' c:\espressif\examples\esp8266\hello_world_cpp\default/../driver/uart.c:44: undefined reference `uartdev' c:\espressif\examples\esp8266\hello_world_cpp\default/../driver/uart.c:44: undefined reference `uart_div_modify' c:\espressif\examples\esp8266\hello_world_cpp\default/../driver/uart.c:46: undefined reference `uartdev' c:\espressif\examples\esp8266\hello_world_cpp\default/../driver/uart.c:46: undefined reference `uartdev' c:\espressif\examples\esp8266\hello_world_cpp\default/../driver/uart.c:46: undefined reference `uartdev' c:\espressif\examples\esp8266\hello_world_cpp\default/../driver/uart.c:46: undefined reference `uartdev' c:\espressif\examples\esp8266\hello_world_cpp\default/../driver/uart.c:57: undefined reference `uartdev' driver\uart.o: in function `uart0_tx_buffer': c:\espressif\examples\esp8266\hello_world_cpp\default/../driver/uart.c:163: undefined reference `uart_tx_one_char' driver\uart.o: in function `uart_init': c:\espressif\examples\esp8266\hello_world_cpp\default/../driver/uart.c:178: undefined reference `uartdev' c:\espressif\examples\esp8266\hello_world_cpp\default/../driver/uart.c:180: undefined reference `uartdev' c:\espressif\examples\esp8266\hello_world_cpp\default/../driver/uart.c:182: undefined reference `ets_isr_unmask' c:\espressif\examples\esp8266\hello_world_cpp\default/../driver/uart.c:185: undefined reference `ets_install_putc1' user\user_main.o: in function `hello_cb': c:\espressif\examples\esp8266\hello_world_cpp\default/../user/user_main.cpp:135: undefined reference `ets_uart_printf' user\user_main.o: in function `zn1a5printev': c:\espressif\examples\esp8266\hello_world_cpp\default/../user/user_main.cpp:100: undefined reference `ets_uart_printf' user\user_main.o: in function `user_rf_cal_sector_set': c:\espressif\examples\esp8266\hello_world_cpp\default/../user/user_main.cpp:155: undefined reference `system_get_flash_size_map' user\user_main.o: in function `do_global_ctors': c:\espressif\examples\esp8266\hello_world_cpp\default/../user/user_main.cpp:124: undefined reference `__init_array_start' c:\espressif\examples\esp8266\hello_world_cpp\default/../user/user_main.cpp:124: undefined reference `__init_array_end' c:\espressif\examples\esp8266\hello_world_cpp\default/../user/user_main.cpp:124: undefined reference `__init_array_end' user\user_main.o: in function `user_init': c:\espressif\examples\esp8266\hello_world_cpp\default/../user/user_main.cpp:194: undefined reference `ets_uart_printf' c:\espressif\examples\esp8266\hello_world_cpp\default/../user/user_main.cpp:198: undefined reference `ets_timer_disarm' c:\espressif\examples\esp8266\hello_world_cpp\default/../user/user_main.cpp:200: undefined reference `ets_timer_setfn' c:\espressif\examples\esp8266\hello_world_cpp\default/../user/user_main.cpp:202: undefined reference `ets_timer_arm_new' c:\espressif\examples\esp8266\hello_world_cpp\default/../user/user_main.cpp:204: undefined reference `ets_uart_printf' user\user_main.o:c:\espressif\examples\esp8266\hello_world_cpp\default/../user/user_main.cpp:137: undefined reference `pvportmalloc' user\user_main.o: in function `znaj': c:\espressif\examples\esp8266\hello_world_cpp\default/../user/user_main.cpp:47: undefined reference `pvportmalloc' user\user_main.o:c:\espressif\examples\esp8266\hello_world_cpp\default/../user/user_main.cpp:47: undefined reference `vportfree' user\user_main.o: in function `zdapv': c:\espressif\examples\esp8266\hello_world_cpp\default/../user/user_main.cpp:57: undefined reference `vportfree' c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libmingw32.a(main.o):(.text.startup+0xa0): undefined reference `winmain@16' collect2.exe: error: ld returned 1 exit status 19:44:03 build finished (took 890ms)
it appears cdt running gcc
host development opposed gcc cross-compiler needed generating code arduino board.
are using "vanilla" cdt, or have using arduino plug-ins eclipse.
two consider:
Comments
Post a Comment