Skip to content

Conversation

@ceolin
Copy link
Member

@ceolin ceolin commented Oct 21, 2024

The default heap is not enough not even to initialize the Bluetooth stack. Increase the memory heap when Bluetooth is selected to be able at least to do basic things.

The default heap is not enough not even to initialize the
Bluetooth stack. Increase the memory heap when Bluetooth
is selected to be able at least to do basic things.

Signed-off-by: Flavio Ceolin <[email protected]>
@zephyrbot zephyrbot added platform: ESP32 Espressif ESP32 size: XS A PR changing only a single line of code labels Oct 21, 2024
@sylvioalves
Copy link
Contributor

@ceolin hum, which revision you have tested? Just tested with latest main and I get both bluetooth/peripherals and bluetooth/ibeacon working good. Can you provide more info?

*** Booting Zephyr OS build (tainted) v3.7.0-4826-g372b3a9b8da2 ***
[00:00:00.046,000] <inf> fs_nvs: 8 Sectors of 4096 bytes
[00:00:00.046,000] <inf> fs_nvs: alloc wra: 0, fe8
[00:00:00.046,000] <inf> fs_nvs: data wra: 0, 0
[00:00:00.047,000] <inf> esp32_bt_adapter: BT controller compile version [963cad4]
[00:00:00.442,000] <inf> bt_hci_core: No ID address. App must call settings_load()
Bluetooth initialized
[00:00:00.447,000] <inf> bt_hci_core: Identity: 64:E8:33:98:6D:3C (public)
[00:00:00.448,000] <inf> bt_hci_core: HCI: version 5.0 (0x09) revision 0x0016, manufacturer 0x02e5
[00:00:00.448,000] <inf> bt_hci_core: LMP: version 5.0 (0x09) subver 0x0016
Advertising successfully started
Indicate VND attr 0x3c0306d4 (UUID 12345678-1234-5678-1234-56789abcdef1)

@ceolin
Copy link
Member Author

ceolin commented Oct 21, 2024

Curious, I am using 372b3a9b8da2967e43676943392daf9091affdb1

Building with:

west build -p -b esp32c3_devkitm samples/bluetooth/ibeacon -DCONFIG_BOOTLOADER_REGION_PROTECTION_ENABLE=n && west flash

That is the error I get:


I (145) boot: padd: lma 0x0003b41c vma 0x00000000 len 0x4bdc   (19420)
I (151) boot: DMAP: lma 0x00040000 vma 0x3c020000 len 0x4228   (16936)
I (157) boot: Image with 6 segments
I (161) boot: DROM segment: paddr=00040000h, vaddr=3c020000h, size=04230h ( 16944) map
I (168) boot: IROM segment: paddr=00020000h, vaddr=42000000h, size=1B412h (111634) map
I (211) heap_runtime: ESP heap runtime init at 0x3fc96d70 size 212 kB.
*** Booting Zephyr OS build (tainted) v3.7.0-4826-g372b3a9b8da2 ***
Starting iBeacon Demo
[00:00:00.024,000] <inf> esp32_bt_adapter: BT controller compile version [963cad4]
[00:00:00.087,000] <err> bt_hci_driver_esp32: Not enough memory to initialize Bluetooth.
[00:00:00.087,000] <err> bt_hci_driver_esp32: Consider increasing CONFIG_HEAP_MEM_POOL_SIZE value.
[00:00:00.087,000] <err> bt_hci_core: HCI driver open failed (-12)
Bluetooth init failed (err -12)

The controller revision is the same too.

Btw, if I enable boot loader protection I get:

