aboutsummaryrefslogtreecommitdiff
path: root/makefiles/firmware.mk
diff options
context:
space:
mode:
authorpx4dev <px4@purgatory.org>2013-01-16 23:40:40 -0800
committerpx4dev <px4@purgatory.org>2013-02-23 22:00:59 -0800
commita7a1cc4625ea4097761a9aef88f9f0b4608944a4 (patch)
tree485d956b313182e5c768682ffe76d91c86e330e1 /makefiles/firmware.mk
parent963621c1f34ce3ed7fd43c9943a0841404431d89 (diff)
downloadpx4-firmware-a7a1cc4625ea4097761a9aef88f9f0b4608944a4.tar.gz
px4-firmware-a7a1cc4625ea4097761a9aef88f9f0b4608944a4.tar.bz2
px4-firmware-a7a1cc4625ea4097761a9aef88f9f0b4608944a4.zip
Add support for per-config ROMFS generation.
Diffstat (limited to 'makefiles/firmware.mk')
-rw-r--r--makefiles/firmware.mk58
1 files changed, 57 insertions, 1 deletions
diff --git a/makefiles/firmware.mk b/makefiles/firmware.mk
index 338bda8d3..d64d39ea4 100644
--- a/makefiles/firmware.mk
+++ b/makefiles/firmware.mk
@@ -23,6 +23,11 @@
# to the directory 'build' under the directory containing the
# parent Makefile.
#
+# ROMFS_ROOT:
+# If set to the path to a directory, a ROMFS image will be generated
+# containing the files under the directory and linked into the final
+# image.
+#
################################################################################
# Paths and configuration
@@ -71,6 +76,7 @@ MKFW = $(PX4_BASE)/Tools/px_mkfw.py
COPY = cp
REMOVE = rm -f
RMDIR = rm -rf
+GENROMFS = genromfs
#
# Sanity-check the PLATFORM variable and then get the platform config.
@@ -135,6 +141,29 @@ LIBS += -lapps -lnuttx
LINK_DEPS += $(wildcard $(addsuffix /*.a,$(LIB_DIRS)))
################################################################################
+# ROMFS generation
+################################################################################
+
+#
+# Note that we can't just put romfs.c in SRCS, as it's depended on by the
+# NuttX export library. Instead, we have to treat it like a library.
+#
+ifneq ($(ROMFS_ROOT),)
+ROMFS_DEPS += $(wildcard \
+ (ROMFS_ROOT)/* \
+ (ROMFS_ROOT)/*/* \
+ (ROMFS_ROOT)/*/*/* \
+ (ROMFS_ROOT)/*/*/*/* \
+ (ROMFS_ROOT)/*/*/*/*/* \
+ (ROMFS_ROOT)/*/*/*/*/*/*)
+ROMFS_IMG = $(WORK_DIR)/romfs.img
+ROMFS_CSRC = $(ROMFS_IMG:.img=.c)
+ROMFS_OBJ = $(ROMFS_CSRC:.c=.o)
+LIBS += $(ROMFS_OBJ)
+LINK_DEPS += $(ROMFS_OBJ)
+endif
+
+################################################################################
# Build rules
################################################################################
@@ -159,7 +188,7 @@ all: $(PRODUCT_BUNDLE)
OBJS = $(foreach src,$(SRCS),$(WORK_DIR)/$(src).o)
#
-# Rules
+# SRCS -> OBJS rules
#
$(filter %.c.o,$(OBJS)): $(WORK_DIR)/%.c.o: %.c $(GLOBAL_DEPS)
@@ -174,11 +203,19 @@ $(filter %.S.o,$(OBJS)): $(WORK_DIR)/%.S.o: %.S $(GLOBAL_DEPS)
@mkdir -p $(dir $@)
$(call ASSEMBLE,$<,$@)
+#
+# Build directory setup rules
+#
+
$(NUTTX_CONFIG_HEADER): $(NUTTX_ARCHIVE)
@echo %% Unpacking $(NUTTX_ARCHIVE)
$(Q) unzip -q -o -d $(WORK_DIR) $(NUTTX_ARCHIVE)
$(Q) touch $@
+#
+# Built product rules
+#
+
$(PRODUCT_BUNDLE): $(PRODUCT_BIN)
@echo %% Generating $@
$(Q) $(MKFW) --prototype $(IMAGE_DIR)/$(PLATFORM).prototype \
@@ -191,6 +228,25 @@ $(PRODUCT_BIN): $(PRODUCT_SYM)
$(PRODUCT_SYM): $(OBJS) $(GLOBAL_DEPS) $(LINK_DEPS)
$(call LINK,$@,$(OBJS))
+#
+# ROMFS rules
+#
+
+$(ROMFS_OBJ): $(ROMFS_CSRC)
+ $(call COMPILE,$<,$@)
+
+$(ROMFS_CSRC): $(ROMFS_IMG)
+ @echo %% generating $@
+ $(Q) (cd $(dir $<) && xxd -i $(notdir $<)) > $@
+
+$(ROMFS_IMG): $(ROMFS_DEPS)
+ @echo %% generating $@
+ $(Q) $(GENROMFS) -f $@ -d $(ROMFS_ROOT) -V "NSHInitVol"
+
+#
+# Utility rules
+#
+
upload: $(PRODUCT_BUNDLE) $(PRODUCT_BIN)
$(Q) make -f $(PX4_MK_INCLUDE)/upload.mk \
METHOD=serial \