Compile SECoreBin without main
Hi.
I am trying to compile the SBSFU project for STM32L, more exact i am using b-l475e-iot01a.
I have put together the following makefile, trying to compile SECoreBin, but i cannot work out how to link it together without getting
/usr/lib/gcc/arm-none-eabi/8.2.0/../../../../arm-none-eabi/bin/ld: /usr/lib/gcc/arm-none-eabi/8.2.0/../../../../arm-none-eabi/lib/thumb/v7e-m+fp/softfp/crt0.o: in function `_start':
(.text+0x44): undefined reference to `main'Makefile.
######################################
# Makefile by CubeMX2Makefile.py
######################################
######################################
# target
######################################
TARGET = SECoreBin
######################################
# building variables
######################################
# debug build?
DEBUG = 0
# optimization
OPT = -O0
#######################################
# pathes
#######################################
# Build path
BUILD_DIR = build
######################################
# source
######################################
SE_SOURCES = ../Middlewares/STM32_Secure_Engine/Core/se_bootinfo.c
SE_SOURCES += ../Middlewares/STM32_Secure_Engine/Core/se_callgate.c
SE_SOURCES += ../Middlewares/STM32_Secure_Engine/Core/se_crypto_common.c
SE_SOURCES += ../Middlewares/STM32_Secure_Engine/Core/se_exception.c
SE_SOURCES += ../Middlewares/STM32_Secure_Engine/Core/se_fwimg.c
SE_SOURCES += ../Middlewares/STM32_Secure_Engine/Core/se_startup.c
SE_SOURCES += ../Middlewares/STM32_Secure_Engine/Core/se_user_application.c
SE_SOURCES += ../Middlewares/STM32_Secure_Engine/Core/se_utils.c
SE_SOURCES_ASM = ../Middlewares/STM32_Secure_Engine/Core/se_stack_smuggler_GNU.s
SE_INCLUDES = -I../Middlewares/STM32_Secure_Engine/Core
SE_INCLUDES += -I../Middlewares/STM32_Secure_Engine/Key
HAL_SOURCES = ../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_crc.c
HAL_SOURCES += ../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_crc_ex.c
HAL_SOURCES += ../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_firewall.c
HAL_SOURCES += ../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash.c
HAL_SOURCES += ../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ex.c
HAL_INCLUDES = -I../Drivers/STM32L4xx_HAL_Driver/Inc
CRYPTO_LIB = ../Middlewares/STM32_Cryptographic/Fw_Crypto/STM32L4/Lib/libSTM32CryptographicV3.0.0_CM4_GCC.a
CRYPTO_INCLUDES = -I../Middlewares/STM32_Cryptographic/Fw_Crypto/STM32L4/Inc
DEVICE_INCLUDES = -I../Drivers/CMSIS/Device/ST/STM32L4xx/Include
DEVICE_INCLUDES += -I../Drivers/CMSIS/Include
DEVICE_INCLUDES += -I../Drivers/BSP/B-L475E-IOT01
DEVICE_INCLUDES += -I../Drivers/BSP/Components/Common
SE_KEY_ASM = SECoreBin/build/se_key.s
C_SOURCES = $(SE_SOURCES) $(HAL_SOURCES) Src/se_crypto_bootloader.c Src/se_low_level.c data_init.c
ASM_SOURCES = startup_stm32l475xx.s $(SE_SOURCES_ASM) $(SE_KEY_ASM)
#######################################
# binaries
#######################################
CC = arm-none-eabi-gcc
AS = arm-none-eabi-gcc -x assembler-with-cpp
CP = arm-none-eabi-objcopy
AR = arm-none-eabi-ar
SZ = arm-none-eabi-size
HEX = $(CP) -O ihex
BIN = $(CP) -O binary -S
#######################################
# CFLAGS
#######################################
# macros for gcc
AS_DEFS =
C_DEFS = -DSTM32L475xx -DUSE_HAL_DRIVER -DUSE_STM32L475E_IOT01
# includes for gcc
AS_INCLUDES =
C_INCLUDES = -IInc -I../SBSFU/SBSFU/App -I../Linker_Common $(SE_INCLUDES) $(HAL_INCLUDES) $(DEVICE_INCLUDES) $(CRYPTO_INCLUDES)
# compile gcc flags
ASFLAGS = -mthumb -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -specs=nosys.specs -specs=nano.specs $(AS_DEFS) $(AS_INCLUDES) $(OPT)
CFLAGS = -mthumb -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -specs=nosys.specs -specs=nano.specs $(C_DEFS) $(C_INCLUDES) $(OPT)
ifeq ($(DEBUG), 1)
CFLAGS += -g -gdwarf-2
endif
# Generate dependency information
CFLAGS += -std=gnu11 -MD -MP -MF $(BUILD_DIR)/.dep/$(@F).d
#######################################
# LDFLAGS
#######################################
# link script
LDSCRIPT = STM32L475VGTx_FLASH.ld
# libraries
LIBS = $(CRYPTO_LIB)
LIBDIR =
LDFLAGS = -mthumb -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -specs=nosys.specs -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -L../Linker_Common -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections
# default action: build all
all: prebuild $(BUILD_DIR)/$(TARGET).bin
prebuild:
mkdir -p $(BUILD_DIR) && ./prebuild.sh $(BUILD_DIR)
#######################################
# build the application
#######################################
# list of objects
OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
vpath %.c $(sort $(dir $(C_SOURCES)))
# list of ASM program objects
OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o)))
vpath %.s $(sort $(dir $(ASM_SOURCES)))
$(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR)
$(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@
$(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR)
$(AS) -c $(CFLAGS) $< -o $@
$(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile
$(CC) $(OBJECTS) $(LDFLAGS) -o $@
$(SZ) $@
$(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
$(HEX) $< $@
$(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
$(BIN) $< $@
$(BUILD_DIR):
mkdir -p $@/.dep
#######################################
# clean up
#######################################
clean:
-rm -fR $(BUILD_DIR)
#######################################
# dependencies
#######################################
-include $(shell mkdir -p $(BUILD_DIR)/.dep 2>/dev/null) $(wildcard $(BUILD_DIR)/.dep/*)
.PHONY: clean all
# *** EOF ***All the paths are correct, but i feel like i am missing a linkerflag or a cflag somewhere.
