Compile fails esphal.h: No such file or directory

I’m attempting to compile a yaml inside esphome (2022.6.2) running as an add-on in Home assistant OS (core-2022.6.7). However, whenever i try to compile the yaml, it errors out and terminates the compilation due to “No such file or directory” referring to esphal.h. This is quite confusing to me, as i can navigate to the file’s location in the github repository the yaml is pointing at and can see the file just fine.

I’m quite new to home assistant and esphome, so this might be a bit of an ambitious first project for me, but any help with this would be greatly appreciated. A copy of the yaml, error logs, and a couple links to relevant github files are below. I’d be happy to provide any other necessary files or info.

Hardware: Raspberry Pi4, Nodemcu-32s and tmc2209
YAML:

substitutions:
  device_name: val-1000
  pulley_diameter_mm: "12.2" # 1 turn about 47 mm
  gear_ratio: "1" # not used yet for simplicity
  distance_mm: "600" # about 10 turns
  acceleration: 600 steps/s^2
  velocity: 600 steps/s # 1 turn per second
  open_current: 800ma
  open_stall_threshold: "20"
  close_current: 800ma
  close_stall_threshold: "20"
  tcool_threshold: "910"
  microsteps: "2"
  change_direction: "True"

external_components:
  source: github://glmnet/esphome@stepper-tmc2209
  components: [tmc2209]

esphome:
  name: ${device_name}
  platform: ESP32
  board: nodemcu-32s
  platformio_options:
    upload_speed: 921600

  on_boot:
    - tmc2209.setup:
        microsteps: 2
        tcool_threshold: ${tcool_threshold}
        current: 600mA
        stall_threshold: 20

wifi:
  ssid: SSID
  password: PASSWWORD

# Enable logging
logger:
  level: INFO

# verbose logger over uart causes motor artifacts as pulses are generated in main loop
# logger:
#   level: VERY_VERBOSE
#   logs:
#     api: DEBUG
#     api.service: DEBUG
#     scheduler: DEBUG

ota:

uart:
  id: uart_stepper
  tx_pin: GPIO17
  rx_pin: GPIO16
  baud_rate: 9600

status_led:
  pin: GPIO26

api:
  services:
    - service: control_stepper
      variables:
        target: int
        speed: int
        microsteps: int
        tcool_threshold: int
        stall_threshold: int
        rms_current_amps: float
      then:
        - tmc2209.setup:
            id: my_stepper
            microsteps: !lambda "return microsteps;"
            tcool_threshold: !lambda "return tcool_threshold;"
            stall_threshold: !lambda "return stall_threshold;"
            current: !lambda "return rms_current_amps;"
        - logger.log:
            format: moving to %d
            args: [target]
        - stepper.set_speed:
            id: my_stepper
            speed: !lambda "return speed;"
        - stepper.set_target:
            id: my_stepper
            target: !lambda "return target;"
    - service: set_stepper_zero
      then:
        - stepper.report_position:
            id: my_stepper
            position: 0
        - stepper.set_target:
            id: my_stepper
            target: 0
            
binary_sensor:
  - platform: gpio
    name: Button1
    pin:
      number: GPIO23
      inverted: true
      mode: INPUT
    on_press:
      then:
        - cover.open:
            id: template_cov
        
  - platform: gpio
    name: Button2
    pin:
      number: GPIO34
      inverted: true
      mode: INPUT
    on_press:
      then:
        - cover.close:
            id: template_cov

  - platform: gpio
    name: Sensor1
    pin:
      number: GPIO22
      inverted: true
  - platform: gpio
    name: SensorGPIO0
    pin:
      number: GPIO0
      inverted: true
  - platform: gpio
    name: Sensor2
    pin:
      number: GPIO32
      inverted: true
  - platform: gpio
    id: stall_guard_sensor
    name: StallGuard
    pin: GPIO2
    on_press:
      script.execute: stop_at_current_position

stepper:
  - platform: tmc2209
    id: my_stepper

    step_pin: GPIO13
    dir_pin: 
      number: GPIO14
      inverted: ${change_direction}

    sleep_pin:
      number: GPIO27
      inverted: true
    
    acceleration: ${acceleration}
    max_speed: ${velocity}

script:
  - id: stop_at_current_position
    then:
      stepper.set_target:
        id: my_stepper
        target: !lambda "return id(my_stepper).current_position;"

globals:
  - id: open_position
    type: float
    initial_value: ${distance_mm} / (${pulley_diameter_mm} * PI) * 200 * ${microsteps}

