Skip to content

samples: fade_led: fix build error when PWM is not enabled #85281

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 6, 2025

Conversation

pillo79
Copy link
Collaborator

@pillo79 pillo79 commented Feb 6, 2025

The Arduino Nano 33 BLE defines a PWM LED whose controller is disabled by default due to conflicts with other peripherals:

pwmleds2 {
compatible = "pwm-leds";
/* Cannot be used together with spi2. */
status = "disabled";
yellow_pwm_led: led_pwm_3 {
pwms = <&pwm2 0 PWM_MSEC(20) PWM_POLARITY_NORMAL>;
label = "Yellow PWM LED";
};
};

In this case, the new sample code introduced in a5fd92b fails to build with a missing symbol error because it assumes defined nodes are usable.

Fix this by checking in the sample if the PWM device (the parent of the LED alias) is enabled before using it. This implicitly discards invalid aliases, as before.

Some boards may define LEDs but disable them by default due to conflicts
with other peripherals. In this case, the new sample code introduced in
a5fd92b ("samples: fade_led: use all available LEDs") fails to build
with a missing symbol error.

Fix this by checking if the PWM device (the parent of the LED alias) is
enabled before using it. This implicitly discards invalid aliases.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
@pillo79 pillo79 marked this pull request as ready for review February 6, 2025 09:11
@zephyrbot zephyrbot added the area: Samples Samples label Feb 6, 2025
@zephyrbot zephyrbot requested review from kartben and nashif February 6, 2025 09:14
@pillo79 pillo79 requested review from soburi and simonguinot February 6, 2025 09:16
@pillo79 pillo79 added the Hotfix Fix for issues blocking development, i.e. CI issues, tests failing in CI, etc. label Feb 6, 2025
Copy link
Member

@soburi soburi left a comment

Choose a reason for hiding this comment

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

It seems that we were lax in our check. I'm sorry. Thank you.

Copy link
Collaborator

@simonguinot simonguinot left a comment

Choose a reason for hiding this comment

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

Thanks !

@kartben kartben merged commit 187a8ad into zephyrproject-rtos:main Feb 6, 2025
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Samples Samples Hotfix Fix for issues blocking development, i.e. CI issues, tests failing in CI, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants