From 43ff9fdac05c0ceb696685f683bba077bd2c8da2 Mon Sep 17 00:00:00 2001
From: jaseg <git-bigdata-wsl-arch@jaseg.de>
Date: Thu, 27 Feb 2020 15:58:23 +0100
Subject: Build working

---
 controller/fw/Makefile | 24 +++++++++---------------
 controller/fw/musl     |  1 +
 2 files changed, 10 insertions(+), 15 deletions(-)
 create mode 160000 controller/fw/musl

(limited to 'controller/fw')

diff --git a/controller/fw/Makefile b/controller/fw/Makefile
index 8b0dbd1..e2f0f4c 100644
--- a/controller/fw/Makefile
+++ b/controller/fw/Makefile
@@ -12,11 +12,12 @@ C_SOURCES		+= $(CMSIS_DIR)/CMSIS/DSP/Source/TransformFunctions/arm_rfft_f32.c
 C_SOURCES		+= $(CMSIS_DIR)/CMSIS/DSP/Source/TransformFunctions/arm_bitreversal.c
 C_SOURCES		+= $(CMSIS_DIR)/CMSIS/DSP/Source/TransformFunctions/arm_cfft_radix4_f32.c
 C_SOURCES		+= $(MUSL_DIR)/src/math/tanhf.c $(MUSL_DIR)/src/math/atanhf.c
+C_SOURCES		+= $(MUSL_DIR)/src/math/expm1f.c $(MUSL_DIR)/src/math/log1pf.c
 
 CXX_SOURCES		+= src/ldpc_wrapper.cpp
 
 BUILDDIR 	?= build
-BINARY 		:= safetyreset
+BINARY 		:= safetyreset.elf
 LDSCRIPT 	:= stm32f407.ld
 OPENCM3_LIB	:= opencm3_stm32f4
 
@@ -41,38 +42,37 @@ MUSL_DIR_ABS		:= $(abspath $(MUSL_DIR))
 
 CFLAGS		+= -I$(OPENCM3_DIR_ABS)/include -Imspdebug/util -Imspdebug/drivers
 CFLAGS		+= -I$(CMSIS_DIR_ABS)/CMSIS/DSP/Include -I$(CMSIS_DIR_ABS)/CMSIS/Core/Include
+CFLAGS		+= -I$(abspath musl_include_shims)
 
 CFLAGS	+= -Os -std=gnu11 -g -DSTM32F4
 # Note: libopencm3 requires some standard libc definitions from stdint.h and stdbool.h, so we don't pass -nostdinc here.
 CFLAGS	+= -nostdlib -ffreestanding
 CFLAGS	+= -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16
 CFLAGS	+= -fno-common -ffunction-sections -fdata-sections
-CFLAGS	+= -I$(MUSL_DIR_ABS)/src/internal -I$(MUSL_DIR_ABS)/include -I$(BUILDDIR)/musl/obj/include -I$(MUSL_DIR_ABS)/arch/arm -I$(MUSL_DIR_ABS)/arch/generic
 
-INT_CFLAGS	+= -Wextra -Wshadow -Wimplicit-function-declaration -Wundef
+INT_CFLAGS	+= -Wall -Wextra -Wshadow -Wimplicit-function-declaration -Wundef
 INT_CFLAGS	+= -Wredundant-decls -Wmissing-prototypes -Wstrict-prototypes
 
 CXXFLAGS	+= -Os -g
 CXXFLAGS	+= -nostdlib -ffreestanding
 CXXFLAGS	+= -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16
 CXXFLAGS	+= -fno-common -ffunction-sections -fdata-sections
-CXXFLAGS	+= -Wextra -Wshadow -Wundef -Wredundant-decls
+CXXFLAGS	+= -Wall -Wextra -Wshadow -Wundef -Wredundant-decls
 CXXFLAGS	+= -I.
 
 LDFLAGS		+= --static -nostartfiles
-LDFLAGS		+= -T$(LDSCRIPT)
 LDFLAGS		+= -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -g
 LDFLAGS		+= -Wl,--cre
 #LDFLAGS	+= -Wl,--gc-sections
 LDFLAGS		+= -Wl,--start-group -lc -lgcc -lnosys -Wl,--end-group
 LDFLAGS		+= -L$(OPENCM3_DIR_ABS)/lib -l$(OPENCM3_LIB) $(shell $(CC) -print-libgcc-file-name)
 
-all: $(BUILDDIR)/$(BINARY).elf
+all: $(BUILDDIR)/$(BINARY)
 
 OBJS := $(addprefix $(BUILDDIR)/,$(C_SOURCES:.c=.o) $(CXX_SOURCES:.cpp=.o))
 
-$(BUILDDIR)/%.elf: $(OBJS) $(LDSCRIPT) $(OPENCM3_DIR)/lib/lib$(OPENCM3_LIB).a $(BUILDDIR)/libsodium/src/libsodium/.libs/libsodium.a $(BUILDDIR)/tinyaes/aes.o
-	$(LD) $(OBJS) $(LDFLAGS) -o $@ -Wl,-Map=$(BUILDDIR)/src/$*.map $(BUILDDIR)/libsodium/src/libsodium/.libs/libsodium.a $(BUILDDIR)/tinyaes/aes.o
+$(BUILDDIR)/$(BINARY): $(OBJS) $(OPENCM3_DIR)/lib/lib$(OPENCM3_LIB).a $(BUILDDIR)/libsodium/src/libsodium/.libs/libsodium.a $(BUILDDIR)/tinyaes/aes.o
+	$(LD) -T$(LDSCRIPT) $(LDFLAGS) -o $@ -Wl,-Map=$(BUILDDIR)/src/$*.map $^
 
 $(BUILDDIR)/src/%.o: src/%.c
 	mkdir -p $(@D)
@@ -93,19 +93,13 @@ $(BUILDDIR)/libsodium/src/libsodium/.libs/libsodium.a:
 	mkdir -p $(BUILDDIR)/libsodium
 	cd $(BUILDDIR)/libsodium && CFLAGS="$(CFLAGS) -DDEV_MODE=1" $(LIBSODIUM_DIR_ABS)/configure --host=arm-none-eabi && $(MAKE) -j $(shell nproc)
 
-$(BUILDDIR)/musl/obj/include/bits/alltypes.h:
-	mkdir -p $(BUILDDIR)/musl
-	cd $(BUILDDIR)/musl && CFLAGS="$(CFLAGS)" CC=$(CC) LD=$(LD) AR=$(AR) $(MUSL_DIR_ABS)/configure && $(MAKE) TARGET=arm-linux-musleabihf GCC_CONFIG="--with-arch=armv7-m --with-fpu=fpv4_sp_d16" -j $(shell nproc) obj/include/bits/alltypes.h
-
-$(BUILDDIR)/$(MUSL_DIR)/src/math/tanhf.o $(BUILDDIR)/$(MUSL_DIR)/src/math/atanhf.o: $(BUILDDIR)/musl/obj/include/bits/alltypes.h
-
 $(BUILDDIR)/tinyaes/aes.o:
 	mkdir -p $(@D)
 	make -C $(@D) -f $(TINYAES_DIR_ABS)/Makefile VPATH=$(TINYAES_DIR_ABS) CFLAGS="$(CFLAGS) -c" CC=$(CC) LD=$(LD) AR=$(AR) aes.o
 
 clean:
 	-rm -r $(BUILDDIR)/src
-	-rm $(BUILDDIR)/$(BINARY).elf
+	-rm $(BUILDDIR)/$(BINARY)
 
 mrproper: clean
 	-rm -r build
diff --git a/controller/fw/musl b/controller/fw/musl
new file mode 160000
index 0000000..040c1d1
--- /dev/null
+++ b/controller/fw/musl
@@ -0,0 +1 @@
+Subproject commit 040c1d16b468c50c04fc94edff521f1637708328
-- 
cgit