Error when compiling with xtensa-esp32-elf

fgh1999
Posts: 7
Joined: Tue Jun 25, 2019 3:25 am

Error when compiling with xtensa-esp32-elf

Postby fgh1999 » Mon Jul 08, 2019 7:03 am

Hi,
When I compile the example without modifying anything, I got this error:

/home/fgh/esp/xtensa-esp32-elf/xtensa-esp32-elf/sys-include/stdlib.h:155:44: error: expected initializer before '__result_use_check'
void *reallocarray(void *, size_t, size_t) __result_use_check __alloc_size(2)
^~~~~~~~~~~~~~~~~~
/home/fgh/esp/xtensa-esp32-elf/xtensa-esp32-elf/sys-include/stdlib.h:340:52: error: expected initializer before '__alloc_align'
void * aligned_alloc(size_t, size_t) __malloc_like __alloc_align(1)
^~~~~~~~~~~~~
It's so confusing...

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: Error when compiling with xtensa-esp32-elf

Postby ESP_Angus » Mon Jul 08, 2019 8:35 am

Hi fgh1999,

We need some details to try and tell what the problem is. Can you please share your host OS, ESP-IDF version, the full command line you are running and all of the build output (not just the error lines). Plus any other details which may be relevant.

Thanks,

Angus

fgh1999
Posts: 7
Joined: Tue Jun 25, 2019 3:25 am

Re: Error when compiling with xtensa-esp32-elf

Postby fgh1999 » Tue Jul 09, 2019 2:32 am

OS: Ubuntu 18.04 LTS

fgh@ubuntu:~/esp/esp-mdf/examples/function_demo/mwifi/no_router$ make
Toolchain path: /home/fgh/esp/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc
WARNING: Toolchain version is not supported: esp32-2019r1
Expected to see version: crosstool-ng-1.22.0-80-g6c4433a
Please check ESP-IDF setup instructions and update the toolchain, or proceed at your own risk.
WARNING: Compiler version is not supported: 8.2.0
Expected to see version(s): 5.2.0
Please check ESP-IDF setup instructions and update the toolchain, or proceed at your own risk.
WARNING: Toolchain version is not supported: esp32-2019r1
Expected to see version: crosstool-ng-1.22.0-80-g6c4433a
Please check ESP-IDF setup instructions and update the toolchain, or proceed at your own risk.
WARNING: Compiler version is not supported: 8.2.0
Expected to see version(s): 5.2.0
Please check ESP-IDF setup instructions and update the toolchain, or proceed at your own risk.

Python requirements from /home/fgh/esp/esp-mdf/esp-idf/requirements.txt are satisfied.
CXX build/asio/asio/asio/src/asio.o
In file included from /home/fgh/esp/xtensa-esp32-elf/xtensa-esp32-elf/include/c++/8.2.0/cstdlib:75,
from /home/fgh/esp/xtensa-esp32-elf/xtensa-esp32-elf/include/c++/8.2.0/ext/string_conversions.h:41,
from /home/fgh/esp/xtensa-esp32-elf/xtensa-esp32-elf/include/c++/8.2.0/bits/basic_string.h:6391,
from /home/fgh/esp/xtensa-esp32-elf/xtensa-esp32-elf/include/c++/8.2.0/string:52,
from /home/fgh/esp/esp-mdf/esp-idf/components/asio/asio/asio/include/asio/impl/error.ipp:19,
from /home/fgh/esp/esp-mdf/esp-idf/components/asio/asio/asio/include/asio/impl/src.hpp:22,
from /home/fgh/esp/esp-mdf/esp-idf/components/asio/asio/asio/src/asio.cpp:11:
/home/fgh/esp/xtensa-esp32-elf/xtensa-esp32-elf/sys-include/stdlib.h:155:44: error: expected initializer before '__result_use_check'
void *reallocarray(void *, size_t, size_t) __result_use_check __alloc_size(2)
^~~~~~~~~~~~~~~~~~
/home/fgh/esp/xtensa-esp32-elf/xtensa-esp32-elf/sys-include/stdlib.h:340:52: error: expected initializer before '__alloc_align'
void * aligned_alloc(size_t, size_t) __malloc_like __alloc_align(1)
^~~~~~~~~~~~~
/home/fgh/esp/esp-mdf/esp-idf/make/component_wrapper.mk:285: recipe for target 'asio/asio/src/asio.o' failed
make[1]: *** [asio/asio/src/asio.o] Error 1
/home/fgh/esp/esp-mdf/esp-idf/make/project.mk:530: recipe for target 'component-asio-build' failed
make: *** [component-asio-build] Error 2


It gave warnings but it seems that I can do nothing because I don't know where to download the toolchain with given version...

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: Error when compiling with xtensa-esp32-elf

Postby ESP_Angus » Tue Jul 09, 2019 4:01 am

Thanks for the extra details. I see from the log output you're using ESP-MDF.

Current version of ESP-MDF is based on ESP-IDF V3.2, so you'll need to follow the V3.2 setup guide here:
https://docs.espressif.com/projects/esp-idf/en/v3.2.2/

This version of the guide has the download links for the correct version of the toolchain.

fgh1999
Posts: 7
Joined: Tue Jun 25, 2019 3:25 am

Re: Error when compiling with xtensa-esp32-elf

Postby fgh1999 » Wed Jul 10, 2019 2:43 pm

Thank you for your help but it still dose not fully work...

fgh@ubuntu:~/esp/esp-mdf/examples/function_demo/mwifi/no_router$ make
Toolchain path: /home/fgh/esp/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc
Toolchain version: crosstool-ng-1.22.0-80-g6c4433a
Compiler version: 5.2.0
Python requirements from /home/fgh/esp/esp-mdf/esp-idf/requirements.txt are satisfied.
CC build/main/no_router_example.o
/home/fgh/esp/esp-mdf/examples/function_demo/mwifi/no_router/main/no_router_example.c:25:24: fatal error: mdf_common.h: No such file or directory
compilation terminated.
/home/fgh/esp/esp-mdf/esp-idf/make/component_wrapper.mk:285: recipe for target 'no_router_example.o' failed
make[1]: *** [no_router_example.o] Error 1
/home/fgh/esp/esp-mdf/esp-idf/make/project.mk:530: recipe for target 'component-main-build' failed
make: *** [component-main-build] Error 2

jspark311
Posts: 7
Joined: Tue Feb 21, 2017 9:40 am

Re: Error when compiling with xtensa-esp32-elf

Postby jspark311 » Tue Jul 16, 2019 6:16 am

I'm having this problem as well, following update to ESP-IDF (master branch), and upgrade of the compiler. I read This github issue: https://github.com/micropython/micropython/issues/4850.

Do I really need to downgrade crosstool-ng to 1.22? That's harsh, if so. Any advice?

  1. $ ct-ng
  2. This is crosstool-NG version 1.24.0
  3.  
  4. $ xtensa-esp32-elf-gcc -v
  5. Using built-in specs.
  6. COLLECT_GCC=xtensa-esp32-elf-gcc
  7. COLLECT_LTO_WRAPPER=/opt/esp/xtensa-esp32-elf/bin/../libexec/gcc/xtensa-esp32-elf/8.2.0/lto-wrapper
  8. Target: xtensa-esp32-elf
  9. Configured with: /builds/idf/crosstool-NG/.build/xtensa-esp32-elf/src/gcc/configure --build=x86_64-build_pc-linux-gnu --host=x86_64-build_pc-linux-gnu --target=xtensa-esp32-elf --prefix=/builds/idf/crosstool-NG/builds/xtensa-esp32-elf --with-local-prefix=/builds/idf/crosstool-NG/builds/xtensa-esp32-elf/xtensa-esp32-elf --with-headers=/builds/idf/crosstool-NG/builds/xtensa-esp32-elf/xtensa-esp32-elf/include --with-newlib --enable-threads=no --disable-shared --with-pkgversion='crosstool-NG esp32-2019r1' --disable-__cxa_atexit --enable-cxx-flags='-fno-rtti -ffunction-sections' --disable-libgomp --disable-libmudflap --disable-libmpx --disable-libssp --disable-libquadmath --disable-libquadmath-support --with-gmp=/builds/idf/crosstool-NG/.build/xtensa-esp32-elf/buildtools --with-mpfr=/builds/idf/crosstool-NG/.build/xtensa-esp32-elf/buildtools --with-mpc=/builds/idf/crosstool-NG/.build/xtensa-esp32-elf/buildtools --with-isl=/builds/idf/crosstool-NG/.build/xtensa-esp32-elf/buildtools --enable-lto --enable-target-optspace --without-long-double-128 --disable-nls --enable-multiarch --enable-languages=c,c++ --disable-libstdcxx-verbose --enable-threads=posix --enable-gcov-custom-rtio --enable-libstdcxx-time=yes
  10. Thread model: posix
  11. gcc version 8.2.0 (crosstool-NG esp32-2019r1)

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: Error when compiling with xtensa-esp32-elf

