esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
290 stars 36 forks source link

fatal error: Arduino.h: No such file or directory when compiling for rp2040 on mac m1 #3989

Closed gepatto closed 1 year ago

gepatto commented 1 year ago

The problem

Esphome installed through pip on a Mac M1 (Ventura 13.1) throws: fatal error: Arduino.h: No such file or directory when compiling for the rp2040

Tried reinstalling and installing with brew as an alternative, but gives the same error.

Which version of ESPHome has the issue?

2022.12.3

What type of installation are you using?

pip

Which version of Home Assistant has the issue?

No response

What platform are you using?

RP2040

Board

picow

Component causing the issue

No response

Example YAML snippet

esphome:
  name: picow

rp2040:
  board: pico

output:
  - platform: gpio
    pin:
      number: 25
      mode: output
    id: LED

interval:
  - interval: 500ms
    then:
    - output.turn_on: LED
    - delay: 250ms
    - output.turn_off: LED

Anything in the logs that might be useful for us?

esphome compile pico.yaml
INFO Reading configuration pico.yaml...
INFO Generating C++ source...
INFO Compiling app...
Processing picow (board: pico; framework: arduino; platform: platformio/raspberrypi @ 1.7.0)
----------------------------------------------------------------------------------------------------------------------------------------------------------------
HARDWARE: RP2040 133MHz, 264KB RAM, 2MB Flash
 - framework-arduino-mbed @ 3.1.1
 - framework-arduinopico @ 1.20604.0 (2.6.4)
 - tool-rp2040tools @ 1.0.2
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
Dependency Graph
|-- WiFi @ 1.0
|   |-- SocketWrapper @ 1.0
Compiling .pioenvs/picow/src/esphome/components/rp2040/core.cpp.o
Compiling .pioenvs/picow/src/esphome/components/rp2040/gpio.cpp.o
Compiling .pioenvs/picow/src/esphome/components/rp2040/preferences.cpp.o
Compiling .pioenvs/picow/src/esphome/core/helpers.cpp.o
Compiling .pioenvs/picow/src/main.cpp.o
Generating LD script .pioenvs/picow/cpp.linker_script.ld
Compiling .pioenvs/picow/lib008/SocketWrapper/MbedClient.cpp.o
Compiling .pioenvs/picow/lib008/SocketWrapper/MbedSSLClient.cpp.o
Compiling .pioenvs/picow/lib008/SocketWrapper/MbedServer.cpp.o
Compiling .pioenvs/picow/lib008/SocketWrapper/MbedUdp.cpp.o
Compiling .pioenvs/picow/lib008/SocketWrapper/SocketHelpers.cpp.o
In file included from /Users/REDACTEDUSERNAME/.platformio/packages/framework-arduino-mbed/libraries/SocketWrapper/src/MbedServer.cpp:1:
/Users/REDACTEDUSERNAME/.platformio/packages/framework-arduino-mbed/libraries/SocketWrapper/src/MbedServer.h:20:10: fatal error: Arduino.h: No such file or directory

*****************************************************************
* Looking for Arduino.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:Arduino.h"
* Web  > https://registry.platformio.org/search?q=header:Arduino.h
*
*****************************************************************

   20 | #include "Arduino.h"
      |          ^~~~~~~~~~~
In file included from src/esphome/components/rp2040/gpio.cpp:3:
src/esphome/components/rp2040/gpio.h:5:10: fatal error: Arduino.h: No such file or directory

*****************************************************************
* Looking for Arduino.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:Arduino.h"
* Web  > https://registry.platformio.org/search?q=header:Arduino.h
*
*****************************************************************

    5 | #include <Arduino.h>
      |          ^~~~~~~~~~~
src/esphome/components/rp2040/preferences.cpp:3:10: fatal error: Arduino.h: No such file or directory

*****************************************************************
* Looking for Arduino.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:Arduino.h"
* Web  > https://registry.platformio.org/search?q=header:Arduino.h
*
*****************************************************************

    3 | #include <Arduino.h>
      |          ^~~~~~~~~~~
In file included from /Users/REDACTEDUSERNAME/.platformio/packages/framework-arduino-mbed/libraries/SocketWrapper/src/MbedSSLClient.h:23,
                 from /Users/REDACTEDUSERNAME/.platformio/packages/framework-arduino-mbed/libraries/SocketWrapper/src/MbedSSLClient.cpp:1:
/Users/REDACTEDUSERNAME/.platformio/packages/framework-arduino-mbed/libraries/SocketWrapper/src/MbedClient.h:23:10: fatal error: Arduino.h: No such file or directory

*****************************************************************
* Looking for Arduino.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:Arduino.h"
* Web  > https://registry.platformio.org/search?q=header:Arduino.h
*
*****************************************************************

   23 | #include "Arduino.h"
      |          ^~~~~~~~~~~
In file included from /Users/REDACTEDUSERNAME/.platformio/packages/framework-arduino-mbed/libraries/SocketWrapper/src/MbedClient.cpp:1:
/Users/REDACTEDUSERNAME/.platformio/packages/framework-arduino-mbed/libraries/SocketWrapper/src/MbedClient.h:23:10: fatal error: Arduino.h: No such file or directory

*****************************************************************
* Looking for Arduino.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:Arduino.h"
* Web  > https://registry.platformio.org/search?q=header:Arduino.h
*
*****************************************************************

   23 | #include "Arduino.h"
      |          ^~~~~~~~~~~
In file included from src/esphome/components/rp2040/core.cpp:3:
src/esphome/components/rp2040/core.h:5:10: fatal error: Arduino.h: No such file or directory

*****************************************************************
* Looking for Arduino.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:Arduino.h"
* Web  > https://registry.platformio.org/search?q=header:Arduino.h
*
*****************************************************************

    5 | #include <Arduino.h>
      |          ^~~~~~~~~~~
In file included from /Users/REDACTEDUSERNAME/.platformio/packages/framework-arduino-mbed/libraries/SocketWrapper/src/MbedUdp.cpp:1:
/Users/REDACTEDUSERNAME/.platformio/packages/framework-arduino-mbed/libraries/SocketWrapper/src/MbedUdp.h:23:10: fatal error: Arduino.h: No such file or directory

*****************************************************************
* Looking for Arduino.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:Arduino.h"
* Web  > https://registry.platformio.org/search?q=header:Arduino.h
*
*****************************************************************

   23 | #include "Arduino.h"
      |          ^~~~~~~~~~~
compilation terminated.
compilation terminated.
compilation terminated.
compilation terminated.
compilation terminated.
compilation terminated.
compilation terminated.
*** [.pioenvs/picow/lib008/SocketWrapper/MbedSSLClient.cpp.o] Error 1
*** [.pioenvs/picow/src/esphome/components/rp2040/preferences.cpp.o] Error 1
*** [.pioenvs/picow/src/esphome/components/rp2040/gpio.cpp.o] Error 1
*** [.pioenvs/picow/lib008/SocketWrapper/MbedClient.cpp.o] Error 1
*** [.pioenvs/picow/lib008/SocketWrapper/MbedServer.cpp.o] Error 1
*** [.pioenvs/picow/src/esphome/components/rp2040/core.cpp.o] Error 1
*** [.pioenvs/picow/lib008/SocketWrapper/MbedUdp.cpp.o] Error 1
In file included from /Users/REDACTEDUSERNAME/.platformio/packages/framework-arduino-mbed/libraries/SocketWrapper/src/SocketHelpers.cpp:1:
/Users/REDACTEDUSERNAME/.platformio/packages/framework-arduino-mbed/libraries/SocketWrapper/src/SocketHelpers.h:20:10: fatal error: Arduino.h: No such file or directory

*****************************************************************
* Looking for Arduino.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:Arduino.h"
* Web  > https://registry.platformio.org/search?q=header:Arduino.h
*
*****************************************************************

   20 | #include "Arduino.h"
      |          ^~~~~~~~~~~
compilation terminated.
*** [.pioenvs/picow/lib008/SocketWrapper/SocketHelpers.cpp.o] Error 1
src/esphome/core/helpers.cpp:28:10: fatal error: hardware/structs/rosc.h: No such file or directory
   28 | #include <hardware/structs/rosc.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
In file included from src/esphome.h:8,
                 from src/main.cpp:3:
src/esphome/components/rp2040/core.h:5:10: fatal error: Arduino.h: No such file or directory

*****************************************************************
* Looking for Arduino.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:Arduino.h"
* Web  > https://registry.platformio.org/search?q=header:Arduino.h
*
*****************************************************************

    5 | #include <Arduino.h>
      |          ^~~~~~~~~~~
compilation terminated.
*** [.pioenvs/picow/src/esphome/core/helpers.cpp.o] Error 1
*** [.pioenvs/picow/src/main.cpp.o] Error 1
================================================================== [FAILED] Took 0.98 seconds ==================================================================

Additional information

FIles in the build directory:

Screenshot 2022-12-30 at 11 49 07

Generated platformio.ini

; Auto generated code by esphome

[common]
lib_deps =
build_flags =
upload_flags =

; ========== AUTO GENERATED CODE BEGIN ===========
[env:picow]
board = pico
board_build.core = earlephilhower
board_build.filesystem_size = 1m
build_flags =
    -DUSE_ARDUINO
    -DUSE_RP2040
    -DUSE_RP2040_FRAMEWORK_ARDUINO
    -Wno-sign-compare
    -Wno-unused-but-set-variable
    -Wno-unused-variable
    -fno-exceptions
framework = arduino
lib_deps =
    ${common.lib_deps}
platform = platformio/raspberrypi @ 1.7.0
platform_packages =
    earlephilhower/framework-arduinopico @ https://github.com/earlephilhower/arduino-pico/releases/download/2.6.4/rp2040-2.6.4.zip
; =========== AUTO GENERATED CODE END ============
Deishelon commented 1 year ago

Same issue on Linux:

(esp_venv) $:~/projects/pico-esphome$ esphome version
Version: 2022.12.3
(esp_venv) $:~/projects/pico-esphome$ python --version
Python 3.10.6
ssieb commented 1 year ago

You need:

rp2040:
  board: pico
  framework:
    platform_version: https://github.com/maxgerhardt/platform-raspberrypi.git
grokbeer commented 1 year ago

Thanks for raising this issue @gepatto as I was struggling with this too and thought I'd tried everything. As @ssieb commented, the fix is to override the platform_version. This will be required until https://github.com/platformio/platform-raspberrypi/pull/36 is merged.

It looks like you're using a Pico W so there's a couple of other changes to your YAML you'll need as well. The "board" for Pico W is "rpipicow" and the on-board LED is accessed via GPIO pin 32 rather than 25 for the Pico.

See @geerlingguy's https://github.com/geerlingguy/pico-w-garage-door-sensor/blob/master/led-blink.yml for an updated led-blink.yml for the Pico W.

gepatto commented 1 year ago

Thank you ! @ssieb and @grokbeer . It's working now :)