Bluetooth initialization fails

f.h-f.s.
Posts: 214
Joined: Thu Dec 08, 2016 2:53 pm

Bluetooth initialization fails

Postby f.h-f.s. » Wed Mar 08, 2017 1:41 pm

Hi,

I'm having a problem with my Bluetooth initialization when I'm combining all the functionality I need. My program needs three things: Bluetooth, MQTT client over tls, HTTPS client.

When I build my program, any combination with two out of three work.

Building with all three components causes the ESP32 to crash during the Bluetooth initialization.

First some errors/warnings:

Code: Select all

    E (2596) phy_init: load_cal_data_from_nvs_handle: failed to get cal_data(4354)

    W (2693) cpu_start: failed to load RF calibration data, falling back to full calibration
Then during the Bluetooth initialization:

Code: Select all

    BTDM CONTROLLER VERSION: 010101
    btip start
    copy .data from 4000d890 to 3ffae6e0, len 00001830
    set .bss 0x0 from 3ffb8000 to 3ffbff70, len 00007f70
    BTDM ROM VERSION 0101
    BD_ADDR: 24:0A:C4:00:8D:8A
    Guru Meditation Error of type IllegalInstruction occurred on core 0 at pc=40190840. Setting bp and returning..
    Register dump:
    PC : 0x40190840 PS : 0x00060130 A0 : 0x800823ba A1 : 0x3ffdeb10
    A2 : 0x0000001b A3 : 0x0000001b A4 : 0x00000024 A5 : 0xffffffff
    A6 : 0x00000000 A7 : 0xffffffff A8 : 0x8017d6a8 A9 : 0x3ffdeaf0
    A10 : 0x00000000 A11 : 0x3ffdeaa2 A12 : 0x3ffdea4f A13 : 0x00000041
    A14 : 0x00000000 A15 : 0x3ffdea53 SAR : 0x00000005 EXCCAUSE: 0x00000000
    EXCVADDR: 0x00000000 LBEG : 0x4000c46c LEND : 0x4000c477 LCOUNT : 0x00000000

    Backtrace: 0x40190840:0x3ffdeb10 0x400823ba:0x3ffdeb30 0x400823fd:0x3ffdeb60 0x4008249d:0x3ffdeb80 0x40118977:0x3ffdeba0
I have put the build logs, output logs and some additional information on http://pastebin.com/Mm2jwv2d. I suspect it is a nvs(flash) issue since the image corrupts after. Might it be overwriting the Bluetooth flash data?

Any ideas on how to fix this?

Topic on Sysprogs: https://sysprogs.com/w/forums/topic/blu ... ils-esp32/

ESP_igrr
Posts: 2071
Joined: Tue Dec 01, 2015 8:37 am

Re: Bluetooth initialization fails

Postby ESP_igrr » Wed Mar 08, 2017 4:14 pm

May be caused by binary size growing over certain margin? Can you enable debug output in bootloader and post what it prints at startup (for the case when all three components are enabled)?

f.h-f.s.
Posts: 214
Joined: Thu Dec 08, 2016 2:53 pm

Re: Bluetooth initialization fails

Postby f.h-f.s. » Wed Mar 08, 2017 5:22 pm

i've defined:

Code: Select all

#define CONFIG_LOG_BOOTLOADER_LEVEL 5
#define CONFIG_LOG_DEFAULT_LEVEL 5
#define CONFIG_LOG_BOOTLOADER_LEVEL_VERBOSE 1
#define CONFIG_LOG_DEFAULT_LEVEL_VERBOSE 1
But I don't see any extra lines in the debug output, am I missing a define for bootloader log?
http://pastebin.com/AKiumv6k

ESP_igrr
Posts: 2071
Joined: Tue Dec 01, 2015 8:37 am

Re: Bluetooth initialization fails

Postby ESP_igrr » Thu Mar 09, 2017 5:32 am

You have made these changes by going into 'make menuconfig', not by modifying sdkconfig.h, right?

f.h-f.s.
Posts: 214
Joined: Thu Dec 08, 2016 2:53 pm

Re: Bluetooth initialization fails

Postby f.h-f.s. » Thu Mar 09, 2017 9:06 am

I use VisualGDB, I have to make those changes there.

You are correct! I have grown over some other data needed by the bluetooth init.

When growing INSTR_FLASH over an specific amount between 874KB and 883KB(might just be between 882~885KB, looking at my other log)
From:

Code: Select all

1>         ------------------- Memory utilization report -------------------
1>         Used DATA_FLASH: 323KB out of 8192KB (3%) [+140]
1>         Used INSTR_FLASH: 874KB out of 3264KB (26%)
1>         Used INSTR_RAM: 114KB out of 128KB (89%)
1>         Used DATA_RAM: 101KB out of 320KB (31%)
To:

Code: Select all

1>         ------------------- Memory utilization report -------------------
1>         Used DATA_FLASH: 323KB out of 8192KB (3%)
1>         Used INSTR_FLASH: 883KB out of 3264KB (27%)
1>         Used INSTR_RAM: 114KB out of 128KB (89%)
1>         Used DATA_RAM: 101KB out of 320KB (31%)
this problem is also specific to INSTR_FLASH, growing DATA_FLASH does not have any effect.

How do I move what is located there. Or how do I work around this?

ESP_igrr
Posts: 2071
Joined: Tue Dec 01, 2015 8:37 am

Re: Bluetooth initialization fails

Postby ESP_igrr » Thu Mar 09, 2017 10:29 am

Can you find the uploaded application binary size? I don't know where VisualGDB would store it, but ESP-IDF puts it into build/your-app-name.bin. Alternatively, find application ELF file (would probably be in the same directory) and attach it to this topic if you may.

The issue here is probably that the application binary gets larger than the partition size reserved for the application (1 Megabyte by default), and the bootloader only maps 1 megabyte of flash into instruction memory, so you get InvalidInstruction exception when code outside of this boundary is called.
If you can modify the partition table (see http://esp-idf.readthedocs.io/en/latest ... ables.html for instructions), increasing the size of application partition to, say, 2 megabytes might help.

f.h-f.s.
Posts: 214
Joined: Thu Dec 08, 2016 2:53 pm

Re: Bluetooth initialization fails

Postby f.h-f.s. » Thu Mar 09, 2017 12:58 pm

Yeah, modifying the partition file works pefectly. I was over the 1M limit! thanks alot.

Who is online

Users browsing this forum: jsmith56x, sterisa and 284 guests