platformio / platform-espressif32

Espressif 32: development platform for PlatformIO
https://registry.platformio.org/platforms/platformio/espressif32
Apache License 2.0
913 stars 621 forks source link

ESP32 - Cannot find libhal on VS Code #656

Closed Kampi closed 2 years ago

Kampi commented 3 years ago

I try to compile an espidf / Arduino project with PlatformIO (v2.3.4) and VS Code (1.61.2) on a Windows OS (10) and I got this error during the linking stage:

Tool Manager: Installing tool-mkspiffs @ ~2.230.0
Downloading  [####################################]  100%
Unpacking  [####################################]  100%
Tool Manager: tool-mkspiffs @ 2.230.0 has been installed!
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
PLATFORM: Espressif 32 (1.12.4) > Espressif ESP32 Dev Module
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
 - framework-arduinoespressif32 0.0.0+sha.3616c2e
 - framework-espidf 3.40001.200521 (4.0.1)
 - tool-cmake 3.16.4
 - tool-esptoolpy 1.20600.0 (2.6.0)
 - tool-idf 1.0.1
 - tool-mconf 1.4060000.20190628 (406.0.0)
 - tool-mkspiffs 2.230.0 (2.30)
 - tool-ninja 1.9.0
 - toolchain-esp32ulp 1.22851.191205 (2.28.51)
 - toolchain-xtensa32 3.80200.200512 (8.2.0)
Reading CMake configuration...
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 2 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <ArduinoJson> 6.18.5
|-- <RAK3172> 1.5.0+sha.d36577e
Building in debug mode
Linking .pio\build\debug\bootloader.elf
.../.platformio/packages/toolchain-xtensa32/bin/../lib/gcc/xtensa-esp32-elf/8.2.0/../../../../xtensa-esp32-elf/bin/ld.exe: cannot find -l....platformiopackagesframework-espidfcomponentsxtensaesp32libhal
collect2.exe: error: ld returned 1 exit status
Archiving .pio\build\debug\lib031\libRAK3172.a
*** [.pio\build\debug\bootloader.elf] Error 1
Indexing .pio\build\debug\lib031\libRAK3172.a
=========================================================== [FAILED] Took 15.08 seconds ===========================================================
Der Terminalprozess "...\.platformio\penv\Scripts\platformio.exe 'run', '--target', 'upload'" wurde mit folgendem Exitcode beendet: 1.

It looks like that the path for the linker isn´t resolved correctly.

Jason2866 commented 2 years ago

Your used framework

- framework-arduinoespressif32 0.0.0+sha.3616c2e
 - framework-espidf 3.40001.200521 (4.0.1)

needs the actual gcc compiler. 8.2.0 is too old. In short your platformio setup is wrong

Kampi commented 2 years ago

Hi,

I use the same framework on another PC and everything is compiling without any issues, so I don´t think that there is a problem with the framework.

Jason2866 commented 2 years ago

Wirhout your complete setup only guess work can be done

Kampi commented 2 years ago

What exactly do you need?

Jason2866 commented 2 years ago

All Platformio entrys

Kampi commented 2 years ago

Where do I find them?

MLStoltzenburg commented 2 years ago

Hi, I have been the same problem! I don't know what or why this happened! I use this configuration file for months.

I just reinstall the PlatformIO.

The only diference this file for original is I put the newer compiler to test, after I read this issue, but I got the same problem.


Error:

Generating project linker script .pio\build\poc\esp32.project.ld Compiling .pio\build\poc\lib09c\EthernetENC\utility\uip.c.o Archiving .pio\build\poc\bootloader\esp-idf\micro-ecc\libmicro-ecc.a Linking .pio\build\poc\bootloader.elf c:/users/mlstoltzenburg/.platformio/packages/toolchain-xtensa32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: cannot find -lUsersMLStoltzenburg.platformiopackagesframework-espidfcomponentsxtensaesp32libhal collect2.exe: error: ld returned 1 exit status *** [.pio\build\poc\bootloader.elf] Error 1


PlatformIO Core, version 5.2.2

VSCode:

Versão: 1.61.2 (system setup) Confirmar: 6cba118ac49a1b88332f312a8f67186f7f3c1643 Data: 2021-10-19T14:57:20.575Z Electron: 13.5.1 Chrome: 91.0.4472.164 Node.js: 14.16.0 V8: 9.1.269.39-electron.0 SO: Windows_NT x64 10.0.22000


[env:poc] platform = https://github.com/platformio/platform-espressif32.git#feature/idf-v4.0 framework = arduino, espidf board = esp32dev

platform_packages = toolchain-xtensa32 @ 2.80400.210211 framework-arduinoespressif32 @ https://github.com/marcovannoord/arduino-esp32.git#idf-release/v4.0

lib_deps = PubSubClient@>=2.8 ESP32Ping@>=1.5 ArduinoJson@>=6.16.0 CRC32@>=2.0.0 Adafruit BME280 Library@>=2.0.2 adafruit/DHT sensor library@^1.4.2 adafruit/RTClib @ ^1.14.1

build_flags = -DESP32=1 -DARDUINO=10805 -DARDUINO_ARCH_ESP32=1 -std=gnu++17 -L./libdeps -lalgobsec build_unflags = -std=gnu++11 monitor_speed = 115200 upload_protocol = esptool board_build.partitions = partitions_4MB.csv monitor_port = COM4 upload_port= COM4


Jason2866 commented 2 years ago

@MLStoltzenburg toolchain-xtensa32 @ 2.80400.210211 is to old when you use Arduino framework based on IDF4.x Use the actual toolchains 8.4.0+2021r1 for. Your setup is problematic in general. Arduino ESP32 does only support IDF4.4 as underlying base. You should rethink / refactor your setup

Jason2866 commented 2 years ago

This setup is working for actual Arduino32 based on IDF4.4

platform                = https://github.com/platformio/platform-espressif32.git#feature/arduino-idf-master
platform_packages       = framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#2.0.1-RC1

There are no build flags needed to adjust gcc

Jason2866 commented 2 years ago

@valeros imho it would be a good idea to remove Arduino support from branch idf-release/v4.0 since it is not supported and very very old. Or drop the complete branch since IDF4.0 isnt a good choice anymore too. At least update to latest version.

MLStoltzenburg commented 2 years ago

@Jason2866 Hi, I rethought my setup a few days ago and now I put the arduino as a component in the IDF. I also updated my solution to IDF 4.3.

Your advice showed me I followed right way.

Thank you for the advice.

Kampi commented 2 years ago

framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#2.0.1-RC1

But this is Arduino only. It doesn´t work with esp-idf and Arduino.

Warning! Arduino framework as an ESP-IDF component doesn't handle the `variant` field! The default `esp32` variant will be used.
Reading CMake configuration...
-- mconf-idf version mconf-v4.6.0.0-idf-20190628-win32
-- The C compiler identification is GNU 8.4.0
-- The CXX compiler identification is GNU 8.4.0
-- The ASM compiler identification is GNU
-- Found assembler: C:/Users/Danie/.platformio/packages/toolchain-xtensa32/bin/xtensa-esp32-elf-gcc.exe
-- Check for working C compiler: C:/Users/Danie/.platformio/packages/toolchain-xtensa32/bin/xtensa-esp32-elf-gcc.exe
-- Check for working C compiler: C:/Users/Danie/.platformio/packages/toolchain-xtensa32/bin/xtensa-esp32-elf-gcc.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/Users/Danie/.platformio/packages/toolchain-xtensa32/bin/xtensa-esp32-elf-g++.exe
-- Check for working CXX compiler: C:/Users/Danie/.platformio/packages/toolchain-xtensa32/bin/xtensa-esp32-elf-g++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Project is not inside a git repository, or git repository has no commits; will not use 'git describe' to determine PROJECT_VER.
-- Project version: 1
-- Building ESP-IDF components for target esp32
-- Configuring incomplete, errors occurred!
See also "D:/Downloads/firmware/.pio/build/debug/CMakeFiles/CMakeOutput.log".
See also "D:/Downloads/firmware/.pio/build/debug/CMakeFiles/CMakeError.log".

fatal: not a git repository (or any of the parent directories): .git
CMake Error at C:/Users/Danie/.platformio/packages/framework-espidf/tools/cmake/build.cmake:185 (message):
  Failed to resolve component 'esp_ipc'.
Call Stack (most recent call first):
  C:/Users/Danie/.platformio/packages/framework-espidf/tools/cmake/build.cmake:216 (__build_resolve_and_add_req)
  C:/Users/Danie/.platformio/packages/framework-espidf/tools/cmake/build.cmake:425 (__build_expand_requirements)
  C:/Users/Danie/.platformio/packages/framework-espidf/tools/cmake/project.cmake:348 (idf_build_process)
  CMakeLists.txt:4 (project)
mhaberler commented 2 years ago

This setup is working for actual Arduino32 based on IDF4.4

platform                = https://github.com/platformio/platform-espressif32.git#feature/arduino-idf-master
platform_packages       = framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#2.0.1-RC1

There are no build flags needed to adjust gcc

interestingly this does not work for me:

platform                = https://github.com/platformio/platform-espressif32.git#feature/arduino-idf-master
framework = arduino
platform_packages =
    framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#2.0.1-RC1

which causes: /Users/mah/.platformio/packages/toolchain-xtensa32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: final link failed: bad value collect2: error: ld returned 1 exit status *** [.pio/build/m5stack-core2-MacOS/firmware.elf] Error 1

what does work for me is:

platform = https://github.com/platformio/platform-espressif32.git#feature/arduino-upstream
platform_packages =
    framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#2.0.1-RC1
    espressif/toolchain-xtensa-esp32 @ 8.4.0+2021r1
Jason2866 commented 2 years ago

@mhaberler should not be needed. Delete hidden folder .platformio and let platformio rebuild. It will work without the extra entry for the toolchain. Anyway it does no harm and makes sure the needed one is used.

mhaberler commented 2 years ago

@Jason2866 confirmed to work, thanks! example repo: https://github.com/mhaberler/arduino-esp32-bleedingedge-pio

maakbaas commented 2 years ago

Today I did not succeed to do a build of a project that has been running fine for months without changes. Just like @MLStoltzenburg.

Clearly something seems to have been broken. This issue is also raised here: https://community.platformio.org/t/xtensa-esp32-elf-bin-ld-exe-cannot-find-library/23963

If I create a completely empty new project with platformio.ini defined as:

[env:esp32dev]
platform = espressif32@1.12.4
board = esp32dev
framework = espidf

and a c file with an empty app_main() function, I also get this:

.../.platformio/packages/toolchain-xtensa32/bin/../lib/gcc/xtensa-esp32-elf/8.2.0/../../../../xtensa-esp32-elf/bin/ld.exe: cannot find -l....platformiopackagesframework-espidfcomponentsxtensaesp32libhal
collect2.exe: error: ld returned 1 exit status
Jason2866 commented 2 years ago

@Kampi This one works for Arduino v.2.0.2 and IDF4.4

platform = https://github.com/tasmota/platform-espressif32/releases/download/v2.0.2idf/platform-espressif32-2.0.2.zip