TillFleisch / ESPHome-HLK-LD2450

ESPHome support for the HI-Link HLK-LD2450 millimeter wave sensor (external component) with support for custom zones using convex polygons.
MIT License
105 stars 19 forks source link

ESP32-C6 compilation issue #20

Closed egoleos closed 5 months ago

egoleos commented 5 months ago

There is an error in zone.cpp:41:70

The last changes, framework: type: esp-idf

should be

ESP_LOGCONFIG(TAG, " template polygon update interval: %lu", template_evaluation_interval_);

The log

|-- ArduinoJson @ 6.18.5
Compiling .pioenvs/esphome_living_room_sensor1/src/esphome/components/LD2450/LD2450.o
Compiling .pioenvs/esphome_living_room_sensor1/src/esphome/components/LD2450/zone.o
Compiling .pioenvs/esphome_living_room_sensor1/src/esphome/components/api/api_pb2_service.o
Compiling .pioenvs/esphome_living_room_sensor1/src/esphome/components/api/api_server.o
Compiling .pioenvs/esphome_living_room_sensor1/src/esphome/components/api/list_entities.o
Compiling .pioenvs/esphome_living_room_sensor1/src/esphome/components/api/proto.o
Compiling .pioenvs/esphome_living_room_sensor1/src/esphome/components/api/subscribe_state.o
Compiling .pioenvs/esphome_living_room_sensor1/src/esphome/components/api/user_services.o
In file included from src/esphome/components/uart/uart.h:6,
                 from src/esphome/components/LD2450/LD2450.h:4,
                 from src/esphome/components/LD2450/LD2450.cpp:1:
src/esphome/components/LD2450/LD2450.cpp: In member function 'virtual void esphome::ld2450::LD2450::dump_config()':
src/esphome/components/LD2450/LD2450.cpp:55:28: error: format '%i' expects argument of type 'int', but argument 5 has type 'double' [-Werror=format=]
   55 |         ESP_LOGCONFIG(TAG, "  max_detection_tilt_angle: %i °", max_detection_tilt_angle_);
      |                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/esphome/core/log.h:72:36: note: in definition of macro 'ESPHOME_LOG_FORMAT'
   72 | #define ESPHOME_LOG_FORMAT(format) format
      |                                    ^~~~~~
src/esphome/core/log.h:153:33: note: in expansion of macro 'esph_log_config'
  153 | #define ESP_LOGCONFIG(tag, ...) esph_log_config(tag, __VA_ARGS__)
      |                                 ^~~~~~~~~~~~~~~
src/esphome/components/LD2450/LD2450.cpp:55:9: note: in expansion of macro 'ESP_LOGCONFIG'
   55 |         ESP_LOGCONFIG(TAG, "  max_detection_tilt_angle: %i °", max_detection_tilt_angle_);
      |         ^~~~~~~~~~~~~
src/esphome/components/LD2450/LD2450.cpp:55:58: note: format string is defined here
   55 |         ESP_LOGCONFIG(TAG, "  max_detection_tilt_angle: %i °", max_detection_tilt_angle_);
      |                                                         ~^
      |                                                          |
      |                                                          int
      |                                                         %f
src/esphome/components/LD2450/LD2450.cpp:56:28: error: format '%i' expects argument of type 'int', but argument 5 has type 'double' [-Werror=format=]
   56 |         ESP_LOGCONFIG(TAG, "  min_detection_tilt_angle: %i °", min_detection_tilt_angle_);
      |                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/esphome/core/log.h:72:36: note: in definition of macro 'ESPHOME_LOG_FORMAT'
   72 | #define ESPHOME_LOG_FORMAT(format) format
      |                                    ^~~~~~
src/esphome/core/log.h:153:33: note: in expansion of macro 'esph_log_config'
  153 | #define ESP_LOGCONFIG(tag, ...) esph_log_config(tag, __VA_ARGS__)
      |                                 ^~~~~~~~~~~~~~~
