New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SD Card File Hangs while trying to open #4495
Comments
Can you please explain this part of code? .allocation_unit_size = size//img->wimg->c // 16 * 1024 what is your intention when setting the filesystem allocation unit size to the framebuffer size? As for the troubleshooting, could you please enable verbose log output in |
Hey, my intention is to write a jpeg image to the file, i figured i only needed to allocate as much memory as the image would take, I changed it back to the original 16*1024 in the example for this output The free heap after opening the drive and before opening the file is: 3865700 [SD] size: 3988 [SD] FREE HEAP BEFORE OPENING FILE: 3865700 [SD] OPENING FILE |
Thank you, one more request: please enable the following two options in
These should result in a panic when the task hangs up, along with a backtrace which will be decoded by IDF monitor. Also I haven't realized at first that you are using PSRAM. Instead of checking the total available memory size, could you print out just the size of the internal free memory? This would be
|
Ok cool, Heres the dump and the free memory: [SD] size: 4090 [SD] FREE HEAP BEFORE OPENING FILE: 3865700 [SD] OPENING FILE |
D (63819) sdmmc_req: process_command_response: error 0x107 (status=00000100) Also You can try to change SPI bus pullup resistors to 15K (it helps sometimes) |
Hi Caleb. |
Hi Caleb, |
Hello!
I am unable to write a jpeg image to the SD Card after doing some Image processing ( deep learning using the ESP-FACE library)
--> The code follows the SD Card example provided by ESP-idf
--> Testing the code BEFORE the image processing works without issue (image saves as expected)
--> The issue only happens AFTER the processing.
I am unsure if I am doing something wrong, but testing it BEFORE processing works just fine
I will put The SD card saving Code and after the function that calls it
void saveImage(camera_fb_t *in,int id)
{
size_t _jpg_buf_len = 0;
uint8_t * _jpg_buf = NULL;
//camera_fb_t * out = NULL;
int size = in->len;
sdmmc_host_t host = SDMMC_HOST_DEFAULT();
sdmmc_slot_config_t slot_config = SDMMC_SLOT_CONFIG_DEFAULT();
gpio_set_pull_mode(15, GPIO_PULLUP_ONLY); // CMD, needed in 4- and 1- line modes
gpio_set_pull_mode(2, GPIO_PULLUP_ONLY); // D0, needed in 4- and 1-line modes
gpio_set_pull_mode(4, GPIO_PULLUP_ONLY); // D1, needed in 4-line mode only
gpio_set_pull_mode(12, GPIO_PULLUP_ONLY); // D2, needed in 4-line mode only
gpio_set_pull_mode(13, GPIO_PULLUP_ONLY); // D3, needed in 4- and 1-line modes
esp_vfs_fat_sdmmc_mount_config_t mount_config = {
.format_if_mount_failed = true,//false,
.max_files = 5,
.allocation_unit_size = size//img->wimg->c // 16 * 1024
};
sdmmc_card_t card;
esp_err_t ret = esp_vfs_fat_sdmmc_mount("/sdcard", &host, &slot_config, &mount_config, &card);
HERE IS WHERE THE CODE HANGS (FILE NOT NULL)
printf("\n[SD] FILE OPENED ...size: %i \n",size);
//=====================
//write the image
size_t fb_len = 0;
if (in->format == PIXFORMAT_JPEG)
{ printf("\nJPEG FORMAT! LETS TRY WRITING\n");
fb_len = in->len;
printf("SIZE: %i inside: %i \n",size,in->len);
fwrite((const char *)in->buf,sizeof(char *),in->len,f);
//use size instead of in->len if not good
}
else
{
printf("\n WRONG FORMAT!\n");
fclose(f);
esp_vfs_fat_sdmmc_unmount();
return;
};
fclose(f);
printf("\nFile written\n");
esp_vfs_fat_sdmmc_unmount();
}
CALLED BY*
void analyzeImage()
{
size_t _jpg_buf_len = 0;
uint8_t * _jpg_buf = NULL;
camera_fb_t * pic = NULL;
esp_err_t err = ESP_OK;
// Take Picture with Camera
vTaskDelay(1000/portMAX_DELAY);
pic = esp_camera_fb_get();
if(!pic)
{
printf("ERR TAKING PICTURE");
return;//NULL;
}
//allocate array
dl_matrix3du_t *image_matrix = dl_matrix3du_alloc(1, pic->width, pic->height, 3);
if(!image_matrix)
{
dl_matrix3du_free(image_matrix);
esp_camera_fb_return(pic);
printf("image matrix allocation failed");
return;//NULL;
}
if(!fmt2rgb888(pic->buf,pic->len,pic->format,image_matrix->item))
{
dl_matrix3du_free(image_matrix);
esp_camera_fb_return(pic);
printf("FORMAT 2 RGB 888 FAILED");
return;// NULL;
}
initConf(1);
initOut(1,1,1,1);
float minLeaf=80; //120;//80;
float pyramid=.707;//.5;//.707;
//pnet forward -->
box_array_t *pBoxes;
pBoxes=pnet_forward( image_matrix,minLeaf,pyramid,currentConfig );
if(pBoxes != NULL )//|| pBoxes->box[0].box_p[0]< 0 )
{
if( pBoxes->box[0].box_p[0]> 0 && pBoxes->box[0].box_p[3] > 0 )
{
setOutput(NULL,3);
initConf(2);//init Rnet config
box_array_t *rBoxes;
rBoxes=rnet_forward(image_matrix, pBoxes,currentConfig);
if(rBoxes!=NULL)
{
if(!fmt2jpg(image_matrix->item, pic->widthpic->height3, pic->width, pic->height, PIXFORMAT_RGB888, 80, &_jpg_buf, &_jpg_buf_len)){
}
}
}
}
//free the camera frame for next picture
esp_camera_fb_return(pic);
pic=NULL;
dl_matrix3du_free(image_matrix);
//return image_matrix;
}
The text was updated successfully, but these errors were encountered: