build: move NVS cache objects that can pin the DRAM heap to SPIRAM if available
What changed, and why it matters
This commit changes how the Jade hardware wallet's firmware uses memory. It moves some internal storage cache objects from the main RAM (DRAM) to external RAM (PSRAM/SPIRAM) when available. This is a memory-optimization change, not a direct security fix. It may help prevent out-of-memory situations, which can indirectly improve stability, but it does not patch a known vulnerability.
Treat as a routine build/memory optimization. No immediate security action required. If reviewing for security, verify that SPIRAM is initialized securely and that sensitive NVS cache contents are not exposed through external RAM interfaces, though the diff itself does not introduce such exposure.
Security signals we found
Memory layout change: moves NVS cache from DRAM to SPIRAM
No direct security fix or vulnerability patch present in diff
No mention of CVE, security researcher, or security advisory in commit
Change is build/configuration only
Evidence from the diff
The commit sets CONFIG_NVS_ALLOCATE_CACHE_IN_SPIRAM=y across production and development sdkconfig files and updates a test threshold for free SPIRAM. NVS (Non-Volatile Storage) cache objects are moved from internal DRAM to external SPIRAM when PSRAM is present. This reduces DRAM heap pressure. The change is accompanied by a test adjustment lowering the expected free SPIRAM floor from 0 to 1024. There is no direct security-relevant code change, cryptographic change, or vulnerability patch in the diff.
Changed components
ESP32 sdkconfig defaults for Jade v2/v2c production and dev buildstools/switch_to.sh build configuration scripttest_jade.py memory-statistics assertionsInspect captured patch +7 / −1
### configs/production/sdkconfig_jade_v2_prod.defaults
@@ -60,6 +60,7 @@ CONFIG_LOG_DEFAULT_LEVEL_NONE=y
CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=n
CONFIG_MBEDTLS_ECP_RESTARTABLE=y
CONFIG_NT99141_SUPPORT=n
+CONFIG_NVS_ALLOCATE_CACHE_IN_SPIRAM=y
CONFIG_OV2640_SUPPORT=n
CONFIG_OV3660_SUPPORT=n
CONFIG_OV5640_SUPPORT=n
### configs/production/sdkconfig_jade_v2_smoketest.defaults
@@ -59,6 +59,7 @@ CONFIG_LIBC_STDOUT_LINE_ENDING_LF=y
CONFIG_LOG_DEFAULT_LEVEL_NONE=y
CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=n
CONFIG_NT99141_SUPPORT=n
+CONFIG_NVS_ALLOCATE_CACHE_IN_SPIRAM=y
CONFIG_OV2640_SUPPORT=n
CONFIG_OV3660_SUPPORT=n
CONFIG_OV5640_SUPPORT=n
### configs/production/sdkconfig_jade_v2c_prod.defaults
@@ -60,6 +60,7 @@ CONFIG_LOG_DEFAULT_LEVEL_NONE=y
CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=n
CONFIG_MBEDTLS_ECP_RESTARTABLE=y
CONFIG_NT99141_SUPPORT=n
+CONFIG_NVS_ALLOCATE_CACHE_IN_SPIRAM=y
CONFIG_OV2640_SUPPORT=n
CONFIG_OV3660_SUPPORT=n
CONFIG_OV5640_SUPPORT=n
### configs/sdkconfig_dev_jade_v2.defaults
@@ -55,6 +55,7 @@ CONFIG_LIBC_NEWLIB_NANO_FORMAT=y
CONFIG_LOG_DEFAULT_LEVEL_NONE=y
CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=n
CONFIG_NT99141_SUPPORT=n
+CONFIG_NVS_ALLOCATE_CACHE_IN_SPIRAM=y
CONFIG_OV2640_SUPPORT=n
CONFIG_OV3660_SUPPORT=n
CONFIG_OV5640_SUPPORT=n
### configs/sdkconfig_dev_jade_v2c.defaults
@@ -55,6 +55,7 @@ CONFIG_LIBC_NEWLIB_NANO_FORMAT=y
CONFIG_LOG_DEFAULT_LEVEL_NONE=y
CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=n
CONFIG_NT99141_SUPPORT=n
+CONFIG_NVS_ALLOCATE_CACHE_IN_SPIRAM=y
CONFIG_OV2640_SUPPORT=n
CONFIG_OV3660_SUPPORT=n
CONFIG_OV5640_SUPPORT=n
### test_jade.py
@@ -1838,7 +1838,7 @@ def check_mem_stats(jadeapi, startinfo, endinfo, has_psram, has_ble, strict, ret
for field, limit in [('JADE_FREE_HEAP', 1536),
('JADE_FREE_DRAM', 8192 if has_ble else 1536),
('JADE_LARGEST_DRAM', dram_frag_limit),
- ('JADE_FREE_SPIRAM', 0),
+ ('JADE_FREE_SPIRAM', 1024),
('JADE_LARGEST_SPIRAM', 0 if check_frag else -1)]:
initial = int(startinfo[field])
final = int(endinfo[field])
### tools/switch_to.sh
@@ -282,6 +282,7 @@ if [ -n "$PSRAM" ]; then
# Use the same PSRAM malloc thresholds as the devices with PSRAM
set_config CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL 256
set_config CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL 65536
+ set_config CONFIG_NVS_ALLOCATE_CACHE_IN_SPIRAM y
if [ -n "$WEBDISPLAY" ]; then
echo "updating config file for webdisplay build ..."
# remove settingsWhy this scored 19/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.