Skip to content

Commit 6f703f9

Browse files
committed
unicorn: Add CONFIG option to Makefile to build different versions.
1 parent 694357d commit 6f703f9

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

Diff for: unicorn/Makefile

+14-5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
# Select the configuration to build with, defaulting to "minimal"
2+
CONFIG ?= minimal
3+
ifeq ($(wildcard mpconfigport_$(CONFIG).h),)
4+
$(error Invalid CONFIG specified)
5+
endif
6+
7+
BUILD = build_$(CONFIG)
8+
FIRMWARE = $(BUILD)/firmware_$(CONFIG)
9+
110
include ../micropython/py/mkenv.mk
211

312
# qstr definitions (must come before including py.mk)
@@ -10,11 +19,11 @@ CROSS_COMPILE = arm-none-eabi-
1019

1120
INC += -I.
1221
INC += -I$(TOP)
13-
INC += -I$(TOP)/stmhal
1422
INC += -I$(BUILD)
1523

1624
CFLAGS_CORTEX_M4 = -mthumb -mtune=cortex-m4 -mabi=aapcs-linux -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -fsingle-precision-constant -Wdouble-promotion
1725
CFLAGS = $(INC) -Wall -Werror -std=c99 -nostdlib $(CFLAGS_CORTEX_M4) $(COPT)
26+
CFLAGS += -DMP_CONFIGFILE="<mpconfigport_$(CONFIG).h>"
1827

1928
#Debugging/Optimization
2029
ifeq ($(DEBUG), 1)
@@ -37,14 +46,14 @@ SRC_C = \
3746

3847
OBJ = $(PY_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
3948

40-
all: $(BUILD)/firmware.bin
49+
all: $(FIRMWARE).bin
4150

42-
$(BUILD)/firmware.elf: $(OBJ)
51+
$(FIRMWARE).elf: $(OBJ)
4352
$(ECHO) "LINK $@"
4453
$(Q)$(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
4554
$(Q)$(SIZE) $@
4655

47-
$(BUILD)/firmware.bin: $(BUILD)/firmware.elf
48-
$(Q)$(OBJCOPY) -O binary -j .isr_vector -j .text -j .data $^ $(BUILD)/firmware.bin
56+
$(FIRMWARE).bin: $(FIRMWARE).elf
57+
$(Q)$(OBJCOPY) -O binary -j .isr_vector -j .text -j .data $^ $@
4958

5059
include $(TOP)/py/mkrules.mk

Diff for: unicorn/mpconfigport_minimal.h

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#include "mpconfigport.h"

0 commit comments

Comments
 (0)