Skip to content

Commit fff68c9

Browse files
authored
Merge pull request #5927 from tannewt/esp_ble_scan
Add BLE scanning for S3 and C3.
2 parents ac7a807 + d9966c1 commit fff68c9

37 files changed

+2582
-55
lines changed

devices/ble_hci/common-hal/_bleio/__init__.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
#include "hci.h"
3636

3737
void bleio_hci_background(void);
38-
void bleio_reset(void);
3938

4039
typedef struct {
4140
// ble_gap_enc_key_t own_enc;

ports/espressif/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ set(ENV{IDF_PATH} ${CMAKE_SOURCE_DIR}/esp-idf)
66

77
# The component list here determines what options we get in menuconfig and what the ninja file
88
# can build.
9-
set(COMPONENTS esptool_py soc driver log main esp-tls mbedtls esp_event esp_adc_cal esp_netif esp_wifi lwip wpa_supplicant freertos)
9+
set(COMPONENTS esptool_py soc driver log main esp-tls mbedtls esp_event esp_adc_cal esp_netif esp_wifi lwip wpa_supplicant freertos bt)
1010

1111
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
1212
project(circuitpython)

ports/espressif/Makefile

Lines changed: 31 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,14 @@ INC += \
8686
-isystem esp-idf \
8787
-isystem esp-idf/components/app_update/include \
8888
-isystem esp-idf/components/bootloader_support/include \
89+
-isystem esp-idf/components/bt/host/nimble/esp-hci/include \
90+
-isystem esp-idf/components/bt/host/nimble/nimble/nimble/host/include \
91+
-isystem esp-idf/components/bt/host/nimble/nimble/nimble/host/services/gap/include \
92+
-isystem esp-idf/components/bt/host/nimble/nimble/nimble/include \
93+
-isystem esp-idf/components/bt/host/nimble/nimble/nimble/host/util/include \
94+
-isystem esp-idf/components/bt/host/nimble/nimble/porting/nimble/include \
95+
-isystem esp-idf/components/bt/host/nimble/nimble/porting/npl/freertos/include \
96+
-isystem esp-idf/components/bt/host/nimble/port/include \
8997
-isystem esp-idf/components/driver/include \
9098
-isystem esp-idf/components/driver/$(IDF_TARGET)/include \
9199
-isystem esp-idf/components/$(IDF_TARGET)/include \
@@ -133,6 +141,7 @@ endif
133141

134142
CFLAGS += \
135143
-DHAVE_CONFIG_H \
144+
-DESP_PLATFORM=1 \
136145
-DMBEDTLS_CONFIG_FILE=\"mbedtls/esp_config.h\" \
137146
-DUNITY_INCLUDE_CONFIG_H -DWITH_POSIX
138147

@@ -148,7 +157,12 @@ ifeq ($(DEBUG), 1)
148157
# CFLAGS += -fno-inline -fno-ipa-sra
149158
else
150159
CFLAGS += -DNDEBUG -ggdb3
151-
OPTIMIZATION_FLAGS ?= -O2
160+
ifeq ($(IDF_TARGET_ARCH),xtensa)
161+
OPTIMIZATION_FLAGS ?= -O2
162+
else
163+
# RISC-V is larger than xtensa so do -Os for it
164+
OPTIMIZATION_FLAGS ?= -Os
165+
endif
152166
# TODO: Test with -flto
153167
### CFLAGS += -flto
154168
endif
@@ -298,8 +312,10 @@ else
298312
DEBUG_SDKCONFIG = esp-idf-config/sdkconfig-opt.defaults
299313
endif
300314

301-
SDKCONFIGS = esp-idf-config/sdkconfig.defaults;$(DEBUG_SDKCONFIG);$(FLASH_SDKCONFIG);$(TARGET_SDKCONFIG);boards/$(BOARD)/sdkconfig
302-
315+
SDKCONFIGS := esp-idf-config/sdkconfig.defaults;$(DEBUG_SDKCONFIG);$(FLASH_SDKCONFIG);$(TARGET_SDKCONFIG);boards/$(BOARD)/sdkconfig
316+
ifneq ($(CIRCUITPY_BLEIO),0)
317+
SDKCONFIGS := esp-idf-config/sdkconfig-ble.defaults;$(SDKCONFIGS)
318+
endif
303319
# create the config headers
304320
$(BUILD)/esp-idf/config/sdkconfig.h: boards/$(BOARD)/sdkconfig | $(BUILD)/esp-idf
305321
IDF_PATH=$(IDF_PATH) cmake -S . -B $(BUILD)/esp-idf -DSDKCONFIG=$(BUILD)/esp-idf/sdkconfig -DSDKCONFIG_DEFAULTS="$(SDKCONFIGS)" -DCMAKE_TOOLCHAIN_FILE=$(IDF_PATH)/tools/cmake/toolchain-$(IDF_TARGET).cmake -DIDF_TARGET=$(IDF_TARGET) -GNinja
@@ -332,6 +348,12 @@ BINARY_WIFI_BLOBS = libcoexist.a libcore.a libespnow.a libmesh.a libnet80211.a l
332348
BINARY_BLOBS = esp-idf/components/esp_phy/lib/$(IDF_TARGET)/libphy.a $(addprefix esp-idf/components/esp_wifi/lib/$(IDF_TARGET)/, $(BINARY_WIFI_BLOBS))
333349

334350
ESP_IDF_COMPONENTS_LINK = $(IDF_TARGET_ARCH) app_update bootloader_support driver efuse esp_adc_cal esp_common esp_event esp_hw_support esp_ipc esp_netif esp_pm esp_phy esp_ringbuf esp_rom esp_system esp_timer esp-tls esp_wifi freertos hal heap log lwip mbedtls newlib nvs_flash pthread soc spi_flash vfs wpa_supplicant
351+
ifneq ($(CIRCUITPY_BLEIO),0)
352+
ESP_IDF_COMPONENTS_LINK += bt
353+
BINARY_BLOBS += esp-idf/components/esp_phy/lib/$(IDF_TARGET)/libbtbb.a \
354+
esp-idf/components/bt/controller/lib_esp32c3_family/$(IDF_TARGET)/libbtdm_app.a
355+
endif
356+
335357
ESP_IDF_COMPONENTS_EXPANDED = $(foreach component, $(ESP_IDF_COMPONENTS_LINK), $(BUILD)/esp-idf/esp-idf/$(component)/lib$(component).a)
336358

337359
MBEDTLS_COMPONENTS_LINK = crypto tls x509
@@ -350,6 +372,11 @@ else
350372
BOOTLOADER_OFFSET = 0x1000
351373
endif
352374

375+
IDF_CMAKE_TARGETS = \
376+
bootloader/bootloader.bin \
377+
esp-idf/esp_system/__ldgen_output_sections.ld \
378+
$(foreach component, $(ESP_IDF_COMPONENTS_LINK), esp-idf/$(component)/lib$(component).a)
379+
353380
PARTITION_TABLE_OFFSET = 0x8000
354381
FIRMWARE_OFFSET = 0x10000
355382

@@ -367,41 +394,7 @@ endif
367394

368395
.PHONY: esp-idf-stamp
369396
esp-idf-stamp: $(BUILD)/esp-idf/config/sdkconfig.h
370-
$(Q)ninja -C $(BUILD)/esp-idf \
371-
bootloader/bootloader.bin \
372-
esp-idf/esp_system/__ldgen_output_sections.ld \
373-
esp-idf/app_update/libapp_update.a \
374-
esp-idf/bootloader_support/libbootloader_support.a \
375-
esp-idf/driver/libdriver.a \
376-
esp-idf/efuse/libefuse.a \
377-
esp-idf/esp_adc_cal/libesp_adc_cal.a \
378-
esp-idf/esp_common/libesp_common.a \
379-
esp-idf/esp_event/libesp_event.a \
380-
esp-idf/esp_hw_support/libesp_hw_support.a \
381-
esp-idf/esp_ipc/libesp_ipc.a \
382-
esp-idf/esp_netif/libesp_netif.a \
383-
esp-idf/esp_phy/libesp_phy.a \
384-
esp-idf/esp_pm/libesp_pm.a \
385-
esp-idf/esp_ringbuf/libesp_ringbuf.a \
386-
esp-idf/esp_rom/libesp_rom.a \
387-
esp-idf/esp_system/libesp_system.a \
388-
esp-idf/esp_timer/libesp_timer.a \
389-
esp-idf/esp-tls/libesp-tls.a \
390-
esp-idf/esp_wifi/libesp_wifi.a \
391-
esp-idf/freertos/libfreertos.a \
392-
esp-idf/hal/libhal.a \
393-
esp-idf/heap/libheap.a \
394-
esp-idf/log/liblog.a \
395-
esp-idf/lwip/liblwip.a \
396-
esp-idf/mbedtls/libmbedtls.a \
397-
esp-idf/newlib/libnewlib.a \
398-
esp-idf/nvs_flash/libnvs_flash.a \
399-
esp-idf/pthread/libpthread.a \
400-
esp-idf/soc/libsoc.a \
401-
esp-idf/spi_flash/libspi_flash.a \
402-
esp-idf/vfs/libvfs.a \
403-
esp-idf/wpa_supplicant/libwpa_supplicant.a \
404-
esp-idf/$(IDF_TARGET_ARCH)/lib$(IDF_TARGET_ARCH).a
397+
$(Q)ninja -C $(BUILD)/esp-idf $(IDF_CMAKE_TARGETS)
405398

406399
$(BUILD)/firmware.elf: $(OBJ) | esp-idf-stamp
407400
$(STEPECHO) "LINK $@"

0 commit comments

Comments
 (0)