Skip to content

Commit 6d79937

Browse files
pi-anldpgeorge
authored andcommitted
esp32: Add support for esp32c6.
This commit adds general support for ESP32-C6 SoCs. Signed-off-by: Andrew Leech <andrew@alelec.net>
1 parent e5eeaa7 commit 6d79937

21 files changed

+112
-39
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ track of the code size of the core runtime and VM.
108108

109109
In addition, the following ports are provided in this repository:
110110
- [cc3200](ports/cc3200) -- Texas Instruments CC3200 (including PyCom WiPy).
111-
- [esp32](ports/esp32) -- Espressif ESP32 SoC (including ESP32S2, ESP32S3, ESP32C3).
111+
- [esp32](ports/esp32) -- Espressif ESP32 SoC (including ESP32S2, ESP32S3, ESP32C3, ESP32C6).
112112
- [esp8266](ports/esp8266) -- Espressif ESP8266 SoC.
113113
- [mimxrt](ports/mimxrt) -- NXP m.iMX RT (including Teensy 4.x).
114114
- [nrf](ports/nrf) -- Nordic Semiconductor nRF51 and nRF52.

docs/esp32/quickref.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ working with this board it may be useful to get an overview of the microcontroll
1818
general.rst
1919
tutorial/index.rst
2020

21-
Note that there are several varieties of ESP32 -- ESP32, ESP32C3, ESP32S2, ESP32S3 --
21+
Note that there are several varieties of ESP32 -- ESP32, ESP32C3, ESP32C6, ESP32S2, ESP32S3 --
2222
supported by MicroPython, with some differences in functionality between them.
2323

2424
Installing MicroPython
@@ -61,13 +61,13 @@ The :mod:`esp32` module::
6161
import esp32
6262

6363
esp32.raw_temperature() # read the internal temperature of the MCU, in Fahrenheit
64-
esp32.ULP() # access to the Ultra-Low-Power Co-processor, not on ESP32C3
64+
esp32.ULP() # access to the Ultra-Low-Power Co-processor, not on ESP32C3/C6
6565

6666
Note that the temperature sensor in the ESP32 will typically read higher than
6767
ambient due to the IC getting warm while it runs. This effect can be minimised
6868
by reading the temperature sensor immediately after waking up from sleep.
6969

70-
ESP32C3, ESP32S2, and ESP32S3 also have an internal temperature sensor available.
70+
ESP32C3, ESP32C6, ESP32S2, and ESP32S3 also have an internal temperature sensor available.
7171
It is implemented a bit differently to the ESP32 and returns the temperature in
7272
Celsius::
7373

