Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@AZKKXL
Copy link
Contributor

@AZKKXL AZKKXL commented Aug 13, 2025

Summary

The is esp32c5 officially supported in IDF v5.5
Pulling together changes and generic board support needed here.

Some details

  1. I2S is not enabled: #define MICROPY_PY_MACHINE_I2S (0)
  2. As of the release/v5.5 version of ESP-IDF, there is only one configuration option for XTAL_FREQ, which is XTAL_FREQ_AUTO. This causes configuration options like CONFIG_XTAL_FREQ_40 added in sdkconfig to not take effect. I have made simple modifications in the source code, which can be adjusted once ESP-IDF opens up the configuration options in the future.
  3. Reference links:CONFIG_XTAL_FREQ = 0 for esp32c5 #17903 and CONFIG_XTAL_FREQ & ESP32C5 with release/v5.5 (IDFGH-16270) espressif/esp-idf#17426

Tesing

  • machine.pin

  • machine.i2c

  • machine.adc

  • machine.pwm

  • machine.timer

@dpgeorge
Copy link
Member

Thanks for the contribution.

Please can you separate the changes here into two commits:

  • adding C5 support
  • adding the new board

@AZKKXL AZKKXL force-pushed the seeed_xiao_esp32c5 branch 2 times, most recently from d66fea2 to 24a0bda Compare August 14, 2025 01:23
@AZKKXL
Copy link
Contributor Author

AZKKXL commented Aug 14, 2025

@dpgeorge
Thank you for your reply. It has now been revised.

@projectgus projectgus self-requested a review August 20, 2025 05:00
@Vincent1-python
Copy link

@AZKKXL #17971 When this PR ends, this automatic reading problem may be avoided, and he will not ask for XTAL frequency at compile time.

@AZKKXL
Copy link
Contributor Author

AZKKXL commented Aug 26, 2025

@Vincent1-python WOW! That's cool!

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.

Couple of minor suggestions, but this PR looks mostly good to me.

Although it would be good to have a ESP32_GENERIC_C5 board as well as the SEEED board.

Note we currently do all nightly builds with IDF v5.4.2, so we won't be able to start building ESP32-C5 in nightly builds (or CI) until we bump that version. (Same applies for ESP32-P4 support, I think).

@AZKKXL
Copy link
Contributor Author

AZKKXL commented Sep 1, 2025

@projectgus OK,I resolved conversation : )

@AZKKXL AZKKXL force-pushed the seeed_xiao_esp32c5 branch from e0cdaec to 3b53f8d Compare September 2, 2025 07:09
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.

I see you've changed the XIAO board to ESP32_GENERIC_C5, but some additional changes are needed to add this as a generic board.

I have a C5 Devkit on order, so I can help test this PR when it arrives.

@robert-hh
Copy link
Contributor

Compiled with a no-name ESP3C5 board using esp-idf v5.5.1. At first, the firmware was too large for the factory partition, ~32k overflow. SO I added the line below to sdkconfig.board, which reduces the firmware size by about 90k. The line does not have any impact on performance.

CONFIG_COMPILER_OPTIMIZATION_CHECKS_SILENT=y

@Josverl Josverl added the board-definition New or updated board definition files. Combine with a port- label. label Sep 27, 2025
@dpgeorge
Copy link
Member

@AZKKXL the esp32 port now uses IDF v5.5.1, so this C5 support should work.

Can you please rebase this on latest master?

@dpgeorge dpgeorge added this to the release-1.27.0 milestone Oct 17, 2025
@AZKKXL
Copy link
Contributor Author

AZKKXL commented Oct 23, 2025

@AZKKXL the esp32 port now uses IDF v5.5.1, so this C5 support should work.

Can you please rebase this on latest master?

Already rebase.

@github-actions
Copy link

github-actions bot commented Oct 23, 2025

Code size report:

Reference:  esp32/esp32_rmt: Update RMT module to use the new RMT API. [2a3b9b0]
Comparison: tools/ci.sh: Build ESP32_GENERIC_C5 as part of esp32 CI. [merge of 336d463]
  mpy-cross:    +0 +0.000% 
   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 
   unix x64:    +0 +0.000% standard
      stm32:    +0 +0.000% PYBV10
     mimxrt:    +0 +0.000% TEENSY40
        rp2:    +0 +0.000% RPI_PICO_W
       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS
  qemu rv32:    +0 +0.000% VIRT_RV32

@codecov
Copy link

codecov bot commented Oct 23, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.38%. Comparing base (2a3b9b0) to head (336d463).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #17912   +/-   ##
=======================================
  Coverage   98.38%   98.38%           
=======================================
  Files         171      171           
  Lines       22294    22294           
=======================================
  Hits        21933    21933           
  Misses        361      361           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@projectgus
Copy link
Contributor

@AZKKXL Something went wrong when you rebased (it had 255 commits showing in the PR). I've rebased again and squashed down to one commit so we can re-review.

If you need to make any more local changes then you'll need to reset your local branch to match this remote branch, first. (To do this, run git fetch origin and then git reset --hard origin/seeed_xiao_esp32c5 - but you will lose any other local changes you have in the branch!!)

@projectgus projectgus self-requested a review October 28, 2025 23:08
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.

@AZKKXL Looks like this PR only needs some minor cleanup and we can merge it.

@AZKKXL
Copy link
Contributor Author

AZKKXL commented Nov 14, 2025

n

I apologize for only seeing this now due to personal reasons. Could you confirm if the current submission format is correct? If not, please let me know. I will pay close attention to this in the coming days and strive to complete this PR.

@AZKKXL AZKKXL force-pushed the seeed_xiao_esp32c5 branch 2 times, most recently from 82f4f46 to a98ada0 Compare November 14, 2025 03:03
@dpgeorge
Copy link
Member

I tested building the new ESP32_GENERIC_C5 board, and it doesn't build due to two reasons:

  • error with redefinition of CONFIG_XTAL_FREQ
  • firmware is too big to fit in flash

For the first problem, I suggest dynamically calculating the I2C bus frequency using (in machine_i2c.c):

@@ -263,7 +263,13 @@ static void machine_hw_i2c_init(machine_hw_i2c_obj_t *self, bool first_init) {
         .master.clk_speed = self->freq,
     };
     i2c_param_config(self->port, &conf);
-    int timeout = i2c_ll_calculate_timeout_us_to_reg_val(I2C_SCLK_FREQ, self->timeout_us);
+    #if CONFIG_IDF_TARGET_ESP32C5
+    uint32_t i2c_sclk_freq;
+    check_esp_err(esp_clk_tree_src_get_freq_hz(I2C_CLK_SRC_DEFAULT, ESP_CLK_TREE_SRC_FREQ_PRECISION_APPROX, &i2c_sclk_freq));
+    #else
+    uint32_t i2c_sclk_freq = I2C_SCLK_FREQ;
+    #endif
+    int timeout = i2c_ll_calculate_timeout_us_to_reg_val(i2c_sclk_freq, self->timeout_us);
     i2c_set_timeout(self->port, (timeout > I2C_LL_MAX_TIMEOUT) ? I2C_LL_MAX_TIMEOUT : timeout);
     i2c_driver_install(self->port, I2C_MODE_MASTER, 0, 0, 0);
 }

For the second problem, include the boards/sdkconfig.riscv fragment in the SDKCONFIG_DEFAULTS list of files.

@dpgeorge
Copy link
Member

Oh, and I think a dependencies lock file needs to be added for C5 as well.

@AZKKXL
Copy link
Contributor Author

AZKKXL commented Nov 15, 2025

Oh, and I think a dependencies lock file needs to be added for C5 as well.

Sorry, could we ask you to handle the maintenance of this after merging the PR later?

@dpgeorge
Copy link
Member

OK, I've now added to this PR the following:

  • fix I2C build on C5
  • add dependencies lockfile for esp32c5
  • add ESP32_GENERIC_C5 to the CI, to test that it builds

@dpgeorge dpgeorge merged commit 336d463 into micropython:master Nov 17, 2025
74 of 76 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

board-definition New or updated board definition files. Combine with a port- label. port-esp32

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants