Skip to content

Commit c6feed9

Browse files
committed
Initial changes to compile under ESP-IDF v5.1
1 parent f1b06d2 commit c6feed9

Some content is hidden

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

46 files changed

+265
-581
lines changed

CMakeLists.txt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
# export ARDUINO_SKIP_IDF_VERSION_CHECK=1
66
# idf.py build
77

8-
set(min_supported_idf_version "4.4.0")
9-
set(max_supported_idf_version "4.4.99")
8+
set(min_supported_idf_version "5.1.0")
9+
set(max_supported_idf_version "5.1.99")
1010
set(idf_version "${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}.${IDF_VERSION_PATCH}")
1111

1212
if ("${idf_version}" AND NOT "$ENV{ARDUINO_SKIP_IDF_VERSION_CHECK}")
@@ -121,7 +121,6 @@ set(LIBRARY_SRCS
121121
libraries/WebServer/src/Parsing.cpp
122122
libraries/WebServer/src/detail/mimetable.cpp
123123
libraries/WiFiClientSecure/src/ssl_client.cpp
124-
libraries/WiFiClientSecure/src/esp_crt_bundle.c
125124
libraries/WiFiClientSecure/src/WiFiClientSecure.cpp
126125
libraries/WiFi/src/WiFiAP.cpp
127126
libraries/WiFi/src/WiFiClient.cpp
@@ -207,8 +206,8 @@ set(includedirs
207206

208207
set(srcs ${CORE_SRCS} ${LIBRARY_SRCS} ${BLE_SRCS})
209208
set(priv_includes cores/esp32/libb64)
210-
set(requires spi_flash mbedtls mdns esp_adc_cal wifi_provisioning nghttp wpa_supplicant)
211-
set(priv_requires fatfs nvs_flash app_update spiffs bootloader_support openssl bt esp_ipc esp_hid)
209+
set(requires spi_flash mbedtls mdns wifi_provisioning wpa_supplicant esp_adc esp_eth http_parser)
210+
set(priv_requires fatfs nvs_flash app_update spiffs bootloader_support bt esp_hid esp_insights)
212211

213212
idf_component_register(INCLUDE_DIRS ${includedirs} PRIV_INCLUDE_DIRS ${priv_includes} SRCS ${srcs} REQUIRES ${requires} PRIV_REQUIRES ${priv_requires})
214213

cores/esp32/Arduino.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@ void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val);
173173
#include "Udp.h"
174174
#include "HardwareSerial.h"
175175
#include "Esp.h"
176-
#include "esp32/spiram.h"
177176

178177
// Use float-compatible stl abs() and round(), we don't use Arduino macros to avoid issues with the C++ libraries
179178
using std::abs;
@@ -192,7 +191,8 @@ size_t getArduinoLoopTaskStackSize(void);
192191
#define SET_LOOP_TASK_STACK_SIZE(sz) size_t getArduinoLoopTaskStackSize() { return sz;}
193192

194193
// allows user to bypass esp_spiram_test()
195-
#define BYPASS_SPIRAM_TEST(bypass) bool testSPIRAM(void) { if (bypass) return true; else return esp_spiram_test(); }
194+
bool esp_psram_extram_test(void);
195+
#define BYPASS_SPIRAM_TEST(bypass) bool testSPIRAM(void) { if (bypass) return true; else return esp_psram_extram_test(); }
196196

197197
unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L);
198198
unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L);

