8000 esp32: Enable NimBLE support on all builds (IDF 3.3 and 4.0). · micropython/micropython@3032ae1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3032ae1

Browse files
jimmodpgeorge
authored andcommitted
esp32: Enable NimBLE support on all builds (IDF 3.3 and 4.0).
This commit updates the IDFv3 version to v3.3.1, and enables the "ubluetooth" module by default on IDFv3 builds.
1 parent c14ff61 commit 3032ae1

File tree

4 files changed

+65
-11
lines changed

4 files changed

+65
-11
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ jobs:
213213
- make ${MAKEOPTS} -C mpy-cross
214214
# IDF v3 build
215215
- git -C esp-idf checkout $(grep "ESPIDF_SUPHASH_V3 :=" ports/esp32/Makefile | cut -d " " -f 3)
216-
- git -C esp-idf submodule update --init components/json/cJSON components/esp32/lib components/esptool_py/esptool components/expat/expat components/lwip/lwip components/mbedtls/mbedtls components/micro-ecc/micro-ecc components/nghttp/nghttp2
216+
- git -C esp-idf submodule update --init components/json/cJSON components/esp32/lib components/esptool_py/esptool components/expat/expat components/lwip/lwip components/mbedtls/mbedtls components/micro-ecc/micro-ecc components/nghttp/nghttp2 components/nimble components/bt
217217
- make ${MAKEOPTS} -C ports/esp32 submodules
218218
- make ${MAKEOPTS} -C ports/esp32
219219
# clean

ports/esp32/Makefile

Lines changed: 53 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ OBJDUMP = $(CROSS_COMPILE)objdump
5151
SDKCONFIG_COMBINED = $(BUILD)/sdkconfig.combined
5252
SDKCONFIG_H = $(BUILD)/sdkconfig.h
5353

54-
# the git hash of the currently supported ESP IDF version
55-
ESPIDF_SUPHASH_V3 := 6ccb4cf5b7d1fdddb8c2492f9cbc926abaf230df
54+
# The git hash of the currently supported ESP IDF version.
55+
# These correspond to v3.3.1 and v4.0-beta1.
56+
ESPIDF_SUPHASH_V3 := 143d26aa49df524e10fb8e41a71d12e731b9b71d
5657
ESPIDF_SUPHASH_V4 := 310beae373446ceb9a4ad9b36b5428d7fdf2705f
5758

5859
define print_supported_git_hash
@@ -112,15 +113,13 @@ $(info Add the xtensa toolchain to your PATH. See README.md)
112113
$(error C compiler missing)
113114
endif
114115

115-
# Support BLE by default when building with IDF 4.x.
116+
# Support BLE by default.
116117
# Can be explicitly disabled on the command line or board config.
117-
ifeq ($(ESPIDF_CURHASH),$(ESPIDF_SUPHASH_V4))
118118
MICROPY_PY_BLUETOOTH ?= 1
119119
ifeq ($(MICROPY_PY_BLUETOOTH),1)
120120
SDKCONFIG += boards/sdkconfig.ble
121121
MICROPY_BLUETOOTH_NIMBLE = 1
122122
endif
123-
endif
124123

125124
# include sdkconfig to get needed configuration values
126125
include $(SDKCONFIG)
@@ -158,6 +157,7 @@ INC_ESPCOMP += -I$(ESPCOMP)/tcpip_adapter/include
158157
INC_ESPCOMP += -I$(ESPCOMP)/lwip/lwip/src/include
159158
INC_ESPCOMP += -I$(ESPCOMP)/lwip/port/esp32/include
160159
INC_ESPCOMP += -I$(ESPCOMP)/lwip/include/apps
160+
INC_ESPCOMP += -I$(ESPCOMP)/lwip/include/apps/sntp
161161
INC_ESPCOMP += -I$(ESPCOMP)/mbedtls/mbedtls/include
162162
INC_ESPCOMP += -I$(ESPCOMP)/mbedtls/port/include
163163
INC_ESPCOMP += -I$(ESPCOMP)/mdns/include
@@ -218,9 +218,28 @@ INC_ESPCOMP += -I$(ESPCOMP)/json/port/include
218218
INC_ESPCOMP += -I$(ESPCOMP)/micro-ecc/micro-ecc
219219
INC_ESPCOMP += -I$(ESPCOMP)/nghttp/port/include
220220
INC_ESPCOMP += -I$(ESPCOMP)/nghttp/nghttp2/lib/includes
221+
ifeq ($(CONFIG_NIMBLE_ENABLED),y)
222+
INC_ESPCOMP += -I$(ESPCOMP)/bt/include
223+
INC_ESPCOMP += -I$(ESPCOMP)/nimble/nimble/porting/nimble/include
224+
INC_ESPCOMP += -I$(ESPCOMP)/nimble/port/include
225+
INC_ESPCOMP += -I$(ESPCOMP)/nimble/nimble/nimble/include
226+
INC_ESPCOMP += -I$(ESPCOMP)/nimble/nimble/nimble/host/include
227+
INC_ESPCOMP += -I$(ESPCOMP)/nimble/nimble/nimble/host/services/ans/include
228+
INC_ESPCOMP += -I$(ESPCOMP)/nimble/nimble/nimble/host/services/bas/include
229+
INC_ESPCOMP += -I$(ESPCOMP)/nimble/nimble/nimble/host/services/gap/include
230+
INC_ESPCOMP += -I$(ESPCOMP)/nimble/nimble/nimble/host/services/gatt/include
231+
INC_ESPCOMP += -I$(ESPCOMP)/nimble/nimble/nimble/host/services/ias/include
232+
INC_ESPCOMP += -I$(ESPCOMP)/nimble/nimble/nimble/host/services/lls/include
233+
INC_ESPCOMP += -I$(ESPCOMP)/nimble/nimble/nimble/host/services/tps/include
234+
INC_ESPCOMP += -I$(ESPCOMP)/nimble/nimble/nimble/host/util/include
235+
INC_ESPCOMP += -I$(ESPCOMP)/nimble/nimble/nimble/host/store/ram/include
236+
INC_ESPCOMP += -I$(ESPCOMP)/nimble/nimble/nimble/host/store/config/include
237+
INC_ESPCOMP += -I$(ESPCOMP)/nimble/nimble/porting/npl/freertos/include
238+
INC_ESPCOMP += -I$(ESPCOMP)/nimble/nimble/ext/tinycrypt/include
239+
INC_ESPCOMP += -I$(ESPCOMP)/nimble/esp-hci/include
240+
endif
221241
endif
222242

223-
ifeq ($(ESPIDF_CURHASH),$(ESPIDF_SUPHASH_V4))
224243
ifeq ($(MICROPY_PY_BLUETOOTH),1)
225244
CFLAGS_MOD += -DMICROPY_PY_BLUETOOTH=1
226245
CFLAGS_MOD += -DMICROPY_PY_BLUETOOTH_ENABLE_CENTRAL_MODE=1
@@ -229,7 +248,6 @@ ifeq ($(MICROPY_BLUETOOTH_NIMBLE),1)
229248
CFLAGS_MOD += -DMICROPY_BLUETOOTH_NIMBLE=1
230249
endif
231250
endif
232-
endif
233251

