8000 esp32c2 support (IDF v5.3) by TrekMax · Pull Request #15906 · micropython/micropython · GitHub
[go: up one dir, main page]

Skip to content

esp32c2 support (IDF v5.3) #15906

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

TrekMax
Copy link
@TrekMax TrekMax commented Sep 24, 2024

Summary

The is esp32c2 officially supported in IDF v5.2 but requires a number of changes to work...
Pulling together changes and generic board support needed here.

Testing

Functions verified by actual hardware include:

  • machine.pin
  • machine.i2c
  • machine.adc
  • machine.pwm
  • machine.timer
  • bluetooth

@agatti
Copy link
Contributor
agatti commented Sep 24, 2024

Isn't this already covered by #11869?

@sanderjo
Copy link

Isn't this already covered by #11869?

That is about esp32c6

This PR has subject esp32c2.

So c6 versus c2?

@andrewleech
Copy link
Contributor

Nice one @sanderjo there's a bunch of new chips getting added to IDF these days!

It still needs testing but this commit on the top of my C6 branch is intended to make it easier to bring in new chips like this one if you want to take a look: #15862

8000

@agatti
Copy link
Contributor
agatti commented Sep 24, 2024

@sanderjo I saw the ESP32C2 definition in mpconfigport.h in @andrewleech's branch so I thought it had basic C2 integration too, along with IDF 5.2 - my bad.

@agatti
Copy link
Contributor
agatti commented Sep 24, 2024

@TrekMax MICROPY_EMIT_RV32 being enabled should work on ESP32C2 too, it has the same RV32 core as C3 after all. Same for MICROPY_NLR_SETJMP being disabled.

Edit: forgot to mention that MICROPY_EMIT_RV32 used with MICROPY_NLR_SETJMP will crash native tests unless N_NLR_SETJMP is enabled in py/emitnrv32.c. So just follow C3's definitions set in ports/esp32/mpconfigport.h.

@andrewleech
Copy link
Contributor

@agatti the latest changes on C6 (about to push) should enable the emitter on all risk chips based on the soc defines, rather than listing individual chips.

I suggest this PR would be well placed to rebase on top of the C6 work once it's merged as lots of people have contributed to that PR to help it fill gaps / support that will then naturally apply to many of the newer chips.

@agatti
Copy link
Contributor
agatti commented Sep 24, 2024

@andrewleech oh, that's nice to hear. Hopefully that would make support for the C5 easier to add once that chip shows up in production :)

@projectgus
Copy link
Contributor

Thanks @TrekMax for updating your PR! (Note for housekeeping: this is replacing earlier PR #15440).

Similar to discussions above, suggest we tackle in this order:

  1. Merge esp32c6 support (IDF v5.2) #11869
  2. Damien will do the upcoming 1.24 MicroPython release.
  3. Merge ports/esp32: Use capability defines to configure features. #15862 - this should make adding future SoCs much simpler, but has some risk of bugs in other SoCs.
  4. Rebase this branch, then review and merge ESP32-C2 support.

@TrekMax Let us know if we can help with any part of this process. It should be possible to update this PR with totally new commits without needing to close and open a new PR. There is a guide to doing this online at https://github.com/jimmo/git-and-micropython#README

@TrekMax
Copy link
Author
TrekMax commented Sep 27, 2024

@projectgus Thanks. I will wait for esp32c6 support (IDF v5.2) #11869 to be merged, then rebase this branch, and then review and commit ESP32-C2 support.

@TrekMax TrekMax force-pushed the port/esp32c2 branch 5 times, most recently from c7d3a2b to 67dec7c Compare October 14, 2024 13:34
@TrekMax
Copy link
Author
TrekMax commented Oct 14, 2024

@projectgus Hey , the commit has been rebased to the latest master, please review it. Thanks!

@andrewleech
Copy link
Contributor

Hi @TrekMax could you also take a look at this which is intended to make it much easier to bring in new chips: #15862

@TrekMax
Copy link
Author
TrekMax commented Oct 16, 2024

@andrewleech Of course. I have ESP32C3, ESP32C2 and ESP32S3 to verify it.

@dpgeorge
Copy link
Member

@TrekMax please can you rebase this PR on the latest master, because there have been a lot of changes to the esp32 port, in particular support for IDF v5.3.

@projectgus
Copy link
Contributor

@TrekMax Further to damien's request: now that #15862 is merged a lot of the C2 specific #ifdefs are probably not needed, so the PR will hopefully become very simple. 😁

@TrekMax TrekMax force-pushed the port/esp32c2 branch 2 times, most recently from 0c8abf5 to 642eb25 Compare December 11, 2024 13:39
@TrekMax TrekMax changed the title esp32c2 support (IDF v5.2.2) esp32c2 support (IDF v5.3) Dec 12, 2024
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.

Thanks for your patience and for the quick update of this PR, @TrekMax ! I have some comments below, mostly minor.

@@ -50,7 +50,11 @@
#endif

#if SOC_I2C_SUPPORT_XTAL
#if CONFIG_IDF_TARGET_ESP32C2
#define I2C_SCLK_FREQ APB_CLK_FREQ
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this right? I would expect that because SOC_I2C_SUPPORT_XTAL is set, the I2C frequency will be the XTAL frequency (so no change needed for C2 in this file).

boards/sdkconfig.base
${SDKCONFIG_IDF_VERSION_SPECIFIC}
boards/sdkconfig.ble
boards/sdkconfig.26mhz
Copy link
Contributor

Choose a reason for hiding this comment

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

Do all ESP32-C2 modules use 26MHz crystals? I see the docs say it can support both 26MHz and 40MHz.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see you moved this into the sdkconfig.c2 file, which is fine.

Do we need to add a comment in board.md that is supports boards with 26MHz crystals? Or do the modules all have 26MHz crystals, already?

esp32/esp32c2: Fix heap size is too small to enable Bluetooth.

Signed-off-by: TianShuangKe <qinyun575@gmail.com>
@projectgus
Copy link
Contributor

@TrekMax Thanks for updating the PR in response to the review! It's looking pretty tidy.

There are a couple of unresolved questions above, do you know the answer to them?

@@ -0,0 +1,14 @@
Program your board using the esptool.py program, found [here](https://github.com/espressif/esptool).
Copy link
Contributor

Choose a reason for hiding this comment

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

A reminder for the future that #16535 deletes these copy-paste deploy.md files, so depending on which PR merges first there is a cleanup step for the PR which is merged second.

Copy link
Contributor

Choose a reason for hiding this comment

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

The linked PR just merged, so it's OK to rebase this, remove this file, and link to the generic deploy.md now.

@AmirHmZz
Copy link
Contributor
AmirHmZz commented Mar 7, 2025

@TrekMax Any updates on this PR?

@dpgeorge dpgeorge added this to the release-1.26.0 milestone Mar 13, 2025
@dpgeorge
Copy link
Member

Current status of this PR: it needs rebasing on latest master, and resolving the few questions above left by @projectgus .

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.

7 participants
0