src/esphome/components/LD2450/LD2450.cpp:56:9: note: in expansion of macro 'ESP_LOGCONFIG'
   56 |         ESP_LOGCONFIG(TAG, "  min_detection_tilt_angle: %i °", min_detection_tilt_angle_);
      |         ^~~~~~~~~~~~~
src/esphome/components/LD2450/LD2450.cpp:56:58: note: format string is defined here
   56 |         ESP_LOGCONFIG(TAG, "  min_detection_tilt_angle: %i °", min_detection_tilt_angle_);
      |                                                         ~^
      |                                                          |
      |                                                          int
      |                                                         %f
src/esphome/components/LD2450/LD2450.cpp:59:28: error: format '%i' expects argument of type 'int', but argument 5 has type 'double' [-Werror=format=]
   59 |         ESP_LOGCONFIG(TAG, "  tilt_angle_margin: %i °", tilt_angle_margin_);
      |                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~
src/esphome/core/log.h:72:36: note: in definition of macro 'ESPHOME_LOG_FORMAT'
   72 | #define ESPHOME_LOG_FORMAT(format) format
      |                                    ^~~~~~
src/esphome/core/log.h:153:33: note: in expansion of macro 'esph_log_config'
  153 | #define ESP_LOGCONFIG(tag, ...) esph_log_config(tag, __VA_ARGS__)
      |                                 ^~~~~~~~~~~~~~~
src/esphome/components/LD2450/LD2450.cpp:59:9: note: in expansion of macro 'ESP_LOGCONFIG'
   59 |         ESP_LOGCONFIG(TAG, "  tilt_angle_margin: %i °", tilt_angle_margin_);
      |         ^~~~~~~~~~~~~
src/esphome/components/LD2450/LD2450.cpp:59:51: note: format string is defined here
   59 |         ESP_LOGCONFIG(TAG, "  tilt_angle_margin: %i °", tilt_angle_margin_);
      |                                                  ~^
      |                                                   |
      |                                                   int
      |                                                  %f
Compiling .pioenvs/esphome_living_room_sensor1/src/esphome/components/binary_sensor/automation.o
In file included from src/esphome/components/sensor/sensor.h:3,
                 from src/esphome/components/LD2450/polling_sensor.h:4,
                 from src/esphome/components/LD2450/target.h:5,
                 from src/esphome/components/LD2450/zone.h:3,
                 from src/esphome/components/LD2450/zone.cpp:1:
src/esphome/components/LD2450/zone.cpp: In member function 'void esphome::ld2450::Zone::dump_config()':
src/esphome/components/LD2450/zone.cpp:41:32: error: format '%i' expects argument of type 'int', but argument 5 has type 'uint32_t' {aka 'long unsigned int'} [-Werror=format=]
   41 |             ESP_LOGCONFIG(TAG, "  template polygon update interval: %i", template_evaluation_interval_);
      |                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/esphome/core/log.h:72:36: note: in definition of macro 'ESPHOME_LOG_FORMAT'
   72 | #define ESPHOME_LOG_FORMAT(format) format
      |                                    ^~~~~~
src/esphome/core/log.h:153:33: note: in expansion of macro 'esph_log_config'
  153 | #define ESP_LOGCONFIG(tag, ...) esph_log_config(tag, __VA_ARGS__)
      |                                 ^~~~~~~~~~~~~~~
src/esphome/components/LD2450/zone.cpp:41:13: note: in expansion of macro 'ESP_LOGCONFIG'
   41 |             ESP_LOGCONFIG(TAG, "  template polygon update interval: %i", template_evaluation_interval_);
      |             ^~~~~~~~~~~~~
src/esphome/components/LD2450/zone.cpp:41:70: note: format string is defined here
   41 |             ESP_LOGCONFIG(TAG, "  template polygon update interval: %i", template_evaluation_interval_);
      |                                                                     ~^
      |                                                                      |
      |                                                                      int
      |                                                                     %li