I (211) heap_runtime: ESP heap runtime init at 0x3fc96e70 size 212 kB.
[00:00:00.088,000] <err> os:  mcause: 7, Store/AMO access fault
[00:00:00.088,000] <err> os:   mtval: 3fd1200e
--- 4 messages dropped ---
[00:00:00.088,000] <err> os:      a0: 3fc94720    t0: 4005890e
[00:00:00.088,000] <err> os:      a1: 3fd1200e    t1: 4038804c
[00:00:00.088,000] <err> os:      a2: 00000006    t2: 40386494
[00:00:00.088,000] <err> os:      a3: 0000fb1d    t3: 40383e74
[00:00:00.088,000] <err> os:      a4: 000001ff    t4: 40383e6a
[00:00:00.088,000] <err> os:      a5: 00008000    t5: 40385e58
[00:00:00.088,000] <err> os:      a6: 403862fc    t6: 40386270
[00:00:00.088,000] <err> os:      a7: 4038469e
[00:00:00.088,000] <err> os:      sp: 3fc94190
[00:00:00.088,000] <err> os:      ra: 420001f4
[00:00:00.088,000] <err> os:    mepc: 420000f0
[00:00:00.088,000] <err> os: mstatus: 00001800
[00:00:00.088,000] <err> os: 
[00:00:00.088,000] <err> os: call trace:
[00:00:00.088,000] <err> os:       0: sp: 3fc94190 ra: 420000f0
[00:00:00.088,000] <err> os:       1: sp: 3fc941b0 ra: 420004ba
[00:00:00.088,000] <err> os:       2: sp: 3fc941e0 ra: 420034b8
[00:00:00.088,000] <err> os:       3: sp: 3fc941f0 ra: 42003b48
[00:00:00.088,000] <err> os:       4: sp: 3fc9423c ra: 4200514c
[00:00:00.088,000] <err> os:       5: sp: 3fc94240 ra: 42006d2a
[00:00:00.088,000] <err> os:       6: sp: 3fc94298 ra: 42000002
[00:00:00.088,000] <err> os:       7: sp: 3fc942a0 ra: 42005a92
[00:00:00.088,000] <err> os: 
[00:00:00.088,000] <err> os: >>> ZEPHYR FATAL ERROR 0: CPU exception on CPU 0
[00:00:00.088,000] <err> os: Current thread: 0x3fc96850 (unknown)
[00:00:00.243,000] <err> os: Halting system

Looking the HAL, the initialization failed in btdm_controller_init which is a call to the binary code, so I can't get more info.

@sylvioalves
Copy link
Contributor

sylvioalves commented Oct 22, 2024

@ceolin I tried the same commands you did. Still got it working. Would you mind sharing the initial log output so I can get more info about the esp32c3 memory stuff? Is west blobs fetch hal_espressif updated?

I (146) boot: padd: lma 0x0003b560 vma 0x00000000 len 0x4a98   (19096)
I (153) boot: DMAP: lma 0x00040000 vma 0x3c020000 len 0x42e4   (17124)
I (159) boot: Image with 6 segments
I (162) boot: DROM segment: paddr=00040000h, vaddr=3c020000h, size=042F0h ( 17136) map
I (170) boot: IROM segment: paddr=00020000h, vaddr=42000000h, size=1B558h (111960) map
I (212) heap_runtime: ESP heap runtime init at 0x3fc97080 size 211 kB.
*** Booting Zephyr OS build (tainted) v3.7.0-4826-g372b3a9b8da2 ***
Starting iBeacon Demo
[00:00:00.024,000] <inf> esp32_bt_adapter: BT controller compile version [963cad4]
[00:00:00.103,000] <inf> bt_hci_core: Identity: 64:E8:33:98:6D:3C (public)
[00:00:00.103,000] <inf> bt_hci_core: HCI: version 5.0 (0x09) revision 0x0016, manufacturer 0x02e5
[00:00:00.103,000] <inf> bt_hci_core: LMP: version 5.0 (0x09) subver 0x0016
Bluetooth initialized
iBeacon started

@marekmatej
Copy link
Contributor

@ceolin this was fixed here #79523
Can you rebase and give it a try?


config HEAP_MEM_POOL_ADD_SIZE_BOARD
int
default 32768 if BT
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BT and WiFi should be using the runtime heap, so increasing the system heap doesn't make sense now.

@ceolin
Copy link
Member Author

ceolin commented Oct 25, 2024

It was indeed fixed. Thank you guys for the support.

@ceolin ceolin closed this Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

platform: ESP32 Espressif ESP32 size: XS A PR changing only a single line of code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants