@@ -86,6 +86,14 @@ INC += \
86
86
-isystem esp-idf \
87
87
-isystem esp-idf/components/app_update/include \
88
88
-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 \
89
97
-isystem esp-idf/components/driver/include \
90
98
-isystem esp-idf/components/driver/$(IDF_TARGET ) /include \
91
99
-isystem esp-idf/components/$(IDF_TARGET ) /include \
@@ -133,6 +141,7 @@ endif
133
141
134
142
CFLAGS += \
135
143
-DHAVE_CONFIG_H \
144
+ -DESP_PLATFORM=1 \
136
145
-DMBEDTLS_CONFIG_FILE=\"mbedtls/esp_config.h\" \
137
146
-DUNITY_INCLUDE_CONFIG_H -DWITH_POSIX
138
147
@@ -148,7 +157,12 @@ ifeq ($(DEBUG), 1)
148
157
# CFLAGS += -fno-inline -fno-ipa-sra
149
158
else
150
159
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
152
166
# TODO: Test with -flto
153
167
# ## CFLAGS += -flto
154
168
endif
@@ -298,8 +312,10 @@ else
298
312
DEBUG_SDKCONFIG = esp-idf-config/sdkconfig-opt.defaults
299
313
endif
300
314
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
303
319
# create the config headers
304
320
$(BUILD ) /esp-idf/config/sdkconfig.h : boards/$(BOARD ) /sdkconfig | $(BUILD ) /esp-idf
305
321
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
332
348
BINARY_BLOBS = esp-idf/components/esp_phy/lib/$(IDF_TARGET ) /libphy.a $(addprefix esp-idf/components/esp_wifi/lib/$(IDF_TARGET ) /, $(BINARY_WIFI_BLOBS ) )
333
349
334
350
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
+
335
357
ESP_IDF_COMPONENTS_EXPANDED = $(foreach component, $(ESP_IDF_COMPONENTS_LINK ) , $(BUILD ) /esp-idf/esp-idf/$(component ) /lib$(component ) .a)
336
358
337
359
MBEDTLS_COMPONENTS_LINK = crypto tls x509
@@ -350,6 +372,11 @@ else
350
372
BOOTLOADER_OFFSET = 0x1000
351
373
endif
352
374
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
+
353
380
PARTITION_TABLE_OFFSET = 0x8000
354
381
FIRMWARE_OFFSET = 0x10000
355
382
@@ -367,41 +394,7 @@ endif
367
394
368
395
.PHONY : esp-idf-stamp
369
396
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 )
405
398
406
399
$(BUILD ) /firmware.elf : $(OBJ ) | esp-idf-stamp
407
400
$(STEPECHO ) " LINK $@ "
0 commit comments