cores/esp32/Esp.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include "Arduino.h"
2121
#include "Esp.h"
2222
#include "esp_sleep.h"
23-
#include "esp_spi_flash.h"
23+
#include "spi_flash_mmap.h"
2424
#include <memory>
2525
#include <soc/soc.h>
2626
#include <esp_partition.h>
@@ -32,6 +32,9 @@ extern "C" {
3232

3333
#include "soc/spi_reg.h"
3434
#include "esp_system.h"
35+
#include "esp_chip_info.h"
36+
#include "esp_mac.h"
37+
#include "esp_flash.h"
3538
#ifdef ESP_IDF_VERSION_MAJOR // IDF 4+
3639
#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4
3740
#include "esp32/rom/spi_flash.h"
@@ -330,7 +333,7 @@ uint32_t EspClass::getFlashChipSize(void)
330333
uint32_t EspClass::getFlashChipSpeed(void)
331334
{
332335
esp_image_header_t fhdr;
333-
if(flashRead(ESP_FLASH_IMAGE_BASE, (uint32_t*)&fhdr, sizeof(esp_image_header_t)) && fhdr.magic != ESP_IMAGE_HEADER_MAGIC) {
336+
if(esp_flash_read(esp_flash_default_chip, (void*)&fhdr, ESP_FLASH_IMAGE_BASE, sizeof(esp_image_header_t)) && fhdr.magic != ESP_IMAGE_HEADER_MAGIC) {
334337
return 0;
335338
}
336339
return magicFlashChipSpeed(fhdr.spi_speed);
@@ -405,18 +408,18 @@ FlashMode_t EspClass::magicFlashChipMode(uint8_t byte)
405408

406409
bool EspClass::flashEraseSector(uint32_t sector)
407410
{
408-
return spi_flash_erase_sector(sector) == ESP_OK;
411+
return esp_flash_erase_region(esp_flash_default_chip, sector * SPI_FLASH_SEC_SIZE, SPI_FLASH_SEC_SIZE) == ESP_OK;
409412
}
410413

411414
// Warning: These functions do not work with encrypted flash
412415
bool EspClass::flashWrite(uint32_t offset, uint32_t *data, size_t size)
413416
{
414-
return spi_flash_write(offset, (uint32_t*) data, size) == ESP_OK;
417+
return esp_flash_write(esp_flash_default_chip, (const void*) data, offset, size) == ESP_OK;
415418
}
416419

417420
bool EspClass::flashRead(uint32_t offset, uint32_t *data, size_t size)
418421
{
419-
return spi_flash_read(offset, (uint32_t*) data, size) == ESP_OK;
422+
return esp_flash_read(esp_flash_default_chip, (void*) data, offset, size) == ESP_OK;
420423
}
421424

422425
bool EspClass::partitionEraseRange(const esp_partition_t *partition, uint32_t offset, size_t size)

cores/esp32/Esp.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <Arduino.h>
2424
#include <esp_partition.h>
2525
#include <hal/cpu_hal.h>
26+
#include "esp_cpu.h"
2627

2728
/**
2829
* AVR macros for WDT managment
@@ -111,7 +112,7 @@ class EspClass
111112

112113
uint32_t ARDUINO_ISR_ATTR EspClass::getCycleCount()
113114
{
114-
return cpu_hal_get_cycle_count();
115+
return (uint32_t)esp_cpu_get_cycle_count();
115116
}
116117

117118
extern EspClass ESP;

cores/esp32/FirmwareMSC.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@
1818
#include <cstring>
1919
#include "esp_partition.h"
2020
#include "esp_ota_ops.h"
21+
#include "esp_image_format.h"
2122
#include "esp32-hal.h"
2223
#include "pins_arduino.h"
2324
#include "firmware_msc_fat.h"
25+
#include "spi_flash_mmap.h"
2426

2527
#ifndef USB_FW_MSC_VENDOR_ID
2628
#define USB_FW_MSC_VENDOR_ID "ESP32" //max 8 chars

cores/esp32/HWCDC.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "esp_intr_alloc.h"
2424
#include "soc/periph_defs.h"
2525
#include "hal/usb_serial_jtag_ll.h"
26+
#include "rom/ets_sys.h"
2627

2728
ESP_EVENT_DEFINE_BASE(ARDUINO_HW_CDC_EVENTS);
2829

cores/esp32/USB.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#include "esp32-hal-tinyusb.h"
2121
#include "common/tusb_common.h"
2222
#include "StreamString.h"
23+
#include "rom/ets_sys.h"
24+
#include "esp_mac.h"
2325

2426
#ifndef USB_VID
2527
#define USB_VID USB_ESPRESSIF_VID

cores/esp32/USBCDC.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include "USBCDC.h"
1818
#include "esp32-hal-tinyusb.h"
19+
#include "rom/ets_sys.h"
1920

2021
ESP_EVENT_DEFINE_BASE(ARDUINO_USB_CDC_EVENTS);
2122
esp_err_t arduino_usb_event_post(esp_event_base_t event_base, int32_t event_id, void *event_data, size_t event_data_size, TickType_t ticks_to_wait);

cores/esp32/WMath.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ extern "C" {
2828
#include "esp_system.h"
2929
}
3030
#include "esp32-hal-log.h"
31+
#include "esp_random.h"
3132

3233
void randomSeed(unsigned long seed)
3334
{

cores/esp32/esp32-hal-adc.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
static uint8_t __analogAttenuation = 3;//11db
2828
static uint8_t __analogWidth = ADC_WIDTH_MAX - 1; //3 for ESP32/ESP32C3; 4 for ESP32S2
29-
static uint8_t __analogReturnedWidth = SOC_ADC_MAX_BITWIDTH; //12 for ESP32/ESP32C3; 13 for ESP32S2
29+
static uint8_t __analogReturnedWidth = SOC_ADC_RTC_MAX_BITWIDTH; //12 for ESP32/ESP32C3; 13 for ESP32S2
3030
static uint8_t __analogClockDiv = 1;
3131
static adc_attenuation_t __pin_attenuation[SOC_GPIO_PIN_COUNT];
3232

@@ -256,13 +256,6 @@ void __analogSetVRefPin(uint8_t pin){
256256
__analogVRefPin = pin;
257257
}
258258

259-
int __hallRead() //hall sensor using idf read
260-
{
261-
pinMode(36, ANALOG);
262-
pinMode(39, ANALOG);
263-
__analogSetWidth(12);
264-
return hall_sensor_read();
265-
}
266259
#endif
267260

268261
extern uint16_t analogRead(uint8_t pin) __attribute__ ((weak, alias("__analogRead")));
@@ -277,5 +270,4 @@ extern bool adcAttachPin(uint8_t pin) __attribute__ ((weak, alias("__adcAttachPi
277270
#if CONFIG_IDF_TARGET_ESP32
278271
extern void analogSetVRefPin(uint8_t pin) __attribute__ ((weak, alias("__analogSetVRefPin")));
279272
extern void analogSetWidth(uint8_t bits) __attribute__ ((weak, alias("__analogSetWidth")));
280-
extern int hallRead() __attribute__ ((weak, alias("__hallRead")));
281273
#endif

0 commit comments

Comments
 (0)