I am porting nRF8001 library to a stm32 mcu and in the makefile no matter how I include the header files it’s not recognizing the path. I am not sure what’s wrong with this makefile
TARGET=main
EXECUTABLE=main.elf
BINARYOUT=main.bin
# STLINK=~/Downloads/stlink
LIBPATH=C:/Users/gkowshik/OneDrive - PragmatIC Semiconductor Ltd/Documents/kowshik_work/wearables_demo/STM32L1xx_StdPeriph_Lib
# COMPILER=C:/ST/STM32CubeIDE_1.13.1/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.win32_1.1.0.202305231506/tools/bin
# CC=$(COMPILER)/arm-none-eabi-gcc.exe
# LD=$(COMPILER)/arm-none-eabi-gcc.exe
# AR=$(COMPILER)/arm-none-eabi-ar.exe
# AS=$(COMPILER)/arm-none-eabi-as.exe
# CP=$(COMPILER)/arm-none-eabi-objcopy.exe
# OD=$(COMPILER)/arm-none-eabi-objdump.exe
CC=arm-none-eabi-gcc
LD=arm-none-eabi-gcc
AR=arm-none-eabi-ar
AS=arm-none-eabi-as
CP=arm-none-eabi-objcopy
OD=arm-none-eabi-objdump
BIN=$(CP) -O ihex
DEFS = -DUSE_STDPERIPH_DRIVER -DSTM32L1xx -DSTM32L1XX_MD -DHSE_VALUE=8000000
STARTUP = $(LIBPATH)/Libraries/CMSIS/Device/ST/STM32L1xx/Source/Templates/gcc_ride7/startup_stm32l151cbuxa.s
MCU = cortex-m3
MCFLAGS = -mcpu=$(MCU) -mthumb -mlittle-endian -mfloat-abi=soft -std=c99
STM32_INCLUDES = -I$(LIBPATH)/Libraries/CMSIS/Device/ST/STM32L1xx/Include/
-I$(LIBPATH)/Libraries/CMSIS/Include/
-I$(LIBPATH)/Libraries/STM32L1xx_StdPeriph_Driver/inc/
-I./inc/
-I./inc/BLE/
OPTIMIZE = -O0
CFLAGS = $(MCFLAGS) $(OPTIMIZE) $(DEFS) -I. -I$(STM32_INCLUDES) -Wl,-T,stm32_flash.ld
AFLAGS = $(MCFLAGS)
#-mapcs-float use float regs. small increase in code size
SRC = ./src/main.c
./src/millis.c
./src/usart.c
./src/spi.c
./src/debug.c
./src/stm32l1xx_it.c
./src/system_stm32l1xx.c
./src/BLE/io_support.c
./src/BLE/acilib.c
./src/BLE/aci_queue.c
./src/BLE/aci_setup.c
./src/BLE/hal_aci_tl.c
./src/BLE/lib_aci.c
$(LIBPATH)/Libraries/STM32L1xx_StdPeriph_Driver/src/misc.c
$(LIBPATH)/Libraries/STM32L1xx_StdPeriph_Driver/src/stm32l1xx_adc.c
$(LIBPATH)/Libraries/STM32L1xx_StdPeriph_Driver/src/stm32l1xx_crc.c
$(LIBPATH)/Libraries/STM32L1xx_StdPeriph_Driver/src/stm32l1xx_aes.c
$(LIBPATH)/Libraries/STM32L1xx_StdPeriph_Driver/src/stm32l1xx_dac.c
$(LIBPATH)/Libraries/STM32L1xx_StdPeriph_Driver/src/stm32l1xx_dbgmcu.c
$(LIBPATH)/Libraries/STM32L1xx_StdPeriph_Driver/src/stm32l1xx_dma.c
$(LIBPATH)/Libraries/STM32L1xx_StdPeriph_Driver/src/stm32l1xx_exti.c
$(LIBPATH)/Libraries/STM32L1xx_StdPeriph_Driver/src/stm32l1xx_flash_ramfunc.c
$(LIBPATH)/Libraries/STM32L1xx_StdPeriph_Driver/src/stm32l1xx_flash.c
$(LIBPATH)/Libraries/STM32L1xx_StdPeriph_Driver/src/stm32l1xx_fsmc.c
$(LIBPATH)/Libraries/STM32L1xx_StdPeriph_Driver/src/stm32l1xx_gpio.c
$(LIBPATH)/Libraries/STM32L1xx_StdPeriph_Driver/src/stm32l1xx_i2c.c
$(LIBPATH)/Libraries/STM32L1xx_StdPeriph_Driver/src/stm32l1xx_iwdg.c
$(LIBPATH)/Libraries/STM32L1xx_StdPeriph_Driver/src/stm32l1xx_lcd.c
$(LIBPATH)/Libraries/STM32L1xx_StdPeriph_Driver/src/stm32l1xx_opamp.c
$(LIBPATH)/Libraries/STM32L1xx_StdPeriph_Driver/src/stm32l1xx_pwr.c
$(LIBPATH)/Libraries/STM32L1xx_StdPeriph_Driver/src/stm32l1xx_rcc.c
$(LIBPATH)/Libraries/STM32L1xx_StdPeriph_Driver/src/stm32l1xx_rtc.c
$(LIBPATH)/Libraries/STM32L1xx_StdPeriph_Driver/src/stm32l1xx_sdio.c
$(LIBPATH)/Libraries/STM32L1xx_StdPeriph_Driver/src/stm32l1xx_spi.c
$(LIBPATH)/Libraries/STM32L1xx_StdPeriph_Driver/src/stm32l1xx_syscfg.c
$(LIBPATH)/Libraries/STM32L1xx_StdPeriph_Driver/src/stm32l1xx_tim.c
$(LIBPATH)/Libraries/STM32L1xx_StdPeriph_Driver/src/stm32l1xx_usart.c
$(LIBPATH)/Libraries/STM32L1xx_StdPeriph_Driver/src/stm32l1xx_wwdg.c
OBJDIR = .
OBJ = $(SRC:%.c=$(OBJDIR)/%.o)
STARTUP_OBJ = $(STARTUP:%.s=$(OBJDIR)/%.o)
all: $(TARGET)
$(TARGET): $(EXECUTABLE)
$(CP) -O ihex $(EXECUTABLE) $(TARGET).hex
$(CP) -O binary $(EXECUTABLE) $(BINARYOUT)
$(EXECUTABLE): $(OBJ) $(STARTUP_OBJ)
$(CC) $(CFLAGS) $(OBJ) $(STARTUP_OBJ) -lm -lc -lnosys -o $(EXECUTABLE)
$(OBJDIR)/%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
$(OBJDIR)/%.o: %.s
$(AS) $(AFLAGS) -c $< -o $@
clean:
rm -f $(OBJDIR)/*.o $(TARGET) $(EXECUTABLE) $(BINARYOUT) $(TARGET).hex
I have ensured that the header files do exist in the same directory are added into the makefile during compilation. Here’s the compilation error I get
kowshik@KG01LW0637:/mnt/c/Users/gkowshik/OneDrive - PragmatIC Semiconductor Ltd/Documents/kowshik_work/wearables_demo/nrf8001-stm32f4$ make clean && make all
rm -f ./*.o main main.elf main.bin main.hex
arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -mlittle-endian -mfloat-abi=soft -std=c99 -O0 -DUSE_STDPERIPH_DRIVER -DSTM32L1xx -DSTM32L1XX_MD -DHSE_VALUE=8000000 -I. -I./ -I""C:/Users/gkowshik/OneDrive - PragmatIC Semiconductor Ltd/Documents/kowshik_work/wearables_demo/STM32L1xx_StdPeriph_Lib"/Libraries/CMSIS/Device/ST/STM32L1xx/Include/" -I""C:/Users/gkowshik/OneDrive - PragmatIC Semiconductor Ltd/Documents/kowshik_work/wearables_demo/STM32L1xx_StdPeriph_Lib"/Libraries/CMSIS/Include/" -I""C:/Users/gkowshik/OneDrive - PragmatIC Semiconductor Ltd/Documents/kowshik_work/wearables_demo/STM32L1xx_StdPeriph_Lib"/Libraries/STM32L1xx_StdPeriph_Driver/inc/" -I./inc/ -I./inc/BLE/ -Wl,-T,stm32_flash.ld -c src/main.c -o src/main.o
src/main.c:4:10: fatal error: stm32l1xx.h: No such file or directory
4 | #include <stm32l1xx.h>
| ^~~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:94: src/main.o] Error 1
If I change the inclusion in the main.c to the below way it is able to see the file, However I can’t take this approach as there are tens of header files and hundreds of code lines where includes are done hence we took the makefile approach of including it once and we can directly call it, is there something wrong with the way my path is declared? i.e., ‘OneDrive ‘ has many space in it. Could that be an issue?
#include "../../STM32L1xx_StdPeriph_Lib/Libraries/CMSIS/Device/ST/STM32L1xx/Include/stm32l1xx.h
Tried to change the path of the folder(Instead of long ‘OneDrive ‘ folder with spaces) but still the same error occurs.
12