Skip to content

Commit 82e41de

Browse files
committed
WIP: Initial support for PSRAM (QSPI and OPI)
1 parent c210d24 commit 82e41de

File tree

94 files changed

+1122
-1822
lines changed

Some content is hidden

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

94 files changed

+1122
-1822
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-psram.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ bool psramInit(){
9090
#if CONFIG_SPIRAM_USE_MALLOC && !CONFIG_ARDUINO_ISR_IRAM
9191
heap_caps_malloc_extmem_enable(CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL);
9292
#endif
93+
#endif /* CONFIG_SPIRAM_BOOT_INIT */
9394
log_i("PSRAM enabled");
94-
#endif
9595
spiramDetected = true;
9696
return true;
9797
}

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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/////////////////////////////////////////////////////////////////////////////////////////
8+
// ESP Memory Protection API (PMS)
9+
// - allows configuration and violation-interrupt handling of the PMS module operations
10+
// - not intended for public use.
11+
12+
#pragma once
13+
14+
#include "sdkconfig.h"
15+
#if CONFIG_ESP_SYSTEM_MEMPROT_FEATURE || CONFIG_ESP_SYSTEM_MEMPROT_TEST
16+
17+
#include <stdbool.h>
18+
#include <stdint.h>
19+
#include "esp_err.h"
20+
#include "esp_memprot_err.h"
21+
#include "soc_memprot_types.h"
22+
#include "esp_memprot_types.h"
23+
24+
#ifdef __cplusplus
25+
extern "C" {
26+
#endif
27+
28+
#define ESP_MEMPROT_ERR_CHECK(retval, fnc) if ((retval=fnc) != ESP_OK) { return retval; }
29+
30+
/**
31+
* @brief Basic PMS interrupt source info
32+
*/
33+
typedef struct {
34+
esp_mprot_mem_t mem_type; /*!< Memory type containing the faulting address */
35+
int core; /*!< CPU/Core ID running the faulting instruction */
36+
} esp_memp_intr_source_t;
37+
38+
/**
39+
* @brief Clears current interrupt ON flag for given Memory type and CPU/Core ID
40+
*
41+
* This operation is non-atomic for some chips by PMS module design
42+
* In such a case the interrupt clearing happens in two steps:
43+
* 1. Interrupt CLR flag is set (clears interrupt-ON status and inhibits linked interrupt processing)
44+
* 2. Interrupt CLR flag is reset (resumes the interrupt monitoring)
45+
*
46+
* @param mem_type Memory type (see esp_mprot_mem_t enum)
47+
* @param core Target CPU/Core ID (see *_CPU_NUM defs in soc.h). Can be NULL on 1-CPU systems
48+
*
49+
* @return ESP_OK on success
50+
* ESP_ERR_INVALID_ARG on passing invalid pointer
51+
* ESP_ERR_MEMPROT_MEMORY_TYPE_INVALID on invalid mem_type
52+
*/
53+
esp_err_t esp_mprot_monitor_clear_intr(const esp_mprot_mem_t mem_type, int const *const core);
54+
55+
/**
56+
* @brief Checks whether any of the PMS settings is locked
57+
*
58+
* @param[out] locked Any lock on? (true/false)
59+
*
60+
* @return ESP_OK on success
61+
* ESP_ERR_INVALID_ARG on invalid locked ptr
62+
* Other failures: error code of any failing esp_mprot_get_*_lock() routine (called internally)
63+
*/
64+
esp_err_t esp_mprot_is_conf_locked_any(bool *locked);
65+
66+
/**
67+
* @brief Checks whether any PMS violation-interrupt monitoring is enabled
68+
*
69+
* @param[out] locked Any PMS violation interrupt monitor is enabled (true/false)
70+
*
71+
* @return ESP_OK on success
72+
* ESP_ERR_INVALID_ARG on invalid enabled ptr
73+
* Other failures: error code of esp_mprot_get_monitor_en() routine (called internally for all Memory types)
74+
*/
75+
esp_err_t esp_mprot_is_intr_ena_any(bool *enabled);
76+
77+
/**
78+
* @brief Returns active PMS violation-interrupt Memory type if any (MEMPROT_TYPE_NONE when none detected)
79+
* and the CPU/CoreID which was running the faulty code (-1 when no interrupt available)
80+
*
81+
* If there are more interrupts indicated on (shouldn't happen), the order of precedence is given by 'esp_mprot_mem_t' enum definition (low->high)
82+
*
83+
* @param[out] mem_type Out-pointer for Memory type given by the faulting address (see esp_mprot_mem_t enum)
84+
* @param[out] core Out-pointer for CPU/Core ID (see *_CPU_NUM defs in soc.h)
85+
*
86+
* @return ESP_OK on success
87+
* ESP_ERR_INVALID_ARG on passing invalid pointer(s)
88+
*/
89+
esp_err_t esp_mprot_get_active_intr(esp_memp_intr_source_t *active_memp_intr);
90+
91+
/**
92+
* @brief Returns the address which caused the violation interrupt for given Memory type and CPU/Core ID.
93+
* This function is to be called after a basic resolving of (current) interrupt's parameters (ie corresponding
94+
* Memory type and CPU ID see esp_mprot_get_active_intr()). This is to minimize processing time of actual exception
95+
* as this API is typicaly used in a panic-handling code.
96+
* If there is no active interrupt available for the Memory type/CPU ID required, fault_addr is set to NULL.
97+
*
98+
* @param mem_type memory type
99+
* @param[out] fault_addr Address of the operation which caused the PMS violation interrupt
100+
* @param core Faulting instruction CPU/Core ID (see *_CPU_NUM defs in soc.h). Can be NULL on 1-CPU systems
101+
*
102+
* @return ESP_OK on success
103+
* ESP_ERR_MEMPROT_MEMORY_TYPE_INVALID on invalid mem_type
104+
* ESP_ERR_INVALID_ARG on invalid fault_addr pointer
105+
*/
106+
esp_err_t esp_mprot_get_violate_addr(const esp_mprot_mem_t mem_type, void **fault_addr, int const *const core);
107+
108+
/**
109+
* @brief Returns PMS World identifier of the code causing the violation interrupt
110+
*
111+
* The value is read from appropriate PMS violation status register and thus might be 0 if the interrupt is not currently active.
112+
*
113+
* @param mem_type Memory type
114+
* @param[out] world PMS World type (see esp_mprot_pms_world_t)
115+
* @param core Faulting instruction CPU/Core ID (see *_CPU_NUM defs in soc.h). Can be NULL on 1-CPU systems
116+
*
117+
* @return ESP_OK on success
118+
* ESP_ERR_MEMPROT_MEMORY_TYPE_INVALID on invalid mem_type
119+
* ESP_ERR_INVALID_ARG on passing invalid pointer(s)
120+
* ESP_ERR_MEMPROT_WORLD_INVALID on invalid World identifier fetched from the register
121+
*/
122+
esp_err_t esp_mprot_get_violate_world(const esp_mprot_mem_t mem_type, esp_mprot_pms_world_t *world, int const *const core);
123+
124+
/**
125+
* @brief Returns an operation type which caused the violation interrupt
126+
*
127+
* The operation resolving is processed over various PMS status register flags, according to given Memory type argument.
128+
* If the interrupt is not active the result returned is irrelevant (likely evaluated to MEMPROT_OP_READ).
129+
*
130+
* @param mem_type Memory type
131+
* @param[out] oper Operation type (see MEMPROT_OP_* defines)
132+
* @param core Faulting instruction CPU/Core ID (see *_CPU_NUM defs in soc.h). Can be NULL on 1-CPU systems
133+
*
134+
* @return ESP_OK on success
135+
* ESP_ERR_MEMPROT_MEMORY_TYPE_INVALID on invalid mem_type
136+
* ESP_ERR_INVALID_ARG on invalid oper pointer
137+
*/
138+
esp_err_t esp_mprot_get_violate_operation(const esp_mprot_mem_t mem_type, uint32_t *oper, int const *const core);
139+
140+
/**
141+
* @brief Checks whether given memory type supports byte-enables info
142+
*
143+
* Byte-enables status is available only for DMA/DRAM operations
144+
*
145+
* @param mem_type memory type
146+
*
147+
* @return byte-enables info available true/false
148+
*/
149+
bool esp_mprot_has_byte_enables(const esp_mprot_mem_t mem_type);
150+
151+
/**
152+
* @brief Returns byte-enables for the address which caused the violation interrupt
153+
*
154+
* The value is taken from appropriate PMS violation status register, based on given Memory type
155+
*
156+
* @param mem_type Memory type (MEMPROT_TYPE_DRAM0_SRAM)
157+
* @param[out] byte_en Byte-enables bits
158+
* @param core Faulting instruction CPU/Core ID (see *_CPU_NUM defs in soc.h). Can be NULL on 1-CPU systems
159+
*
160+
* @return ESP_OK on success
161+
* ESP_ERR_MEMPROT_MEMORY_TYPE_INVALID on invalid mem_type
162+
* ESP_ERR_INVALID_ARGUMENT on invalid byte_en pointer
163+
*/
164+
esp_err_t esp_mprot_get_violate_byte_enables(const esp_mprot_mem_t mem_type, uint32_t *byte_en, int const *const core);
165+
166+
/**
167+
* @brief Convenient routine for setting the PMS defaults
168+
*
169+
* Called on system startup, depending on ESP_SYSTEM_MEMPROT_FEATURE Kconfig value
170+
*
171+
* @param memp_config pointer to Memprot configuration structure (esp_memp_config_t). The structure si chip-specific,
172+
* for details and defaults see appropriate [target-chip]/soc_memprot_types.h
173+
*
174+
* @return ESP_OK on success
175+
* Other failures: error code of the failing routine called internally. No specific error processing provided in such a case
176+
* due to large number of embedded calls (ie no global unique error table is provided and thus one error code can have different meanings,
177+
* depending on the routine issuing the error)
178+
*/
179+
esp_err_t esp_mprot_set_prot(const esp_memp_config_t *memp_config);
180+
181+
/**
182+
* @brief Generates PMS configuration string of actual device (diagnostics)
183+
*
184+
* The functions generates a string from current configuration, control and status registers of the PMS (or similar) module of actual device.
185+
* The values are fetched using HAL LL calls to help finding possible errors in the Memprot API implementation
186+
*
187+
* @param[out] dump_info_string configuration string buffer pointer. The string is allocated by the callee and must be freed by the caller.
188+
*
189+
* @return ESP_OK on success
190+
* ESP_ERR_NO_MEM on buffer allocation failure
191+
* ESP_ERR_INVALID_ARGUMENT on invalid dump_info_string pointer
192+
*/
193+
esp_err_t esp_mprot_dump_configuration(char **dump_info_string);
194+
195+
#ifdef __cplusplus
196+
}
197+
#endif
198+
199+
#endif //CONFIG_ESP_SYSTEM_MEMPROT_FEATURE || CONFIG_ESP_SYSTEM_MEMPROT_TEST

0 commit comments

Comments
 (0)