Skip to content
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

the conflict of camera driver and wi-fi, #501

Closed
Tilie opened this issue Jan 27, 2023 · 2 comments
Closed

the conflict of camera driver and wi-fi, #501

Tilie opened this issue Jan 27, 2023 · 2 comments

Comments

@Tilie
Copy link

Tilie commented Jan 27, 2023

ask for guide to resolve the conflict

The IDF version:
v5.0,matser branch
the camera is ov2640
the chip is esp32s3

what i do:
i copy the example of esp-idf http-client:
`// ==== Memory allocator that takes advantage of PSRAM if present =======================
char* my_allocateMemory(char* aPtr, size_t aSize){

if (aPtr != NULL) free(aPtr);

char* ptr = NULL;

ptr = (char*)malloc(aSize);

memset(ptr, 0, aSize); 

return ptr;

}

void task_post(){

char *post_data = "{\"field1\":\"value1\"}";
//post_data = pic_char;
ESP_LOGW(TAG_my_main,"post start");
esp_http_client_handle_t my_http_client_handle = my_http_stream_init();
ESP_LOGW(TAG_my_main,"get_client_handle");

esp_http_client_set_post_field(my_http_client_handle, post_data, strlen(post_data));
ESP_LOGW(TAG_my_main,"set_post_field");

esp_err_t err = esp_http_client_perform(my_http_client_handle);

if (err == ESP_OK) {
    ESP_LOGI(TAG, "HTTP POST Status = %d, content_length = %lld",
            esp_http_client_get_status_code(my_http_client_handle),
            esp_http_client_get_content_length(my_http_client_handle));
} else {
    ESP_LOGE(TAG, "HTTP POST request failed: %s", esp_err_to_name(err));
}

my_http_stream_clean(my_http_client_handle);

}`

and do same with camera driver

'void task_capture(){
camera_fb_t *pic = my_camera_capture();

//  If frame size is more that we have previously allocated - request  125% of the current frame space
if (pic->len > pic_size){
    pic_size = pic->len * 1.5;
    pic_char = my_allocateMemory(pic_char,pic_size);
}

ESP_LOGI(TAG_my_main, "Picture taken! Its was: %d", pic->len);


sprintf(pic_char ,"{\"field1\":\"");

int i=5;
while(i < pic->len){
    sprintf(pic_char + i*2 +1,"%02x",pic->buf[i]);
    i++;
}

sprintf(pic_char + i*2 ,"\"}");

my_camera_return(pic);
//vTaskDelay(5000);

}'

both them are run successfuly while separately. but have problem when they run together.
i try to local the where the problem, i find that the system reboot when the process of esp_http_client_init try to malloc the ram ,then log many warning.
i not sure which part have the dirt ram allocate. hope for guide to how to deal with.

the log message:
`assert failed: block_trim_free tlsf.c:496 (block_is_free(block) && "block must be free")

Backtrace: 0x40375c1a:0x3fcf3500 0x4037fc95:0x3fcf3520 0x40386c31:0x3fcf3540 0x40385188:0x3fcf3660 0x40384ace:0x3fcf3680 0x40376551:0x3fcf36a0 0x403765f8:0x3fcf36c0 0x40386c41:0x3fcf36e0 0x4201ebbf:0x3fcf3700 0x42009c9a:0x3fcf3730 0x42009d21:0x3fcf37e0 0x42009ea9:0x3fcf3810 0x4209e95b:0x3fcf3830 0x40382669:0x3fcf3860
0x40375c1a: panic_abort at /Users/jinyi/esp/esp-idf/components/esp_system/panic.c:452

0x4037fc95: esp_system_abort at /Users/jinyi/esp/esp-idf/components/esp_system/port/esp_system_chip.c:77

0x40386c31: __assert_func at /Users/jinyi/esp/esp-idf/components/newlib/assert.c:78

0x40385188: block_trim_free at /Users/jinyi/esp/esp-idf/components/heap/tlsf/tlsf.c:496
(inlined by) block_prepare_used at /Users/jinyi/esp/esp-idf/components/heap/tlsf/tlsf.c:579
(inlined by) tlsf_malloc at /Users/jinyi/esp/esp-idf/components/heap/tlsf/tlsf.c:1005

0x40384ace: multi_heap_malloc_impl at /Users/jinyi/esp/esp-idf/components/heap/multi_heap.c:207

0x40376551: heap_caps_malloc_base at /Users/jinyi/esp/esp-idf/components/heap/heap_caps.c:145

0x403765f8: heap_caps_malloc_default at /Users/jinyi/esp/esp-idf/components/heap/heap_caps.c:198

0x40386c41: malloc at /Users/jinyi/esp/esp-idf/components/newlib/heap.c:24

0x4201ebbf: esp_http_client_init at /Users/jinyi/esp/esp-idf/components/esp_http_client/esp_http_client.c:715 (discriminator 1)

0x42009c9a: my_http_stream_init at /Users/jinyi/Desktop/Graduate_Design/trash_cans/main/my_http_get.c:38

0x42009d21: task_post at /Users/jinyi/Desktop/Graduate_Design/trash_cans/main/main.c:31

0x42009ea9: app_main at /Users/jinyi/Desktop/Graduate_Design/trash_cans/main/main.c:108

0x4209e95b: main_task at /Users/jinyi/esp/esp-idf/components/freertos/app_startup.c:208 (discriminator 13)

0x40382669: vPortTaskWrapper at /Users/jinyi/esp/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:162

ELF file SHA256: 49dff066672d6b6f`

@Tilie
Copy link
Author

Tilie commented Jan 29, 2023

update: try handling task with freertos may help with this situation.

@github-actions
Copy link

This issue appears to be stale. Please close it if its no longer valid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant