espressif / arduino-esp32

Arduino core for the ESP32
GNU Lesser General Public License v2.1
13.41k stars 7.37k forks source link

arduino-esp32 BLE program works using make but not CMake #2549

Closed ecc1 closed 5 years ago

ecc1 commented 5 years ago

Hardware:

Board: ttgo-lora32-v1 Core Installation version: 1.0.1-git IDE name: IDF component

Description:

I wrote a simple BLE server using the Arduino BLE library and am trying to build it using arduino-esp32 as an ESP-IDF component.

When I use the make-based build system, it works as expected.

When I use the CMake-based build system, it doesn't; it fails to initialize the Bluetooth controller:

E (473) BLEDevice: esp_bt_controller_init: rc=259 Unknown ESP_ERR error

Good boot log (built with make)

rst:0x1 (POWERON_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:6300
load:0x40078000,len:11308
ho 0 tail 12 room 4
load:0x40080400,len:6680
entry 0x40080760
I (33) boot: ESP-IDF v3.3-beta1-506-gebdcbe8c6 2nd stage bootloader
I (33) boot: compile time 13:57:24
I (33) boot: Enabling RNG early entropy source...
I (38) boot: SPI Speed      : 40MHz
I (43) boot: SPI Mode       : DIO
I (47) boot: SPI Flash Size : 4MB
I (51) boot: Partition Table:
I (54) boot: ## Label            Usage          Type ST Offset   Length
I (62) boot:  0 nvs              WiFi data        01 02 00009000 00005000
I (69) boot:  1 otadata          OTA data         01 00 0000e000 00002000
I (76) boot:  2 app0             OTA app          00 10 00010000 00140000
I (84) boot:  3 app1             OTA app          00 11 00150000 00140000
I (91) boot:  4 eeprom           Unknown data     01 99 00290000 00001000
I (99) boot:  5 spiffs           Unknown data     01 82 00291000 0016f000
I (106) boot: End of partition table
I (111) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x2c87c (182396) map
I (184) esp_image: segment 1: paddr=0x0003c8a4 vaddr=0x3ffbdb60 size=0x02d00 ( 11520) load
I (188) esp_image: segment 2: paddr=0x0003f5ac vaddr=0x40080000 size=0x00400 (  1024) load
0x40080000: _WindowOverflow4 at /opt/esp/esp-idf/components/freertos/xtensa_vectors.S:1779

I (191) esp_image: segment 3: paddr=0x0003f9b4 vaddr=0x40080400 size=0x0065c (  1628) load
I (200) esp_image: segment 4: paddr=0x00040018 vaddr=0x400d0018 size=0x98f50 (626512) map
0x400d0018: _flash_cache_start at ??:?

I (427) esp_image: segment 5: paddr=0x000d8f70 vaddr=0x40080a5c size=0x11748 ( 71496) load
I (468) boot: Loaded app from partition at offset 0x10000
I (468) boot: Disabling RNG early entropy source...
I (469) cpu_start: Pro cpu up.
I (472) cpu_start: Application information:
I (477) cpu_start: Project name:     bletest
I (482) cpu_start: App version:      95933aa-dirty
I (487) cpu_start: Compile time:     Mar  5 2019 13:57:09
I (493) cpu_start: ELF file SHA256:  fdf6c60e5aebdf3e...
I (499) cpu_start: ESP-IDF:          v3.3-beta1-506-gebdcbe8c6
I (506) cpu_start: Starting app cpu, entry point is 0x400810cc
0x400810cc: call_start_cpu1 at /opt/esp/esp-idf/components/esp32/cpu_start.c:267

I (0) cpu_start: App cpu up.
D (516) memory_layout: Checking 11 reserved memory ranges:
D (522) memory_layout: Reserved memory range 0x3ffae000 - 0x3ffae6e0
D (528) memory_layout: Reserved memory range 0x3ffae6e0 - 0x3ffaff10
D (534) memory_layout: Reserved memory range 0x3ffb0000 - 0x3ffb6388
D (541) memory_layout: Reserved memory range 0x3ffb8000 - 0x3ffb9a20
D (547) memory_layout: Reserved memory range 0x3ffbdb28 - 0x3ffbdb5c
D (554) memory_layout: Reserved memory range 0x3ffbdb60 - 0x3ffca448
D (560) memory_layout: Reserved memory range 0x3ffe0000 - 0x3ffe0440
D (567) memory_layout: Reserved memory range 0x3ffe3f20 - 0x3ffe4350
D (573) memory_layout: Reserved memory range 0x40070000 - 0x40078000
D (579) memory_layout: Reserved memory range 0x40078000 - 0x40080000
0x40080000: _WindowOverflow4 at /opt/esp/esp-idf/components/freertos/xtensa_vectors.S:1779

D (586) memory_layout: Reserved memory range 0x40080000 - 0x400921a1
0x40080000: _WindowOverflow4 at /opt/esp/esp-idf/components/freertos/xtensa_vectors.S:1779

D (592) memory_layout: Building list of available memory regions:
D (598) memory_layout: Available memory region 0x3ffaff10 - 0x3ffb0000
D (605) memory_layout: Available memory region 0x3ffb6388 - 0x3ffb8000
D (612) memory_layout: Available memory region 0x3ffb9a20 - 0x3ffbdb28
D (618) memory_layout: Available memory region 0x3ffbdb5c - 0x3ffbdb60
D (625) memory_layout: Available memory region 0x3ffca448 - 0x3ffcc000
D (631) memory_layout: Available memory region 0x3ffcc000 - 0x3ffce000
D (638) memory_layout: Available memory region 0x3ffce000 - 0x3ffd0000
D (645) memory_layout: Available memory region 0x3ffd0000 - 0x3ffd2000
D (651) memory_layout: Available memory region 0x3ffd2000 - 0x3ffd4000
D (658) memory_layout: Available memory region 0x3ffd4000 - 0x3ffd6000
D (664) memory_layout: Available memory region 0x3ffd6000 - 0x3ffd8000
D (671) memory_layout: Available memory region 0x3ffd8000 - 0x3ffda000
D (678) memory_layout: Available memory region 0x3ffda000 - 0x3ffdc000
D (684) memory_layout: Available memory region 0x3ffdc000 - 0x3ffde000
D (691) memory_layout: Available memory region 0x3ffde000 - 0x3ffe0000
D (697) memory_layout: Available memory region 0x3ffe0440 - 0x3ffe3f20
D (704) memory_layout: Available memory region 0x3ffe4350 - 0x3ffe8000
D (711) memory_layout: Available memory region 0x3ffe8000 - 0x3fff0000
D (717) memory_layout: Available memory region 0x3fff0000 - 0x3fff8000
D (724) memory_layout: Available memory region 0x3fff8000 - 0x3fffc000
D (730) memory_layout: Available memory region 0x3fffc000 - 0x40000000
D (737) memory_layout: Available memory region 0x400921a4 - 0x40094000
D (744) memory_layout: Available memory region 0x40094000 - 0x40096000
D (750) memory_layout: Available memory region 0x40096000 - 0x40098000
D (757) memory_layout: Available memory region 0x40098000 - 0x4009a000
D (763) memory_layout: Available memory region 0x4009a000 - 0x4009c000
D (770) memory_layout: Available memory region 0x4009c000 - 0x4009e000
D (776) memory_layout: Available memory region 0x4009e000 - 0x400a0000
I (783) heap_init: Initializing. RAM available for dynamic allocation:
D (790) heap_init: New heap initialised at 0x3ffaff10
I (795) heap_init: At 3FFAFF10 len 000000F0 (0 KiB): DRAM
D (801) heap_init: New heap initialised at 0x3ffb6388
I (807) heap_init: At 3FFB6388 len 00001C78 (7 KiB): DRAM
D (813) heap_init: New heap initialised at 0x3ffb9a20
I (818) heap_init: At 3FFB9A20 len 00004108 (16 KiB): DRAM
I (824) heap_init: At 3FFBDB5C len 00000004 (0 KiB): DRAM
D (830) heap_init: New heap initialised at 0x3ffca448
I (835) heap_init: At 3FFCA448 len 00015BB8 (86 KiB): DRAM
I (841) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (848) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
D (854) heap_init: New heap initialised at 0x400921a4
I (859) heap_init: At 400921A4 len 0000DE5C (55 KiB): IRAM
I (865) cpu_start: Pro cpu start user code
D (877) clk: RTC_SLOW_CLK calibration value: 3107466
D (216) intr_alloc: Connected src 46 to int 2 (cpu 0)
D (217) intr_alloc: Connected src 57 to int 3 (cpu 0)
D (219) intr_alloc: Connected src 24 to int 9 (cpu 0)
I (222) cpu_start: Starting scheduler on PRO CPU.
D (0) intr_alloc: Connected src 25 to int 2 (cpu 1)
I (0) cpu_start: Starting scheduler on APP CPU.
D (237) heap_init: New heap initialised at 0x3ffe0440
D (247) heap_init: New heap initialised at 0x3ffe4350
D (257) intr_alloc: Connected src 16 to int 12 (cpu 0)
D (257) nvs: nvs_flash_init_custom partition=nvs start=9 count=5
I (277) BTDM_INIT: BT controller compile version [d4658dd]
D (277) BTDM_INIT: .data initialise [0x3ffae6e0] <== [0x4000d890]
D (277) BTDM_INIT: .bss initialise [0x3ffb0000] - [0x3ffb09a8]
D (287) BTDM_INIT: .bss initialise [0x3ffb09a8] - [0x3ffb1ddc]
D (287) BTDM_INIT: .bss initialise [0x3ffb1ddc] - [0x3ffb2730]
D (297) BTDM_INIT: .bss initialise [0x3ffb2730] - [0x3ffb6388]
D (307) BTDM_INIT: .bss initialise [0x3ffb8000] - [0x3ffb9a20]
D (307) BTDM_INIT: .bss initialise [0x3ffbdb28] - [0x3ffbdb5c]
I (317) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE

Bad boot log (build with CMake)

rst:0x1 (POWERON_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:6300
load:0x40078000,len:11308
ho 0 tail 12 room 4
load:0x40080400,len:6680
entry 0x40080760
I (33) boot: ESP-IDF v3.3-beta1-506-gebdcbe8c6 2nd stage bootloader
I (33) boot: compile time 13:48:20
I (33) boot: Enabling RNG early entropy source...
I (38) boot: SPI Speed      : 40MHz
I (43) boot: SPI Mode       : DIO
I (47) boot: SPI Flash Size : 4MB
I (51) boot: Partition Table:
I (54) boot: ## Label            Usage          Type ST Offset   Length
I (62) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (69) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (76) boot:  2 factory          factory app      00 00 00010000 00100000
I (84) boot: End of partition table
I (88) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x2c4ec (181484) map
I (161) esp_image: segment 1: paddr=0x0003c514 vaddr=0x3ffbdb60 size=0x02d00 ( 11520) load
I (165) esp_image: segment 2: paddr=0x0003f21c vaddr=0x40080000 size=0x00400 (  1024) load
0x40080000: _WindowOverflow4 at /opt/esp/esp-idf/components/freertos/xtensa_vectors.S:1779

I (168) esp_image: segment 3: paddr=0x0003f624 vaddr=0x40080400 size=0x009ec (  2540) load
I (177) esp_image: segment 4: paddr=0x00040018 vaddr=0x400d0018 size=0x98ed4 (626388) map
0x400d0018: _flash_cache_start at ??:?

I (404) esp_image: segment 5: paddr=0x000d8ef4 vaddr=0x40080dec size=0x113d4 ( 70612) load
I (445) boot: Loaded app from partition at offset 0x10000
I (445) boot: Disabling RNG early entropy source...
I (445) cpu_start: Pro cpu up.
I (449) cpu_start: Application information:
I (454) cpu_start: Project name:     bletest
I (459) cpu_start: App version:      95933aa
I (464) cpu_start: Compile time:     Mar  5 2019 13:47:51
I (470) cpu_start: ELF file SHA256:  f5ea7046e93ae4f0...
I (476) cpu_start: ESP-IDF:          v3.3-beta1-506-gebdcbe8c6
I (482) cpu_start: Starting app cpu, entry point is 0x400810a0
0x400810a0: call_start_cpu1 at /opt/esp/esp-idf/components/esp32/cpu_start.c:267

I (0) cpu_start: App cpu up.
D (492) memory_layout: Checking 11 reserved memory ranges:
D (498) memory_layout: Reserved memory range 0x3ffae000 - 0x3ffae6e0
D (504) memory_layout: Reserved memory range 0x3ffae6e0 - 0x3ffaff10
D (511) memory_layout: Reserved memory range 0x3ffb0000 - 0x3ffb6388
D (517) memory_layout: Reserved memory range 0x3ffb8000 - 0x3ffb9a20
D (523) memory_layout: Reserved memory range 0x3ffbdb28 - 0x3ffbdb5c
D (530) memory_layout: Reserved memory range 0x3ffbdb60 - 0x3ffca450
D (536) memory_layout: Reserved memory range 0x3ffe0000 - 0x3ffe0440
D (543) memory_layout: Reserved memory range 0x3ffe3f20 - 0x3ffe4350
D (549) memory_layout: Reserved memory range 0x40070000 - 0x40078000
D (556) memory_layout: Reserved memory range 0x40078000 - 0x40080000
0x40080000: _WindowOverflow4 at /opt/esp/esp-idf/components/freertos/xtensa_vectors.S:1779

D (562) memory_layout: Reserved memory range 0x40080000 - 0x400921bf
0x40080000: _WindowOverflow4 at /opt/esp/esp-idf/components/freertos/xtensa_vectors.S:1779

D (568) memory_layout: Building list of available memory regions:
D (575) memory_layout: Available memory region 0x3ffaff10 - 0x3ffb0000
D (581) memory_layout: Available memory region 0x3ffb6388 - 0x3ffb8000
D (588) memory_layout: Available memory region 0x3ffb9a20 - 0x3ffbdb28
D (594) memory_layout: Available memory region 0x3ffbdb5c - 0x3ffbdb60
D (601) memory_layout: Available memory region 0x3ffca450 - 0x3ffcc000
D (608) memory_layout: Available memory region 0x3ffcc000 - 0x3ffce000
D (614) memory_layout: Available memory region 0x3ffce000 - 0x3ffd0000
D (621) memory_layout: Available memory region 0x3ffd0000 - 0x3ffd2000
D (627) memory_layout: Available memory region 0x3ffd2000 - 0x3ffd4000
D (634) memory_layout: Available memory region 0x3ffd4000 - 0x3ffd6000
D (641) memory_layout: Available memory region 0x3ffd6000 - 0x3ffd8000
D (647) memory_layout: Available memory region 0x3ffd8000 - 0x3ffda000
D (654) memory_layout: Available memory region 0x3ffda000 - 0x3ffdc000
D (660) memory_layout: Available memory region 0x3ffdc000 - 0x3ffde000
D (667) memory_layout: Available memory region 0x3ffde000 - 0x3ffe0000
D (673) memory_layout: Available memory region 0x3ffe0440 - 0x3ffe3f20
D (680) memory_layout: Available memory region 0x3ffe4350 - 0x3ffe8000
D (687) memory_layout: Available memory region 0x3ffe8000 - 0x3fff0000
D (693) memory_layout: Available memory region 0x3fff0000 - 0x3fff8000
D (700) memory_layout: Available memory region 0x3fff8000 - 0x3fffc000
D (706) memory_layout: Available memory region 0x3fffc000 - 0x40000000
D (713) memory_layout: Available memory region 0x400921c0 - 0x40094000
D (720) memory_layout: Available memory region 0x40094000 - 0x40096000
D (726) memory_layout: Available memory region 0x40096000 - 0x40098000
D (733) memory_layout: Available memory region 0x40098000 - 0x4009a000
D (739) memory_layout: Available memory region 0x4009a000 - 0x4009c000
D (746) memory_layout: Available memory region 0x4009c000 - 0x4009e000
D (753) memory_layout: Available memory region 0x4009e000 - 0x400a0000
I (759) heap_init: Initializing. RAM available for dynamic allocation:
D (767) heap_init: New heap initialised at 0x3ffaff10
I (772) heap_init: At 3FFAFF10 len 000000F0 (0 KiB): DRAM
D (778) heap_init: New heap initialised at 0x3ffb6388
I (783) heap_init: At 3FFB6388 len 00001C78 (7 KiB): DRAM
D (789) heap_init: New heap initialised at 0x3ffb9a20
I (794) heap_init: At 3FFB9A20 len 00004108 (16 KiB): DRAM
I (800) heap_init: At 3FFBDB5C len 00000004 (0 KiB): DRAM
D (806) heap_init: New heap initialised at 0x3ffca450
I (811) heap_init: At 3FFCA450 len 00015BB0 (86 KiB): DRAM
I (818) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (824) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
D (830) heap_init: New heap initialised at 0x400921c0
I (835) heap_init: At 400921C0 len 0000DE40 (55 KiB): IRAM
I (842) cpu_start: Pro cpu start user code
D (854) clk: RTC_SLOW_CLK calibration value: 3108490
D (192) intr_alloc: Connected src 46 to int 2 (cpu 0)
D (193) intr_alloc: Connected src 57 to int 3 (cpu 0)
D (195) intr_alloc: Connected src 24 to int 9 (cpu 0)
I (198) cpu_start: Starting scheduler on PRO CPU.
D (0) intr_alloc: Connected src 25 to int 2 (cpu 1)
I (0) cpu_start: Starting scheduler on APP CPU.
D (213) heap_init: New heap initialised at 0x3ffe0440
D (223) heap_init: New heap initialised at 0x3ffe4350
D (233) intr_alloc: Connected src 16 to int 12 (cpu 0)
D (233) nvs: nvs_flash_init_custom partition=nvs start=9 count=6
D (253) BTDM_INIT: Release DRAM [0x3ffae6e0] - [0x3ffaff10]
D (253) BTDM_INIT: Release DRAM [0x3ffb0000] - [0x3ffb6388]
D (253) BTDM_INIT: Release DRAM [0x3ffb8000] - [0x3ffb9a20]
D (263) BTDM_INIT: Release DRAM [0x3ffbdb28] - [0x3ffbdb5c]
D (263) BTDM_INIT: Release BTDM BSS [0x3ffc6934] - [0x3ffc7244]
D (273) BTDM_INIT: Release BTDM Data [0x3ffbdc98] - [0x3ffbdcb8]
E (283) BLEDevice: esp_bt_controller_init: rc=259 Unknown ESP_ERR error

Clearly the BTDM_INIT behavior differs between the two, but I could use some help figuring out where to look further -- how would the different build systems affect it? I can follow up with the verbose make and cmake output if anyone is interested.

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 5 years ago

This stale issue has been automatically closed. Thank you for your contributions.