Skip to content

Library fails to compile with recent "esp32" platform versions #155

@ThomasFTL

Description

@ThomasFTL

Describe the problem

Compiling the library for an ESP32-based board fails when using a recent version of the "esp32" boards platform.

To reproduce

  1. Create a sketch with the following content:
    #include <Servo.h>
    void setup() {}
    void loop() {}
  2. Follow the instructions here to install the latest version of the "esp32" boards platform:
    https://docs.espressif.com/projects/arduino-esp32/en/latest/installing.html#installing-using-arduino-ide
  3. Select Tools > Board > esp32 > Arduino Nano ESP32 from the Arduino IDE menus.
    The "Arduino Nano ESP32" board was chosen arbitrarily. The fault also occurs for other boards.
  4. Compile the sketch.

🐛 Compilation fails:

In file included from c:\Users\foo\Documents\Arduino\libraries\Servo\src/Servo.h:81,
                 from C:\Users\foo\Documents\Arduino\sketch_dec29b\sketch_dec29b.ino:1:
c:\Users\foo\Documents\Arduino\libraries\Servo\src/esp32/ServoTimers.h:3:33: error: 'SOC_LEDC_TIMER_BIT_WIDE_NUM' was not declared in this scope; did you mean 'SOC_LEDC_TIMER_BIT_WIDTH'?
    3 | #define LEDC_MAX_BIT_WIDTH      SOC_LEDC_TIMER_BIT_WIDE_NUM
      |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~
c:\Users\foo\Documents\Arduino\libraries\Servo\src/esp32/ServoTimers.h:5:43: note: in expansion of macro 'LEDC_MAX_BIT_WIDTH'
    5 | constexpr uint32_t BIT_RESOLUTION = (1 << LEDC_MAX_BIT_WIDTH) - 1;
      |                                           ^~~~~~~~~~~~~~~~~~
exit status 1

Compilation error: exit status 1

Library version

f00075a

Additional context

I see the SOC_LEDC_TIMER_BIT_WIDE_NUM macro was removed from ESP-IDF here:

espressif/esp-idf@9402ab4

It seems to have simply been renamed SOC_LEDC_TIMER_BIT_WIDTH.

That change was first released in ESP-IDF version 5.1. The ESP-IDF dependency of the "esp32" platform was bumped from 4.4.7 to 5.1.4 at the 3.0.0 release. So it seems the loss in compatibility between the Servo library and the "esp32" platform was lost at version 3.0.0 of the platform.


The "Compile Examples" workflow does provide coverage of compilation for the "Arduino Nano ESP32" board, but it uses the "Arduino ESP32 Boards" platform instead of the "esp32" platform. Arduino ESP32 Boards is based on "esp32" platform version 2.0.17, so this is why the workflow's Arduino Nano ESP32 runs pass.

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: codeRelated to content of the project itselftype: imperfectionPerceived defect in any part of project

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions