Skip to content

Commit f5a93b1

Browse files
authored
Merge branch 'master' into wifi_client_conn_timeout
2 parents fb1668e + 1e980bd commit f5a93b1

File tree

93 files changed

+5009
-2072
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+5009
-2072
lines changed

Diff for: .github/workflows/push.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ jobs:
9393
# https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/tools/idf-docker-image.html
9494
# for details.
9595
idf_ver: ["release-v5.1"]
96-
idf_target: ["esp32", "esp32s2", "esp32s3", "esp32c3", "esp32c6", "esp32h2"]
96+
idf_target: ["esp32", "esp32s2", "esp32s3", "esp32c2", "esp32c3", "esp32c6", "esp32h2"]
9797
container: espressif/idf:${{ matrix.idf_ver }}
9898
steps:
9999
- name: Check out arduino-esp32 as a component

Diff for: CMakeLists.txt

-12
Original file line numberDiff line numberDiff line change
@@ -254,21 +254,9 @@ function(maybe_add_component component_name)
254254
endif()
255255
endfunction()
256256

257-
maybe_add_component(esp-dsp)
258-
259-
if(CONFIG_ESP_INSIGHTS_ENABLED)
260-
maybe_add_component(esp_insights)
261-
endif()
262-
if(CONFIG_ESP_RMAKER_WORK_QUEUE_TASK_STACK)
263-
maybe_add_component(esp_rainmaker)
264-
maybe_add_component(qrcode)
265-
endif()
266257
if(IDF_TARGET MATCHES "esp32s2|esp32s3" AND CONFIG_TINYUSB_ENABLED)
267258
maybe_add_component(arduino_tinyusb)
268259
endif()
269260
if(NOT CONFIG_ARDUINO_SELECTIVE_COMPILATION OR CONFIG_ARDUINO_SELECTIVE_ArduinoOTA)
270261
maybe_add_component(esp_https_ota)
271262
endif()
272-
if(NOT CONFIG_ARDUINO_SELECTIVE_COMPILATION OR CONFIG_ARDUINO_SELECTIVE_LITTLEFS)
273-
maybe_add_component(esp_littlefs)
274-
endif()

Diff for: boards.txt

+3,285-1,371
Large diffs are not rendered by default.

Diff for: cores/esp32/Arduino.h

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939

4040
#include "stdlib_noniso.h"
4141
#include "binary.h"
42+
#include "extra_attr.h"
4243

4344
#define PI 3.1415926535897932384626433832795
4445
#define HALF_PI 1.5707963267948966192313216916398

Diff for: cores/esp32/Esp.cpp

