Skip to content

Commit 4b6540f

Browse files
authored
Merge pull request #65 from espressif/esp32-s3-support
WIP: Initial support for PSRAM (QSPI and OPI)
2 parents 6a775a6 + 82e41de commit 4b6540f

File tree

95 files changed

+1128
-1826
lines changed

Some content is hidden

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

95 files changed

+1128
-1826
lines changed

Diff for: boards.txt

+10-3
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ esp32s3.build.flash_mode=dio
5555
esp32s3.build.boot=qio
5656
esp32s3.build.partitions=default
5757
esp32s3.build.defines=
58+
esp32s3.build.extra_libs="-L{compiler.sdk.path}/lib/spiram"
5859
esp32s3.build.loop_core=
5960
esp32s3.build.event_core=
6061

@@ -97,8 +98,13 @@ esp32s3.menu.UploadMode.cdc.upload.wait_for_upload_port=true
9798

9899
esp32s3.menu.PSRAM.disabled=Disabled
99100
esp32s3.menu.PSRAM.disabled.build.defines=
100-
esp32s3.menu.PSRAM.enabled=Enabled
101-
esp32s3.menu.PSRAM.enabled.build.defines=-DBOARD_HAS_PSRAM
101+
esp32s3.menu.PSRAM.disabled.build.extra_libs="-L{compiler.sdk.path}/lib/spiram"
102+
esp32s3.menu.PSRAM.qspi=QSPI
103+
esp32s3.menu.PSRAM.qspi.build.defines=-DBOARD_HAS_PSRAM
104+
esp32s3.menu.PSRAM.qspi.build.extra_libs="-L{compiler.sdk.path}/lib/spiram"
105+
esp32s3.menu.PSRAM.opi=OPI
106+
esp32s3.menu.PSRAM.opi.build.defines=-DBOARD_HAS_PSRAM -DCONFIG_SPIRAM_BOOT_INIT -DCONFIG_SPIRAM_MODE_OCT=1
107+
esp32s3.menu.PSRAM.opi.build.extra_libs="-L{compiler.sdk.path}/lib/opiram"
102108

103109
esp32s3.menu.PartitionScheme.default=Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS)
104110
esp32s3.menu.PartitionScheme.default.build.partitions=default
@@ -878,7 +884,8 @@ esp32s3box.build.flash_freq=80m
878884
esp32s3box.build.flash_mode=dio
879885
esp32s3box.build.boot=qio
880886
esp32s3box.build.partitions=default
881-
esp32s3box.build.defines=-DBOARD_HAS_PSRAM
887+
esp32s3box.build.extra_libs="-L{compiler.sdk.path}/lib/opiram"
888+
esp32s3box.build.defines=-DBOARD_HAS_PSRAM -DCONFIG_SPIRAM_BOOT_INIT -DCONFIG_SPIRAM_MODE_OCT=1
882889
esp32s3box.build.loop_core=-DARDUINO_RUNNING_CORE=1
883890
esp32s3box.build.event_core=-DARDUINO_EVENT_RUNNING_CORE=1
884891

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ void initArduino()
235235
#endif
236236
esp_log_level_set("*", CONFIG_LOG_DEFAULT_LEVEL);
237237
esp_err_t err = nvs_flash_init();
238-
if(err == ESP_ERR_NVS_NO_FREE_PAGES){
238+
if(err == ESP_ERR_NVS_NO_FREE_PAGES || err == ESP_ERR_NVS_NEW_VERSION_FOUND){
239239
const esp_partition_t* partition = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_NVS, NULL);
240240
if (partition != NULL) {
241241
err = esp_partition_erase_range(partition, 0, partition->size);
@@ -244,6 +244,8 @@ void initArduino()
244244
} else {
245245
log_e("Failed to format the broken NVS partition!");
246246
}
247+
} else {
248+
log_e("Could not find NVS partition");
247249
}
248250
}
249251
if(err) {

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,12 @@ bool psramInit(){
8787
log_e("PSRAM could not be added to the heap!");
8888
return false;
8989
}
90-
#if CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL && !CONFIG_ARDUINO_ISR_IRAM
91-
heap_caps_malloc_extmem_enable(CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL);
92-
#endif
90+
#if CONFIG_SPIRAM_USE_MALLOC && !CONFIG_ARDUINO_ISR_IRAM
91+
heap_caps_malloc_extmem_enable(CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL);
9392
#endif
93+
#endif /* CONFIG_SPIRAM_BOOT_INIT */
94+
log_i("PSRAM enabled");
9495
spiramDetected = true;
95-
log_d("PSRAM enabled");
9696
return true;
9797
}
9898

Diff for: libraries/HTTPClient/src/HTTPClient.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ bool HTTPClient::beginInternal(String url, const char* expectedProtocol)
255255

256256
_protocol = url.substring(0, index);
257257
if (_protocol != expectedProtocol) {
258-
log_w("unexpected protocol: %s, expected %s", _protocol.c_str(), expectedProtocol);
258+
log_d("unexpected protocol: %s, expected %s", _protocol.c_str(), expectedProtocol);
259259
return false;
260260
}
261261

Diff for: libraries/WiFiClientSecure/src/ssl_client.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ int start_ssl_client(sslclient_context *ssl_client, const char *host, uint32_t p
171171

172172
if (insecure) {
173173
mbedtls_ssl_conf_authmode(&ssl_client->ssl_conf, MBEDTLS_SSL_VERIFY_NONE);
174-
log_i("WARNING: Skipping SSL Verification. INSECURE!");
174+
log_d("WARNING: Skipping SSL Verification. INSECURE!");
175175
} else if (rootCABuff != NULL) {
176176
log_v("Loading CA cert");
177177
mbedtls_x509_crt_init(&ssl_client->ca_cert);

Diff for: platform.txt

+4-3
Large diffs are not rendered by default.

Diff for: tools/platformio-build-esp32s3.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@
307307
"UNITY_INCLUDE_CONFIG_H",
308308
"WITH_POSIX",
309309
"_GNU_SOURCE",
310-
("IDF_VER", '\\"v4.4-rc1\\"'),
310+
("IDF_VER", '\\"v4.4-98-geb3797dc3f\\"'),
311311
"ESP_PLATFORM",
312312
"_POSIX_READER_WRITER_LOCKS",
313313
"ARDUINO_ARCH_ESP32",

Diff for: tools/sdk/esp32s3/include/bt/host/bluedroid/api/include/api/esp_gap_bt_api.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ typedef enum {
236236
#define ESP_BT_GAP_MIN_INQ_LEN (0x01) /*!< Minimum inquiry duration, unit is 1.28s */
237237
#define ESP_BT_GAP_MAX_INQ_LEN (0x30) /*!< Maximum inquiry duration, unit is 1.28s */
238238

239-
/// A2DP state callback parameters
239+
/// GAP state callback parameters
240240
typedef union {
241241
/**
242242
* @brief ESP_BT_GAP_DISC_RES_EVT

Diff for: tools/sdk/esp32s3/include/driver/include/driver/ledc.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -443,9 +443,6 @@ esp_err_t ledc_set_fade_time_and_start(ledc_mode_t speed_mode, ledc_channel_t ch
443443
* - ESP_FAIL Fade function init error
444444
*/
445445
esp_err_t ledc_set_fade_step_and_start(ledc_mode_t speed_mode, ledc_channel_t channel, uint32_t target_duty, uint32_t scale, uint32_t cycle_num, ledc_fade_mode_t fade_mode);
446-
#ifdef __cplusplus
447-
}
448-
#endif
449446

450447
/**
451448
* @brief LEDC callback registration function
@@ -461,3 +458,6 @@ esp_err_t ledc_set_fade_step_and_start(ledc_mode_t speed_mode, ledc_channel_t ch
461458
* - ESP_FAIL Fade function init error
462459
*/
463460
esp_err_t ledc_cb_register(ledc_mode_t speed_mode, ledc_channel_t channel, ledc_cbs_t *cbs, void *user_arg);
461+
#ifdef __cplusplus
462+
}
463+
#endif

Diff for: tools/sdk/esp32s3/include/esp_common/include/esp_check.h

+8
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ extern "C" {
2525
*/
2626
#if defined(CONFIG_COMPILER_OPTIMIZATION_CHECKS_SILENT)
2727
#define ESP_RETURN_ON_ERROR(x, log_tag, format, ...) do { \
28+
(void)log_tag; \
2829
esp_err_t err_rc_ = (x); \
2930
if (unlikely(err_rc_ != ESP_OK)) { \
3031
return err_rc_; \
@@ -35,6 +36,7 @@ extern "C" {
3536
* A version of ESP_RETURN_ON_ERROR() macro that can be called from ISR.
3637
*/
3738
#define ESP_RETURN_ON_ERROR_ISR(x, log_tag, format, ...) do { \
39+
(void)log_tag; \
3840
esp_err_t err_rc_ = (x); \
3941
if (unlikely(err_rc_ != ESP_OK)) { \
4042
return err_rc_; \
@@ -46,6 +48,7 @@ extern "C" {
4648
* sets the local variable 'ret' to the code, and then exits by jumping to 'goto_tag'.
4749
*/
4850
#define ESP_GOTO_ON_ERROR(x, goto_tag, log_tag, format, ...) do { \
51+
(void)log_tag; \
4952
esp_err_t err_rc_ = (x); \
5053
if (unlikely(err_rc_ != ESP_OK)) { \
5154
ret = err_rc_; \
@@ -57,6 +60,7 @@ extern "C" {
5760
* A version of ESP_GOTO_ON_ERROR() macro that can be called from ISR.
5861
*/
5962
#define ESP_GOTO_ON_ERROR_ISR(x, goto_tag, log_tag, format, ...) do { \
63+
(void)log_tag; \
6064
esp_err_t err_rc_ = (x); \
6165
if (unlikely(err_rc_ != ESP_OK)) { \
6266
ret = err_rc_; \
@@ -69,6 +73,7 @@ extern "C" {
6973
* and returns with the supplied 'err_code'.
7074
*/
7175
#define ESP_RETURN_ON_FALSE(a, err_code, log_tag, format, ...) do { \
76+
(void)log_tag; \
7277
if (unlikely(!(a))) { \
7378
return err_code; \
7479
} \
@@ -78,6 +83,7 @@ extern "C" {
7883
* A version of ESP_RETURN_ON_FALSE() macro that can be called from ISR.
7984
*/
8085
#define ESP_RETURN_ON_FALSE_ISR(a, err_code, log_tag, format, ...) do { \
86+
(void)log_tag; \
8187
if (unlikely(!(a))) { \
8288
return err_code; \
8389
} \
@@ -88,6 +94,7 @@ extern "C" {
8894
* sets the local variable 'ret' to the supplied 'err_code', and then exits by jumping to 'goto_tag'.
8995
*/
9096
#define ESP_GOTO_ON_FALSE(a, err_code, goto_tag, log_tag, format, ...) do { \
97+
(void)log_tag; \
9198
if (unlikely(!(a))) { \
9299
ret = err_code; \
93100
goto goto_tag; \
@@ -98,6 +105,7 @@ extern "C" {
98105
* A version of ESP_GOTO_ON_FALSE() macro that can be called from ISR.
99106
*/
100107
#define ESP_GOTO_ON_FALSE_ISR(a, err_code, goto_tag, log_tag, format, ...) do { \
108+
(void)log_tag; \
101109
if (unlikely(!(a))) { \
102110
ret = err_code; \
103111
goto goto_tag; \

Diff for: tools/sdk/esp32s3/include/esp_common/include/esp_err.h

+7-13
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
1-
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
2-
//
3-
// Licensed under the Apache License, Version 2.0 (the "License");
4-
// you may not use this file except in compliance with the License.
5-
// You may obtain a copy of the License at
6-
7-
// http://www.apache.org/licenses/LICENSE-2.0
8-
//
9-
// Unless required by applicable law or agreed to in writing, software
10-
// distributed under the License is distributed on an "AS IS" BASIS,
11-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
// See the License for the specific language governing permissions and
13-
// limitations under the License.
1+
/*
2+
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
147
#pragma once
158

169
#include <stdint.h>
@@ -46,6 +39,7 @@ typedef int esp_err_t;
4639
#define ESP_ERR_MESH_BASE 0x4000 /*!< Starting number of MESH error codes */
4740
#define ESP_ERR_FLASH_BASE 0x6000 /*!< Starting number of flash error codes */
4841
#define ESP_ERR_HW_CRYPTO_BASE 0xc000 /*!< Starting number of HW cryptography module error codes */
42+
#define ESP_ERR_MEMPROT_BASE 0xd000 /*!< Starting number of Memory Protection API error codes */
4943

5044
/**
5145
* @brief Returns string for esp_err_t error codes

0 commit comments

Comments
 (0)