admin管理员组

文章数量:1279116

I have been learning how to work with toolchains and makefiles directly and compile for a teensy 4.1 microcontroller. Ive been basing my code off of the teensy-duino core makefile. My makefile so far is as follows

CC = arm-none-eabi-gcc

# MCU Configs
MCU = IMXRT1062
MCU_LD = imxrt1062_t41.ld

CPUOPTIONS = -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -mthumb

# TARGET executable
Output = BuildOut
TARGET = ..\Build\$(Output)

# Source files
MAIN = main.c 

LIBDIRS = teensy41
LIBS := $(foreach lib,$(LIBDIRS), $(wildcard ../IncludeLibs/$(lib)/*.c)) -T$(MCU_LD)

SOURCES = $(MAIN) $(LIBS) 

LDFLAGS = -Os -Wl,--gc-sections,--relax $(CPUOPTIONS)
CRLIBS = -lm -lstdc++ -larm_cortexM7lfsp_math


# Default rule to build and run the executable
all: $(TARGET).hex

$(TARGET).elf: $(SOURCES) $(MCU_LD)
    $(CC) $(LDFLAGS) -o $@ $(SOURCES) $(CRLIBS)

%.hex: %.elf
    arm-none-eabi-objcopy -O ihex -R .eeprom $< $@
    arm-none-eabi-size $^

# Clean rule to remove generated files
clean:
    rm -f $(TARGET).out $(TARGET).hex

I have been having various errors with compiling, while the code shown is exactly how it is found in the teensy-duino makefile. the error im getting now is cannot open linker script file imxrt1062_t41.ld: No such file or directory

Ive attempeted removing refrences to imxrt1062_t41.ld to see if they were needed however I am met with a similar error with -larm_cortexM7lfsp_math, removing that grants a long list of errors similar to

C:/Program Files (x86)/Arm GNU Toolchain arm-none-eabi/14.2 rel1/bin/../lib/gcc/arm-none-eabi/14.2.1/../../../../arm-none-eabi/bin/ld.exe: C:/Program Files (x86)/Arm GNU Toolchain arm-none-eabi/14.2 rel1/bin/../lib/gcc/arm-none-eabi/14.2.1/thumb/v7e-m+dp/hard\libc.a(libc_a-exit.o): in function `exit':
exit.c:(.text.exit+0x14): undefined reference to `_exit'

I would appreciate any advice or wisdom people have to offer, ive had a hell of a time finding documentation or resources on the matter. I would greatly appreciate links to useful resources on learning how to use arm-none-eabi-gcc or better alternatives

Thanks a ton

本文标签: makefileErrors attempting to compile using make and ArmnoneeabigccStack Overflow