Bluedroid bt controller init Fail

Olfox59
Posts: 23
Joined: Tue May 02, 2017 12:36 pm

Bluedroid bt controller init Fail

Postby Olfox59 » Mon Oct 14, 2024 8:12 am

Hi,

Wroom ESP32S3 N16R8
I'm meeting issue with memory management when i call init_ble_gattc_gatts, a function whitch create and start bleudroid client and server. It is call just after sd card mount function that mount properly :

Code: Select all

void Task_ble(void){

    ESP_LOGI(TAG, "** In task BLE **");

    ESP_LOGI(TAG, "** Init SD CARD **");
    ESP_ERROR_CHECK(example_mount_storage(base_path));


    init_ble_gattc_gatts(true);

It is called in a Tasks started like this:

Code: Select all

void app_main(void)
{    

    queueAV = xQueueCreate( 25, sizeof( uint8_t ) );
    queueAR = xQueueCreate( 25, sizeof( uint8_t ) );

    init_gpio();

   xTaskCreatePinnedToCore( Task_gui,            "gui_Task",               8192, NULL, 1,  NULL,      1);
     xTaskCreatePinnedToCore( Task_screenDrive,    "ScreenDrive_Task",       4096, NULL, 0,  NULL,      1);
    xTaskCreatePinnedToCore( Task_ble,            "ble_Task",               32768, NULL, 0,  NULL,      0);

    esp_task_wdt_reset() ;
}
And here is the error message.
W (2025) BT_INIT: esp_bt_controller_mem_release not implemented, return OK
I (2035) BT_INIT: BT controller compile version [05195c9]
I (2045) phy_init: phy_version 503,13653eb,Jun 1 2022,17:47:08
W (2045) phy_init: failed to load RF calibration data (0x1102), falling back to full calibration
E (2215) BT_INIT: Malloc failed
E (2215) espDMclient: init_ble_gattc_gatts initialize controller failed: ESP_ERR_NO_MEM
Here is custom partitions.csv:
# ESP-IDF Partition Table,,,,,
# Name, Type, SubType, Offset, Size, Flags
nvs,data,nvs,0x9000,0x6000,
phy_init,data,phy,0xf000,0x1000,
factory,app,factory,0x10000,4M,
db_pneus,data,nvs,,0x40000,
#storage,data,spiffs,,0xF0000,

- I tried to move sd mount function below init_ble_gattc_gatts, but this time, it is the sd that doesn't mount ( error message refering to pull up rsistor but sur it is not that because http sd card file serving example works fine).
- I tried to incraease like 100 000 the task ram in xTaskCreatePinnedToCore but it doesn't start the task anymore with this big value, i don't know why because I have 8MB of ram now.
- I tried comment the sd mount function , ble workd fine.
- I tried to move out from bleTask the sd mount function in main(), same memory issue.

I really miss to manage my memory.
The device has been change from 2MB to 8Mb to face this issue but it is still a live, meaning something is not ok somewhere...

Thank you for your precious help.

MicroController
Posts: 1739
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: Bluedroid bt controller init Fail

Postby MicroController » Mon Oct 14, 2024 9:00 am

More than likely something in the code you didn't show consumes a lot of internal RAM.
Notice that there a distinction between internal RAM ("SRAM", 512kB) and external RAM ("PSRAM"/"SPI-RAM", 8MB).
By default, only the internal RAM is used as it is available on every chip/module. To use the external RAM, you need to configure it first; then you may have to explicitly allocate heap memory from the external RAM. Some things are required to reside in internal RAM though, so e.g. Bluedroid may need to allocate some internal RAM in every case.

Olfox59
Posts: 23
Joined: Tue May 02, 2017 12:36 pm

Re: Bluedroid bt controller init Fail

Postby Olfox59 » Mon Oct 14, 2024 2:25 pm

Thanks a lot for your rapplu, i understand much more what's happen. It was not really clear till now.

I confirm what you said.

In addition to bluedroid ( i need may be to switch to nimble as i only use ble) and wifi soft ap, i have 50% of the internal ram used by my gui LVGL for graphic display( a lot of static variable when i export from squareline studio graphic editor).

I succesfully declared in menuconfig and i can see in the log the detection of the psram 8MB.

Now i need to modify lv_conf file to malloc in psram instead of internal ram.

Who is online

Users browsing this forum: Bing [Bot], forrest, Majestic-12 [Bot] and 143 guests