summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjaseg <git@jaseg.net>2017-10-05 13:05:22 +0200
committerjaseg <git@jaseg.net>2017-10-05 13:07:55 +0200
commit9383ced7fb57ebabb2ca509ca64a4ca49bca5875 (patch)
treef62f891271e51dabce8d9eaf3a3d6cde8c9cb33d
parentdbabb04e3acc17afa7368763de2709d69ed14dd9 (diff)
downloadolsndot-9383ced7fb57ebabb2ca509ca64a4ca49bca5875.tar.gz
olsndot-9383ced7fb57ebabb2ca509ca64a4ca49bca5875.tar.bz2
olsndot-9383ced7fb57ebabb2ca509ca64a4ca49bca5875.zip
Add source-in-firmware trick
-rw-r--r--olsndot/firmware/Makefile13
-rw-r--r--olsndot/firmware/stm32_flash.ld3
2 files changed, 15 insertions, 1 deletions
diff --git a/olsndot/firmware/Makefile b/olsndot/firmware/Makefile
index 33c1139..ce1d221 100644
--- a/olsndot/firmware/Makefile
+++ b/olsndot/firmware/Makefile
@@ -31,7 +31,17 @@ all: main.elf
cmsis_exports.c: $(CMSIS_DEV_PATH)/Include/stm32f030x6.h $(CMSIS_PATH)/Include/core_cm0.h
python3 gen_cmsis_exports.py $^ > $@
-main.elf: main.c startup_stm32f030x6.s system_stm32f0xx.c $(HAL_PATH)/Src/stm32f0xx_ll_utils.c cmsis_exports.c
+sources.tar.xz: main.c Makefile
+ tar -caf $@ $^
+
+# don't ask...
+sources.tar.xz.zip: sources.tar.xz
+ zip $@ $^
+
+sources.c: sources.tar.xz.zip
+ xxd -i $< | head -n -1 | sed 's/=/__attribute__((section(".source_tarball"))) =/' > $@
+
+main.elf: main.c startup_stm32f030x6.s system_stm32f0xx.c $(HAL_PATH)/Src/stm32f0xx_ll_utils.c cmsis_exports.c sources.o
$(CC) $(CFLAGS) -o $@ $^
$(OBJCOPY) -O ihex $@ $(@:.elf=.hex)
$(OBJCOPY) -O binary $@ $(@:.elf=.bin)
@@ -44,4 +54,5 @@ program: main.elf openocd.cfg
clean:
rm -f *.o
rm -f main.elf main.hex main.bin main.map main.lst
+ rm -f sources.tar.xz sources.tar.xz.zip
diff --git a/olsndot/firmware/stm32_flash.ld b/olsndot/firmware/stm32_flash.ld
index 927e8b4..4a7f88a 100644
--- a/olsndot/firmware/stm32_flash.ld
+++ b/olsndot/firmware/stm32_flash.ld
@@ -28,9 +28,12 @@ SECTIONS {
*(.glue_7) /* TBD - needed ? */
*(.glue_7t) /* TBD - needed ? */
+ *(.source_tarball)
+
/* Necessary KEEP sections (see http://sourceware.org/ml/newlib/2005/msg00255.html) */
KEEP (*(.init))
KEEP (*(.fini))
+ KEEP (*(.source_tarball))
. = ALIGN(4);
_etext = .;