Skip to content

Commit 6c4bfd6

Browse files
authored
Merge pull request #9222 from tannewt/esp_ble_server
Add ESP BLE GATT server support
2 parents 6b80a76 + 689c6fa commit 6c4bfd6

File tree

105 files changed

+1182
-209
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+1182
-209
lines changed

devices/ble_hci/common-hal/_bleio/Service.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ void common_hal_bleio_service_construct(bleio_service_obj_t *self, bleio_uuid_ob
3737
}
3838
}
3939

40+
void common_hal_bleio_service_deinit(bleio_service_obj_t *self) {
41+
}
42+
4043
void bleio_service_from_connection(bleio_service_obj_t *self, mp_obj_t connection) {
4144
self->handle = 0xFFFF;
4245
self->uuid = NULL;

ports/espressif/Makefile

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66

77
include ../../py/circuitpy_mkenv.mk
88

9-
ifeq ($(IDF_TARGET),esp32c3)
9+
ifeq ($(IDF_TARGET),esp32c2)
10+
IDF_TARGET_ARCH = riscv
11+
CROSS_COMPILE = riscv32-esp-elf-
12+
else ifeq ($(IDF_TARGET),esp32c3)
1013
IDF_TARGET_ARCH = riscv
1114
CROSS_COMPILE = riscv32-esp-elf-
1215
else ifeq ($(IDF_TARGET),esp32c6)
@@ -50,7 +53,9 @@ INC += \
5053
-isystem esp-idf/components/bt/host/nimble/esp-hci/include \
5154
-isystem esp-idf/components/bt/host/nimble/nimble/nimble/controller/include \
5255
-isystem esp-idf/components/bt/host/nimble/nimble/nimble/host/include \
56+
-isystem esp-idf/components/bt/host/nimble/nimble/nimble/host/services/ans/include \
5357
-isystem esp-idf/components/bt/host/nimble/nimble/nimble/host/services/gap/include \
58+
-isystem esp-idf/components/bt/host/nimble/nimble/nimble/host/services/gatt/include \
5459
-isystem esp-idf/components/bt/host/nimble/nimble/nimble/include \
5560
-isystem esp-idf/components/bt/host/nimble/nimble/nimble/host/util/include \
5661
-isystem esp-idf/components/bt/host/nimble/nimble/nimble/transport/include \
@@ -205,6 +210,12 @@ LDFLAGS += \
205210
-T$(IDF_TARGET).rom.newlib-data.ld \
206211
-T$(IDF_TARGET).rom.newlib-funcs.ld \
207212
-T$(IDF_TARGET).rom.spiflash.ld
213+
else ifeq ($(IDF_TARGET),esp32c2)
214+
LDFLAGS += \
215+
-Tesp32c2.rom.heap.ld \
216+
-Tesp32c2.rom.newlib.ld \
217+
-Tesp32c2.rom.version.ld
218+
CFLAGS += -DSOC_XTAL_FREQ_MHZ=CONFIG_XTAL_FREQ
208219
else ifeq ($(IDF_TARGET),esp32c3)
209220
LDFLAGS += \
210221
-Tesp32c3.rom.newlib.ld \
@@ -246,6 +257,8 @@ endif
246257
# Always add these because we might be doing host.
247258
ifeq ($(IDF_TARGET),esp32)
248259
CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_ESP32
260+
else ifeq ($(IDF_TARGET),esp32c2)
261+
CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_ESP32C2
249262
else ifeq ($(IDF_TARGET),esp32c3)
250263
CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_ESP32C3
251264
else ifeq ($(IDF_TARGET),esp32c6)
@@ -390,10 +403,14 @@ else
390403
UF2_BOOTLOADER ?= $(CIRCUITPY_USB_DEVICE)
391404
ifeq ($(UF2_BOOTLOADER), 1)
392405
FLASH_SIZE_SDKCONFIG ?= esp-idf-config/sdkconfig-flash-$(CIRCUITPY_ESP_FLASH_SIZE).defaults
406+
else
407+
ifeq ($(CIRCUITPY_ESP_FLASH_SIZE), 4MB)
408+
FLASH_SIZE_SDKCONFIG ?= esp-idf-config/sdkconfig-flash-$(CIRCUITPY_ESP_FLASH_SIZE)-no-ota-no-uf2.defaults
393409
else
394410
FLASH_SIZE_SDKCONFIG ?= esp-idf-config/sdkconfig-flash-$(CIRCUITPY_ESP_FLASH_SIZE)-no-uf2.defaults
395411
endif
396412
endif
413+
endif
397414
FLASH_MODE_SDKCONFIG ?= esp-idf-config/sdkconfig-flash-$(CIRCUITPY_ESP_FLASH_MODE).defaults
398415
FLASH_SPEED_SDKCONFIG ?= esp-idf-config/sdkconfig-flash-$(CIRCUITPY_ESP_FLASH_FREQ).defaults
399416

@@ -451,11 +468,15 @@ update-all-sdkconfigs: $(BUILD)/esp-idf/config/sdkconfig.h
451468
update-board-sdkconfig: $(BUILD)/esp-idf/config/sdkconfig.h
452469
python tools/update_sdkconfig.py --board=$(BOARD) --debug=$(DEBUG)
453470

454-
BINARY_WIFI_BLOBS = libcore.a libespnow.a libmesh.a libnet80211.a libpp.a libsmartconfig.a libwapi.a
471+
BINARY_WIFI_BLOBS = libcore.a libespnow.a libnet80211.a libpp.a libsmartconfig.a
455472
BINARY_BLOBS = esp-idf/components/esp_phy/lib/$(IDF_TARGET)/libphy.a
456473
ifneq ($(CIRCUITPY_WIFI),0)
457474
BINARY_BLOBS += esp-idf/components/esp_coex/lib/$(IDF_TARGET)/libcoexist.a $(addprefix esp-idf/components/esp_wifi/lib/$(IDF_TARGET)/, $(BINARY_WIFI_BLOBS))
475+
ifneq ($(IDF_TARGET),esp32c2)
476+
BINARY_BLOBS += $(addprefix esp-idf/components/esp_wifi/lib/$(IDF_TARGET)/, libmesh.a libwapi.a)
477+
endif
458478
endif
479+
459480
ifeq ($(IDF_TARGET),esp32)
460481
BINARY_BLOBS += esp-idf/components/esp_phy/lib/$(IDF_TARGET)/librtc.a
461482
endif
@@ -475,6 +496,9 @@ ifneq ($(CIRCUITPY_BLEIO),0)
475496

476497
ESP_IDF_COMPONENTS_LINK += bt
477498
ifeq ($(BLE_IMPL),esp32)
499+
# BLE will hang the ESP32 and trigger an interrupt watchdog without this undefined symbol at
500+
# link because a weak version of the interrupt that BLE uses will be linked incorrectly.
501+
LDFLAGS += -u ld_include_hli_vectors_bt
478502
BINARY_BLOBS += esp-idf/components/bt/controller/lib_esp32/$(IDF_TARGET)/libbtdm_app.a
479503
endif
480504

@@ -526,6 +550,8 @@ ifeq ($(IDF_TARGET),esp32)
526550
BOOTLOADER_OFFSET = 0x1000
527551
else ifeq ($(IDF_TARGET),esp32h2)
528552
BOOTLOADER_OFFSET = 0x0
553+
else ifeq ($(IDF_TARGET),esp32c2)
554+
BOOTLOADER_OFFSET = 0x0
529555
else ifeq ($(IDF_TARGET),esp32c3)
530556
BOOTLOADER_OFFSET = 0x0
531557
else ifeq ($(IDF_TARGET),esp32c6)

ports/espressif/README.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Support Status:
1111

1212
ESP32, "beta"
1313
ESP32-H2, "alpha"
14+
ESP32-C2, "alpha"
1415
ESP32-C3, "beta"
1516
ESP32-C6, "alpha"
1617
ESP32-S2, "stable"

ports/espressif/boards/01space_lcd042_esp32c3/mpconfigboard.mk

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,9 @@ CIRCUITPY_ESP_FLASH_MODE = qio
77
CIRCUITPY_ESP_FLASH_FREQ = 80m
88
CIRCUITPY_ESP_FLASH_SIZE = 4MB
99

10+
# Override partition layout to preserve compatibility because the default has changed.
11+
FLASH_SIZE_SDKCONFIG = esp-idf-config/sdkconfig-flash-4MB-no-uf2.defaults
12+
CIRCUITPY_DUALBANK = 1
13+
CIRCUITPY_BLEIO = 0
14+
1015
CIRCUITPY_ESP_USB_SERIAL_JTAG = 1

ports/espressif/boards/adafruit_feather_huzzah32/mpconfigboard.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ CIRCUITPY_ESP_FLASH_MODE = qio
77
CIRCUITPY_ESP_FLASH_FREQ = 80m
88
CIRCUITPY_ESP_FLASH_SIZE = 4MB
99

10+
CIRCUITPY_BLEIO = 0
1011
CIRCUITPY_ESPCAMERA = 0

ports/espressif/boards/adafruit_huzzah32_breakout/mpconfigboard.mk

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,9 @@ CIRCUITPY_ESP_FLASH_MODE = qio
77
CIRCUITPY_ESP_FLASH_FREQ = 80m
88
CIRCUITPY_ESP_FLASH_SIZE = 4MB
99

10+
# Override partition layout to preserve compatibility because the default has changed.
11+
FLASH_SIZE_SDKCONFIG = esp-idf-config/sdkconfig-flash-4MB-no-uf2.defaults
12+
CIRCUITPY_DUALBANK = 1
13+
CIRCUITPY_BLEIO = 0
14+
1015
CIRCUITPY_ESPCAMERA = 0

ports/espressif/boards/adafruit_qtpy_esp32c3/mpconfigboard.mk

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ CIRCUITPY_ESP_FLASH_MODE = qio
77
CIRCUITPY_ESP_FLASH_FREQ = 80m
88
CIRCUITPY_ESP_FLASH_SIZE = 4MB
99

10+
# Override partition layout to preserve compatibility because the default has changed.
11+
FLASH_SIZE_SDKCONFIG = esp-idf-config/sdkconfig-flash-4MB-no-uf2.defaults
12+
CIRCUITPY_DUALBANK = 1
13+
CIRCUITPY_BLEIO = 0
14+
1015
CIRCUITPY_ESP_USB_SERIAL_JTAG = 1
1116

1217
# Not enough pins.

ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.mk

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,9 @@ CIRCUITPY_ESP_FLASH_MODE = qio
77
CIRCUITPY_ESP_FLASH_FREQ = 80m
88
CIRCUITPY_ESP_FLASH_SIZE = 4MB
99

10+
# Override partition layout to preserve compatibility because the default has changed.
11+
FLASH_SIZE_SDKCONFIG = esp-idf-config/sdkconfig-flash-4MB-no-uf2.defaults
12+
CIRCUITPY_DUALBANK = 1
13+
CIRCUITPY_BLEIO = 0
14+
1015
CIRCUITPY_ESP_USB_SERIAL_JTAG = 0

ports/espressif/boards/beetle-esp32-c3/mpconfigboard.mk

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,9 @@ CIRCUITPY_ESP_FLASH_MODE=qio
88
CIRCUITPY_ESP_FLASH_FREQ=80m
99
CIRCUITPY_ESP_FLASH_SIZE=4MB
1010

11+
# Override partition layout to preserve compatibility because the default has changed.
12+
FLASH_SIZE_SDKCONFIG = esp-idf-config/sdkconfig-flash-4MB-no-uf2.defaults
13+
CIRCUITPY_DUALBANK = 1
14+
CIRCUITPY_BLEIO = 0
15+
1116
CIRCUITPY_ESP_USB_SERIAL_JTAG = 1

0 commit comments

Comments
 (0)