cc1plus: some warnings being treated as errors
*** [.pioenvs/esphome_living_room_sensor1/src/esphome/components/LD2450/LD2450.o] Error 1
cc1plus: some warnings being treated as errors
*** [.pioenvs/esphome_living_room_sensor1/src/esphome/components/LD2450/zone.o] Error 1
========================= [FAILED] Took 10.81 seconds =========================
egoleos commented 5 months ago

I see that you fixed the errors in LD2450.cpp, but my ESPHome is loading the old code. Can you tell me why?

TillFleisch commented 5 months ago

I see that you fixed the errors in LD2450.cpp, but my ESPHome is loading the old code. Can you tell me why?

ESPHome caches external components and updates them only occasionally. You can change this behavior with the refresh parameter like this:

external_components:
  - source: github://TillFleisch/ESPHome-HLK-LD2450@c6
    refresh: 30min

Note that the branch is different c6, which contains a fix for this issue. I don't have access to a ESP32-C6, so I can't run/test the change. I went ahead and tried to compile this using your configuration, which worked. Creating a valid binary for the ESP failed with the following error:

A fatal error occurred: Contents of segment at SHA256 digest offset 0xb0 are not all zero. Refusing to overwrite.

Altering the idf version resolved the issue.

esp32:
  board: esp32-c6-devkitc-1
  variant: esp32c6
  flash_size: 8MB
  framework:
    type: esp-idf
    #version: 5.1.2
    version: 5.1.0
    platform_version: 6.5.0

Can you verify this change (branch c6) is working for you by using the above external component configuration? Is this an unusual/currently unsupported Hardware configuration in ESPHome?

(Eventually I will get to improving the CI-Pipeline to include different HW variants, which should prevent issues like these in the future)

egoleos commented 5 months ago

None of the configuration options, both with the old platform versions and the new ones, helped.

esp32:
  board: esp32-c6-devkitc-1
  variant: esp32c6
  flash_size: 8MB
  framework:
    type: esp-idf
    version: 5.1.0
    platform_version: 6.5.0
esp32:
  board: esp32-c6-devkitc-1
  variant: esp32c6
  flash_size: 8MB
  framework:
    type: esp-idf
    version: 5.1.2
    platform_version: 6.5.0

The result is the same:

A fatal error occurred: Contents of segment at SHA256 digest offset 0xb0 are not all zero. Refusing to overwrite.

egoleos commented 5 months ago

The configuration:

esp32:
  board: esp32-c6-devkitm-1
  variant: esp32c6
  flash_size: 8MB
  framework:
    type: esp-idf
    version: 5.2.1
    platform_version: 6.6.0

does not work for me at all.

egoleos commented 5 months ago

There is currently no Arduino framework for the C6. The only configuration that worked without issues was the one I provided earlier.

TillFleisch commented 5 months ago

The A fatal error occurred: Contents of segment at SHA256 digest offset 0xb0 are not all zero. Refusing to overwrite. is also present in a minimal ESPHome configuration, this rules out that this is an issue with this external component.

Maybe the following steps can help:

I found that (in a new environment and) when using the following configuration, ESPHome did generate a valid binary: (Though I don't know this this is a valid configuration for the hardware you're using.)

esp32:
  board: esp32-c6-devkitc-1
  variant: esp32c6
  flash_size: 8MB
  framework:
    type: esp-idf
    version: 5.1.2 # or 5.1.0, both worked
    platform_version: 6.5.0
    sdkconfig_options:
      CONFIG_ESPTOOLPY_FLASHSIZE_8MB: y
egoleos commented 5 months ago

Thank you for the suggestion. With parameter

CONFIG_ESPTOOLPY_FLASHSIZE_8MB: y

everything compiled and works as expected. Yesterday, I tried different options, but without the one you suggested. Thanks again for your help