+95-21
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ extern "C" {
4848
#include "esp32s3/rom/spi_flash.h"
4949
#include "soc/efuse_reg.h"
5050
#define ESP_FLASH_IMAGE_BASE 0x0000 // Esp32s3 is located at 0x0000
51+
#elif CONFIG_IDF_TARGET_ESP32C2
52+
#include "esp32c2/rom/spi_flash.h"
53+
#define ESP_FLASH_IMAGE_BASE 0x0000 // Esp32c2 is located at 0x0000
5154
#elif CONFIG_IDF_TARGET_ESP32C3
5255
#include "esp32c3/rom/spi_flash.h"
5356
#define ESP_FLASH_IMAGE_BASE 0x0000 // Esp32c3 is located at 0x0000
@@ -366,7 +369,7 @@ FlashMode_t EspClass::getFlashChipMode(void)
366369
#if CONFIG_IDF_TARGET_ESP32S2
367370
uint32_t spi_ctrl = REG_READ(PERIPHS_SPI_FLASH_CTRL);
368371
#else
369-
#if CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32C6
372+
#if CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C6
370373
uint32_t spi_ctrl = REG_READ(DR_REG_SPI0_BASE + 0x8);
371374
#else
372375
uint32_t spi_ctrl = REG_READ(SPI_CTRL_REG(0));
@@ -391,38 +394,109 @@ FlashMode_t EspClass::getFlashChipMode(void)
391394

392395
uint32_t EspClass::magicFlashChipSize(uint8_t byte)
393396
{
397+
/*
398+
FLASH_SIZES = {
399+
"1MB": 0x00,
400+
"2MB": 0x10,
401+
"4MB": 0x20,
402+
"8MB": 0x30,
403+
"16MB": 0x40,
404+
"32MB": 0x50,
405+
"64MB": 0x60,
406+
"128MB": 0x70,
407+
}
408+
*/
394409
switch(byte & 0x0F) {
395-
case 0x0: // 8 MBit (1MB)
396-
return (1_MB);
397-
case 0x1: // 16 MBit (2MB)
398-
return (2_MB);
399-
case 0x2: // 32 MBit (4MB)
400-
return (4_MB);
401-
case 0x3: // 64 MBit (8MB)
402-
return (8_MB);
403-
case 0x4: // 128 MBit (16MB)
404-
return (16_MB);
405-
default: // fail?
410+
case 0x0: return (1_MB); // 8 MBit (1MB)
411+
case 0x1: return (2_MB); // 16 MBit (2MB)
412+
case 0x2: return (4_MB); // 32 MBit (4MB)
413+
case 0x3: return (8_MB); // 64 MBit (8MB)
414+
case 0x4: return (16_MB); // 128 MBit (16MB)
415+
case 0x5: return (32_MB); // 256 MBit (32MB)
416+
case 0x6: return (64_MB); // 512 MBit (64MB)
417+
case 0x7: return (128_MB); // 1 GBit (128MB)
418+
default: // fail?
406419
return 0;
407420
}
408421
}
409422

410423
uint32_t EspClass::magicFlashChipSpeed(uint8_t byte)
411424
{
425+
#if CONFIG_IDF_TARGET_ESP32C2
426+
/*
427+
FLASH_FREQUENCY = {
428+
"60m": 0xF,
429+
"30m": 0x0,
430+
"20m": 0x1,
431+
"15m": 0x2,
432+
}
433+
*/
434+
switch(byte & 0x0F) {
435+
case 0xF: return (60_MHz);
436+
case 0x0: return (30_MHz);
437+
case 0x1: return (20_MHz);
438+
case 0x2: return (15_MHz);
439+
default: // fail?
440+
return 0;
441+
}
442+
443+
444+
#elif CONFIG_IDF_TARGET_ESP32C6
445+
/*
446+
FLASH_FREQUENCY = {
447+
"80m": 0x0, # workaround for wrong mspi HS div value in ROM
448+
"40m": 0x0,
449+
"20m": 0x2,
450+
}
451+
*/
452+
switch(byte & 0x0F) {
453+
case 0x0: return (80_MHz);
454+
case 0x2: return (20_MHz);
455+
default: // fail?
456+
return 0;
457+
}
458+
459+
#elif CONFIG_IDF_TARGET_ESP32H2
460+
461+
/*
462+
FLASH_FREQUENCY = {
463+
"48m": 0xF,
464+
"24m": 0x0,
465+
"16m": 0x1,
466+
"12m": 0x2,
467+
}
468+
*/
412469
switch(byte & 0x0F) {
413-
case 0x0: // 40 MHz
414-
return (40_MHz);
415-
case 0x1: // 26 MHz
416-
return (26_MHz);
417-
case 0x2: // 20 MHz
418-
return (20_MHz);
419-
case 0xf: // 80 MHz
420-
return (80_MHz);
421-
default: // fail?
470+
case 0xF: return (48_MHz);
471+
case 0x0: return (24_MHz);
472+
case 0x1: return (16_MHz);
473+
case 0x2: return (12_MHz);
474+
default: // fail?
422475
return 0;
423476
}
477+
478+
479+
#else
480+
/*
481+
FLASH_FREQUENCY = {
482+
"80m": 0xF,
483+
"40m": 0x0,
484+
"26m": 0x1,
485+
"20m": 0x2,
486+
}
487+
*/
488+
switch(byte & 0x0F) {
489+
case 0xF: return (80_MHz);
490+
case 0x0: return (40_MHz);
491+
case 0x1: return (26_MHz);
492+
case 0x2: return (20_MHz);
493+
default: // fail?
494+
return 0;
495+
}
496+
#endif
424497
}
425498

499+
426500
FlashMode_t EspClass::magicFlashChipMode(uint8_t byte)
427501
{
428502
FlashMode_t mode = (FlashMode_t) byte;

Diff for: cores/esp32/HWCDC.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ bool HWCDC::deinit(void * busptr)
181181
running = true;
182182
// Setting USB D+ D- pins
183183
bool retCode = true;
184-
retCode &= perimanSetPinBus(USB_DM_GPIO_NUM, ESP32_BUS_TYPE_INIT, NULL);
185-
retCode &= perimanSetPinBus(USB_DP_GPIO_NUM, ESP32_BUS_TYPE_INIT, NULL);
184+
retCode &= perimanClearPinBus(USB_DM_GPIO_NUM);
185+
retCode &= perimanClearPinBus(USB_DP_GPIO_NUM);
186186
if (retCode) {
187187
// Force the host to re-enumerate (BUS_RESET)
188188
pinMode(USB_DM_GPIO_NUM, OUTPUT_OPEN_DRAIN);
@@ -220,10 +220,10 @@ void HWCDC::begin(unsigned long baud)
220220
end();
221221
return;
222222
}
223-
if (perimanSetBusDeinit(ESP32_BUS_TYPE_USB, HWCDC::deinit)) {
223+
if (perimanSetBusDeinit(ESP32_BUS_TYPE_USB_DM, HWCDC::deinit) && perimanSetBusDeinit(ESP32_BUS_TYPE_USB_DP, HWCDC::deinit)) {
224224
// Setting USB D+ D- pins
225-
perimanSetPinBus(USB_DM_GPIO_NUM, ESP32_BUS_TYPE_USB, (void *) this);
226-
perimanSetPinBus(USB_DP_GPIO_NUM, ESP32_BUS_TYPE_USB, (void *) this);
225+
perimanSetPinBus(USB_DM_GPIO_NUM, ESP32_BUS_TYPE_USB_DM, (void *) this, -1, -1);
226+
perimanSetPinBus(USB_DP_GPIO_NUM, ESP32_BUS_TYPE_USB_DP, (void *) this, -1, -1);
227227
} else {
228228
log_e("Serial JTAG Pins can't be set into Peripheral Manager.");
229229
}

Diff for: cores/esp32/HardwareSerial.h

+8
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ typedef enum {
118118
#define SOC_RX0 (gpio_num_t)3
119119
#elif CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
120120
#define SOC_RX0 (gpio_num_t)44
121+
#elif CONFIG_IDF_TARGET_ESP32C2
122+
#define SOC_RX0 (gpio_num_t)19
121123
#elif CONFIG_IDF_TARGET_ESP32C3
122124
#define SOC_RX0 (gpio_num_t)20
123125
#elif CONFIG_IDF_TARGET_ESP32C6
@@ -132,6 +134,8 @@ typedef enum {
132134
#define SOC_TX0 (gpio_num_t)1
133135
#elif CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
134136
#define SOC_TX0 (gpio_num_t)43
137+
#elif CONFIG_IDF_TARGET_ESP32C2
138+
#define SOC_TX0 (gpio_num_t)20
135139
#elif CONFIG_IDF_TARGET_ESP32C3
136140
#define SOC_TX0 (gpio_num_t)21
137141
#elif CONFIG_IDF_TARGET_ESP32C6
@@ -149,6 +153,8 @@ typedef enum {
149153
#define RX1 (gpio_num_t)26
150154
#elif CONFIG_IDF_TARGET_ESP32S2
151155
#define RX1 (gpio_num_t)4
156+
#elif CONFIG_IDF_TARGET_ESP32C2
157+
#define RX1 (gpio_num_t)10
152158
#elif CONFIG_IDF_TARGET_ESP32C3
153159
#define RX1 (gpio_num_t)18
154160
#elif CONFIG_IDF_TARGET_ESP32S3
@@ -165,6 +171,8 @@ typedef enum {
165171
#define TX1 (gpio_num_t)27
166172
#elif CONFIG_IDF_TARGET_ESP32S2
167173
#define TX1 (gpio_num_t)5
174+
#elif CONFIG_IDF_TARGET_ESP32C2
175+
#define TX1 (gpio_num_t)18
168176
#elif CONFIG_IDF_TARGET_ESP32C3
169177
#define TX1 (gpio_num_t)19
170178
#elif CONFIG_IDF_TARGET_ESP32S3

Diff for: cores/esp32/chip-debug-report.cpp

+19-2
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,8 @@ static void printBoardInfo(void){
242242
static void printPerimanInfo(void){
243243
chip_report_printf("GPIO Info:\n");
244244
chip_report_printf("------------------------------------------\n");
245+
chip_report_printf(" GPIO : BUS_TYPE[bus/unit][chan]\n");
246+
chip_report_printf(" -------------------------------------- \n");
245247
for(uint8_t i = 0; i < SOC_GPIO_PIN_COUNT; i++){
246248
if(!perimanPinIsValid(i)){
247249
continue;//invalid pin
@@ -250,8 +252,23 @@ static void printPerimanInfo(void){
250252
if(type == ESP32_BUS_TYPE_INIT){
251253
continue;//unused pin
252254
}
253-
chip_report_printf(" %17u : ", i);
254-
chip_report_printf("%s\n", perimanGetTypeName(type));
255+
const char* extra_type = perimanGetPinBusExtraType(i);
256+
chip_report_printf(" %4u : ", i);
257+
if(extra_type){
258+
chip_report_printf("%s", extra_type);
259+
}
260+
else {
261+
chip_report_printf("%s", perimanGetTypeName(type));
262+
}
263+
int8_t bus_number = perimanGetPinBusNum(i);
264+
if (bus_number != -1){
265+
chip_report_printf("[%u]", bus_number);
266+
}
267+
int8_t bus_channel = perimanGetPinBusChannel(i);
268+
if (bus_channel != -1){
269+
chip_report_printf("[%u]", bus_channel);
270+
}
271+
chip_report_printf("\n");
255272
}
256273
}
257274

Diff for: cores/esp32/esp32-hal-adc.c

+12-4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@
2121
#include "esp_adc/adc_continuous.h"
2222
#include "esp_adc/adc_cali_scheme.h"
2323

24+
// ESP32-C2 does not define those two for some reason
25+
#ifndef SOC_ADC_DIGI_RESULT_BYTES
26+
#define SOC_ADC_DIGI_RESULT_BYTES (4)
27+
#endif
28+
#ifndef SOC_ADC_DIGI_DATA_BYTES_PER_CONV
29+
#define SOC_ADC_DIGI_DATA_BYTES_PER_CONV (4)
30+
#endif
31+
2432
static uint8_t __analogAttenuation = ADC_11db;
2533
static uint8_t __analogWidth = SOC_ADC_RTC_MAX_BITWIDTH;
2634
static uint8_t __analogReturnedWidth = SOC_ADC_RTC_MAX_BITWIDTH;
@@ -213,7 +221,7 @@ esp_err_t __analogInit(uint8_t pin, adc_channel_t channel, adc_unit_t adc_unit){
213221
}
214222
}
215223

216-
if(!perimanSetPinBus(pin, ESP32_BUS_TYPE_ADC_ONESHOT, (void *)(pin+1))){
224+
if(!perimanSetPinBus(pin, ESP32_BUS_TYPE_ADC_ONESHOT, (void *)(pin+1), adc_unit, channel)){
217225
adcDetachBus((void *)(pin+1));
218226
return err;
219227
}
@@ -388,7 +396,7 @@ static bool adcContinuousDetachBus(void * adc_unit_number){
388396
int io_pin;
389397
adc_oneshot_channel_to_io(adc_unit, channel, &io_pin);
390398
if(perimanGetPinBusType(io_pin) == ESP32_BUS_TYPE_ADC_CONT){
391-
if(!perimanSetPinBus(io_pin, ESP32_BUS_TYPE_INIT, NULL)){
399+
if(!perimanClearPinBus(io_pin)){
392400
return false;
393401
}
394402
}
@@ -489,7 +497,7 @@ bool analogContinuous(uint8_t pins[], size_t pins_count, uint32_t conversions_pe
489497
//Set periman deinit function and reset all pins to init state.
490498
perimanSetBusDeinit(ESP32_BUS_TYPE_ADC_CONT, adcContinuousDetachBus);
491499
for(int j = 0; j < pins_count; j++){
492-
if(!perimanSetPinBus(pins[j], ESP32_BUS_TYPE_INIT, NULL)){
500+
if(!perimanClearPinBus(pins[j])){
493501
return false;
494502
}
495503
}
@@ -563,7 +571,7 @@ bool analogContinuous(uint8_t pins[], size_t pins_count, uint32_t conversions_pe
563571
}
564572

565573
for(int k = 0; k < pins_count; k++){
566-
if(!perimanSetPinBus(pins[k], ESP32_BUS_TYPE_ADC_CONT, (void *)(adc_unit+1))){
574+
if(!perimanSetPinBus(pins[k], ESP32_BUS_TYPE_ADC_CONT, (void *)(adc_unit+1), adc_unit, channel[k])){
567575
log_e("perimanSetPinBus to ADC Continuous failed!");
568576
adcContinuousDetachBus((void *)(adc_unit+1));
569577
return false;

Diff for: cores/esp32/esp32-hal-cpu.c

+6-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include "esp_attr.h"
2020
#include "esp_log.h"
2121
#include "soc/rtc.h"
22-
#if !defined(CONFIG_IDF_TARGET_ESP32C6) && !defined(CONFIG_IDF_TARGET_ESP32H2)
22+
#if !defined(CONFIG_IDF_TARGET_ESP32C2) && !defined(CONFIG_IDF_TARGET_ESP32C6) && !defined(CONFIG_IDF_TARGET_ESP32H2)
2323
#include "soc/rtc_cntl_reg.h"
2424
#include "soc/apb_ctrl_reg.h"
2525
#endif
@@ -38,6 +38,8 @@
3838
#elif CONFIG_IDF_TARGET_ESP32S3
3939
#include "freertos/xtensa_timer.h"
4040
#include "esp32s3/rom/rtc.h"
41+
#elif CONFIG_IDF_TARGET_ESP32C2
42+
#include "esp32c2/rom/rtc.h"
4143
#elif CONFIG_IDF_TARGET_ESP32C3
4244
#include "esp32c3/rom/rtc.h"
4345
#elif CONFIG_IDF_TARGET_ESP32C6
@@ -153,7 +155,7 @@ bool removeApbChangeCallback(void * arg, apb_change_cb_t cb){
153155
}
154156

155157
static uint32_t calculateApb(rtc_cpu_freq_config_t * conf){
156-
#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32H2
158+
#if CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32H2
157159
return APB_CLK_FREQ;
158160
#else
159161
if(conf->freq_mhz >= 80){
@@ -228,7 +230,7 @@ bool setCpuFrequencyMhz(uint32_t cpu_freq_mhz){
228230
}
229231
//Make the frequency change
230232
rtc_clk_cpu_freq_set_config_fast(&conf);
231-
#if !defined(CONFIG_IDF_TARGET_ESP32C6) && !defined(CONFIG_IDF_TARGET_ESP32H2)
233+
#if !defined(CONFIG_IDF_TARGET_ESP32C2) && !defined(CONFIG_IDF_TARGET_ESP32C6) && !defined(CONFIG_IDF_TARGET_ESP32H2)
232234
if(capb != apb){
233235
//Update REF_TICK (uncomment if REF_TICK is different than 1MHz)
234236
//if(conf.freq_mhz < 80){
@@ -241,7 +243,7 @@ bool setCpuFrequencyMhz(uint32_t cpu_freq_mhz){
241243
}
242244
#endif
243245
//Update FreeRTOS Tick Divisor
244-
#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2
246+
#if CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2
245247

246248
#elif CONFIG_IDF_TARGET_ESP32S3
247249

0 commit comments

Comments
 (0)