cover:
  - platform: template
    id: template_cov
    name: "${device_name} cover"
    
    open_action:
      - tmc2209.setup:
          current: ${open_current}
          stall_threshold: ${open_stall_threshold}
          microsteps: 2
      - stepper.set_target:
          id: my_stepper
          target: !lambda "return id(open_position);"

    close_action:
      - tmc2209.setup:
          current: ${close_current}
          stall_threshold: ${close_stall_threshold}
          microsteps: 2
      - stepper.set_target:
          id: my_stepper
          # 0 Means closed
          target: 0

    position_action:
      - stepper.set_target:
          id: my_stepper
          target: !lambda "return id(open_position) * pos;"

    stop_action:
      - script.execute: stop_at_current_position

interval:
  interval: 5s
  then:
    lambda: |-
      static auto operation = COVER_OPERATION_IDLE;
      static auto position = id(my_stepper).current_position;
      if (operation != id(template_cov).current_operation ||
          position != id(my_stepper).current_position)
      {
        ESP_LOGD("main", "Stepper Position is: %d/%d", id(my_stepper).current_position, (int)id(open_position));
        if (id(my_stepper).current_position > id(my_stepper).target_position)
          operation = COVER_OPERATION_CLOSING;
        else if (id(my_stepper).current_position < id(my_stepper).target_position)
          operation = COVER_OPERATION_OPENING;
        else
          operation = COVER_OPERATION_IDLE;
        id(template_cov).current_operation = operation;

        position =  id(my_stepper).current_position;
        id(template_cov).position = position / id(open_position);

        id(template_cov).publish_state();
      }

Compile Log:

INFO Reading configuration /config/esphome/val-1000.yaml...
WARNING GPIO0 is a Strapping PIN and should be avoided.
Attaching external pullup/down resistors to strapping pins can cause unexpected failures.
See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins
WARNING GPIO2 is a Strapping PIN and should be avoided.
Attaching external pullup/down resistors to strapping pins can cause unexpected failures.
See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins
INFO Generating C++ source...
INFO Compiling app...
Processing val-1000 (board: nodemcu-32s; framework: arduino; platform: platformio/espressif32 @ 3.5.0)
--------------------------------------------------------------------------------
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
Library Manager: Installing teemuatlut/TMCStepper @ 0.7.1

Unpacking  [------------------------------------]    0%
Unpacking  [------------------------------------]    1%
Unpacking  [#-----------------------------------]    3%
Unpacking  [##----------------------------------]    5%
Unpacking  [##----------------------------------]    7%
Unpacking  [###---------------------------------]    9%
Unpacking  [####--------------------------------]   11%
Unpacking  [####--------------------------------]   13%
Unpacking  [#####-------------------------------]   15%
Unpacking  [######------------------------------]   16%
Unpacking  [######------------------------------]   18%
Unpacking  [#######-----------------------------]   20%
Unpacking  [########----------------------------]   22%
Unpacking  [########----------------------------]   24%
Unpacking  [#########---------------------------]   26%
Unpacking  [##########--------------------------]   28%
Unpacking  [##########--------------------------]   30%
Unpacking  [###########-------------------------]   32%
Unpacking  [############------------------------]   33%
Unpacking  [############------------------------]   35%
Unpacking  [#############-----------------------]   37%
Unpacking  [##############----------------------]   39%
Unpacking  [##############----------------------]   41%
Unpacking  [###############---------------------]   43%
Unpacking  [################--------------------]   45%
Unpacking  [################--------------------]   47%
Unpacking  [#################-------------------]   49%
Unpacking  [##################------------------]   50%
Unpacking  [###################-----------------]   52%
Unpacking  [###################-----------------]   54%
Unpacking  [####################----------------]   56%
Unpacking  [#####################---------------]   58%
Unpacking  [#####################---------------]   60%
Unpacking  [######################--------------]   62%
Unpacking  [#######################-------------]   64%
Unpacking  [#######################-------------]   66%
Unpacking  [########################------------]   67%
Unpacking  [#########################-----------]   69%
Unpacking  [#########################-----------]   71%
Unpacking  [##########################----------]   73%
Unpacking  [###########################---------]   75%
Unpacking  [###########################---------]   77%
Unpacking  [############################--------]   79%
Unpacking  [#############################-------]   81%
Unpacking  [#############################-------]   83%
Unpacking  [##############################------]   84%
Unpacking  [###############################-----]   86%
Unpacking  [###############################-----]   88%
Unpacking  [################################----]   90%
Unpacking  [#################################---]   92%
Unpacking  [#################################---]   94%
Unpacking  [##################################--]   96%
Unpacking  [###################################-]   98%
Unpacking  [####################################]  100%
Library Manager: TMCStepper @ 0.7.1 has been installed!
Dependency Graph
|-- <WiFi> 1.0
|-- <ESPmDNS> 1.0
|-- <Update> 1.0
|-- <TMCStepper> 0.7.1
Compiling /data/val-1000/.pioenvs/val-1000/src/esphome/components/api/api_connection.cpp.o
Compiling /data/val-1000/.pioenvs/val-1000/src/esphome/components/api/api_frame_helper.cpp.o
Compiling /data/val-1000/.pioenvs/val-1000/src/esphome/components/api/api_pb2.cpp.o
Compiling /data/val-1000/.pioenvs/val-1000/src/esphome/components/api/api_pb2_service.cpp.o
Compiling /data/val-1000/.pioenvs/val-1000/src/esphome/components/api/api_server.cpp.o
Compiling /data/val-1000/.pioenvs/val-1000/src/esphome/components/api/list_entities.cpp.o
Compiling /data/val-1000/.pioenvs/val-1000/src/esphome/components/api/proto.cpp.o
Compiling /data/val-1000/.pioenvs/val-1000/src/esphome/components/api/subscribe_state.cpp.o
Compiling /data/val-1000/.pioenvs/val-1000/src/esphome/components/api/user_services.cpp.o
Compiling /data/val-1000/.pioenvs/val-1000/src/esphome/components/binary_sensor/automation.cpp.o
Compiling /data/val-1000/.pioenvs/val-1000/src/esphome/components/binary_sensor/binary_sensor.cpp.o
Compiling /data/val-1000/.pioenvs/val-1000/src/esphome/components/binary_sensor/filter.cpp.o
Compiling /data/val-1000/.pioenvs/val-1000/src/esphome/components/cover/cover.cpp.o
Compiling /data/val-1000/.pioenvs/val-1000/src/esphome/components/esp32/core.cpp.o
Compiling /data/val-1000/.pioenvs/val-1000/src/esphome/components/esp32/gpio_arduino.cpp.o
Compiling /data/val-1000/.pioenvs/val-1000/src/esphome/components/esp32/gpio_idf.cpp.o
Compiling /data/val-1000/.pioenvs/val-1000/src/esphome/components/esp32/preferences.cpp.o
Compiling /data/val-1000/.pioenvs/val-1000/src/esphome/components/gpio/binary_sensor/gpio_binary_sensor.cpp.o
Compiling /data/val-1000/.pioenvs/val-1000/src/esphome/components/logger/logger.cpp.o
Compiling /data/val-1000/.pioenvs/val-1000/src/esphome/components/md5/md5.cpp.o
Compiling /data/val-1000/.pioenvs/val-1000/src/esphome/components/mdns/mdns_component.cpp.o
Compiling /data/val-1000/.pioenvs/val-1000/src/esphome/components/mdns/mdns_esp32_arduino.cpp.o
Compiling /data/val-1000/.pioenvs/val-1000/src/esphome/components/mdns/mdns_esp8266.cpp.o
Compiling /data/val-1000/.pioenvs/val-1000/src/esphome/components/mdns/mdns_esp_idf.cpp.o
Compiling /data/val-1000/.pioenvs/val-1000/src/esphome/components/network/util.cpp.o
Compiling /data/val-1000/.pioenvs/val-1000/src/esphome/components/ota/ota_backend_arduino_esp32.cpp.o
Compiling /data/val-1000/.pioenvs/val-1000/src/esphome/components/ota/ota_backend_arduino_esp8266.cpp.o
Compiling /data/val-1000/.pioenvs/val-1000/src/esphome/components/ota/ota_backend_esp_idf.cpp.o
Compiling /data/val-1000/.pioenvs/val-1000/src/esphome/components/ota/ota_component.cpp.o
Compiling /data/val-1000/.pioenvs/val-1000/src/esphome/components/script/script.cpp.o
Compiling /data/val-1000/.pioenvs/val-1000/src/esphome/components/socket/bsd_sockets_impl.cpp.o
Compiling /data/val-1000/.pioenvs/val-1000/src/esphome/components/socket/lwip_raw_tcp_impl.cpp.o
Compiling /data/val-1000/.pioenvs/val-1000/src/esphome/components/socket/socket.cpp.o
Compiling /data/val-1000/.pioenvs/val-1000/src/esphome/components/status_led/status_led.cpp.o
Compiling /data/val-1000/.pioenvs/val-1000/src/esphome/components/stepper/stepper.cpp.o
Compiling /data/val-1000/.pioenvs/val-1000/src/esphome/components/template/cover/template_cover.cpp.o
Compiling /data/val-1000/.pioenvs/val-1000/src/esphome/components/tmc2209/tmc2209.cpp.o
In file included from src/esphome/components/tmc2209/tmc2209.cpp:1:0:
src/esphome/components/tmc2209/tmc2209.h:4:33: fatal error: esphome/core/esphal.h: No such file or directory
compilation terminated.
*** [/data/val-1000/.pioenvs/val-1000/src/esphome/components/tmc2209/tmc2209.cpp.o] Error 1
========================= [FAILED] Took 34.61 seconds =========================

Thank you again for any advice y’all can provide, I’ve been pulling my hair out at this for a few days now.

Hey, did you figure it out? I’m stuck in the same place.

did someone get it to work?