Skip to content

Conversation

@tommaso-merlini
Copy link

@tommaso-merlini tommaso-merlini commented Nov 5, 2025

ESP-BSP Pull Request checklist

  • Version of modified component bumped
  • CI passing

Change description

Component

mpu6050

Issue

The mpu6050.h header includes <driver/gpio.h>, which is provided by the esp_driver_gpio component. However, esp_driver_gpio was not declared in the component's dependencies.

This triggers a build error when inlcuding the library via idf.py add-dependency "espressif/mpu6050^1.1.1":

Compilation failed because mpu6050.h (in "espressif__mpu6050" component) includes driver/gpio.h, provided by esp_driver_gpio component(s).
However, esp_driver_gpio component(s) is not in the requirements list of "espressif__mpu6050".
To fix this, add esp_driver_gpio to PRIV_REQUIRES list of idf_component_register call in /home/tommaso/Documents/idf-esp-project/managed_components/espressif__mpu6050/CMakeLists.txt.
   19 | #include "driver/gpio.h"
      |          ^~~~~~~~~~~~~~~
compilation terminated.

Note

Adds conditional esp_driver_gpio/esp_driver_i2c dependencies for IDF>=5.3 and bumps component version to 1.2.1.

  • mpu6050:
    • Dependencies: In components/mpu6050/CMakeLists.txt, conditionally add esp_driver_gpio and esp_driver_i2c to REQUIRES when IDF_VERSION >= 5.3; keep driver required.
    • Version: Update components/mpu6050/idf_component.yml from 1.2.0 to 1.2.1.

Written by Cursor Bugbot for commit 77c58aa. This will update automatically on new commits. Configure here.

Copilot AI review requested due to automatic review settings November 5, 2025 10:03
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is being reviewed by Cursor Bugbot

Details

Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

SRCS "mpu6050.c"
INCLUDE_DIRS "include"
REQUIRES "driver"
PRIV_REQUIRES "esp_driver_gpio"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Misplaced dependency breaks transitive public API access

The esp_driver_gpio dependency is added to PRIV_REQUIRES but should be in REQUIRES instead. The public header mpu6050.h (located in the public include directory) includes driver/gpio.h and uses gpio_num_t and gpio_isr_t types in its public API. When a public header includes files from another component, that component must be listed in REQUIRES (not PRIV_REQUIRES) so that users of the mpu6050 component get transitive access to the GPIO driver headers. Using PRIV_REQUIRES will cause compilation errors for projects that include mpu6050.h but don't directly depend on esp_driver_gpio.

Fix in Cursor Fix in Web

Copy link
Collaborator

@espzav espzav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget bump component version for release the component into component registry.

SRCS "mpu6050.c"
INCLUDE_DIRS "include"
REQUIRES "driver"
PRIV_REQUIRES "esp_driver_gpio"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use something like this:

set(REQ esp_driver_gpio esp_driver_i2c)
for backward compatibility

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done @espzav, thanks for the suggestion!

Now it uses the set(REQ ...) pattern and the version is bumped

diff --git a/components/mpu6050/CMakeLists.txt b/components/mpu6050/CMakeLists.txt
index 7447101..5654d82 100644
--- a/components/mpu6050/CMakeLists.txt
+++ b/components/mpu6050/CMakeLists.txt
@@ -1,6 +1,7 @@
+set(REQ esp_driver_gpio esp_driver_i2c)
+
 idf_component_register(
     SRCS "mpu6050.c"
     INCLUDE_DIRS "include"
-    REQUIRES "driver"
-    PRIV_REQUIRES "esp_driver_gpio"
+    REQUIRES driver ${REQ}
 )
diff --git a/components/mpu6050/idf_component.yml b/components/mpu6050/idf_component.yml
index 4d544f0..14bcd20 100644
--- a/components/mpu6050/idf_component.yml
+++ b/components/mpu6050/idf_component.yml
@@ -1,4 +1,4 @@
-version: "1.2.0"
+version: "1.2.1"
 description: I2C driver for MPU6050 6-axis gyroscope and accelerometer
 url: https://github.com/espressif/esp-bsp/tree/master/components/mpu6050
 dependencies:

@github-actions github-actions bot changed the title Fix/mpu6050 missing "esp_driver_gpio" dependency Fix/mpu6050 missing "esp_driver_gpio" dependency (BSP-735) Nov 5, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a private dependency on the esp_driver_gpio component to the mpu6050 component's CMakeLists configuration.

  • Adds esp_driver_gpio as a private requirement to the mpu6050 component

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@tommaso-merlini tommaso-merlini force-pushed the fix/mpu6050-missing-gpio-dependency branch from 1907d32 to 591c966 Compare November 5, 2025 10:29
SRCS "mpu6050.c"
INCLUDE_DIRS "include"
REQUIRES "driver"
REQUIRES driver ${REQ}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Backward Compatibility Bug in ESP-IDF Driver Linkage

Missing backward compatibility check for ESP-IDF versions before 5.3. The code unconditionally uses esp_driver_gpio and esp_driver_i2c components which don't exist in IDF versions < 5.3. The component claims to support "idf: >=4.0" but will fail to build on versions before 5.3. Should use a conditional check like: if("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_GREATER_EQUAL "5.3") to set REQ to the new driver components, else use the legacy "driver" component.

Fix in Cursor Fix in Web

@tommaso-merlini tommaso-merlini force-pushed the fix/mpu6050-missing-gpio-dependency branch 3 times, most recently from b1f26d6 to ddb6a86 Compare November 5, 2025 10:45
@@ -1,5 +1,7 @@
set(REQ esp_driver_gpio esp_driver_i2c)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
set(REQ esp_driver_gpio esp_driver_i2c)
if("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_GREATER_EQUAL "5.3")
set(REQ esp_driver_gpio esp_driver_i2c)
else()
set(REQ driver)
endif()

SRCS "mpu6050.c"
INCLUDE_DIRS "include"
REQUIRES "driver"
REQUIRES driver ${REQ}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
REQUIRES driver ${REQ}
REQUIRES ${REQ}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just added the driver in the requires and set the conditional requires, thank you for you patience.

Copy link
Collaborator

@espzav espzav Nov 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tommaso-merlini Still missing else in condition and removed driver in REQUIRES. For IDF 6 cannot be driver there. It is divided into esp_driver_gpio esp_driver_i2c

@tommaso-merlini tommaso-merlini force-pushed the fix/mpu6050-missing-gpio-dependency branch from ddb6a86 to 77c58aa Compare November 5, 2025 10:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants