Commit graph

56 commits

Author SHA1 Message Date
me-no-dev afa091fe79 prevent heap_caps_add_region exception if region is empty
Calling `esp_bt_controller_mem_release` or `esp_bt_mem_release` might result in exception if any of the regions returned to heap are empty. This happens usually if BT/BLE is enabled, but not used/linked in the final firmware.
2018-08-17 08:49:48 +02:00
Tian Hao ee787085f9 component/bt : decrease memory consumption by conn number
1. BLE only with 9(max) connection will decrease 3K DRAM
2. BR/EDR only with 7(max) connection will decrease 16K DRAM
3. Any of BLE or BR/EDR connection number decrease will also decrease DRAM consumption
4. Decrease one BLE connection will save about 1KB DRAM
5. Decrease one BR/EDR ACL connection will save about 1.2KB DRAM
6. Decrease one BR/EDR SCO/eSCO will save 2KB DRAM.
7. fix some definition and kconfig
8. remove 1.2k of vhci tx cache and make .bss & .data to heap about 1.4K
9. modify BT Reserved Memory size and modify example to support new bt kconfig
2018-08-14 02:29:17 +00:00
Angus Gratton a5ae5ac4b3 soc: Allow components to reserve fixed memory ranges that they need
No longer necessary to keep all reserved addresses in 'soc'.

Means 'soc' does not need to know about 'bt', for example.

Also means that Bluetooth can be enabled in config without any memory being reserved for BT
controller. Only if code calling the BT controller is linked in, will this memory be reserved...
2018-08-06 01:37:55 +00:00
Jiang Jiang Jian b3dd6ff9fc Merge branch 'bugfix/btdm_controller_deinit' into 'master'
bt : fix bug that bluetooth controller init/disable/enable/disable may cause exception

See merge request idf/esp-idf!2800
2018-07-25 21:00:35 +08:00
Tian Hao 6e4342a877 bt : fix bug that bluetooth controller init/disable/enable/disable may cause exception
1. when one task do deinit/init/disable/enable, especially different cpu
core, it may cause controller crash in ISR handler
2. fix while BLE is scanning, bluetooth controller is disabled cause BLE
scan is not abort.
2018-07-20 14:10:55 +08:00
Hrishikesh Dhayagude f610249bdd Reclaim BT/BTDM BSS and Data in bluetooth memory release function
1. Modify esp_bt_controller_mem_release() to release BTDM BSS and Data to heap if
ESP_BT_MODE_BTDM mode is passed to it
2. Add a new API esp_bt_mem_release() which internally calls
esp_bt_controller_mem_release() with the provided mode and then if mode
is ESP_BT_MODE_BTDM, releases BT BSS and Data to heap.

Background:
For Wi-Fi and BT/BLE applications, for e.g. the usecase is like when
Bluetooth is used for provisioning and once the device is connected to the Wi-Fi
AP, we can turn off Bluetooth completely. In such scenarios, it should be possible to
reclaim all the memory of Bluetooth. Although, currently this does not
happen.

Experiment:
Made the following modifications to examples/bluetooth/gatt_server :
1. Added support of simple_wifi to it
2. Moved all the bluetooth related code under CONFIG_BT_ENABLED config
option
3. Calculated the free heap in 2 similar scenarios:
   i. Disabled BT (CONFIG_BT_ENABLED undefined) and checked the free
heap after STA connected
   ii. Kept BT enabled and disabled it after STA connected and checked
the free heap
Ideally, the numbers for i., ii. above should have been similar. But
there was a delta of almost 30-31K. (i. > ii.)
4. Through make size-components checked the common BSS for libbta.a and libbtdm_app.a
and found it to be almost 30K. Data is around 1K

Solution:
1. Modified the linker script to mark the BSS and Data for these libraries and
free it when ESP_BT_MODE_BTDM mode is passed to mem release APIs.
2. Verified that the free heap is comparable for i. and ii. above.

Note: It is known that once this is done, Bluetooth can only be used
again post reboot.

Signed-off-by: Hrishikesh Dhayagude <hrishi@espressif.com>
2018-07-20 11:33:26 +05:30
Mahavir Jain bd177a34c6 bt: fix OS abstraction layer for correct critical section API usage
Signed-off-by: Mahavir Jain <mahavir@espressif.com>
2018-07-01 19:07:51 +05:30
Tian Hao e3df7d97a7 esp32: fix coex bug
1. fix BLE connection missing in coex mode
    2. modify other parameters to make coex priority more reasonable
    3. fix modem sleep procedure trap cause Wifi disable RF when BT is
    working. Such cause that BR/EDR is difficult to be connected, BLE
    connection stability decrease and so on.
    4. modify BR/EDR coexist duration to imrove BR/EDR connect success
    ratio.
    5. Due to the hardware coexist bug, BLE scan interval/window should
    be less than 0x100(about 160ms). Therefore, it will cause BLE cannot
    scan any advertising packet while WiFi have higher priority
    behaviour(such like RX beacon, scan, TX/RX VO packets and etc.).
2018-06-29 16:28:11 +08:00
Jiang Jiang Jian 9510f77f7a Merge branch 'bugfix/btdm_rm_assert_in_isr' into 'master'
bugfix/btdm_rm_assert_in_isr

See merge request idf/esp-idf!2633
2018-06-29 14:24:28 +08:00
wangmengyang 04ea784011 prevent Dynamic Frequency Scaling when using bluetooth modem sleep
This constraint will be elimiated after the issue is fixed
2018-06-28 18:08:18 +08:00
wangmengyang 02a620811d component/bt: remove the call of assert in time conversion functions which can be caused in ISR 2018-06-27 17:23:23 +08:00
zhiweijian 212b786119 Component/bt: fix throughput_demo_fail 2018-05-30 19:58:31 +08:00
zhiweijian 340ad5c430 Component/bt: fix scan duplicate 2018-05-21 15:23:15 +08:00
wangmengyang 4c4e143a2f component/bt: implement HFP Hands Free Unit Role 2018-05-21 11:33:30 +08:00
wangmengyang 22e21b38f7 component/bt: implement bluetooth modem sleep mode, one mode for BLE only and another for dual mode bluetooth
1. provide options for bluetooth low power mode
2. provide two options for bluetooth low power clock: main XTAL and external 32kHz XTAL
3. provide function and callbacks to control bluetooth low power mode, including enable/disable sleep, software wakeup request, low power clock settings, check power state, etc
4. modify vhci API vhci_host_send_packet to use blocking mode
5. note that DFS and bluetooth modem sleep can not be used together currently.
2018-05-19 15:37:26 +08:00
Liu Zhi Fu ed46976f41 esp32/bt/driver: support static allocation of FreeRTOS queues used by ISR routine
Support static allocation of FreeRTOS queues used by ISR routine in WiFi/BT/esp_timer/driver etc
2018-04-27 15:02:30 +08:00
Tian Hao e660785532 component/bt : add BR/EDR TX power set 2018-04-25 15:28:19 +08:00
Anton Maklakov 046ff2e628 Make error codes looks like literals in the code of them (easy for searching). Minor fixes, typos 2018-04-09 13:54:18 +10:00
island 9b7454de0c support wifi&bt coexist (v0.9.1)
1. refactor wifi modem sleep
2. refactor wifi and bt phy enable/diable coexistence
3. support wifi&bt coexist (v0.9.1)
3. add coex pause resume
4. fix bt library interrupt reaction slowly
5. make a2dp more smooth when coex
6. add coexist preference option
7. Make CI do not check libcoexist.a printf/ets_printf
8. disable Wifi RX AMPDU when software coexistence enable && update wifi lib
9. bluetooth call modem sleep api
2018-04-02 13:44:48 +08:00
Tian Hao 4b1ef083ee component/bt : add bluetooth controller library compile version 2018-03-27 16:35:00 +08:00
Hrishikesh Dhayagude 4a7d445301 components/bt examples/bluetooth: Fix typographical errors
Signed-off-by: Hrishikesh Dhayagude <hrishi@espressif.com>
2018-02-13 13:25:33 +05:30
Tian Hao 65bdb2d7ff component/bt : fix btdm mem release cause 0x3ffbbb28-0x3ffbdb28 add to region but should not.
1. fix the bug. Modify the condition that esp_bt_controller_mem_release() shoud be only called before esp_bt_controller_init() or after esp_bt_controller_deinit()
2. modify the example to use esp_bt_controller_mem_release()
2017-12-13 11:38:39 +08:00
Tian Hao 583dceb69b component/btdm : change bt.h name to esp_bt.h to form the name prefix 2017-12-08 10:33:50 +08:00
wangmengyang bd6394db92 component/bt: clean up WIFI_CLK_EN_REG settings for Bluetooth
1. move settings of WIFI_CLK_EN_REG for bluetooth into controller init/deinit APIs
2. modify the bit mask used in phy_rf init/deinit to use WIFI-BT shared bits
2017-11-02 15:24:21 +08:00
Tian Hao 85eb5d4374 component/bt : fix bug of sw interrupt cause to run btdm to different cpu core.
1. add sw interrupt cause osi to controller.
2. modify the kconfig to improve the option view.
3. add option of the cpu core which bluedroid run.
4. add option of the cpu core which bluetooth controller run.
2017-10-24 16:13:58 +08:00
Ivan Grokhotkov d503b991b4 bt: lock APB frequency while BT controller is enabled 2017-10-18 14:37:22 +08:00
Tian Hao b54ef13fae component/bt : allow init after de-init 2017-10-10 15:35:17 +08:00
Tian Hao 3e2ee24e4f component/bt : support bluetooth controller DRAM release dynamically
1. remove CONFIG_BT_DRAM_RELEASE from Kconfig
2. add API to release bluetooth controller DRAM to heap
2017-09-21 14:31:20 +08:00
Tian Hao b54719d00f component/bt : fix bluetooth controller enable limit && release memory when de-initialize bluetooth controller
1. fix bluetooth controller enable limit
2. release memory when de-initialize bluetooth controller
3. fix heap_caps_add_region limit
2017-09-19 21:14:28 +08:00
Tian Hao b500d6558a component/bt : add osi_is_in_isr && fix vhci delay 2017-07-25 19:58:39 +08:00
Tian Hao 006a90e075 component/bt : add ble tx power && fix controller deinit mem leak
1. add ble tx power functions
2. add more osi functions.
3. modify bluetooth controller task procedure
4. fix a memory leak when controller deinit
5. add controller disable return value.
2017-07-18 20:22:28 +08:00
Tian Hao 808b07799c component/bt : fix task post bug && fix controller init protection
1. fix bluedroid task post to blocking.
2. use semphore protect btdm controller task when be called from higher priority task
2017-06-13 17:14:50 +08:00
Tian Hao bd309731da component/bt : fix bug of task schedule delayed.
1. BLE RX test mode require quick task reaction, so allow higher priority task schedule from ISR.
2. Maybe other scenario also require this.
2017-06-07 14:58:17 +08:00
Tian Hao d90a35af19 component/bt : modify bluetooth config style 2017-04-06 11:35:53 +08:00
Tian Hao 95d691afdb component/bt : support UART HCI and fix some bugs
1. support UART HCI, devolper need not to make a bridge between VHCI and UART.
2. fix bug of rand/srand called in ISR.
3. fix bug of BLE rx packets may cause assert.
2017-04-05 21:23:43 +08:00
Tian Hao f5ebeb4c4d component/bt : add uart(1/2) as HCI IO directly 2017-04-05 21:23:42 +08:00
XiaXiaotian d3eede2110 mac address: add the number of MAC address generated from efuse for user to choose
1. Add the number of MAC address generated from efuse for user to choose.

2. Add MAC address derive method.
2017-03-02 15:54:35 +08:00
wangmengyang 6d061ec903 component/bt: modify the bluetooth read_efuse_mac interface 2017-03-01 21:04:12 +08:00
Tian Hao 55693b1168 component/bt : add option to release about 30K from BT if BLE only
1. later BT/BLE will be separated by BT/BLE macro, but this option should use when user make sure that in BLE only mode.
2017-02-21 17:46:59 +08:00
Tian Hao 12a7293b31 component/bt : add bluetooth status check
1. add bluetooth controller/host initialize status check
2. separate bluetooth controller task schedule loop from controller init
2017-02-21 01:05:37 +08:00
Tian Hao 4bd5b0c91a component/bt : add bt enable/disable for power save
1. add new APIs bt controller enable/disab/deinit
2. make bt controller work need to call two APIs of esp_bt_controller_init and enable
3. modify phy init to make mac reset once
2017-02-17 19:24:58 +08:00
XiaXiaotian cd13c9e95d disable phy and rf
1. add a macro in menuconfig for users to choose whether store phy calibration data into NVS or not.

2. rename some disable phy and rf APIs so that existing code which calls old APIS will fail to compile.
2017-02-17 10:24:55 +08:00
XiaXiaotian eb14284c92 disable PHY and RF when stop WiFi and disable BT
1. Add disable PHY and RF when WiFi and BT are both disabled(including call sniffer disable API).

2. Do not init PHY and RF when cpu start. Init PHY and RF when call Wifi or BT start APIs(including sniffer enable API).

3. Add a temporary lib: librtc_clk.a and will delete it when CPU frequency switching function is done.

4. Add an function to get OS tick rate.

5. Do not put the whole pp.a in iram0, only put lmac.o, ieee80211_misc.o, ets_time.o and wdev.o in iram0.
2017-02-17 10:24:54 +08:00
wangmengyang 2e7748d625 component/bt: modify bluetooth API
1. VHCI api and doxygen
2. Controller api and doxygen
3. bluedroid init/enable api and doxygen
4. cleanup demo codes
2017-01-05 20:02:06 +08:00
Angus Gratton 06e03ff52e Replace backwards-compatible portTICK_RATE_MS with FreeRTOS v8+ portTICK_PERIOD_MS
Closes github #51 https://github.com/espressif/esp-idf/issues/51
2016-12-28 10:23:13 +11:00
Tian Hao 5a9801aca7 Merge branch 'master' into feature/btdm_bluedroid
# Conflicts:
#	components/esp32/cpu_freq.c
#	components/esp32/lib
2016-11-29 18:38:37 +08:00
Tian Hao 19273c7b2d component/bt : run astyle handle the code files 2016-11-25 02:10:15 +08:00
Ivan Grokhotkov df6edb50e9 implement esp_deep_sleep, fix build issues 2016-11-22 21:54:49 +08:00
Tian Hao 24df5e2041 component/bt : cleanup ^M
someone use editor in windows, so use "LF" in your editor, please.
2016-10-18 21:49:00 +08:00
yulong 02ad223eea component bt: 1.modified the btu buffer size from 15 to 60;
2.change the smp method
2016-10-15 05:46:10 -04:00