ESP32-S2使用外部PSRAM,使用超过16K后,写入后,再读出,数据对不上

122722629@qq.com
Posts: 20
Joined: Wed Feb 16, 2022 7:01 am

ESP32-S2使用外部PSRAM,使用超过16K后,写入后,再读出,数据对不上

Postby 122722629@qq.com » Thu Mar 17, 2022 5:10 am

Code: Select all

uint32_t i = 0 ;

ESP_LOGI(TAG,"free size (psram):%d",heap_caps_get_free_size(MALLOC_CAP_SPIRAM));

uint8_t * tbuf = (uint8_t*)heap_caps_malloc( 32*1024 , MALLOC_CAP_SPIRAM | MALLOC_CAP_32BIT );

ESP_LOGI(TAG,"addr[%x]",(uint32_t)tbuf);

ESP_LOGI(TAG,"free size (psram):%d",heap_caps_get_free_size(MALLOC_CAP_SPIRAM));

for(i=0 ; i < 32*1024 ; i++)
{  
   tbuf[i] = 0 ;
}

show_hex(tbuf,256);


PS D:\202203\ESP32\ESP32-S3\blink> C:\Users\hyj\.espressif\python_env\idf4.4_py3.8_env\Scripts\python.exe C:\Users\hyj\esp\esp-idf\tools\idf.py -p COM98 monitor
Executing action: monitor
Running idf_monitor in directory d:\202203\esp32\esp32-s3\blink
Executing "C:\Users\hyj\.espressif\python_env\idf4.4_py3.8_env\Scripts\python.exe C:\Users\hyj\esp\esp-idf\tools/idf_monitor.py -p COM98 -b 115200 --toolchain-prefix xtensa-esp32s3-elf- --target esp32s3 d:\202203\esp32\esp32-s3\blink\build\blink.elf -m 'C:\Users\hyj\.espressif\python_env\idf4.4_py3.8_env\Scripts\python.exe' 'C:\Users\hyj\esp\esp-idf\tools\idf.py' '-p' 'COM98'"...
--- WARNING: GDB cannot open serial ports accessed as COMx
--- Using \\.\COM98 instead...
--- idf_monitor on \\.\COM98 115200 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
ESP-ROM:esp32s2-rc4-20191025
Build:Oct 25 2019
rst:0x1 (POWERON),boot:0x8 (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3ffe6100,len:0x176c
load:0x4004c000,len:0xa48
load:0x40050000,len:0x2e48
SHA-256 comparison failed:
Calculated: 67ba66aac9d3b0847048c39f9d2dce93a10a30f43a9fce62292c438cecd9d47e
Expected: c47b10cf00b4932fac9990c607467c8b94c15be45c18b3dd1fc8b512a5c4126b
Attempting to boot anyway...
entry 0x4004c204
I (40) boot: ESP-IDF v4.4-dirty 2nd stage bootloader
I (40) boot: compile time 10:55:31
I (40) boot: chip revision: 0
I (43) boot.esp32s2: SPI Speed : 80MHz
I (47) boot.esp32s2: SPI Mode : DIO
I (52) boot.esp32s2: SPI Flash Size : 4MB
I (57) boot: Enabling RNG early entropy source...
I (62) boot: Partition Table:
I (66) boot: ## Label Usage Type ST Offset Length
I (73) boot: 0 nvs WiFi data 01 02 00009000 00006000
I (81) boot: 1 phy_init RF data 01 01 0000f000 00001000
I (88) boot: 2 factory factory app 00 00 00010000 00100000
I (95) boot: End of partition table
I (100) esp_image: segment 0: paddr=00010020 vaddr=3f000020 size=a0fach (659372) map
I (240) esp_image: segment 1: paddr=000b0fd4 vaddr=3ffc4ac0 size=01c98h ( 7320) load
I (242) esp_image: segment 2: paddr=000b2c74 vaddr=40028000 size=0cab4h ( 51892) load
I (258) esp_image: segment 3: paddr=000bf730 vaddr=50000000 size=00010h ( 16) load
I (259) esp_image: segment 4: paddr=000bf748 vaddr=00000000 size=008d0h ( 2256)
I (265) esp_image: segment 5: paddr=000c0020 vaddr=40080020 size=19764h (104292) map
I (300) boot: Loaded app from partition at offset 0x10000
I (300) boot: Disabling RNG early entropy source...
I (311) cache: Instruction cache : size 16KB, 4Ways, cache line size 32Byte
I (311) cache: Data cache : size 16KB, 4Ways, cache line size 32Byte
I (315) spiram: Found 64MBit SPI RAM device
I (320) spiram: SPI RAM mode: sram 40m
I (324) spiram: PSRAM initialized, cache is in normal (1-core) mode.
I (331) cpu_start: Pro cpu up.
I (1977) s�f�ff�����%�SRAM memory test OK
I (1986) cpu_start: Pro cpu start user code
I (1986) cpu_start: cpu freq: 240000000
I (1986) cpu_start: Application information:
I (1989) cpu_start: Project name: sd_card
I (1994) cpu_start: App version: 4268a2d-dirty
I (2000) cpu_start: Compile time: Mar 17 2022 10:55:19
I (2006) cpu_start: ELF file SHA256: 0c865a360af9db45...
I (2012) cpu_start: ESP-IDF: v4.4-dirty
I (2018) heap_init: Initializing. RAM available for dynamic allocation:
I (2025) heap_init: At 3FF9E000 len 00002000 (8 KiB): RTCRAM
I (2031) heap_init: At 3FFC8280 len 00033D80 (207 KiB): DRAM
I (2037) heap_init: At 3FFFC000 len 00003A10 (14 KiB): DRAM
I (2044) spiram: Adding pool of 8192K of external SPI memory to heap allocator
I (2052) spi_flash: detected chip: generic
I (2057) spi_flash: flash io: dio
I (2061) cpu_start: Starting scheduler on PRO CPU.
I (2066) spiram: Reserving pool of 32K of internal memory for DMA/internal allocations
I (5219) player: free size (psram):8386191
I (5219) player: addr[3f780974]
I (5219) player: free size (psram):8353423
I (5224) led_mem_test: show hex at 3f780974 , len 256
I (5227) led_mem_test: 0000 ff ff ff ff ff ff ff ff ff ff ff ff 00 00 8f ff
I (5234) led_mem_test: 0016 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
I (5242) led_mem_test: 0032 ff ff ff ff ff ff ff ff ff ff ff ff 00 00 8f ff
I (5250) led_mem_test: 0048 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
I (5258) led_mem_test: 0064 ff ff ff ff ff ff ff ff ff ff ff ff 00 00 8f ff
I (5265) led_mem_test: 0080 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
I (5273) led_mem_test: 0096 ff ff ff ff ff ff ff ff ff ff ff ff 00 00 8f ff
I (5281) led_mem_test: 0112 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
I (5288) led_mem_test: 0128 ff ff ff ff ff ff ff ff ff ff ff ff 00 00 0f ff
I (5296) led_mem_test: 0144 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
I (5304) led_mem_test: 0160 ff ff ff ff ff ff ff ff ff ff ff ff 00 00 8f ff
I (5312) led_mem_test: 0176 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
I (5319) led_mem_test: 0192 ff ff ff ff ff ff ff ff ff ff ff ff 00 00 0f ff
I (5327) led_mem_test: 0208 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
I (5335) led_mem_test: 0224 ff ff ff ff ff ff ff ff ff ff ff ff 00 00 0f ff
I (5343) led_mem_test: 0240 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff

ESP_morris
Posts: 290
Joined: Wed Sep 05, 2018 6:23 am

Re: ESP32-S2使用外部PSRAM,使用超过16K后,写入后,再读出,数据对不上

Postby ESP_morris » Fri Mar 18, 2022 8:03 am

我在master分支上试了下,没有发现你说的问题
测试代码:

Code: Select all

#include <stdio.h>
#include "sdkconfig.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_chip_info.h"
#include "esp_log.h"
#include "esp_heap_caps.h"
#include "esp_spi_flash.h"

static const char *TAG = "example";

void app_main(void)
{
    ESP_LOGI(TAG, "free size (psram):%d", heap_caps_get_free_size(MALLOC_CAP_SPIRAM));
    uint8_t *tbuf = (uint8_t *)heap_caps_malloc( 32 * 1024, MALLOC_CAP_SPIRAM | MALLOC_CAP_32BIT );

    ESP_LOGI(TAG, "addr @%p", tbuf);

    ESP_LOGI(TAG, "free size (psram):%d", heap_caps_get_free_size(MALLOC_CAP_SPIRAM));

    for (int i = 0 ; i < 32 * 1024 ; i++) {
        tbuf[i] = 0 ;
    }

    int k = 0;
    for (int i = 0; i < 32; i++) {
        for (int j = 0; j < 8; j++) {
            printf("%02x ", tbuf[k++]);
        }
        printf("\r\n");
    }
}
运行 log

Code: Select all

I (688) spiram: Reserving pool of 32K of internal memory for DMA/internal allocations
I (688) example: free size (psram):2094735
I (698) example: addr @0x3f500974
I (698) example: free size (psram):2061963
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
如果你的问题还存在,请附上你的sdkconfig

122722629@qq.com
Posts: 20
Joined: Wed Feb 16, 2022 7:01 am

Re: ESP32-S2使用外部PSRAM,使用超过16K后,写入后,再读出,数据对不上

Postby 122722629@qq.com » Fri Mar 18, 2022 11:35 am

ESP_morris wrote:
Fri Mar 18, 2022 8:03 am
我在master分支上试了下,没有发现你说的问题
测试代码:

Code: Select all

#include <stdio.h>
#include "sdkconfig.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_chip_info.h"
#include "esp_log.h"
#include "esp_heap_caps.h"
#include "esp_spi_flash.h"

static const char *TAG = "example";

void app_main(void)
{
    ESP_LOGI(TAG, "free size (psram):%d", heap_caps_get_free_size(MALLOC_CAP_SPIRAM));
    uint8_t *tbuf = (uint8_t *)heap_caps_malloc( 32 * 1024, MALLOC_CAP_SPIRAM | MALLOC_CAP_32BIT );

    ESP_LOGI(TAG, "addr @%p", tbuf);

    ESP_LOGI(TAG, "free size (psram):%d", heap_caps_get_free_size(MALLOC_CAP_SPIRAM));

    for (int i = 0 ; i < 32 * 1024 ; i++) {
        tbuf[i] = 0 ;
    }

    int k = 0;
    for (int i = 0; i < 32; i++) {
        for (int j = 0; j < 8; j++) {
            printf("%02x ", tbuf[k++]);
        }
        printf("\r\n");
    }
}
运行 log

Code: Select all

I (688) spiram: Reserving pool of 32K of internal memory for DMA/internal allocations
I (688) example: free size (psram):2094735
I (698) example: addr @0x3f500974
I (698) example: free size (psram):2061963
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
如果你的问题还存在,请附上你的sdkconfig
还是有问题,帮我看一下吧,谢谢了。
Attachments
sdkconfig.rar
(8.8 KiB) Downloaded 374 times

122722629@qq.com
Posts: 20
Joined: Wed Feb 16, 2022 7:01 am

Re: ESP32-S2使用外部PSRAM,使用超过16K后,写入后,再读出,数据对不上

Postby 122722629@qq.com » Thu Mar 31, 2022 9:52 am

ESP_morris wrote:
Fri Mar 18, 2022 8:03 am
我在master分支上试了下,没有发现你说的问题
测试代码:

Code: Select all

#include <stdio.h>
#include "sdkconfig.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_chip_info.h"
#include "esp_log.h"
#include "esp_heap_caps.h"
#include "esp_spi_flash.h"

static const char *TAG = "example";

void app_main(void)
{
    ESP_LOGI(TAG, "free size (psram):%d", heap_caps_get_free_size(MALLOC_CAP_SPIRAM));
    uint8_t *tbuf = (uint8_t *)heap_caps_malloc( 32 * 1024, MALLOC_CAP_SPIRAM | MALLOC_CAP_32BIT );

    ESP_LOGI(TAG, "addr @%p", tbuf);

    ESP_LOGI(TAG, "free size (psram):%d", heap_caps_get_free_size(MALLOC_CAP_SPIRAM));

    for (int i = 0 ; i < 32 * 1024 ; i++) {
        tbuf[i] = 0 ;
    }

    int k = 0;
    for (int i = 0; i < 32; i++) {
        for (int j = 0; j < 8; j++) {
            printf("%02x ", tbuf[k++]);
        }
        printf("\r\n");
    }
}
运行 log

Code: Select all

I (688) spiram: Reserving pool of 32K of internal memory for DMA/internal allocations
I (688) example: free size (psram):2094735
I (698) example: addr @0x3f500974
I (698) example: free size (psram):2061963
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
如果你的问题还存在,请附上你的sdkconfig

你好,有发现问题吗?同样的代码,我在S3上面测试是没问题的,但是S2就是不行。

Who is online

Users browsing this forum: Google [Bot] and 43 guests