gnumpi / esphome_audio

Custom audio components for ESPHome
Other
24 stars 10 forks source link

Unable to compile for ESP32-S2-Mini (Lolin) #40

Open danielholm opened 3 weeks ago

danielholm commented 3 weeks ago

Hi, Thanks for the code. I wanted to try it on a small ESP32-S2-Mini (since I get buffer bloat error for the speaker while running ESPHome with esp-idf and I want the media_player as well).

I get the following error while compiling. I guess I need to set some kind of other board, since mine doest have any more LED:s than one blue. Or I might be mistakenly reading the error outuput.

Compiling .pioenvs/esp32-mini1/components/audio_hal/audio_volume.o
components/audio_board/lyrat_v4_3/board_pins_config.c: In function 'get_i2c_pins':
components/audio_board/lyrat_v4_3/board_pins_config.c:39:34: error: 'GPIO_NUM_23' undeclared (first use in this function); did you mean 'GPIO_NUM_43'?
         i2c_config->scl_io_num = GPIO_NUM_23;
                                  ^~~~~~~~~~~
                                  GPIO_NUM_43
components/audio_board/lyrat_v4_3/board_pins_config.c:39:34: note: each undeclared identifier is reported only once for each function it appears in
components/audio_board/lyrat_v4_3/board_pins_config.c: In function 'get_i2s_pins':
components/audio_board/lyrat_v4_3/board_pins_config.c:52:38: error: 'I2S_NUM_1' undeclared (first use in this function); did you mean 'I2S_NUM_0'?
     if (port == I2S_NUM_0 || port == I2S_NUM_1) {
                                      ^~~~~~~~~
                                      I2S_NUM_0
components/audio_board/lyrat_v4_3/board_pins_config.c:54:33: error: 'GPIO_NUM_25' undeclared (first use in this function); did you mean 'GPIO_NUM_45'?
         i2s_config->ws_io_num = GPIO_NUM_25;
                                 ^~~~~~~~~~~
                                 GPIO_NUM_45
In file included from /data/cache/platformio/packages/framework-espidf/components/esp_rom/include/esp32s2/rom/ets_sys.h:21,
                 from /data/cache/platformio/packages/framework-espidf/components/log/include/esp_log.h:17,
                 from components/audio_board/lyrat_v4_3/board_pins_config.c:25:
components/audio_board/lyrat_v4_3/board_pins_config.c: In function 'i2s_mclk_gpio_select':
components/audio_board/lyrat_v4_3/board_pins_config.c:95:53: error: 'FUNC_GPIO0_CLK_OUT1' undeclared (first use in this function); did you mean 'FUNC_GPIO20_CLK_OUT1'?
             PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO0_U, FUNC_GPIO0_CLK_OUT1);
                                                     ^~~~~~~~~~~~~~~~~~~
/data/cache/platformio/packages/framework-espidf/components/soc/esp32s2/include/soc/soc.h:123:45: note: in definition of macro 'REG_WRITE'
             (*(volatile uint32_t *)(_r)) = (_v);                                                                       \
                                             ^~
/data/cache/platformio/packages/framework-espidf/components/soc/esp32s2/include/soc/io_mux_reg.h:94:46: note: in expansion of macro 'REG_SET_FIELD'
 #define PIN_FUNC_SELECT(PIN_NAME, FUNC)      REG_SET_FIELD(PIN_NAME, MCU_SEL, FUNC)
                                              ^~~~~~~~~~~~~
components/audio_board/lyrat_v4_3/board_pins_config.c:95:13: note: in expansion of macro 'PIN_FUNC_SELECT'
             PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO0_U, FUNC_GPIO0_CLK_OUT1);
             ^~~~~~~~~~~~~~~
components/audio_board/lyrat_v4_3/board_pins_config.c:98:53: error: 'FUNC_U0TXD_CLK_OUT3' undeclared (first use in this function); did you mean 'FUNC_U0TXD_CLK_OUT1'?
             PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0TXD_U, FUNC_U0TXD_CLK_OUT3);
                                                     ^~~~~~~~~~~~~~~~~~~
/data/cache/platformio/packages/framework-espidf/components/soc/esp32s2/include/soc/soc.h:123:45: note: in definition of macro 'REG_WRITE'
             (*(volatile uint32_t *)(_r)) = (_v);                                                                       \
                                             ^~
/data/cache/platformio/packages/framework-espidf/components/soc/esp32s2/include/soc/io_mux_reg.h:94:46: note: in expansion of macro 'REG_SET_FIELD'
 #define PIN_FUNC_SELECT(PIN_NAME, FUNC)      REG_SET_FIELD(PIN_NAME, MCU_SEL, FUNC)
                                              ^~~~~~~~~~~~~
components/audio_board/lyrat_v4_3/board_pins_config.c:98:13: note: in expansion of macro 'PIN_FUNC_SELECT'
             PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0TXD_U, FUNC_U0TXD_CLK_OUT3);
             ^~~~~~~~~~~~~~~
components/audio_board/lyrat_v4_3/board_pins_config.c:104:27: error: 'I2S_NUM_1' undeclared (first use in this function); did you mean 'I2S_NUM_0'?
     } else if (i2s_num == I2S_NUM_1) {
                           ^~~~~~~~~
                           I2S_NUM_0
In file included from components/audio_board/lyrat_v4_3/board.h:29,
                 from components/audio_board/lyrat_v4_3/board_pins_config.c:28:
components/audio_board/lyrat_v4_3/board_pins_config.c: In function 'get_green_led_gpio':
components/audio_board/lyrat_v4_3/board_def.h:42:35: error: 'GPIO_NUM_22' undeclared (first use in this function); did you mean 'GPIO_NUM_42'?
 #define GREEN_LED_GPIO            GPIO_NUM_22
                                   ^~~~~~~~~~~
components/audio_board/lyrat_v4_3/board_pins_config.c:186:12: note: in expansion of macro 'GREEN_LED_GPIO'
     return GREEN_LED_GPIO;
            ^~~~~~~~~~~~~~
components/audio_board/lyrat_v4_3/board_pins_config.c:187:1: error: control reaches end of non-void function [-Werror=return-type]
 }
 ^
cc1: some warnings being treated as errors
*** [.pioenvs/esp32-mini1/components/audio_board/lyrat_v4_3/board_pins_config.o] Error 1
========================== [FAILED] Took 5.38 seconds ==========================

This is my config:

esphome:
  name: esp32-mini1
  friendly_name: esp32-mini1
  on_boot:
    - priority: 600
      then:
        - light.turn_on: esp_status_led

external_components:
  - source:
      type: git
      url: https://github.com/gnumpi/esphome_audio
      ref: main
    components: [ adf_pipeline, i2s_audio ]

esp32:
  board: lolin_s2_mini
  framework:
    type: esp-idf
    sdkconfig_options:
      CONFIG_ESP_CONSOLE_USB_CDC: y

debug:
  update_interval: 5s

text_sensor:
  - platform: debug
    device:
      name: "Device Info"
    reset_reason:
      name: "Reset Reason"

# Logger must be at least debug (default)
logger:
  level: debug
  hardware_uart: USB_CDC

#psram:
#  mode: octal
#  speed: 40MHz #80MHz

# Enable Home Assistant API
api:
  encryption:
    key: XX

ota:
  password: XX
wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  power_save_mode: none

captive_portal:

i2s_audio:
  - id: i2s_shared # INMP441
    i2s_lrclk_pin: GPIO34 # WS LRC blå
    i2s_bclk_pin: GPIO35 # SCK BCLK lila
    access_mode: exclusive

adf_pipeline:
  - platform: i2s_audio
    type: audio_out
    id: adf_i2s_out
    i2s_audio_id: i2s_shared
    i2s_dout_pin: GPIO37 #DIN 22 in readme
    fixed_settings: false

  - platform: i2s_audio
    type: audio_in
    id: adf_i2s_in
    i2s_audio_id: i2s_shared
    i2s_din_pin: GPIO38 #SD 23 in readme
    pdm: false #true
    bits_per_sample: 32bit
    channel: right
    fixed_settings: true

microphone: # INMP441
  - platform: adf_pipeline
    id: adf_microphone
    keep_pipeline_alive: true
    pipeline:
      - adf_i2s_in
      - self
#  - platform: i2s_audio
#    adc_type: external
#    pdm: false
#    id: mic
#    channel: right
#    bits_per_sample: 32bit
#    i2s_audio_id: i2s_shared
#    i2s_din_pin: GPIO38 # SD 

media_player:
  - platform: adf_pipeline
    id: adf_media_player
    name: media_player
    keep_pipeline_alive: true
    internal: false
    pipeline:
      - self
      - resampler
      - adf_i2s_out

#speaker: # MAX98357A
#  - platform: i2s_audio
#    id: my_speaker
#    i2s_audio_id: i2s_shared
#    dac_type: external
#    i2s_dout_pin: GPIO37 # DIN Pin of the MAX98357A Audio Amplifier
#    mode: mono

voice_assistant:
  id: assist
  #microphone: mic
  #speaker: my_speaker
  microphone: adf_microphone
  media_player: adf_media_player
  use_wake_word: false
  auto_gain: 31dBFS
  noise_suppression_level: 1 #2
  volume_multiplier: 4.0 #2.0
  on_wake_word_detected: 
    - light.turn_on: esp_status_led
  on_end: 
    - light.turn_off: esp_status_led

light:
  - platform: status_led
    name: "Status LED"
    id: esp_status_led
    icon: "mdi:alarm-light"
    restore_mode: ALWAYS_OFF
    pin:
      number: GPIO15
      inverted: false

binary_sensor:
  - platform: status
    name: API Connection
    id: api_connection
    filters:
      - delayed_on: 1s
    on_press:
      - if:
          condition:
            switch.is_on: use_wake_word
          then:
            - voice_assistant.start_continuous:
    on_release:
      - if:
          condition:
            switch.is_on: use_wake_word
          then:
            - voice_assistant.stop:

switch:
  #- platform: gpio
   ## pin: GPIO40
   ## name: "Mic L/R" 

  - platform: restart
    name: "Restart"

  - platform: template
    name: Use wake word
    id: use_wake_word
    optimistic: true
    icon: mdi:assistant
    restore_mode: RESTORE_DEFAULT_ON
    entity_category: config
    on_turn_on:
      - lambda: id(assist).set_use_wake_word(true);
      - if:
          condition:
            not:
              - voice_assistant.is_running
          then:
            - voice_assistant.start_continuous
    on_turn_off:
      - voice_assistant.stop
      - lambda: id(assist).set_use_wake_word(false);

  - platform: template
    name: Pipeline
    id: pipeline_switch
    optimistic: true
    restore_mode: RESTORE_DEFAULT_OFF

    on_turn_off:
      - media_player.stop

    on_turn_on:
      - media_player.play_media: "https://dl.espressif.com/dl/audio/ff-16b-2c-44100hz.mp3"

button:
  - platform: restart
    id: restart_btn
    name: "REBOOT"
gnumpi commented 3 weeks ago

Please try adding CONFIG_ESP32_S3_BOX_BOARD: "y" to your sdkconfig_options even though it is not the correct board. Unfortunately the ADF-SDK requires a board to be set in order to compile, even though the board specific code is not used by ADF-Pipeline.

danielholm commented 3 weeks ago

Lovely! Thank you very much for the help, as well for the quick reply. It does get a bit further, however I am now stuck at the following:

Compiling .pioenvs/esp32-mini1/components/audio_board/esp32_s3_box/board.o
In file included from components/audio_board/esp32_s3_box/board.h:29,
                 from components/audio_board/esp32_s3_box/board.c:26:
components/audio_board/esp32_s3_box/board.c: In function 'audio_board_lcd_init':
components/audio_board/esp32_s3_box/board_def.h:33:37: error: 'GPIO_NUM_48' undeclared (first use in this function); did you mean 'GPIO_NUM_46'?
 #define LCD_RST_GPIO                GPIO_NUM_48
                                     ^~~~~~~~~~~
components/audio_board/esp32_s3_box/board.c:113:27: note: in expansion of macro 'LCD_RST_GPIO'
         .reset_gpio_num = LCD_RST_GPIO,
                           ^~~~~~~~~~~~
components/audio_board/esp32_s3_box/board_def.h:33:37: note: each undeclared identifier is reported only once for each function it appears in
 #define LCD_RST_GPIO                GPIO_NUM_48
                                     ^~~~~~~~~~~
components/audio_board/esp32_s3_box/board.c:113:27: note: in expansion of macro 'LCD_RST_GPIO'
         .reset_gpio_num = LCD_RST_GPIO,
                           ^~~~~~~~~~~~
*** [.pioenvs/esp32-mini1/components/audio_board/esp32_s3_box/board.o] Error 1
========================= [FAILED] Took 66.41 seconds =========================