formatBCE / Airbnk-MQTTOpenGateway

Gateway to use Airbnk locks with HA custom integration https://github.com/rospogrigio/airbnk_mqtt
GNU Affero General Public License v3.0
12 stars 1 forks source link

I can't install ESPhome on ESP32-C3. #6

Open BurlakovSG opened 1 year ago

BurlakovSG commented 1 year ago

Configuration:

esphome:
  name: airbnk
  platformio_options:
    board_build.f_flash: 40000000L
    board_build.flash_mode: dio
    board_build.flash_size: 4MB
  includes:
    - airbnk-gateway.h
  libraries:
    - "h2zero/NimBLE-Arduino"

esp32:
  variant: ESP32C3
  board: esp32-c3-devkitm-1
  framework:
    type: esp-idf

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "XAGID3V66Sfix9XEi4Y5R3mYm0NQXCqfXsQ2EO1oNSg="

ota:
  password: "096a0bf6b64dee562d161659e67ecee2"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "AirbnkOpenGateway"
    password: "fp5MaNb9uZRm"

mqtt:
  broker: 192.168.1.8e # TODO replace with your MQTT server IP
  username: !secret mqtt_user # TODO replace with your MQTT user or remove
  password: !secret mqtt_password # TODO replace with your MQTT password or remove
  discovery: false

custom_component:
- lambda: |- # TODO replace parameters with your lock mac and HA integration topic
    auto my_node = new AirbnkGatewayNodeComponent("FF:FF:FF:FF:FF:FF", "airbnk");
    return {my_node};  

When compiling I get the following error:

Processing airbnk (board: esp32-c3-devkitm-1; framework: espidf; platform: platformio/espressif32 @ 3.5.0)
--------------------------------------------------------------------------------
HARDWARE: ESP32C3 160MHz, 320KB RAM, 4MB Flash
 - framework-espidf @ 3.40302.0 (4.3.2) 
 - tool-cmake @ 3.16.4 
 - tool-ninja @ 1.7.1 
 - toolchain-riscv32-esp @ 8.4.0+2021r2-patch2 
 - toolchain-xtensa-esp32s2 @ 8.4.0+2021r2-patch2
Reading CMake configuration...
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
Dependency Graph
|-- noise-c @ 0.1.4
|   |-- libsodium @ 1.10018.1
|-- ArduinoJson @ 6.18.5
Compiling /data/airbnk/.pioenvs/airbnk/src/main.o
Compiling /data/airbnk/.pioenvs/airbnk/app_update/esp_app_desc.o
Archiving /data/airbnk/.pioenvs/airbnk/esp-idf/app_update/libapp_update.a
In file included from src/main.cpp:18:
src/airbnk-gateway.h:11: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
*
*****************************************************************

 #include <Arduino.h>
          ^~~~~~~~~~~
compilation terminated.
*** [/data/airbnk/.pioenvs/airbnk/src/main.o] Error 1
Compiling /data/airbnk/.pioenvs/airbnk/asio/asio/asio/src/asio.o
========================== [FAILED] Took 9.42 seconds ==========================
randybb commented 1 year ago

Because esp-idf framework is not arduino, so you have to change that https://esphome.io/components/esp32.html

Probably it will still not like it, so you will need to add some other options (I am running my c3 with these, no idea why :D):

esphome:
  platformio_options:
    platform_packages:
      - framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#2.0.1
    platform:
      - https://github.com/platformio/platform-espressif32.git#feature/arduino-upstream
formatBCE commented 1 year ago

Hey, thanks for reporting.

Yeah, my sketch needs NimBLE from Arduino framework, so used with default ESPHome setup.

Probably, I need to mention that in README.

BurlakovSG commented 1 year ago

Because esp-idf framework is not arduino, so you have to change that https://esphome.io/components/esp32.html

Probably it will still not like it, so you will need to add some other options (I am running my c3 with these, no idea why :D):

esphome:
  platformio_options:
    platform_packages:
      - framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#2.0.1
    platform:
      - https://github.com/platformio/platform-espressif32.git#feature/arduino-upstream

With this parameters:

esphome:
  name: airbnk
  platformio_options:
    board_build.f_flash: 40000000L
    board_build.flash_mode: dio
    board_build.flash_size: 4MB
    platform_packages:
      - framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#master
    platform:
      - https://github.com/platformio/platform-espressif32.git#feature/arduino-upstream
  includes:
    - airbnk-gateway.h
  libraries:
    - "h2zero/NimBLE-Arduino"

esp32:
  variant: ESP32C3
  board: esp32-c3-devkitm-1
  framework:
    type: arduino
    version: 2.0.0

I get the following error:

Linking /data/airbnk/.pioenvs/airbnk/firmware.elf
RAM:   [=         ]  12.6% (used 41420 bytes from 327680 bytes)
Flash: [======    ]  58.6% (used 1075506 bytes from 1835008 bytes)
Building /data/airbnk/.pioenvs/airbnk/firmware.bin
esp32_create_combined_bin(["/data/airbnk/.pioenvs/airbnk/firmware.bin"], ["/data/airbnk/.pioenvs/airbnk/firmware.elf"])
usage: esptool merge_bin [-h] --output OUTPUT [--format {r,a,w}]
                         [--flash_freq {keep,80m,60m,48m,40m,30m,26m,24m,20m,16m,15m,12m}]
                         [--flash_mode {keep,qio,qout,dio,dout}]
                         [--flash_size FLASH_SIZE]
                         [--spi-connection SPI_CONNECTION]
                         [--target-offset TARGET_OFFSET]
                         [--fill-flash-size FILL_FLASH_SIZE]
                         <address> <filename> [<address> <filename> ...]
esptool merge_bin: error: argument <address> <filename>: [Errno 2] No such file or directory: '/data/cache/platformio/packages/framework-arduinoespressif32/tools/sdk/esp32c3/bin/bootloader__40m.bin'
*** [/data/airbnk/.pioenvs/airbnk/firmware.bin] Explicit exit, status 2
formatBCE commented 1 year ago

I believe, Nimble-Arduino isn't supported by esp-idf - they have their own fork at least.

I'm afraid, there's no simple solution.