[Cryptech-Commits] [sw/stm32] 01/02: Reorganize Makefile and directory structure, because it's messy, and it's about to get messier.
git at cryptech.is
git at cryptech.is
Thu Apr 14 22:53:26 UTC 2016
This is an automated email from the git hooks/post-receive script.
paul at psgd.org pushed a commit to branch rtos
in repository sw/stm32.
commit 79b1ba7104dba52dbfacf11a07305702889f440b
Author: Paul Selkirk <paul at psgd.org>
AuthorDate: Mon Apr 11 14:44:44 2016 -0400
Reorganize Makefile and directory structure, because it's messy, and it's about to get messier.
---
.gitmodules | 4 +-
Drivers/Makefile | 14 ----
Makefile | 92 ++++++++--------------
libhal => libraries/libhal | 0
{thirdparty => libraries/thirdparty}/libtfm | 0
projects/board-test/Makefile | 18 +++++
{self-test => projects/board-test}/fmc-perf.c | 0
{self-test => projects/board-test}/fmc-test.c | 0
{self-test => projects/board-test}/led-test.c | 0
{self-test => projects/board-test}/short-test.c | 0
{self-test => projects/board-test}/uart-test.c | 0
projects/libhal-test/Makefile | 33 ++++++++
.../libhal-test/gettimeofday.c | 0
main.c => projects/libhal-test/main.c | 0
printf.c => projects/libhal-test/printf.c | 0
15 files changed, 88 insertions(+), 73 deletions(-)
diff --git a/.gitmodules b/.gitmodules
index 20b8eb8..5960557 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,7 +1,7 @@
[submodule "libhal"]
- path = libhal
+ path = libraries/libhal
url = git at git.cryptech.is:sw/libhal.git
branch = rpc
[submodule "thirdparty/libtfm"]
- path = thirdparty/libtfm
+ path = libraries/thirdparty/libtfm
url = git at git.cryptech.is:sw/thirdparty/libtfm.git
diff --git a/Drivers/Makefile b/Drivers/Makefile
index 29aae70..b179341 100644
--- a/Drivers/Makefile
+++ b/Drivers/Makefile
@@ -5,15 +5,6 @@ AR=arm-none-eabi-ar
vpath %.c STM32F4xx_HAL_Driver/Src
-# Default STDPERIPH_SETTINGS to settings suitable for STM32F429BIT6 (dev-bridge rev01)
-#STDPERIPH_SETTINGS ?= -DUSE_STDPERIPH_DRIVER -DSTM32F4XX -DSTM32F429xx
-
-#CFLAGS += -ggdb -O2 -Wall -Wextra -Warray-bounds
-#CFLAGS += -mcpu=cortex-m4 -mthumb -mlittle-endian -mthumb-interwork
-#CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
-#CFLAGS += -ICMSIS/Include -ICMSIS/Device/ST/STM32F4xx/Include -ISTM32F4xx_HAL_Driver/Inc
-#CFLAGS += $(STDPERIPH_SETTINGS)
-
SRCS = stm32f4xx_hal.c stm32f4xx_hal_msp_template.c \
stm32f4xx_hal_adc.c stm32f4xx_hal_nand.c \
stm32f4xx_hal_adc_ex.c stm32f4xx_hal_nor.c \
@@ -50,13 +41,8 @@ SRCS = stm32f4xx_hal.c stm32f4xx_hal_msp_template.c \
OBJS = $(SRCS:.c=.o)
-.PHONY: libstmf4.a
-
all: libstmf4.a
-%.o : %.c
- $(CC) $(CFLAGS) -c -o $@ $^
-
libstmf4.a: $(OBJS)
$(AR) -r $@ $(OBJS)
diff --git a/Makefile b/Makefile
index f4185bf..c653a4d 100644
--- a/Makefile
+++ b/Makefile
@@ -27,33 +27,25 @@
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-# "stm32-native" projects
-SELF-TESTS = fmc-test led-test short-test uart-test fmc-perf
-vpath %.c self-test
-
-# apps originally written for unix-like environment
-#LIBHAL-TESTS = cores test-bus test-trng test-hash test-aes-key-wrap test-pbkdf2 test-ecdsa test-rsa
-#LIBHAL-TESTS = cores test-hash test-rpc_hash
-LIBHAL-TESTS = test-rpc_server
-vpath %.c libhal/tests libhal/utils
-
# absolute path, because we're going to be passing -I cflags to sub-makes
-TOPLEVEL = $(shell pwd)
+export TOPLEVEL = $(shell pwd)
# Location of the Libraries folder from the STM32F0xx Standard Peripheral Library
STD_PERIPH_LIB = $(TOPLEVEL)/Drivers
+export LIBS = $(STD_PERIPH_LIB)/libstmf4.a
# linker script
-LDSCRIPT = $(TOPLEVEL)/Device/ldscripts/stm32f429bitx.ld
+export LDSCRIPT = $(TOPLEVEL)/Device/ldscripts/stm32f429bitx.ld
# board-specific objects, to link into every project
-BOARD_OBJS = stm32f4xx_hal_msp.o stm32f4xx_it.o stm-fmc.o stm-init.o stm-uart.o \
- Device/startup_stm32f429xx.o Device/system_stm32f4xx.o
-
-# a few objects for libhal/test projects
-LIBC_OBJS = syscalls.o printf.o gettimeofday.o
-
-LIBS = $(STD_PERIPH_LIB)/libstmf4.a libhal/libhal.a thirdparty/libtfm/libtfm.a
+export BOARD_OBJS = $(TOPLEVEL)/stm32f4xx_hal_msp.o \
+ $(TOPLEVEL)/stm32f4xx_it.o \
+ $(TOPLEVEL)/stm-fmc.o \
+ $(TOPLEVEL)/stm-init.o \
+ $(TOPLEVEL)/stm-uart.o \
+ $(TOPLEVEL)/syscalls.o \
+ $(TOPLEVEL)/Device/startup_stm32f429xx.o \
+ $(TOPLEVEL)/Device/system_stm32f4xx.o
# cross-building tools
PREFIX=arm-none-eabi-
@@ -69,68 +61,54 @@ CFLAGS = -ggdb -O2 -Wall -Warray-bounds #-Wextra
CFLAGS += -mcpu=cortex-m4 -mthumb -mlittle-endian -mthumb-interwork
CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
CFLAGS += -DUSE_STDPERIPH_DRIVER -DSTM32F4XX -DSTM32F429xx
+CFLAGS += -D__CORTEX_M4 -DTARGET_STM -DTARGET_STM32F4 -DTARGET_STM32F429ZI -DTOOLCHAIN_GCC -D__FPU_PRESENT=1
CFLAGS += -ffunction-sections -fdata-sections -Wl,--gc-sections
CFLAGS += -std=c99
-CFLAGS += -I $(TOPLEVEL) -I $(STD_PERIPH_LIB)
+CFLAGS += -I $(TOPLEVEL)
+CFLAGS += -I $(STD_PERIPH_LIB)
CFLAGS += -I $(STD_PERIPH_LIB)/CMSIS/Device/ST/STM32F4xx/Include
CFLAGS += -I $(STD_PERIPH_LIB)/CMSIS/Include
CFLAGS += -I $(STD_PERIPH_LIB)/STM32F4xx_HAL_Driver/Inc
-CFLAGS += -I libhal
export CFLAGS
-#all: lib self-test libhal-tests
-all: lib libhal-tests
+all: board-test libhal-test
init:
git submodule update --init --recursive
-lib: $(LIBS)
-
$(STD_PERIPH_LIB)/libstmf4.a:
$(MAKE) -C $(STD_PERIPH_LIB)
-thirdparty/libtfm/libtfm.a:
- $(MAKE) -C thirdparty/libtfm PREFIX=$(PREFIX)
+board-test: $(BOARD_OBJS) $(LIBS)
+ $(MAKE) -C projects/board-test
-libhal/libhal.a: thirdparty/libtfm/libtfm.a
- $(MAKE) -C libhal IO_BUS=fmc RPC_SERVER=yes RPC_TRANSPORT=serial KS=volatile libhal.a
-# $(MAKE) -C libhal RPC_CLIENT=local IO_BUS=fmc KS=volatile libhal.a
+LIBS_DIR = $(TOPLEVEL)/libraries
-self-test: $(SELF-TESTS:=.elf)
+export LIBTFM_DIR = $(LIBS_DIR)/thirdparty/libtfm
-%.elf: %.o $(BOARD_OBJS) $(STD_PERIPH_LIB)/libstmf4.a
- $(CC) $(CFLAGS) $^ -o $@ -T$(LDSCRIPT) -g -Wl,-Map=$*.map
- $(OBJCOPY) -O ihex $*.elf $*.hex
- $(OBJCOPY) -O binary $*.elf $*.bin
- $(OBJDUMP) -St $*.elf >$*.lst
- $(SIZE) $*.elf
+$(LIBTFM_DIR)/libtfm.a:
+ $(MAKE) -C $(LIBTFM_DIR) PREFIX=$(PREFIX)
-libhal-tests: $(LIBHAL-TESTS:=.bin)
+export LIBHAL_DIR = $(LIBS_DIR)/libhal
-# .mo extension for files with main() that need to be wrapped as __main()
-%.mo: %.c
- $(CC) -c $(CFLAGS) -Dmain=__main -o $@ $<
+$(LIBHAL_DIR)/libhal.a: $(LIBTFM_DIR)/libtfm.a
+# $(MAKE) -C $(LIBHAL_DIR) RPC_CLIENT=local IO_BUS=fmc KS=volatile libhal.a
+ $(MAKE) -C $(LIBHAL_DIR) IO_BUS=fmc RPC_SERVER=yes RPC_TRANSPORT=serial KS=volatile libhal.a
-%.bin: %.mo main.o $(BOARD_OBJS) $(LIBC_OBJS) $(LIBS)
- $(CC) $(CFLAGS) $^ -o $*.elf -T$(LDSCRIPT) -g -Wl,-Map=$*.map
- $(OBJCOPY) -O ihex $*.elf $*.hex
- $(OBJCOPY) -O binary $*.elf $*.bin
- $(OBJDUMP) -St $*.elf >$*.lst
- $(SIZE) $*.elf
+libhal-test: $(BOARD_OBJS) $(LIBS) $(LIBHAL_DIR)/libhal.a
+ $(MAKE) -C projects/libhal-test
# don't automatically delete objects, to avoid a lot of unnecessary rebuilding
-.SECONDARY: $(BOARD_OBJS) $(LIBC_OBJS)
+.SECONDARY: $(BOARD_OBJS)
+
+.PHONY: board-test libhal-test
clean:
- find ./ -name '*~' | xargs rm -f
- rm -f $(BOARD_OBJS) $(LIBC_OBJS) *.o *.mo
- rm -f *.elf
- rm -f *.hex
- rm -f *.bin
- rm -f *.map
- rm -f *.lst
+ rm -f $(BOARD_OBJS)
+ $(MAKE) -C projects/board-test clean
+ $(MAKE) -C projects/libhal-test clean
distclean: clean
$(MAKE) -C $(STD_PERIPH_LIB) clean
- $(MAKE) -C thirdparty/libtfm clean
- $(MAKE) -C libhal clean
+ $(MAKE) -C $(LIBHAL_DIR) clean
+ $(MAKE) -C $(LIBTFM_DIR) clean
diff --git a/libhal b/libraries/libhal
similarity index 100%
rename from libhal
rename to libraries/libhal
diff --git a/thirdparty/libtfm b/libraries/thirdparty/libtfm
similarity index 100%
rename from thirdparty/libtfm
rename to libraries/thirdparty/libtfm
diff --git a/projects/board-test/Makefile b/projects/board-test/Makefile
new file mode 100644
index 0000000..21f24c9
--- /dev/null
+++ b/projects/board-test/Makefile
@@ -0,0 +1,18 @@
+TEST = led-test short-test uart-test fmc-test fmc-perf
+
+all: $(TEST:=.elf)
+
+%.elf: %.o $(BOARD_OBJS) $(LIBS)
+ $(CC) $(CFLAGS) $^ -o $@ -T$(LDSCRIPT) -g -Wl,-Map=$*.map
+ $(OBJCOPY) -O ihex $*.elf $*.hex
+ $(OBJCOPY) -O binary $*.elf $*.bin
+ $(OBJDUMP) -St $*.elf >$*.lst
+ $(SIZE) $*.elf
+
+clean:
+ rm -f *.o
+ rm -f *.elf
+ rm -f *.hex
+ rm -f *.bin
+ rm -f *.map
+ rm -f *.lst
diff --git a/self-test/fmc-perf.c b/projects/board-test/fmc-perf.c
similarity index 100%
rename from self-test/fmc-perf.c
rename to projects/board-test/fmc-perf.c
diff --git a/self-test/fmc-test.c b/projects/board-test/fmc-test.c
similarity index 100%
rename from self-test/fmc-test.c
rename to projects/board-test/fmc-test.c
diff --git a/self-test/led-test.c b/projects/board-test/led-test.c
similarity index 100%
rename from self-test/led-test.c
rename to projects/board-test/led-test.c
diff --git a/self-test/short-test.c b/projects/board-test/short-test.c
similarity index 100%
rename from self-test/short-test.c
rename to projects/board-test/short-test.c
diff --git a/self-test/uart-test.c b/projects/board-test/uart-test.c
similarity index 100%
rename from self-test/uart-test.c
rename to projects/board-test/uart-test.c
diff --git a/projects/libhal-test/Makefile b/projects/libhal-test/Makefile
new file mode 100644
index 0000000..b0def35
--- /dev/null
+++ b/projects/libhal-test/Makefile
@@ -0,0 +1,33 @@
+TEST = cores test-bus test-trng test-hash test-aes-key-wrap test-pbkdf2 test-ecdsa test-rsa
+#TEST += test-rpc_hash test-rpc_pkey test-rpc_get_version test-rpc_get_random
+TEST += test-rpc_server
+
+CFLAGS += -I $(LIBHAL_DIR)
+LIBC_OBJS = printf.o gettimeofday.o
+LIBS += $(LIBHAL_DIR)/libhal.a $(LIBTFM_DIR)/libtfm.a
+
+all: $(TEST:=.elf)
+
+vpath %.c $(LIBHAL_DIR)/tests $(LIBHAL_DIR)/utils
+
+# .mo extension for files with main() that need to be wrapped as __main()
+%.mo: %.c
+ $(CC) -c $(CFLAGS) -Dmain=__main -o $@ $<
+
+%.elf: %.mo main.o $(BOARD_OBJS) $(LIBC_OBJS) $(LIBS)
+ $(CC) $(CFLAGS) $^ -o $*.elf -T$(LDSCRIPT) -g -Wl,-Map=$*.map
+ $(OBJCOPY) -O ihex $*.elf $*.hex
+ $(OBJCOPY) -O binary $*.elf $*.bin
+ $(OBJDUMP) -St $*.elf >$*.lst
+ $(SIZE) $*.elf
+
+# don't automatically delete objects, to avoid a lot of unnecessary rebuilding
+.SECONDARY: $(BOARD_OBJS) $(LIBC_OBJS)
+
+clean:
+ rm -f *.o *.mo
+ rm -f *.elf
+ rm -f *.hex
+ rm -f *.bin
+ rm -f *.map
+ rm -f *.lst
diff --git a/gettimeofday.c b/projects/libhal-test/gettimeofday.c
similarity index 100%
rename from gettimeofday.c
rename to projects/libhal-test/gettimeofday.c
diff --git a/main.c b/projects/libhal-test/main.c
similarity index 100%
rename from main.c
rename to projects/libhal-test/main.c
diff --git a/printf.c b/projects/libhal-test/printf.c
similarity index 100%
rename from printf.c
rename to projects/libhal-test/printf.c
More information about the Commits
mailing list