Hi everyone
I try to use esp32 cam in arduino ide to scan qr code
I use this project
I have tested and worked when the frame size is set FRAMESIZE_HVGA(480x320)
However,when I try to scale up the famesize to FRAMESIZE_VGA(640x480),it show the error
cam_hal: FB-SIZE: 303360 != 307200
So,I write a test program to test how the psram store variable,this is my code
#include "esp_camera.h"
#define PWDN_GPIO_NUM 32
#define RESET_GPIO_NUM -1
#define XCLK_GPIO_NUM 0
#define SIOD_GPIO_NUM 26
#define SIOC_GPIO_NUM 27
#define Y9_GPIO_NUM 35
#define Y8_GPIO_NUM 34
#define Y7_GPIO_NUM 39
#define Y6_GPIO_NUM 36
#define Y5_GPIO_NUM 21
#define Y4_GPIO_NUM 19
#define Y3_GPIO_NUM 18
#define Y2_GPIO_NUM 5
#define VSYNC_GPIO_NUM 25
#define HREF_GPIO_NUM 23
#define PCLK_GPIO_NUM 22
void setup() {
psramInit();
Serial.begin(115200);
Serial.println("First\n\n##################################");
Serial.printf("Internal Total heap %d, internal Free Heap %d\n", ESP.getHeapSize(), ESP.getFreeHeap());
Serial.printf("SPIRam Total heap %d, SPIRam Free Heap %d\n", ESP.getPsramSize(), ESP.getFreePsram());
Serial.printf("ChipRevision %d, Cpu Freq %d, SDK Version %s\n", ESP.getChipRevision(), ESP.getCpuFreqMHz(), ESP.getSdkVersion());
Serial.printf("Flash Size %d, Flash Speed %d\n", ESP.getFlashChipSize(), ESP.getFlashChipSpeed());
Serial.println("##################################\n\n");
camera_config_t config;
config.ledc_channel = LEDC_CHANNEL_0;
config.ledc_timer = LEDC_TIMER_0;
config.pin_d0 = Y2_GPIO_NUM;
config.pin_d1 = Y3_GPIO_NUM;
config.pin_d2 = Y4_GPIO_NUM;
config.pin_d3 = Y5_GPIO_NUM;
config.pin_d4 = Y6_GPIO_NUM;
config.pin_d5 = Y7_GPIO_NUM;
config.pin_d6 = Y8_GPIO_NUM;
config.pin_d7 = Y9_GPIO_NUM;
config.pin_xclk = XCLK_GPIO_NUM;
config.pin_pclk = PCLK_GPIO_NUM;
config.pin_vsync = VSYNC_GPIO_NUM;
config.pin_href = HREF_GPIO_NUM;
config.pin_sccb_sda = SIOD_GPIO_NUM;
config.pin_sccb_scl = SIOC_GPIO_NUM;
config.pin_pwdn = PWDN_GPIO_NUM;
config.pin_reset = RESET_GPIO_NUM;
config.xclk_freq_hz = 20000000;
config.frame_size = FRAMESIZE_VGA;
config.pixel_format = PIXFORMAT_GRAYSCALE;
config.grab_mode = CAMERA_GRAB_LATEST;
config.fb_location = CAMERA_FB_IN_PSRAM;
config.jpeg_quality = 4;
config.fb_count = 1;
// camera init
esp_err_t err = esp_camera_init(&config);
if (err != ESP_OK) {
Serial.printf("Camera init failed with error 0x%x", err);
return;
}
//---------------------------------------------------------------------------------------------------------
Serial.println("after initialize\n\n##################################");
Serial.printf("Internal Total heap %d, internal Free Heap %d\n", ESP.getHeapSize(), ESP.getFreeHeap());
Serial.printf("SPIRam Total heap %d, SPIRam Free Heap %d\n", ESP.getPsramSize(), ESP.getFreePsram());
Serial.printf("ChipRevision %d, Cpu Freq %d, SDK Version %s\n", ESP.getChipRevision(), ESP.getCpuFreqMHz(), ESP.getSdkVersion());
Serial.printf("Flash Size %d, Flash Speed %d\n", ESP.getFlashChipSize(), ESP.getFlashChipSpeed());
Serial.println("##################################\n\n");
//---------------------------------------------------------------------------------------------------------
//get pictures
camera_fb_t *fb = NULL;
fb = esp_camera_fb_get();
if (!fb)
{
Serial.println("Camera capture failed");
}
Serial.println("read pictures\n\n##################################");
Serial.printf("Internal Total heap %d, internal Free Heap %d\n", ESP.getHeapSize(), ESP.getFreeHeap());
Serial.printf("SPIRam Total heap %d, SPIRam Free Heap %d\n", ESP.getPsramSize(), ESP.getFreePsram());
Serial.printf("ChipRevision %d, Cpu Freq %d, SDK Version %s\n", ESP.getChipRevision(), ESP.getCpuFreqMHz(), ESP.getSdkVersion());
Serial.printf("Flash Size %d, Flash Speed %d\n", ESP.getFlashChipSize(), ESP.getFlashChipSpeed());
Serial.println("##################################\n\n");
//----------------------------------------------------------------------------------------------------
//release
esp_camera_fb_return(fb);
Serial.println("after release\n\n##################################");
Serial.printf("Internal Total heap %d, internal Free Heap %d\n", ESP.getHeapSize(), ESP.getFreeHeap());
Serial.printf("SPIRam Total heap %d, SPIRam Free Heap %d\n", ESP.getPsramSize(), ESP.getFreePsram());
Serial.printf("ChipRevision %d, Cpu Freq %d, SDK Version %s\n", ESP.getChipRevision(), ESP.getCpuFreqMHz(), ESP.getSdkVersion());
Serial.printf("Flash Size %d, Flash Speed %d\n", ESP.getFlashChipSize(), ESP.getFlashChipSpeed());
Serial.println("##################################\n\n");
}
void loop() {
// put your main code here, to run repeatedly:
}
The output result when I set the framesize to VGA
08:42:52.817 -> ets Jun 8 2016 00:22:57
08:42:52.817 ->
08:42:52.817 -> rst:0x1 (POWERON_RESET),boot:0x12 (SPI_FAST_FLASH_BOOT)
08:42:52.817 -> configsip: 0, SPIWP:0xee
08:42:52.817 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
08:42:52.817 -> mode:DIO, clock div:1
08:42:52.817 -> load:0x3fff0030,len:1184
08:42:52.817 -> load:0x40078000,len:13260
08:42:52.817 -> load:0x40080400,len:3028
08:42:52.817 -> entry 0x400805e4
08:42:53.463 -> First
08:42:53.463 ->
08:42:53.463 -> ##################################
08:42:53.463 -> Internal Total heap 361064, internal Free Heap 330640
08:42:53.463 -> SPIRam Total heap 4192123, SPIRam Free Heap 4192123
08:42:53.463 -> ChipRevision 1, Cpu Freq 240, SDK Version v4.4.7-dirty
08:42:53.463 -> Flash Size 4194304, Flash Speed 80000000
08:42:53.463 -> ##################################
08:42:53.463 ->
08:42:53.463 ->
08:42:54.245 -> after initialize
08:42:54.245 ->
08:42:54.245 -> ##################################
08:42:54.245 -> Internal Total heap 360776, internal Free Heap 300764
08:42:54.245 -> SPIRam Total heap 4192107, SPIRam Free Heap 3884907
08:42:54.245 -> ChipRevision 1, Cpu Freq 240, SDK Version v4.4.7-dirty
08:42:54.245 -> Flash Size 4194304, Flash Speed 80000000
08:42:54.245 -> ##################################
08:42:54.245 ->
08:42:54.245 ->
08:42:54.720 -> E (3613) cam_hal: FB-SIZE: 303360 != 307200
08:42:54.924 -> E (3815) cam_hal: FB-SIZE: 303360 != 307200
08:42:55.128 -> E (4018) cam_hal: FB-SIZE: 303360 != 307200
08:42:55.332 -> E (4221) cam_hal: FB-SIZE: 303360 != 307200
08:42:55.536 -> E (4424) cam_hal: FB-SIZE: 303360 != 307200
08:42:55.740 -> E (4627) cam_hal: FB-SIZE: 303360 != 307200
08:42:55.944 -> E (4830) cam_hal: FB-SIZE: 303360 != 307200
08:42:56.148 -> E (5033) cam_hal: FB-SIZE: 303360 != 307200
08:42:56.352 -> E (5236) cam_hal: FB-SIZE: 303360 != 307200
08:42:56.555 -> E (5439) cam_hal: FB-SIZE: 303360 != 307200
08:42:56.759 -> E (5642) cam_hal: FB-SIZE: 303360 != 307200
08:42:56.963 -> E (5845) cam_hal: FB-SIZE: 303360 != 307200
08:42:57.167 -> E (6048) cam_hal: FB-SIZE: 303360 != 307200
08:42:57.370 -> E (6251) cam_hal: FB-SIZE: 303360 != 307200
08:42:57.574 -> E (6453) cam_hal: FB-SIZE: 303360 != 307200
08:42:57.778 -> E (6656) cam_hal: FB-SIZE: 303360 != 307200
08:42:57.982 -> E (6859) cam_hal: FB-SIZE: 303360 != 307200
08:42:58.186 -> E (7062) cam_hal: FB-SIZE: 303360 != 307200
08:42:58.254 -> Camera capture failed
08:42:58.254 -> read pictures
08:42:58.254 ->
08:42:58.254 -> ##################################
08:42:58.254 -> Internal Total heap 360760, internal Free Heap 300664
08:42:58.254 -> SPIRam Total heap 4192107, SPIRam Free Heap 3884907
08:42:58.254 -> ChipRevision 1, Cpu Freq 240, SDK Version v4.4.7-dirty
08:42:58.254 -> Flash Size 4194304, Flash Speed 80000000
08:42:58.289 -> ##################################
08:42:58.289 ->
08:42:58.289 ->
08:42:58.289 -> after release
08:42:58.289 ->
08:42:58.289 -> ##################################
08:42:58.289 -> Internal Total heap 360760, internal Free Heap 300664
08:42:58.289 -> SPIRam Total heap 4192107, SPIRam Free Heap 3884907
08:42:58.289 -> ChipRevision 1, Cpu Freq 240, SDK Version v4.4.7-dirty
08:42:58.289 -> Flash Size 4194304, Flash Speed 80000000
08:42:58.289 -> ##################################
08:42:58.289 ->
08:42:58.289 ->
08:42:58.390 -> E (7265) cam_hal: FB-SIZE: 303360 != 307200
08:42:58.594 -> E (7468) cam_hal: FB-SIZE: 303360 != 307200
08:42:58.798 -> E (7671) cam_hal: FB-SIZE: 303360 != 307200
08:42:59.002 -> E (7874) cam_hal: FB-SIZE: 303360 != 307200
08:42:59.206 -> E (8077) cam_hal: FB-SIZE: 303360 != 307200
08:42:59.376 -> E (8280) cam_hal: FB-SIZE: 303360 != 307200
08:42:59.581 -> E (8483) cam_hal: FB-SIZE: 303360 != 307200
08:42:59.785 -> E (8685) cam_hal: FB-SIZE: 303360 != 307200
08:42:59.989 -> E (8888) cam_hal: FB-SIZE: 303360 != 307200
08:43:00.193 -> E (9091) cam_hal: FB-SIZE: 303360 != 307200
08:43:00.397 -> E (9294) cam_hal: FB-SIZE: 303360 != 307200
08:43:00.601 -> E (9497) cam_hal: FB-SIZE: 303360 != 307200
08:43:00.805 -> E (9700) cam_hal: FB-SIZE: 303360 != 307200
And the output when I set the framesize to HVGA
08:40:11.082 -> after initialize
08:40:11.082 ->
08:40:11.082 -> ##################################
08:40:11.082 -> Internal Total heap 360776, internal Free Heap 300812
08:40:11.082 -> SPIRam Total heap 4192107, SPIRam Free Heap 4038507
08:40:11.082 -> ChipRevision 1, Cpu Freq 240, SDK Version v4.4.7-dirty
08:40:11.082 -> Flash Size 4194304, Flash Speed 80000000
08:40:11.115 -> ##################################
08:40:11.115 ->
08:40:11.115 ->
08:40:11.353 -> read pictures
08:40:11.353 ->
08:40:11.353 -> ##################################
08:40:11.387 -> Internal Total heap 360776, internal Free Heap 300812
08:40:11.387 -> SPIRam Total heap 4192107, SPIRam Free Heap 4038507
08:40:11.387 -> ChipRevision 1, Cpu Freq 240, SDK Version v4.4.7-dirty
08:40:11.387 -> Flash Size 4194304, Flash Speed 80000000
08:40:11.387 -> ##################################
08:40:11.387 ->
08:40:11.387 ->
08:40:11.387 -> after release
08:40:11.387 ->
08:40:11.387 -> ##################################
08:40:11.387 -> Internal Total heap 360776, internal Free Heap 300812
08:40:11.387 -> SPIRam Total heap 4192107, SPIRam Free Heap 4038507
08:40:11.421 -> ChipRevision 1, Cpu Freq 240, SDK Version v4.4.7-dirty
08:40:11.421 -> Flash Size 4194304, Flash Speed 80000000
08:40:11.421 -> ##################################
08:40:11.421 ->
08:40:11.421 ->
08:40:16.416 -> E (13281) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
08:40:16.416 -> E (13281) task_wdt: - IDLE0 (CPU 0)
08:40:16.416 -> E (13281) task_wdt: Tasks currently running:
08:40:16.416 -> E (13281) task_wdt: CPU 0: loopTask
08:40:16.416 -> E (13281) task_wdt: CPU 1: IDLE1
08:40:16.416 -> E (13281) task_wdt: Aborting.
08:40:16.450 ->
08:40:16.450 -> abort() was called at PC 0x400da2c9 on core 0
It seems that data doesn't store in the psram directly,it store in the internal ram first,and move the data from internal ram to psram,is it correct?
if yes,is there a way can just store data in psram,not store in the internal ram first?