ports/esp32/boards/deploy_c6.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Program your board using the esptool.py program, found [here](https://github.com/espressif/esptool).
2+
3+
If you are putting MicroPython on your board for the first time then you should
4+
first erase the entire flash using:
5+
6+
```bash
7+
esptool.py --chip esp32c6 --port /dev/ttyUSB0 erase_flash
8+
```
9+
10+
From then on program the firmware starting at address 0x0:
11+
12+
```bash
13+
esptool.py --chip esp32c6 --port /dev/ttyUSB0 --baud 460800 write_flash -z 0x0 ESP32_GENERIC_C6-20240602-v1.24.0.bin
14+
```

ports/esp32/esp32_common.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ idf_component_register(
198198
set(MICROPY_TARGET ${COMPONENT_TARGET})
199199

200200
# Define mpy-cross flags, for use with frozen code.
201-
if(NOT IDF_TARGET STREQUAL "esp32c3")
201+
if(CONFIG_IDF_TARGET_ARCH STREQUAL "xtensa")
202202
set(MICROPY_CROSS_FLAGS -march=xtensawin)
203203
endif()
204204

ports/esp32/gccollect.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#include "py/mpthread.h"
3636
#include "gccollect.h"
3737

38-
#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
38+
#if CONFIG_IDF_TARGET_ARCH_XTENSA
3939

4040
#include "xtensa/hal.h"
4141

@@ -61,8 +61,7 @@ void gc_collect(void) {
6161
gc_collect_end();
6262
}
6363

64-
#elif CONFIG_IDF_TARGET_ESP32C3
65-
64+
#elif CONFIG_IDF_TARGET_ARCH_RISCV
6665
#include "shared/runtime/gchelper.h"
6766

6867
void gc_collect(void) {
@@ -74,6 +73,8 @@ void gc_collect(void) {
7473
gc_collect_end();
7574
}
7675

76+
#else
77+
#error unknown CONFIG_IDF_TARGET_ARCH
7778
#endif
7879

7980
#if MICROPY_GC_SPLIT_HEAP_AUTO

ports/esp32/machine_adc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
#define MICROPY_PY_MACHINE_ADC_CLASS_CONSTANTS_WIDTH_9_10_11
4545
#endif
4646

47-
#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S3
47+
#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32S3
4848
#define MICROPY_PY_MACHINE_ADC_CLASS_CONSTANTS_WIDTH_12 \
4949
{ MP_ROM_QSTR(MP_QSTR_WIDTH_12BIT), MP_ROM_INT(12) },
5050
#else
@@ -87,7 +87,7 @@ static const machine_adc_obj_t madc_obj[] = {
8787
{{&machine_adc_type}, ADCBLOCK2, ADC_CHANNEL_7, GPIO_NUM_27},
8888
{{&machine_adc_type}, ADCBLOCK2, ADC_CHANNEL_8, GPIO_NUM_25},
8989
{{&machine_adc_type}, ADCBLOCK2, ADC_CHANNEL_9, GPIO_NUM_26},
90-
#elif CONFIG_IDF_TARGET_ESP32C3
90+
#elif CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6
9191
{{&machine_adc_type}, ADCBLOCK1, ADC_CHANNEL_0, GPIO_NUM_0},
9292
{{&machine_adc_type}, ADCBLOCK1, ADC_CHANNEL_1, GPIO_NUM_1},
9393
{{&machine_adc_type}, ADCBLOCK1, ADC_CHANNEL_2, GPIO_NUM_2},

ports/esp32/machine_adc_block.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ machine_adc_block_obj_t madcblock_obj[] = {
3535
#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S3
3636
{{&machine_adc_block_type}, ADC_UNIT_1, 12, -1, {0}},
3737
{{&machine_adc_block_type}, ADC_UNIT_2, 12, -1, {0}},
38-
#elif CONFIG_IDF_TARGET_ESP32S2
38+
#elif CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32C6
3939
{{&machine_adc_block_type}, ADC_UNIT_1, 13, -1, {0}},
4040
{{&machine_adc_block_type}, ADC_UNIT_2, 13, -1, {0}},
4141
#endif

ports/esp32/machine_bitstream.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
// This is a translation of the cycle counter implementation in ports/stm32/machine_bitstream.c.
4343
static void IRAM_ATTR machine_bitstream_high_low_bitbang(mp_hal_pin_obj_t pin, uint32_t *timing_ns, const uint8_t *buf, size_t len) {
4444
uint32_t pin_mask, gpio_reg_set, gpio_reg_clear;
45-
#if !CONFIG_IDF_TARGET_ESP32C3
45+
#if !CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6
4646
if (pin >= 32) {
4747
pin_mask = 1 << (pin - 32);
4848
gpio_reg_set = GPIO_OUT1_W1TS_REG;

ports/esp32/machine_hw_spi.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@
3838
#include "soc/spi_pins.h"
3939

4040
// SPI mappings by device, naming used by IDF old/new
41-
// upython | ESP32 | ESP32S2 | ESP32S3 | ESP32C3
42-
// ----------+-----------+-----------+---------+---------
43-
// SPI(id=1) | HSPI/SPI2 | FSPI/SPI2 | SPI2 | SPI2
44-
// SPI(id=2) | VSPI/SPI3 | HSPI/SPI3 | SPI3 | err
41+
// upython | ESP32 | ESP32S2 | ESP32S3 | ESP32C3 | ESP32C6
42+
// ----------+-----------+-----------+---------+---------+---------
43+
// SPI(id=1) | HSPI/SPI2 | FSPI/SPI2 | SPI2 | SPI2 | SPI2
44+
// SPI(id=2) | VSPI/SPI3 | HSPI/SPI3 | SPI3 | err | err
4545

4646
// Number of available hardware SPI peripherals.
4747
#if SOC_SPI_PERIPH_NUM > 2
@@ -251,14 +251,14 @@ static void machine_hw_spi_init_internal(machine_hw_spi_obj_t *self, mp_arg_val_
251251

252252
// Select DMA channel based on the hardware SPI host
253253
int dma_chan = 0;
254-
#if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32C3
255-
dma_chan = SPI_DMA_CH_AUTO;
256-
#else
254+
#if CONFIG_IDF_TARGET_ESP32
257255
if (self->host == SPI2_HOST) {
258256
dma_chan = 1;
259257
} else {
260258
dma_chan = 2;
261259
}
260+
#else
261+
dma_chan = SPI_DMA_CH_AUTO;
262262
#endif
263263

264264
ret = spi_bus_initialize(self->host, &buscfg, dma_chan);

ports/esp32/machine_i2c.c

100755100644
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
#endif
5050
#endif
5151

52-
#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S3
52+
#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32S3
5353
#define I2C_SCLK_FREQ XTAL_CLK_FREQ
5454
#elif CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2
5555
#define I2C_SCLK_FREQ APB_CLK_FREQ

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy