[Solved] RTOS undefined methods espconn_create espconn_regist_recvcb

noumes
Posts: 8
Joined: Wed Jan 13, 2016 9:47 am

[Solved] RTOS undefined methods espconn_create espconn_regist_recvcb

Postby noumes » Thu Jan 28, 2016 12:13 pm

Using the latest SDK from github, I am unable to build my application using examples/project-template as a starting point.

Code: Select all

#include "esp_common.h"
#include "espconn.h"
#include "user_config.h"

void recvCB(void *arg, char *pData, unsigned short len);
void eventCB(System_Event_t *event);
void setupUDP();

void recvCB(void *arg, char *pData, unsigned short len) {
 struct espconn *pEspConn = (struct espconn *)arg;
 printf("Received data!! - length = %d\n", len);
 printf(pData);
} // End of recvCB

void setupUDP() {
  static struct espconn conn1;
  static esp_udp udp1;

  udp1.local_port = 25867;

  conn1.type = ESPCONN_UDP;
  conn1.state = ESPCONN_NONE;
  conn1.proto.udp = &udp1;

  espconn_create(&conn1);
  espconn_regist_recvcb(&conn1, recvCB);

  printf("Listening for data\n");
} // End of setupUDP

void eventCB(System_Event_t *event) {
   switch (event->event_id) {
   case EVENT_STAMODE_GOT_IP:
   printf("IP: %d.%d.%d.%d\n", IP2STR(&event->event_info.got_ip.ip));
   setupUDP();
   break; }
} // End of eventCB

void tskconnect(void *pvParameters) {
   //Wait a few secs for the stack to settle down
   vTaskDelay(3000/portTICK_RATE_MS);
   wifi_set_event_handler_cb(eventCB);

   //Go to station mode
   wifi_station_disconnect();
   if (wifi_get_opmode() != STATION_MODE) {
      wifi_set_opmode(STATION_MODE);
   }

   //Connect to the defined access point.
   struct station_config *config=malloc(sizeof(struct station_config));
   memset(config, 0x00, sizeof(struct station_config));
   sprintf(config->ssid, AP_NAME);
   sprintf(config->password, AP_PASS);
   wifi_station_set_config(config);
   wifi_station_connect();
   free(config);

   //We're done. Delete this task.
   vTaskDelete(NULL);
}

void user_init(void)
{
    printf("SDK version:%s\n", system_get_sdk_version());
    xTaskCreate(tskconnect, "tskconnect", 200, NULL, 3, NULL);
}


Yields

root@esp8266-VirtualBox:/home/esp8266/Share/ESP8266_RTOS_SDK/examples/project_template# ./gen_misc.sh
gen_misc.sh version 20150911

SDK_PATH:
/home/esp8266/Share/ESP8266_RTOS_SDK

BIN_PATH:
/home/esp8266/Share/ESP8266_RTOS_SDK/bin

Please check SDK_PATH & BIN_PATH, enter (Y/y) to continue:
y

Please follow below steps(1-5) to generate specific bin(s):
STEP 1: use boot_v1.2+ by default
boot mode: new

STEP 2: choose bin generate(0=eagle.flash.bin+eagle.irom0text.bin, 1=user1.bin, 2=user2.bin)
enter (0/1/2, default 0):

ignore boot
generate bin: eagle.flash.bin+eagle.irom0text.bin

STEP 3: choose spi speed(0=20MHz, 1=26.7MHz, 2=40MHz, 3=80MHz)
enter (0/1/2/3, default 2):

spi speed: 40 MHz

STEP 4: choose spi mode(0=QIO, 1=QOUT, 2=DIO, 3=DOUT)
enter (0/1/2/3, default 0):

spi mode: QIO

STEP 5: choose spi size and map
0= 512KB( 256KB+ 256KB)
2=1024KB( 512KB+ 512KB)
3=2048KB( 512KB+ 512KB)
4=4096KB( 512KB+ 512KB)
5=2048KB(1024KB+1024KB)
6=4096KB(1024KB+1024KB)
enter (0/2/3/4/5/6, default 0):

spi size: 512KB
spi ota map: 256KB + 256KB

start...

