0

I am using Ubuntu 22.04 to do some bare metal programming. I have 3 files to compile and link to create a .elf file name app.elf (im using Makefile to do this). However I encountered the error below:

$ make all    
/opt/gcc-arm-none-eabi/arm-gnu-toolchain-12.3.rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -std=gnu11 -Wall -O0 -c -o main.o main.c
/opt/gcc-arm-none-eabi/arm-gnu-toolchain-12.3.rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -std=gnu11 -Wall -O0 -c -o startup.o startup.c
/opt/gcc-arm-none-eabi/arm-gnu-toolchain-12.3.rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -std=gnu11 -Wall -O0 -c -o gpio.o gpio.c
/opt/gcc-arm-none-eabi/arm-gnu-toolchain-12.3.rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-gcc -nostdlib -T stm32_ls.ld -Wl,-Map=app.map -o app.elf main.o startup.o gpio.o
/opt/gcc-arm-none-eabi/arm-gnu-toolchain-12.3.rel1-x86_64-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld: error: .: read: Is a directory
collect2: error: ld returned 1 exit status
make: *** [Makefile:9: app.elf] Error 1

This is my Makefile script:

CC=/opt/gcc-arm-none-eabi/arm-gnu-toolchain-12.3.rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-gcc
MACH=cortex-m3
CFLAGS=-mcpu=$(MACH) -mthumb -std=gnu11 -Wall -O0
LDFLAGS=-nostdlib -T stm32_ls.ld -Wl,-Map=app.map

all: app.elf

app.elf: main.o startup.o gpio.o
    $(CC) $(LDFLAGS) -o $@ $^

main.o: main.c
    $(CC) $(CFLAGS) -c -o $@ $^

startup.o: startup.c
    $(CC) $(CFLAGS) -c -o $@ $^

gpio.o: gpio.c
    $(CC) $(CFLAGS) -c -o $@ $^

clean:
    rm -f *.o *.elf *.map

I've tried reinstalling the toolchain as well as making sure that all file permissions are in executable state.

I think this error is more on the linux side instead of the toolchain but I may be wrong because I'm still a beginner in both fields.

If anyone know how to solve this please do reply. Thank you !

  • 1
    This error `.: read: Is a directory` looks like the linker has been given the file `.` to try to link, which of course cannot work because `.` is a directory, not a file. I don't immediately see a mistake on the linker command line, which leads me to believe it might be a bug in the linker script you're using `stm32_ls.ld` – MadScientist Aug 16 '23 at 13:30
  • Oh thanks it works now. The dot was meant to be for ". = ALIGN(4)" but it seems i typed the wrong syntax, thanks ! – Dustin Lim Aug 16 '23 at 13:47

0 Answers0