1
+ # get the directory where this makefile resides
2
+ # fails if the path has a space :-(, if that happens define PORT_DIR in the parent makefile
3
+ PORT_DIR ?= $(dir $(abspath $(lastword $(MAKEFILE_LIST ) ) ) )
4
+ PORT_DIR := $(PORT_DIR )
5
+ $(info PORT_DIR=$(PORT_DIR))
6
+
7
+ # if the parent makefile defines MPY_DIR then use that also for TOP (normally generated in mkenv.mk)
8
+ ifneq ($(MPY_DIR ) ,)
9
+ TOP ?= $(MPY_DIR )
10
+ endif
11
+
1
12
# Select the board to build for: if not given on the command line,
2
13
# then default to GENERIC.
3
14
BOARD ?= GENERIC
4
15
5
16
# If the build directory is not given, make it reflect the board name.
6
17
BUILD ?= build-$(BOARD )
7
18
8
- BOARD_DIR ?= boards/$(BOARD )
19
+ BOARD_DIR ?= $( PORT_DIR ) / boards/$(BOARD )
9
20
ifeq ($(wildcard $(BOARD_DIR ) /.) ,)
10
21
$(error Invalid BOARD specified : $(BOARD_DIR ) )
11
22
endif
12
23
13
- include ../../py/mkenv.mk
24
+ include $( PORT_DIR ) / ../../py/mkenv.mk
14
25
15
26
# Optional (not currently used for ESP32)
16
- -include mpconfigport.mk
27
+ -include $( PORT_DIR ) / mpconfigport.mk
17
28
18
29
ifneq ($(SDKCONFIG ) ,)
19
30
$(error Use the BOARD variable instead of SDKCONFIG)
@@ -129,6 +140,7 @@ include $(TOP)/extmod/nimble/nimble.mk
129
140
endif
130
141
131
142
# include sdkconfig to get needed configuration values
143
+ SDKCONFIG := $(addprefix $(PORT_DIR ) /, $(SDKCONFIG ) )
132
144
include $(SDKCONFIG )
133
145
134
146
# ###############################################################################
@@ -253,6 +265,32 @@ CFLAGS_MOD += -DMICROPY_PY_BLUETOOTH=1
253
265
CFLAGS_MOD += -DMICROPY_PY_BLUETOOTH_ENABLE_CENTRAL_MODE=1
254
266
endif
255
267
268
+ # ###############################################################################
269
+ # Generate sdkconfig.h from sdkconfig
270
+
271
+ $(SDKCONFIG_COMBINED ) : $(SDKCONFIG )
272
+ $(Q )$(MKDIR ) -p $(dir $@ )
273
+ $(Q )$(CAT ) $^ > $@
274
+
275
+ $(SDKCONFIG_H ) : $(SDKCONFIG_COMBINED )
276
+ $(ECHO ) " GEN $@ "
277
+ $(Q )$(MKDIR ) -p $(dir $@ )
278
+ $(Q )$(PYTHON ) $(ESPIDF ) /tools/kconfig_new/confgen.py \
279
+ --output header $@ \
280
+ --config $< \
281
+ --kconfig $(ESPIDF ) /Kconfig \
282
+ --env " IDF_TARGET=esp32" \
283
+ --env " IDF_CMAKE=n" \
284
+ --env " COMPONENT_KCONFIGS=$( ESPCOMP_KCONFIGS) " \
285
+ --env " COMPONENT_KCONFIGS_PROJBUILD=$( ESPCOMP_KCONFIGS_PROJBUILD) " \
286
+ --env " IDF_PATH=$( ESPIDF) "
287
+ $(Q ) touch $@
288
+
289
+ $(HEADER_BUILD ) /qstrdefs.generated.h : $(SDKCONFIG_H ) $(BOARD_DIR ) /mpconfigboard.h
290
+
291
+ # The rest of this Makefile is not needed to build dynamic native modules
292
+ ifndef MPY_DYNRUNTIME
293
+
256
294
# these flags are common to C and C++ compilation
257
295
CFLAGS_COMMON = -Os -ffunction-sections -fdata-sections -fstrict-volatile-bitfields \
258
296
-mlongcalls -nostdlib \
@@ -354,6 +392,7 @@ SRC_C = \
354
392
mpthreadport.c \
355
393
machine_rtc.c \
356
394
machine_sdcard.c \
395
+ portnativeglue.c \
357
396
$(wildcard $(BOARD_DIR ) /* .c) \
358
397
$(SRC_MOD )
359
398
@@ -387,29 +426,6 @@ SRC_QSTR += $(SRC_C) $(EXTMOD_SRC_C) $(LIB_SRC_C) $(DRIVERS_SRC_C)
387
426
# Append any auto-generated sources that are needed by sources listed in SRC_QSTR
388
427
SRC_QSTR_AUTO_DEPS +=
389
428
390
- # ###############################################################################
391
- # Generate sdkconfig.h from sdkconfig
392
-
393
- $(SDKCONFIG_COMBINED ) : $(SDKCONFIG )
394
- $(Q )$(MKDIR ) -p $(dir $@ )
395
- $(Q )$(CAT ) $^ > $@
396
-
397
- $(SDKCONFIG_H ) : $(SDKCONFIG_COMBINED )
398
- $(ECHO ) " GEN $@ "
399
- $(Q )$(MKDIR ) -p $(dir $@ )
400
- $(Q )$(PYTHON ) $(ESPIDF ) /tools/kconfig_new/confgen.py \
401
- --output header $@ \
402
- --config $< \
403
- --kconfig $(ESPIDF ) /Kconfig \
404
- --env " IDF_TARGET=esp32" \
405
- --env " IDF_CMAKE=n" \
406
- --env " COMPONENT_KCONFIGS=$( ESPCOMP_KCONFIGS) " \
407
- --env " COMPONENT_KCONFIGS_PROJBUILD=$( ESPCOMP_KCONFIGS_PROJBUILD) " \
408
- --env " IDF_PATH=$( ESPIDF) "
409
- $(Q ) touch $@
410
-
411
- $(HEADER_BUILD ) /qstrdefs.generated.h : $(SDKCONFIG_H ) $(BOARD_DIR ) /mpconfigboard.h
412
-
413
429
# ###############################################################################
414
430
# List of object files from the ESP32 IDF components
415
431
@@ -777,6 +793,7 @@ $(BUILD)/application.elf: $(OBJ) $(LIB) $(BUILD)/esp32_out.ld $(BUILD)/esp32.pro
777
793
$(ECHO ) " LINK $@ "
778
794
$(Q )$(LD ) $(LDFLAGS ) -o $@ $(APP_LD_ARGS )
779
795
$(Q )$(SIZE ) $@
796
+ $(Q )$(SIZE ) -A $@ | egrep iram0.text | sed -e ' s/ */: /' -e ' s; *[^ ]*$$; of 131072;'
780
797
781
798
define compile_cxx
782
799
$(ECHO ) "CXX $< "
@@ -794,6 +811,12 @@ vpath %.cpp . $(TOP)
794
811
$(BUILD ) /% .o : % .cpp
795
812
$(call compile_cxx)
796
813
814
+ ifeq ($(ESPIDF_CURHASH ) ,$(ESPIDF_SUPHASH_V3 ) )
815
+ $(BUILD ) /portnativeglue.o : CFLAGS := $(filter-out -Werror, $(CFLAGS ) )
816
+ else
817
+ $(BUILD ) /portnativeglue.o : CFLAGS += -Wno-builtin-declaration-mismatch
818
+ endif
819
+
797
820
# ###############################################################################
798
821
# Declarations to build the bootloader
799
822
@@ -979,3 +1002,5 @@ $(BUILD)/partitions.bin: $(PART_SRC)
979
1002
# ###############################################################################
980
1003
981
1004
include $(TOP ) /py/mkrules.mk
1005
+
1006
+ endif # MPY_DYNRUNTIME
0 commit comments