espressif / arduino-esp32

Arduino core for the ESP32
GNU Lesser General Public License v2.1
13.76k stars 7.44k forks source link

LEDC missing SemaphoreHandle_t (alpha 3 issue) building for M5Stack Core #9133

Closed sgryphon closed 10 months ago

sgryphon commented 10 months ago

Board

m5stack-core2

Device Description

M5Stack Core2 ESP32 IoT Development Kit for AWS IoT Kit, https://shop.m5stack.com/products/m5stack-core2-esp32-iot-development-kit-for-aws-iot-edukit?variant=37687799251116

Hardware Configuration

Just the M5Stack Core2

Version

latest master (checkout manually)

IDE Name

PlatformIO

Operating System

Ubuntu 22.04

Flash frequency

240Mhz

PSRAM enabled

yes

Upload speed

115200

Description

Note that you don't actually need an M5Stack Core2 to reproduce the issue, as it happens at build stage (before connecting to the device).

Steps to reproduce:

  1. Open VS Code with PlatformIO, and open the PlatformIO CLI.
  2. Create a new project, e.g.
mkdir TestM5
cd TestM5
pio project init --board m5stack-core2
  1. Install the M5Unified package
pio pkg install --library M5Unified
  1. Create src/main.cpp with the code as per Sketch below.

  2. Check the project builds

pio run
  1. Configure the project to use the Arduino ESP32 alpha 3.0.0 by replacing the platform section in platform.ini with:
platform = https://github.com/sgryphon/platform-espressif32.git#sgryphon/add-esp32-arduino-libs
platform_packages =
    platformio/framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#master
    platformio/framework-arduinoespressif32-libs @ https://github.com/espressif/esp32-arduino-libs.git#idf-release/v5.1
  1. Try and build the project, and observe errors.
pio run

What should happen

Build should succeed (although there will be warnings)

Sketch

#include <Arduino.h>
#include <M5Unified.h>

void setup() {
  M5.begin();
  M5.Lcd.print("Hello M5Stack Core2\n(with Arduino framework)\nvia PlatformIO");
}

void loop() {
}

Debug Message

### What happens:

Build fails, with some warnings and the following error:

In file included from .pio/libdeps/m5stack-core2/M5GFX/src/lgfx/v1/platforms/esp32/Light_PWM.cpp:24:
/home/sly/.platformio/packages/framework-arduinoespressif32@src-cba3def1496a47e6af73c0b73bd2e13c/cores/esp32/esp32-hal-ledc.h:44:5: error: 'SemaphoreHandle_t' does not name a type
   44 |     SemaphoreHandle_t lock;        //xSemaphoreCreateBinary

### Other Steps to Reproduce

This is a compilation error and it looks like a missing include / definition.

You can fix the build with the following work around:

### Work around

Open the downloaded package file: `.platformio/packages/framework-arduinoespressif32@src-
cba3def1496a47e6af73c0b73bd2e13c/cores/esp32/esp32-hal-ledc.h`

Modify to add the following includes, immediate after the existing includes:

```cpp
#include "freertos/FreeRTOS.h"
#include "freertos/semphr.h"

After that you can build (although there are warnings), and the app runs successfully on the device.

pio run --target upload

I have checked existing issues, online documentation and the Troubleshooting Guide

P-R-O-C-H-Y commented 10 months ago

Thanks @sgryphon for opening a PR with a the fix.