From 42a6364a311a96e376f3f1e2677007ee603b2ad6 Mon Sep 17 00:00:00 2001
From: Dave Hylands <dhylands@gmail.com>
Date: Thu, 21 Jan 2016 12:41:47 -0800
Subject: [PATCH] stmhal: Add support for building frozen files.

This allows FROZEN_DIR=some-directory to be specified on the make
command line, which will then add all of the files contained within
the indicated frozen directory as frozen files in the image.

There is no change in flash/ram usage if not using the feature.

This is especially useful on smaller MCUs (like the 401) which only
has 64K flash file system.
---
 stmhal/Makefile | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/stmhal/Makefile b/stmhal/Makefile
index 9f8c13a87..1edc31daa 100644
--- a/stmhal/Makefile
+++ b/stmhal/Makefile
@@ -264,6 +264,19 @@ $(BUILD)/$(HAL_DIR)/src/stm32$(MCU_SERIES)xx_hal_sd.o: COPT += -Os
 
 all: $(BUILD)/firmware.dfu $(BUILD)/firmware.hex
 
+ifneq ($(FROZEN_DIR),)
+CFLAGS += -DMICROPY_MODULE_FROZEN
+OBJ += $(BUILD)/frozen-files.o
+MAKE_FROZEN = ../tools/make-frozen.py
+
+$(BUILD)/frozen-files.o: $(BUILD)/frozen-files.c
+	$(call compile_c)
+
+$(BUILD)/frozen-files.c: $(shell find $(FROZEN_DIR) -type f)
+	@$(ECHO) "Creating $@"
+	$(Q)$(PYTHON) $(MAKE_FROZEN) $(FROZEN_DIR) > $@
+endif
+
 .PHONY: deploy
 
 deploy: $(BUILD)/firmware.dfu
-- 
GitLab