make -C user clean; make -C driver clean;
make[1]: Entering directory `/mnt/Share/ESP8266_RTOS_SDK/examples/project_template/user'
rm -f -r .output/eagle/debug
make[1]: Leaving directory `/mnt/Share/ESP8266_RTOS_SDK/examples/project_template/user'
make[1]: Entering directory `/mnt/Share/ESP8266_RTOS_SDK/examples/project_template/driver'
rm -f -r .output/eagle/debug
make[1]: Leaving directory `/mnt/Share/ESP8266_RTOS_SDK/examples/project_template/driver'
rm -f -r .output/eagle/debug
make[1]: Entering directory `/mnt/Share/ESP8266_RTOS_SDK/examples/project_template/user'
DEPEND: xtensa-lx106-elf-gcc -M -Os -g -Wpointer-arith -Wundef -Werror -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -ffunction-sections -fdata-sections -DICACHE_FLASH -I include -I ./ -I ../include -I /home/esp8266/Share/ESP8266_RTOS_SDK/include -I /home/esp8266/Share/ESP8266_RTOS_SDK/extra_include -I /home/esp8266/Share/ESP8266_RTOS_SDK/include/espressif -I /home/esp8266/Share/ESP8266_RTOS_SDK/include/lwip -I /home/esp8266/Share/ESP8266_RTOS_SDK/include/lwip/ipv4 -I /home/esp8266/Share/ESP8266_RTOS_SDK/include/lwip/ipv6 -I /home/esp8266/Share/ESP8266_RTOS_SDK/include/nopoll -I /home/esp8266/Share/ESP8266_RTOS_SDK/include/spiffs -I /home/esp8266/Share/ESP8266_RTOS_SDK/include/ssl user_main.c
make[1]: Leaving directory `/mnt/Share/ESP8266_RTOS_SDK/examples/project_template/user'
make[1]: Entering directory `/mnt/Share/ESP8266_RTOS_SDK/examples/project_template/user'
make[1]: Warning: File `.output/eagle/debug/obj/user_main.d' has modification time 3.4 s in the future
xtensa-lx106-elf-gcc -Os -g -Wpointer-arith -Wundef -Werror -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -ffunction-sections -fdata-sections -DICACHE_FLASH -I include -I ./ -I ../include -I /home/esp8266/Share/ESP8266_RTOS_SDK/include -I /home/esp8266/Share/ESP8266_RTOS_SDK/extra_include -I /home/esp8266/Share/ESP8266_RTOS_SDK/include/espressif -I /home/esp8266/Share/ESP8266_RTOS_SDK/include/lwip -I /home/esp8266/Share/ESP8266_RTOS_SDK/include/lwip/ipv4 -I /home/esp8266/Share/ESP8266_RTOS_SDK/include/lwip/ipv6 -I /home/esp8266/Share/ESP8266_RTOS_SDK/include/nopoll -I /home/esp8266/Share/ESP8266_RTOS_SDK/include/spiffs -I /home/esp8266/Share/ESP8266_RTOS_SDK/include/ssl -o .output/eagle/debug/obj/user_main.o -c user_main.c
xtensa-lx106-elf-ar ru .output/eagle/debug/lib/libuser.a .output/eagle/debug/obj/user_main.o
xtensa-lx106-elf-ar: creating .output/eagle/debug/lib/libuser.a
make[1]: warning: Clock skew detected. Your build may be incomplete.
make[1]: Leaving directory `/mnt/Share/ESP8266_RTOS_SDK/examples/project_template/user'
make[1]: Entering directory `/mnt/Share/ESP8266_RTOS_SDK/examples/project_template/driver'
DEPEND: xtensa-lx106-elf-gcc -M -Os -g -Wpointer-arith -Wundef -Werror -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -ffunction-sections -fdata-sections -DICACHE_FLASH -I include -I ../include -I /home/esp8266/Share/ESP8266_RTOS_SDK/include -I /home/esp8266/Share/ESP8266_RTOS_SDK/extra_include -I /home/esp8266/Share/ESP8266_RTOS_SDK/include/espressif -I /home/esp8266/Share/ESP8266_RTOS_SDK/include/lwip -I /home/esp8266/Share/ESP8266_RTOS_SDK/include/lwip/ipv4 -I /home/esp8266/Share/ESP8266_RTOS_SDK/include/lwip/ipv6 -I /home/esp8266/Share/ESP8266_RTOS_SDK/include/nopoll -I /home/esp8266/Share/ESP8266_RTOS_SDK/include/spiffs -I /home/esp8266/Share/ESP8266_RTOS_SDK/include/ssl i2s_freertos.c
make[1]: Leaving directory `/mnt/Share/ESP8266_RTOS_SDK/examples/project_template/driver'
make[1]: Entering directory `/mnt/Share/ESP8266_RTOS_SDK/examples/project_template/driver'
make[1]: Warning: File `.output/eagle/debug/obj/i2s_freertos.d' has modification time 3.6 s in the future
xtensa-lx106-elf-gcc -Os -g -Wpointer-arith -Wundef -Werror -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -ffunction-sections -fdata-sections -DICACHE_FLASH -I include -I ../include -I /home/esp8266/Share/ESP8266_RTOS_SDK/include -I /home/esp8266/Share/ESP8266_RTOS_SDK/extra_include -I /home/esp8266/Share/ESP8266_RTOS_SDK/include/espressif -I /home/esp8266/Share/ESP8266_RTOS_SDK/include/lwip -I /home/esp8266/Share/ESP8266_RTOS_SDK/include/lwip/ipv4 -I /home/esp8266/Share/ESP8266_RTOS_SDK/include/lwip/ipv6 -I /home/esp8266/Share/ESP8266_RTOS_SDK/include/nopoll -I /home/esp8266/Share/ESP8266_RTOS_SDK/include/spiffs -I /home/esp8266/Share/ESP8266_RTOS_SDK/include/ssl -o .output/eagle/debug/obj/i2s_freertos.o -c i2s_freertos.c
xtensa-lx106-elf-ar ru .output/eagle/debug/lib/libdriver.a .output/eagle/debug/obj/i2s_freertos.o
xtensa-lx106-elf-ar: creating .output/eagle/debug/lib/libdriver.a
make[1]: warning: Clock skew detected. Your build may be incomplete.
make[1]: Leaving directory `/mnt/Share/ESP8266_RTOS_SDK/examples/project_template/driver'
make: Warning: File `user/.output/eagle/debug/lib/libuser.a' has modification time 3.1 s in the future
xtensa-lx106-elf-gcc -L/home/esp8266/Share/ESP8266_RTOS_SDK/lib -Wl,--gc-sections -nostdlib -T/home/esp8266/Share/ESP8266_RTOS_SDK/ld/eagle.app.v6.ld -Wl,--no-check-sections -u call_user_start -Wl,-static -Wl,--start-group -lminic -lgcc -lhal -lphy -lpp -lnet80211 -lwpa -lcrypto -lmain -lfreertos -llwip 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
user/.output/eagle/debug/lib/libuser.a(user_main.o): In function `tskconnect':
/mnt/Share/ESP8266_RTOS_SDK/examples/project_template/user/user_main.c:79: undefined reference to `espconn_create'
/mnt/Share/ESP8266_RTOS_SDK/examples/project_template/user/user_main.c:79: undefined reference to `espconn_regist_recvcb'
user/.output/eagle/debug/lib/libuser.a(user_main.o): In function `setupUDP':
/mnt/Share/ESP8266_RTOS_SDK/examples/project_template/user/user_main.c:49: undefined reference to `espconn_create'
/mnt/Share/ESP8266_RTOS_SDK/examples/project_template/user/user_main.c:50: undefined reference to `espconn_regist_recvcb'
collect2: error: ld returned 1 exit status
make: *** [.output/eagle/debug/image/eagle.app.v6.out] Error 1
root@esp8266-VirtualBox:/home/esp8266/Share/ESP8266_RTOS_SDK/examples/project_template#

ESP_Faye
Posts: 1646
Joined: Mon Oct 27, 2014 11:08 am

Re: RTOS undefined methods espconn_create espconn_regist_recvcb

Postby ESP_Faye » Mon Feb 01, 2016 5:48 pm

Hi,

Please add "-lespconn" in the "LINKFLAGS_eagle.app.v6" area of your makefile, and try it again.

Thanks for your interest in ESP8266 !

noumes
Posts: 8
Joined: Wed Jan 13, 2016 9:47 am

Re: RTOS undefined methods espconn_create espconn_regist_recvcb

Postby noumes » Sat Feb 13, 2016 9:10 am

Fixed it. Thank you!

Who is online

Users browsing this forum: No registered users and 190 guests