234252
# these flags are common to C and C++ compilation
235253
CFLAGS_COMMON = -Os -ffunction-sections -fdata-sections -fstrict-volatile-bitfields \
@@ -421,6 +439,7 @@ ESPIDF_SOC_O = $(patsubst %.c,%.o,\
421439
$(wildcard $(ESPCOMP)/soc/src/hal/*.c) \
422440
)
423441

442+
$(BUILD)/$(ESPCOMP)/cxx/cxx_guards.o: CXXFLAGS += -Wno-error=sign-compare
424443
ESPIDF_CXX_O = $(patsubst %.cpp,%.o,$(wildcard $(ESPCOMP)/cxx/*.cpp))
425444

426445
ESPIDF_PTHREAD_O = $(patsubst %.c,%.o,$(wildcard $(ESPCOMP)/pthread/*.c))
@@ -458,6 +477,7 @@ ESPIDF_APP_UPDATE_O = $(patsubst %.c,%.o,$(wildcard $(ESPCOMP)/app_update/*.c))
458477

459478
ESPIDF_NEWLIB_O = $(patsubst %.c,%.o,$(wildcard $(ESPCOMP)/newlib/*.c))
460479

480+
$(BUILD)/$(ESPCOMP)/nvs_flash/src/nvs_api.o: CXXFLAGS += -Wno-error=sign-compare
461481
ESPIDF_NVS_FLASH_O = $(patsubst %.cpp,%.o,$(wildcard $(ESPCOMP)/nvs_flash/src/*.cpp))
462482

463483
ESPIDF_SMARTCONFIG_ACK_O = $(patsubst %.c,%.o,$(wildcard $(ESPCOMP)/smartconfig_ack/*.c))
@@ -546,6 +566,29 @@ ESPIDF_ETHERNET_O = $(patsubst %.c,%.o,\
546566
$(wildcard $(ESPCOMP)/ethernet/*.c) \
547567
$(wildcard $(ESPCOMP)/ethernet/eth_phy/*.c) \
548568
)
569+
570+
ifeq ($(CONFIG_NIMBLE_ENABLED),y)
571+
ESPIDF_BT_NIMBLE_O = $(patsubst %.c,%.o,\
572+
$(wildcard $(ESPCOMP)/bt/*.c) \
573+
$(wildcard $(ESPCOMP)/nimble/esp-hci/src/*.c) \
574+
$(wildcard $(ESPCOMP)/nimble/nimble/ext/tinycrypt/src/*.c) \
575+
$(wildcard $(ESPCOMP)/nimble/nimble/nimble/host/services/ans/src/*.c) \
576+
$(wildcard $(ESPCOMP)/nimble/nimble/nimble/host/services/bas/src/*.c) \
577+
$(wildcard $(ESPCOMP)/nimble/nimble/nimble/host/services/gap/src/*.c) \
578+
$(wildcard $(ESPCOMP)/nimble/nimble/nimble/host/services/gatt/src/*.c) \
579+
$(wildcard $(ESPCOMP)/nimble/nimble/nimble/host/services/ias/src/*.c) \
580+
$(wildcard $(ESPCOMP)/nimble/nimble/nimble/host/services/lls/src/*.c) \
581+
$(wildcard $(ESPCOMP)/nimble/nimble/nimble/host/services/tps/src/*.c) \
582+
$(wildcard $(ESPCOMP)/nimble/nimble/nimble/host/src/*.c) \
583+
$(wildcard $(ESPCOMP)/nimble/nimble/nimble/host/store/config/src/ble_store_config.c) \
584+
$(wildcard $(ESPCOMP)/nimble/nimble/nimble/host/store/config/src/ble_store_nvs.c) \
585+
$(wildcard $(ESPCOMP)/nimble/nimble/nimble/host/store/ram/src/*.c) \
586+
$(wildcard $(ESPCOMP)/nimble/nimble/nimble/host/util/src/*.c) \
587+
$(wildcard $(ESPCOMP)/nimble/nimble/nimble/src/*.c) \
588+
$(wildcard $(ESPCOMP)/nimble/nimble/porting/nimble/src/*.c) \
589+
$(wildcard $(ESPCOMP)/nimble/nimble/porting/npl/freertos/src/*.c) \
590+
)
591+
endif
549592
endif
550593

551594
OBJ_ESPIDF =
@@ -587,14 +630,12 @@ $(eval $(call gen_espidf_lib_rule,mbedtls,$(ESPIDF_MBEDTLS_O)))
587630
$(eval $(call gen_espidf_lib_rule,mdns,$(ESPIDF_MDNS_O)))
588631
$(eval $(call gen_espidf_lib_rule,wpa_supplicant,$(ESPIDF_WPA_SUPPLICANT_O)))
589632
$(eval $(call gen_espidf_lib_rule,sdmmc,$(ESPIDF_SDMMC_O)))
633+
$(eval $(call gen_espidf_lib_rule,bt_nimble,$(ESPIDF_BT_NIMBLE_O)))
590634

591635
ifeq ($(ESPIDF_CURHASH),$(ESPIDF_SUPHASH_V4))
592636
$(eval $(call gen_espidf_lib_rule,esp_common,$(ESPIDF_ESP_COMMON_O)))
593637
$(eval $(call gen_espidf_lib_rule,esp_event,$(ESPIDF_ESP_EVENT_O)))
594638
$(eval $(call gen_espidf_lib_rule,esp_wifi,$(ESPIDF_ESP_WIFI_O)))
595-
ifeq ($(CONFIG_BT_NIMBLE_ENABLED),y)
596-
$(eval $(call gen_espidf_lib_rule,bt_nimble,$(ESPIDF_BT_NIMBLE_O)))
597-
endif
598639
$(eval $(call gen_espidf_lib_rule,esp_eth,$(ESPIDF_ESP_ETH_O)))
599640
$(eval $(call gen_espidf_lib_rule,xtensa,$(ESPIDF_XTENSA_O)))
600641
else
@@ -714,6 +755,7 @@ APP_LD_ARGS += -L$(ESPCOMP)/bt/controller/lib -lbtdm_app
714755
APP_LD_ARGS += -L$(ESPCOMP)/esp_wifi/lib_esp32 -lcore -lmesh -lnet80211 -lphy -lrtc -lpp -lsmartconfig -lcoexist
715756
else
716757
APP_LD_ARGS += $(ESPCOMP)/esp32/libhal.a
758+
APP_LD_ARGS += -L$(ESPCOMP)/bt/lib -lbtdm_app
717759
APP_LD_ARGS += -L$(ESPCOMP)/esp32/lib -lcore -lmesh -lnet80211 -lphy -lrtc -lpp -lwpa -lsmartconfig -lcoexist -lwps -lwpa2
718760
endif
719761
APP_LD_ARGS += $(OBJ)
@@ -769,6 +811,7 @@ BOOTLOADER_LIB_BOOTLOADER_SUPPORT_OBJ = $(addprefix $(BUILD)/bootloader/$(ESPCOM
769811
bootloader_support/src/bootloader_clock.o \
770812
bootloader_support/src/bootloader_common.o \
771813
bootloader_support/src/bootloader_flash.o \
814+
bootloader_support/src/bootloader_flash_config.o \
772815
bootloader_support/src/bootloader_init.o \
773816
bootloader_support/src/bootloader_random.o \
774817
bootloader_support/src/bootloader_utility.o \

ports/esp32/boards/sdkconfig.base

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# The following options override the defaults
33

44
CONFIG_IDF_TARGET="esp32"
5+
CONFIG_IDF_FIRMWARE_CHIP_ID=0x0000
56

67
# Application manager
78
CONFIG_APP_EXCLUDE_PROJECT_VER_VAR=y

ports/esp32/boards/sdkconfig.ble

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,13 @@ CONFIG_BT_NIMBLE_MAX_CONNECTIONS=4
1212
CONFIG_BT_NIMBLE_PINNED_TO_CORE_0=n
1313
CONFIG_BT_NIMBLE_PINNED_TO_CORE_1=y
1414
CONFIG_BT_NIMBLE_PINNED_TO_CORE=1
15+
16+
# v3.3-only (renamed in 4.0)
17+
CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY=y
18+
CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY=
19+
CONFIG_BTDM_CONTROLLER_MODE_BTDM=
20+
CONFIG_BLUEDROID_ENABLED=n
21+
CONFIG_NIMBLE_ENABLED=y
22+
CONFIG_NIMBLE_MAX_CONNECTIONS=4
23+
CONFIG_NIMBLE_PINNED_TO_CORE_0=n
24+
CONFIG_NIMBLE_PINNED_TO_CORE_1=y

0 commit comments

Comments
 (0)
0