Skip to content

ports/esp32: Use capability defines to configure features. #15862

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
Dec 10, 2024

Conversation

andrewleech
Copy link
Contributor

@andrewleech andrewleech commented Sep 17, 2024

Summary

Was broken out from #11869

This updates esp32 code where appropriate to replace ifdefs based on a list of specific chips with a feature SOC_* definition, eg.

#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3

to

#if SOC_TOUCH_SENSOR_SUPPORTED

Testing

TBD - each of these changes will requires review and test to confirm no unexpected regressions.

Trade-offs and Alternatives

This should simplify adding new esp32-* chips in future, deferring chip feature support to the IDF.

@andrewleech
Copy link
Contributor Author

Hi @projectgus the soc capability changes commit has been moved here and I think is ready for review / test again.
I've fixed your previous suggestions from the original MR.

@projectgus projectgus self-requested a review September 25, 2024 03:58
@andrewleech andrewleech force-pushed the esp32_capabilities branch 3 times, most recently from 0917e27 to a7a424e Compare October 11, 2024 05:16
@andrewleech
Copy link
Contributor Author

@projectgus I've rebased this now that C6 has merged, but haven't tested anything beyond it being able to compile for C6

Copy link
Contributor

@projectgus projectgus left a comment

Choose a reason for hiding this comment

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

These changes look good, thanks @andrewleech. I have a couple of comments but it's pretty straightforward.

I can help test this PR on some of the other SoCs, although I haven't done this yet.

@andrewleech
Copy link
Contributor Author

Thanks @projectgus I've fixed that adc issue and reworked the PWM over in #16090 as suggested.

@projectgus
Copy link
Contributor

@andrewleech When you have a moment to rebase this and drop the PWM change then it'd be great to get it merged.

@andrewleech
Copy link
Contributor Author

Ah yes, thanks for the reminder @projectgus I've rebased it now.

Copy link
Contributor

@projectgus projectgus left a comment

Choose a reason for hiding this comment

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

This looks great, @andrewleech! I have one small suggestion but otherwise looks good.

I can help do some testing on various boards and then I think we should get this in, should streamline future ESP32 additions. 🚀

@@ -147,30 +147,34 @@ static void machine_sleep_helper(wake_type_t wake_type, size_t n_args, const mp_
esp_sleep_enable_timer_wakeup(((uint64_t)expiry) * 1000);
}

#if !(CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6)

#if SOC_PM_SUPPORT_EXT0_WAKEUP
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should leave this for an additional PR, but should we also do more filtering in machine_pin_irq (machine_pin.c) where the user sets the different wake up types? It looks like some invalid settings will fail, but I feel like some will be silently accepted (and then do nothing.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yeah that's a good point. Pin irq / sleep settings that do / don't work seem to come up in issues regularly so a concerted effort to clean up and test these would be valuable. This arguably applies to all ports though, just just esp32...

Copy link
Contributor

@projectgus projectgus left a comment

Choose a reason for hiding this comment

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

Great work @andrewleech! I think we should merge this to progress some of the other ESP32-related PRs that add new chips or tweak features.

(I ended up doing less testing than I anticipated, although did try out the ADC on the ESP32-C6 which seems to work correctly. Have re-read the other diff items and I don't see any potential for subtle bugs like the PWM clock source - the I2C clock sources are disjoint so that one shouldn't change anything.)

This updates esp32 code where appropriate to replace ifdef's based on a
list of specific chips with a feature SOC_* definition.  This should
simplify adding new esp32-* chips in future, deferring chip feature support
to the IDF.

Signed-off-by: Andrew Leech <andrew@alelec.net>
@dpgeorge dpgeorge merged commit 9441ce6 into micropython:master Dec 10, 2024
8 checks passed
@andrewleech andrewleech deleted the esp32_capabilities branch December 18, 2024 22:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants