Skip to content

Commit cdb281f

Browse files
authored
Merge branch 'dev-bluetooth' into dev-deepsleep
2 parents e04cf4c + 1d2a575 commit cdb281f

File tree

7 files changed

+4206
-42
lines changed

7 files changed

+4206
-42
lines changed

esp32/Makefile

Lines changed: 219 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ include ../py/mkenv.mk
22

33
# qstr definitions (must come before including py.mk)
44
QSTR_DEFS = qstrdefsport.h
5+
QSTR_GEN_EXTRA_CFLAGS += $(INC_BT)
56

67
MICROPY_PY_USSL = 0
78
MICROPY_SSL_AXTLS = 0
@@ -43,49 +44,89 @@ endif
4344
# pretty format of ESP IDF version, used internally by the IDF
4445
IDF_VER := $(shell git -C $(ESPIDF) describe)
4546

46-
INC += -I.
47-
INC += -I..
48-
INC += -I../lib/mp-readline
49-
INC += -I../lib/netutils
50-
INC += -I../lib/timeutils
51-
INC += -I$(BUILD)
52-
INC += -I$(ESPCOMP)/bootloader_support/include
53-
INC += -I$(ESPCOMP)/driver/include
54-
INC += -I$(ESPCOMP)/driver/include/driver
55-
INC += -I$(ESPCOMP)/nghttp/port/include
56-
INC += -I$(ESPCOMP)/nghttp/include
57-
INC += -I$(ESPCOMP)/esp32/include
58-
INC += -I$(ESPCOMP)/soc/esp32/include
59-
INC += -I$(ESPCOMP)/ethernet/include
60-
INC += -I$(ESPCOMP)/expat/include/expat
61-
INC += -I$(ESPCOMP)/expat/port/include
62-
INC += -I$(ESPCOMP)/json/include
63-
INC += -I$(ESPCOMP)/json/port/include
64-
INC += -I$(ESPCOMP)/log/include
65-
INC += -I$(ESPCOMP)/newlib/include
66-
INC += -I$(ESPCOMP)/nvs_flash/include
67-
INC += -I$(ESPCOMP)/freertos/include
68-
INC += -I$(ESPCOMP)/tcpip_adapter/include
69-
INC += -I$(ESPCOMP)/lwip/include/lwip
70-
INC += -I$(ESPCOMP)/lwip/include/lwip/port
71-
INC += -I$(ESPCOMP)/lwip/include/lwip/posix
72-
INC += -I$(ESPCOMP)/mbedtls/include
73-
INC += -I$(ESPCOMP)/mbedtls/port/include
74-
INC += -I$(ESPCOMP)/spi_flash/include
75-
INC += -I$(ESPCOMP)/vfs/include
76-
INC += -I$(ESPCOMP)/newlib/platform_include
77-
INC += -I$(ESPCOMP)/xtensa-debug-module/include
78-
INC += -I$(ESPCOMP)/wpa_supplicant/include
79-
INC += -I$(ESPCOMP)/wpa_supplicant/port/include
80-
INC += -I$(ESPCOMP)/ethernet/include
81-
INC += -I$(ESPCOMP)/tcpip_adapter/include
82-
83-
CFLAGS = -std=gnu99 -Os -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -mlongcalls -nostdlib -Wall -Werror -Wno-error=unused-function -Wno-error=unused-but-set-variable -Wno-error=unused-variable -Wno-error=deprecated-declarations -DMBEDTLS_CONFIG_FILE='"mbedtls/esp_config.h"' -DHAVE_CONFIG_H -DESP_PLATFORM $(INC)
47+
48+
# Include dirs for both BT and MAIN
49+
INC_COMMON = -I.
50+
INC_COMMON += -I..
51+
INC_COMMON += -I$(BUILD)
52+
INC_COMMON += -I$(ESPCOMP)/log/include
53+
INC_COMMON += -I$(ESPCOMP)/esp32/include
54+
INC_COMMON += -I$(ESPCOMP)/soc/esp32/include
55+
INC_COMMON += -I$(ESPCOMP)/freertos/include
56+
INC_COMMON += -I$(ESPCOMP)/tcpip_adapter/include
57+
INC_COMMON += -I$(ESPCOMP)/lwip/include/lwip
58+
INC_COMMON += -I$(ESPCOMP)/lwip/include/lwip/port
59+
INC_COMMON += -I$(ESPCOMP)/driver/include/driver
60+
INC_COMMON += -I$(ESPCOMP)/driver/include
61+
INC_COMMON += -I$(ESPCOMP)/nvs_flash/include
62+
63+
# Include dirs for main code base, excluding BT
64+
INC_MAIN += -I../lib/mp-readline
65+
INC_MAIN += -I../lib/netutils
66+
INC_MAIN += -I../lib/timeutils
67+
INC_MAIN += -I$(ESPCOMP)/spi_flash/include
68+
INC_MAIN += -I$(ESPCOMP)/bootloader_support/include
69+
INC_MAIN += -I$(ESPCOMP)/nghttp/port/include
70+
INC_MAIN += -I$(ESPCOMP)/nghttp/include
71+
INC_MAIN += -I$(ESPCOMP)/ethernet/include
72+
INC_MAIN += -I$(ESPCOMP)/expat/include/expat
73+
INC_MAIN += -I$(ESPCOMP)/expat/port/include
74+
INC_MAIN += -I$(ESPCOMP)/json/include
75+
INC_MAIN += -I$(ESPCOMP)/json/port/include
76+
INC_MAIN += -I$(ESPCOMP)/newlib/include
77+
INC_MAIN += -I$(ESPCOMP)/lwip/include/lwip/port
78+
INC_MAIN += -I$(ESPCOMP)/lwip/include/lwip/posix
79+
INC_MAIN += -I$(ESPCOMP)/mbedtls/include
80+
INC_MAIN += -I$(ESPCOMP)/mbedtls/port/include
81+
INC_MAIN += -I$(ESPCOMP)/vfs/include
82+
INC_MAIN += -I$(ESPCOMP)/newlib/platform_include
83+
INC_MAIN += -I$(ESPCOMP)/xtensa-debug-module/include
84+
INC_MAIN += -I$(ESPCOMP)/wpa_supplicant/include
85+
INC_MAIN += -I$(ESPCOMP)/wpa_supplicant/port/include
86+
INC_MAIN += -I$(ESPCOMP)/ethernet/include
87+
INC_MAIN += -I$(ESPCOMP)/tcpip_adapter/include
88+
89+
90+
# Bluetooth includes have to be separate because
91+
# esp-idf/components/bt/bluedroid/osi/include/list.h
92+
# somehow interferes with compiling FreeRTOS, as it
93+
# makes List_t "not defined."
94+
#
95+
# This is why we have separate build rules for
96+
# objects in the /bt/ directory, and for
97+
# the MicroPython esp32/network_bluetooth.c
98+
99+
# Include dirs for BT components
100+
INC_BT =
101+
INC_BT += -I$(ESPCOMP)/bt/bluedroid/api/include/
102+
INC_BT += -I$(ESPCOMP)/bt/bluedroid/bta/include/
103+
INC_BT += -I$(ESPCOMP)/bt/bluedroid/bta/sys/include/
104+
INC_BT += -I$(ESPCOMP)/bt/bluedroid/btc/include/
105+
INC_BT += -I$(ESPCOMP)/bt/bluedroid/btc/profile/esp/blufi/include/
106+
INC_BT += -I$(ESPCOMP)/bt/bluedroid/btc/profile/esp/include
107+
INC_BT += -I$(ESPCOMP)/bt/bluedroid/btc/profile/std/include
108+
INC_BT += -I$(ESPCOMP)/bt/bluedroid/btcore/include/
109+
INC_BT += -I$(ESPCOMP)/bt/bluedroid/device/include/
110+
INC_BT += -I$(ESPCOMP)/bt/bluedroid/gki/include/
111+
INC_BT += -I$(ESPCOMP)/bt/bluedroid/hci/include/
112+
INC_BT += -I$(ESPCOMP)/bt/bluedroid/include/
113+
INC_BT += -I$(ESPCOMP)/bt/bluedroid/osi/include/ # Causes problems with List_t in FreeRTOS
114+
INC_BT += -I$(ESPCOMP)/bt/bluedroid/stack/gap/include/
115+
INC_BT += -I$(ESPCOMP)/bt/bluedroid/stack/gatt/include/
116+
INC_BT += -I$(ESPCOMP)/bt/bluedroid/stack/include/
117+
INC_BT += -I$(ESPCOMP)/bt/bluedroid/stack/l2cap/include/
118+
INC_BT += -I$(ESPCOMP)/bt/bluedroid/stack/smp/include/
119+
INC_BT += -I$(ESPCOMP)/bt/include
120+
INC_BT += -I$(ESPCOMP)/bt/bluedroid/stack/sdp/include/
121+
122+
CFLAGS = -std=gnu99 -Os -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -mlongcalls -nostdlib -Wall -Werror -Wno-error=unused-function -Wno-error=unused-but-set-variable -Wno-error=unused-variable -Wno-error=deprecated-declarations -DMBEDTLS_CONFIG_FILE='"mbedtls/esp_config.h"' -DHAVE_CONFIG_H -DESP_PLATFORM
123+
84124
CFLAGS += -DIDF_VER=\"$(IDF_VER)\"
85125
CFLAGS += $(CFLAGS_MOD)
126+
#CFLAGS += -H
86127

