Skip to content

Commit

Permalink
Merge branch 'bugfix/return_error_when_fail_detect_oct_psram_v4.4' in…
Browse files Browse the repository at this point in the history
…to 'release/v4.4'

esp_psram: return error when fail to detect oct psram (v4.4)

See merge request espressif/esp-idf!22613
  • Loading branch information
suda-morris committed Mar 9, 2023
2 parents 4b498e8 + cf9cb57 commit 7d727ff
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
5 changes: 5 additions & 0 deletions components/esp_hw_support/port/esp32s3/opiram_psram.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#define OCT_PSRAM_RD_DUMMY_BITLEN (2*(10-1))
#define OCT_PSRAM_WR_DUMMY_BITLEN (2*(5-1))
#define OCT_PSRAM_CS1_IO SPI_CS1_GPIO_NUM
#define OCT_PSRAM_VENDOR_ID 0xD

#define OCT_PSRAM_CS_SETUP_TIME 3
#define OCT_PSRAM_CS_HOLD_TIME 3
Expand Down Expand Up @@ -255,6 +256,10 @@ esp_err_t psram_enable(psram_cache_mode_t mode, psram_vaddr_mode_t vaddrmode)
s_init_psram_mode_reg(1, &mode_reg);
//Print PSRAM info
s_get_psram_mode_reg(1, &mode_reg);
if (mode_reg.mr1.vendor_id != OCT_PSRAM_VENDOR_ID) {
ESP_EARLY_LOGE(TAG, "PSRAM ID read error: 0x%08x, PSRAM chip not found or not supported, or wrong PSRAM line mode", mode_reg.mr1.vendor_id);
return ESP_ERR_NOT_SUPPORTED;
}
s_print_psram_info(&mode_reg);
s_psram_size = mode_reg.mr2.density == 0x1 ? PSRAM_SIZE_32MBITS :
mode_reg.mr2.density == 0X3 ? PSRAM_SIZE_64MBITS :
Expand Down
4 changes: 2 additions & 2 deletions components/esp_hw_support/port/esp32s3/spiram_psram.c
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,8 @@ esp_err_t psram_enable(psram_cache_mode_t mode, psram_vaddr_mode_t vaddrmode)
*/
psram_read_id(SPI1_NUM, &s_psram_id);
if (!PSRAM_IS_VALID(s_psram_id)) {
ESP_EARLY_LOGE(TAG, "PSRAM ID read error: 0x%08x", s_psram_id);
return ESP_FAIL;
ESP_EARLY_LOGE(TAG, "PSRAM ID read error: 0x%08x, PSRAM chip not found or not supported, or wrong PSRAM line mode", (uint32_t)s_psram_id);
return ESP_ERR_NOT_SUPPORTED;
}
}

Expand Down
5 changes: 4 additions & 1 deletion components/esp_hw_support/port/esp32s3/spiram_psram.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ psram_size_t psram_get_size(void);
*
* @param mode SPI mode to access psram in
* @param vaddrmode Mode the psram cache works in.
* @return ESP_OK on success, ESP_ERR_INVALID_STATE when VSPI peripheral is needed but cannot be claimed.
* @return
* - ESP_OK: on success
* - ESP_ERR_NOT_SUPPORTED: PSRAM ID / vendor ID check fail
* - ESP_ERR_INVALID_STATE when VSPI peripheral is needed but cannot be claimed.
*/
esp_err_t psram_enable(psram_cache_mode_t mode, psram_vaddr_mode_t vaddrmode);

Expand Down

0 comments on commit 7d727ff

Please sign in to comment.