Postby ESP_Angus » Tue Jul 16, 2019 7:25 am

jspark311 wrote:
Tue Jul 16, 2019 6:16 am
Do I really need to downgrade crosstool-ng to 1.22? That's harsh, if so. Any advice?
You don't need to use crosstool-ng at all unless you want to build your own toolchain, but you will need to install an earlier toolchain version (gcc 5.2.0) that was built with crosstool-ng 1.22.

You can find this by following the Getting Started guide for the current stable release (v3.2.2):
https://docs.espressif.com/projects/esp-idf/en/stable/

jspark311
Posts: 7
Joined: Tue Feb 21, 2017 9:40 am

Re: Error when compiling with xtensa-esp32-elf

Postby jspark311 » Wed Jul 17, 2019 1:12 am

ESP_Angus, thanks for your help but following your instructions causes this output (which is why I upgraded to 8.2 in the first place).

Code: Select all

$ make
Toolchain path: /opt/esp/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc
WARNING: Toolchain version is not supported: crosstool-ng-1.22.0-80-g6c4433a
Expected to see version: esp32-2019r1
Please check ESP-IDF setup instructions and update the toolchain, or proceed at your own risk.
WARNING: Compiler version is not supported: 5.2.0
Expected to see version(s): 8.2.0
Please check ESP-IDF setup instructions and update the toolchain, or proceed at your own risk.
Python requirements from /opt/esp/requirements.txt are satisfied.
WARNING: Toolchain version is not supported: crosstool-ng-1.22.0-80-g6c4433a
Expected to see version: esp32-2019r1
Please check ESP-IDF setup instructions and update the toolchain, or proceed at your own risk.
WARNING: Compiler version is not supported: 5.2.0
Expected to see version(s): 8.2.0
Please check ESP-IDF setup instructions and update the toolchain, or proceed at your own risk.
It builds. But not without lots of noise and disclaimer. Any idea how to rectify this?

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: Error when compiling with xtensa-esp32-elf

Postby ESP_Angus » Wed Jul 17, 2019 1:17 am

What version of IDF do you have and how did you get the IDF code (via Micropython or a standalone git clone or some other method)?

If you're using ESP-IDF master branch (v4.0-dev), then you will need gcc 8.2.0 for this. For earlier ESP-IDF versions (v3.x, such as the version shipped with MicroPython) then you will need gcc 5.2.0.

jspark311
Posts: 7
Joined: Tue Feb 21, 2017 9:40 am

Re: Error when compiling with xtensa-esp32-elf

Postby jspark311 » Wed Jul 17, 2019 1:51 am

Stand-alone git request. Pulled fresh last night. By your hypothesis, I'm on 4.0. I will revert to latest 3.x and report back. Thanks again, ESP_Angus. :-)

Code: Select all

$ git log
commit fdab15dc76a3464ed10ce03e9b9cf1a5cd2aa0d1 (HEAD -> master, origin/master, origin/HEAD)
Merge: 6ae352c3a 8f2d13d9d
Author: Jiang Jiang Jian <jack@espressif.com>
Date:   Mon Jul 15 12:41:59 2019 +0800

    Merge branch 'bugfix/modify_wifi_country_struct' into 'master'
    
    esp32: make wifi_country_t in idf consistent with VNC
    
    See merge request espressif/esp-idf!5463

Who is online

Users browsing this forum: No registered users and 142 guests