87128
# this is what ESPIDF uses for c++ compilation
88-
CXXFLAGS = -std=gnu++11 -fno-exceptions -fno-rtti -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -mlongcalls -nostdlib -Wall -Werror -Wno-error=unused-function -Wno-error=unused-but-set-variable -Wno-error=unused-variable -Wno-error=deprecated-declarations -DESP_PLATFORM $(INC)
129+
CXXFLAGS = -std=gnu++11 -fno-exceptions -fno-rtti -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -mlongcalls -nostdlib -Wall -Werror -Wno-error=unused-function -Wno-error=unused-but-set-variable -Wno-error=unused-variable -Wno-error=deprecated-declarations -DESP_PLATFORM $(INC_COMMON) $(INC_MAIN)
89130

90131
LDFLAGS = -nostdlib -Map=$(@:.elf=.map) --cref
91132
LDFLAGS += --gc-sections -static -EL
@@ -106,6 +147,9 @@ COPT += -Os -DNDEBUG
106147
#LDFLAGS += --gc-sections
107148
endif
108149

150+
CFLAGS_BT := $(CFLAGS) $(INC_COMMON) $(INC_BT)
151+
CFLAGS += $(INC_COMMON) $(INC_MAIN)
152+
109153
################################################################################
110154
# List of MicroPython source and object files
111155

@@ -129,6 +173,8 @@ SRC_C = \
129173
modesp.c \
130174
espneopixel.c \
131175
machine_rtc.c \
176+
network_bluetooth.c \
177+
132178
machine_hw_spi.c \
133179
mpthreadport.c \
134180
$(SRC_MOD)
@@ -256,6 +302,135 @@ ESPIDF_ETHERNET_O = $(addprefix $(ESPCOMP)/ethernet/,\
256302
emac_main.o \
257303
)
258304

305+
$(BUILD)/$(ESPCOMP)/bt/%.o: CFLAGS = $(CFLAGS_BT)
306+
$(BUILD)/$(ESPCOMP)/bt/bluedroid/btc/profile/esp/blufi/blufi_prf.o: CFLAGS += -Wno-error=strict-aliasing
307+
$(BUILD)/$(ESPCOMP)/bt/bluedroid/stack/btu/btu_task.o: CFLAGS += -Wno-error=strict-aliasing
308+
309+
ESPIDF_BLUETOOTH_O = $(addprefix $(ESPCOMP)/bt/,\
310+
bluedroid/api/esp_bt_device.o \
311+
bluedroid/api/esp_bt_main.o \
312+
bluedroid/api/esp_gap_ble_api.o \
313+
bluedroid/api/esp_gattc_api.o \
314+
bluedroid/api/esp_gatts_api.o \
315+
bluedroid/bta/dm/bta_dm_act.o \
316+
bluedroid/bta/dm/bta_dm_api.o \
317+
bluedroid/bta/dm/bta_dm_cfg.o \
318+
bluedroid/bta/dm/bta_dm_ci.o \
319+
bluedroid/bta/dm/bta_dm_main.o \
320+
bluedroid/bta/dm/bta_dm_pm.o \
321+
bluedroid/bta/gatt/bta_gattc_act.o \
322+
bluedroid/bta/gatt/bta_gattc_api.o \
323+
bluedroid/bta/gatt/bta_gattc_cache.o \
324+
bluedroid/bta/gatt/bta_gattc_ci.o \
325+
bluedroid/bta/gatt/bta_gattc_main.o \
326+
bluedroid/bta/gatt/bta_gattc_utils.o \
327+
bluedroid/bta/gatt/bta_gatts_act.o \
328+
bluedroid/bta/gatt/bta_gatts_api.o \
329+
bluedroid/bta/gatt/bta_gatts_main.o \
330+
bluedroid/bta/gatt/bta_gatts_utils.o \
331+
bluedroid/bta/sys/bta_sys_conn.o \
332+
bluedroid/bta/sys/bta_sys_main.o \
333+
bluedroid/bta/sys/utl.o \
334+
bluedroid/btc/core/btc_alarm.o \
335+
bluedroid/btc/core/btc_ble_storage.o \
336+
bluedroid/btc/core/btc_config.o \
337+
bluedroid/btc/core/btc_dev.o \
338+
bluedroid/btc/core/btc_dm.o \
339+
bluedroid/btc/core/btc_main.o \
340+
bluedroid/btc/core/btc_manage.o \
341+
bluedroid/btc/core/btc_storage.o \
342+
bluedroid/btc/core/btc_task.o \
343+
bluedroid/btc/core/btc_util.o \
344+
bluedroid/btc/profile/esp/blufi/blufi_prf.o \
345+
bluedroid/btc/profile/esp/blufi/blufi_protocol.o \
346+
bluedroid/btc/profile/std/gap/btc_gap_ble.o \
347+
bluedroid/btc/profile/std/gatt/btc_gatt_util.o \
348+
bluedroid/btc/profile/std/gatt/btc_gattc.o \
349+
bluedroid/btc/profile/std/gatt/btc_gatts.o \
350+
bluedroid/btcore/bdaddr.o \
351+
bluedroid/btif/bta_dm_co.o \
352+
bluedroid/btif/bta_gattc_co.o \
353+
bluedroid/btif/bta_gatts_co.o \
354+
bluedroid/device/controller.o \
355+
bluedroid/device/interop.o \
356+
bluedroid/gki/gki_buffer.o \
357+
bluedroid/gki/gki_ulinux.o \
358+
bluedroid/hci/buffer_allocator.o \
359+
bluedroid/hci/hci_hal_h4.o \
360+
bluedroid/hci/hci_layer.o \
361+
bluedroid/hci/hci_packet_factory.o \
362+
bluedroid/hci/hci_packet_parser.o \
363+
bluedroid/hci/packet_fragmenter.o \
364+
bluedroid/main/bte_init.o \
365+
bluedroid/main/bte_main.o \
366+
bluedroid/osi/alarm.o \
367+
bluedroid/osi/allocator.o \
368+
bluedroid/osi/config.o \
369+
bluedroid/osi/fixed_queue.o \
370+
bluedroid/osi/future.o \
371+
bluedroid/osi/hash_functions.o \
372+
bluedroid/osi/hash_map.o \
373+
bluedroid/osi/list.o \
374+
bluedroid/osi/osi_arch.o \
375+
bluedroid/stack/btm/btm_acl.o \
376+
bluedroid/stack/btm/btm_ble.o \
377+
bluedroid/stack/btm/btm_ble_addr.o \
378+
bluedroid/stack/btm/btm_ble_adv_filter.o \
379+
bluedroid/stack/btm/btm_ble_batchscan.o \
380+
bluedroid/stack/btm/btm_ble_bgconn.o \
381+
bluedroid/stack/btm/btm_ble_cont_energy.o \
382+
bluedroid/stack/btm/btm_ble_gap.o \
383+
bluedroid/stack/btm/btm_ble_multi_adv.o \
384+
bluedroid/stack/btm/btm_ble_privacy.o \
385+
bluedroid/stack/btm/btm_dev.o \
386+
bluedroid/stack/btm/btm_devctl.o \
387+
bluedroid/stack/btm/btm_inq.o \
388+
bluedroid/stack/btm/btm_main.o \
389+
bluedroid/stack/btm/btm_pm.o \
390+
bluedroid/stack/btm/btm_sec.o \
391+
bluedroid/stack/btu/btu_hcif.o \
392+
bluedroid/stack/btu/btu_init.o \
393+
bluedroid/stack/btu/btu_task.o \
394+
bluedroid/stack/gap/gap_api.o \
395+
bluedroid/stack/gap/gap_ble.o \
396+
bluedroid/stack/gap/gap_conn.o \
397+
bluedroid/stack/gatt/att_protocol.o \
398+
bluedroid/stack/gatt/gatt_api.o \
399+
bluedroid/stack/gatt/gatt_attr.o \
400+
bluedroid/stack/gatt/gatt_auth.o \
401+
bluedroid/stack/gatt/gatt_cl.o \
402+
bluedroid/stack/gatt/gatt_db.o \
403+
bluedroid/stack/gatt/gatt_main.o \
404+
bluedroid/stack/gatt/gatt_sr.o \
405+
bluedroid/stack/gatt/gatt_utils.o \
406+
bluedroid/stack/hcic/hciblecmds.o \
407+
bluedroid/stack/hcic/hcicmds.o \
408+
bluedroid/stack/l2cap/l2c_api.o \
409+
bluedroid/stack/l2cap/l2c_ble.o \
410+
bluedroid/stack/l2cap/l2c_csm.o \
411+
bluedroid/stack/l2cap/l2c_fcr.o \
412+
bluedroid/stack/l2cap/l2c_link.o \
413+
bluedroid/stack/l2cap/l2c_main.o \
414+
bluedroid/stack/l2cap/l2c_utils.o \
415+
bluedroid/stack/sdp/sdp_api.o \
416+
bluedroid/stack/sdp/sdp_db.o \
417+
bluedroid/stack/sdp/sdp_utils.o \
418+
bluedroid/stack/smp/aes.o \
419+
bluedroid/stack/smp/p_256_curvepara.o \
420+
bluedroid/stack/smp/p_256_ecc_pp.o \
421+
bluedroid/stack/smp/p_256_multprecision.o \
422+
bluedroid/stack/smp/smp_act.o \
423+
bluedroid/stack/smp/smp_api.o \
424+
bluedroid/stack/smp/smp_br_main.o \
425+
bluedroid/stack/smp/smp_cmac.o \
426+
bluedroid/stack/smp/smp_keys.o \
427+
bluedroid/stack/smp/smp_l2c.o \
428+
bluedroid/stack/smp/smp_main.o \
429+
bluedroid/stack/smp/smp_utils.o \
430+
bt.o \
431+
)
432+
433+
259434
$(BUILD)/$(ESPCOMP)/expat/%.o: CFLAGS += -Wno-unused-function
260435
ESPIDF_EXPAT_O = $(addprefix $(ESPCOMP)/expat/,\
261436
library/xmltok_ns.o \
@@ -534,7 +709,9 @@ ESPIDF_WPA_SUPPLICANT_O = $(addprefix $(ESPCOMP)/wpa_supplicant/,\
534709
port/os_xtensa.o \
535710
)
536711

712+
537713
OBJ_ESPIDF =
714+
OBJ_ESPIDF += $(addprefix $(BUILD)/, $(ESPIDF_BLUETOOTH_O))
538715
OBJ_ESPIDF += $(addprefix $(BUILD)/, $(ESPIDF_NEWLIB_O))
539716
OBJ_ESPIDF += $(addprefix $(BUILD)/, $(ESPIDF_DRIVER_O))
540717
OBJ_ESPIDF += $(addprefix $(BUILD)/, $(ESPIDF_ESP32_O))
@@ -590,17 +767,20 @@ APP_LD_ARGS += -L$(dir $(LIBSTDCXX_FILE_NAME)) -lstdc++
590767
APP_LD_ARGS += $(ESPCOMP)/newlib/lib/libc.a
591768
APP_LD_ARGS += $(ESPCOMP)/newlib/lib/libm.a
592769
APP_LD_ARGS += $(ESPCOMP)/esp32/libhal.a
770+
APP_LD_ARGS += $(ESPCOMP)/bt/lib/libbtdm_app.a
593771
APP_LD_ARGS += -L$(ESPCOMP)/esp32/lib -lcore -lnet80211 -lphy -lrtc -lpp -lwpa -lsmartconfig -lcoexist
594772
APP_LD_ARGS += $(OBJ)
595773
APP_LD_ARGS += --end-group
596774

597775
$(BUILD)/esp32_out.ld: sdkconfig.h
598776
$(Q)$(CC) -I. -C -P -x c -E $(ESPCOMP)/esp32/ld/esp32.ld -o $@
599777

778+
$(BUILD)/network_bluetooth.o: CFLAGS = $(CFLAGS_BT)
600779
$(BUILD)/application.bin: $(BUILD)/application.elf
601780
$(ECHO) "Create $@"
602781
$(Q)$(ESPTOOL) --chip esp32 elf2image --flash_mode $(FLASH_MODE) --flash_freq $(FLASH_FREQ) --flash_size $(FLASH_SIZE) $<
603782

783+
604784
$(BUILD)/application.elf: $(OBJ) $(BUILD)/esp32_out.ld
605785
$(ECHO) "LINK $@"
606786
$(Q)$(LD) $(LDFLAGS) -o $@ $(APP_LD_ARGS)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy