changes in actual esp-idf around rtc ?

jumjum123
Posts: 199
Joined: Mon Oct 17, 2016 3:11 pm

changes in actual esp-idf around rtc ?

Postby jumjum123 » Mon Apr 24, 2017 10:59 am

Our application is running fine with esp-idf v2.0, but with actual sources there are a lot of errors during linking.
Mostly there are undefined references to functions starting with rtc_ or esp_cpu, like rtc_clk_cal, rtc_init, rtc_time_get, .... esp_cpu_stall, esp_set_cpu_freq
Some of them are very confusing (at least to me) like this one:
/home/esp32/esp-idf/components/esp32/lib/librtc.a(rtc_wrap.o): In function `rtc_init_clk':
/home/qgu/git_tree/chip7.1_rtc/board_code/app_test/pp/rtc/rtc_wrap.c:34: undefined reference to `rtc_clk_init'
/home/qgu/git_tree/chip7.1_rtc/board_code/app_test/pp/rtc/rtc_wrap.c:36: undefined reference to `rtc_clk_init'

What is /home/qgu/git_tree/... ?
Is there any change in libs that need to be included since v2.0 ?

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: changes in actual esp-idf around rtc ?

Postby ESP_igrr » Mon Apr 24, 2017 12:09 pm

Make sure you do `git submodule update` after pulling the master branch. These errors indicate either of:

- you haven't updated the submodules
- your application is using some functions from librtc which aren't declared in the header files

If updating submodules and doing make clean all doesn't resolve the issue, please run the following in your project directory:

Code: Select all

find build -name '*.o' | xargs xtensa-esp32-elf-nm -A --undefined-only | grep rtc_
and paste a link to the output here.

jumjum123
Posts: 199
Joined: Mon Oct 17, 2016 3:11 pm

Re: changes in actual esp-idf around rtc ?

Postby jumjum123 » Mon Apr 24, 2017 3:37 pm

Thanks for the fast response. Hope my feedback is helpful.
I didn't get your script running, I get an error a.out no such file.
Just try to figure out, why.
Please let me add some other lines to show what we are doing.

Before compiling with our application esp-idf and template is created this way:

Code: Select all

git clone --recursive https://github.com/espressif/esp-idf.git
cd esp-idf
git submodule update --init
cd ..
git clone https://github.com/espressif/esp-idf-template.git template
nano setenv.sh
>>>
#!/bin/bash
export ESP_IDF_PATH=$(pwd)/esp-idf
export IDF_PATH=$(pwd)/esp-idf
export ESP_APP_TEMPLATE_PATH=$(pwd)/template
export ESP32=1
[[ ":$PATH:" != *":/opt/xtensa-esp32-elf/bin:"* ]] && PATH="/opt/xtensa-esp32-elf/bin:${PATH}"
<<<
chmod u+x setenv.sh
. ./setenv.sh
cd template
make menuconfig
     Component config -> LWIP -> Enable SO_REUSEADDR option [Enable]
     Component config -> ESP32-specific config ->  Task watchdog [Disable]
            sooner or later we need to find a way to refresh Task watchdog
     Component config -> FreeRTOS -> Halt when an SMP-untested function is called [Disable]
            some functions are marked as "SMP-untested" and a call results in a reset
            on our test they work fine, and for testing we need some of them
     Partitions set to partitions_espruino.csv
     copied partitions_espruino.csv to template directory
make
cd ..
Next our application is downloaded from github and make is started
Includes etc is this:

Code: Select all

#
# Definitions for the build of the ESP32
#

ESP32=1

CFLAGS+=-Og -Wpointer-arith -Wno-error=unused-function -Wno-error=unused-but-set-variable \
-Wno-error=unused-variable -Wall -ffunction-sections -fdata-sections -mlongcalls -nostdlib \
-MMD -MP -std=gnu99 -fstrict-volatile-bitfields -fgnu89-inline
SOURCES += targets/esp32/jshardware.c
SOURCES += targets/esp32/esp32_neopixel.c
INCLUDE += -I$(ROOT)/targets/esp32

ifndef ESP_IDF_PATH
$(error "The ESP_IDF_PATH variable must be set")
endif
ifndef ESP_APP_TEMPLATE_PATH
$(error "The ESP_APP_TEMPLATE_PATH variable must be set")
endif
# The prefix for the ESP32 compiler
CCPREFIX=xtensa-esp32-elf-
SOURCES += targets/esp32/main.c
LDFLAGS += -L$(ESP_IDF_PATH)/ld \
-L$(ESP_IDF_PATH)/components/bt/lib \
-L$(ESP_IDF_PATH)/components/esp32/lib \
-L$(ESP_APP_TEMPLATE_PATH)/build/bootloader \
-L$(ESP_APP_TEMPLATE_PATH)/build/bt \
-L$(ESP_APP_TEMPLATE_PATH)/build/driver \
-L$(ESP_APP_TEMPLATE_PATH)/build/esp32 \
-L$(ESP_APP_TEMPLATE_PATH)/build/esptool_py \
-L$(ESP_APP_TEMPLATE_PATH)/build/expat \
-L$(ESP_APP_TEMPLATE_PATH)/build/freertos \
-L$(ESP_APP_TEMPLATE_PATH)/build/json \
-L$(ESP_APP_TEMPLATE_PATH)/build/log \
-L$(ESP_APP_TEMPLATE_PATH)/build/lwip \
-L$(ESP_APP_TEMPLATE_PATH)/build/mbedtls \
-L$(ESP_APP_TEMPLATE_PATH)/build/newlib \
-L$(ESP_APP_TEMPLATE_PATH)/build/nghttp \
-L$(ESP_APP_TEMPLATE_PATH)/build/nvs_flash \
-L$(ESP_APP_TEMPLATE_PATH)/build/partition_table \
-L$(ESP_APP_TEMPLATE_PATH)/build/spi_flash \
-L$(ESP_APP_TEMPLATE_PATH)/build/tcpip_adapter \
-L$(ESP_APP_TEMPLATE_PATH)/build/vfs \
-L$(ESP_APP_TEMPLATE_PATH)/build/newlib \
-L$(ESP_APP_TEMPLATE_PATH)/build/wpa_supplicant \
-L$(ESP_APP_TEMPLATE_PATH)/build/ethernet \
-L$(ESP_APP_TEMPLATE_PATH)/build/app_update \
-lgcc
ESPTOOL?=
INCLUDE+=\
-I$(ESP_APP_TEMPLATE_PATH)/build/include \
-I$(ESP_IDF_PATH)/components \
-I$(ESP_IDF_PATH)/components/newlib/include \
-I$(ESP_IDF_PATH)/components/bt/include \
-I$(ESP_IDF_PATH)/components/driver/include \
-I$(ESP_IDF_PATH)/components/esp32/include \
-I$(ESP_IDF_PATH)/components/freertos/include \
-I$(ESP_IDF_PATH)/components/json/include \
-I$(ESP_IDF_PATH)/components/log/include \
-I$(ESP_IDF_PATH)/components/lwip/include/lwip \
-I$(ESP_IDF_PATH)/components/lwip/include/lwip/port \
-I$(ESP_IDF_PATH)/components/lwip/include/lwip/posix \
-I$(ESP_IDF_PATH)/components/newlib/include \
-I$(ESP_IDF_PATH)/components/spi_flash/include \
-I$(ESP_IDF_PATH)/components/nvs_flash/include \
-I$(ESP_IDF_PATH)/components/tcpip_adapter/include \
-I$(ESP_IDF_PATH)/components/vfs/include \
-I$(ESP_IDF_PATH)/components/soc/esp32/include \
-I$(ESP_IDF_PATH)/components/soc/esp32/include/soc \
-Itargets/esp32/include
LDFLAGS+=-nostdlib -u call_user_start_cpu0 -Wl,--gc-sections -Wl,-static -Wl,-EL
LIBS+=-T esp32_out.ld \
-T$(ESP_IDF_PATH)/components/esp32/ld/esp32.common.ld \
-T$(ESP_IDF_PATH)/components/esp32/ld/esp32.rom.ld \
-T$(ESP_IDF_PATH)/components/esp32/ld/esp32.peripherals.ld \
$(ESP_IDF_PATH)/components/esp32/lib/librtc.a \
$(ESP_IDF_PATH)/components/newlib/lib/libc.a \
$(ESP_IDF_PATH)/components/newlib/lib/libm.a \
$(ESP_IDF_PATH)/components/esp32/lib/libphy.a \
-lbt \
-lbtdm_app \
-ldriver \
-lesp32 \
$(ESP_IDF_PATH)/components/esp32/libhal.a  \
-lcore \
-lnet80211 \
-lphy \
-lwpa_supplicant \
-lrtc \
-lpp \
-lwpa \
-lexpat \
-lfreertos \
-ljson \
-llog \
-llwip \
-lmbedtls \
-lnghttp \
-lnvs_flash \
-lspi_flash \
-ltcpip_adapter \
-lvfs \
-lnewlib \
-lcoexist \
-lethernet \
-lapp_update \
-lstdc++ \
-lgcc

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: changes in actual esp-idf around rtc ?

Postby ESP_igrr » Mon Apr 24, 2017 11:01 pm

There's a new component which you need to link (components/soc), you need to update your Makefile accordingly: add -lsoc and -L build/soc

jumjum123
Posts: 199
Joined: Mon Oct 17, 2016 3:11 pm

Re: changes in actual esp-idf around rtc ?

Postby jumjum123 » Tue Apr 25, 2017 8:17 am

Thanks, compiling and linking works now.

Since this is not the first time, I ran into this kind of problem.
I wonder if there is an easy to folllow recipe, to find this by myself.

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: changes in actual esp-idf around rtc ?

Postby ESP_igrr » Tue Apr 25, 2017 8:45 am

Since you are not using ESP-IDF build system when building your project, i suppose there is no easy way of doing this. We are considering some ways to export build metadata for external build systems, but for now this task is in the backlog. We will possibly work on it for 3.0 (i.e. the version after the next one).

If you are running into linker errors, you can use a recipe similar to the one i gave you above, to find .a files which contain specific functions which the linker complains about.

Who is online

Users browsing this forum: No registered users and 109 guests