在 Mac OS (M1) 上编译时出现 arm-none-eabi-gcc 问题

问题描述 投票:0回答:2
  • 背景:

我使用的是 Mac OS Monterey (12.5.1) 和 M1 pro 处理器

已安装最新版本的 Xcode

我正在尝试构建一个图像以在树莓派内使用它,并尝试与 Piface LED 屏幕进行交互。 使用 PI OS,我在 config.txt 中加载我自己的内核 (.img)

我正在尝试通过 Makefile 使用 (gcc) arm-none-eabi 编译 c :

MAINFILE = a2p1
OBJS    =  lib/piface.o
OBJS    += lib/rpi-gpio.o lib/rpi-armtimer.o lib/rpi-interrupts.o lib/rpi-systimer.o 
OBJS    += lib/startup.o lib/syscalls.o 
OBJS    += $(MAINFILE).o

ELF     = $(MAINFILE).elf
MAIN    = $(MAINFILE).img

CROSS   = arm-none-eabi-
CC      = $(CROSS)gcc
AS      = $(CROSS)as
SIZE    = $(CROSS)size
OCOPY   = $(CROSS)objcopy

CFLAGS  = -march=armv8-a+crc -mtune=cortex-a53 -mfpu=vfp -mfloat-abi=soft -ffunction-sections -fdata-sections -fno-common -g -std=gnu99 -Wall -Wextra -Os -Ilib -DRPI3=1 -DIOBPLUS=1

LFLAGS  = -static -nostartfiles -lc -lgcc -specs=nano.specs -Wl,--gc-sections -lm
LSCRIPT = lib/rpi3.ld

LDFLAGS += -u _printf_float

.PHONY: all clean run

all: $(MAIN)

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

$(ELF): $(OBJS)
    $(CC) -T $(LSCRIPT) $(CFLAGS) $(LFLAGS) $(LDFLAGS) -o $@ $^
    $(SIZE) $@
    
$(MAIN): $(ELF)
    $(OCOPY) $< -O binary $@

clean:
    rm -f $(MAIN) $(ELF) $(OBJS)

run: $(MAIN)

我已经使用“port”这样安装了arm-none-eabi-gcc:

sudo 端口安装arm-none-eabi-gcc

  • 这是我的错误:

找不到-lc_nano:没有这样的文件或目录

/opt/local/lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/bin/ld :找不到-lg_nano:没有这样的文件或目录

/opt/local/lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/bin/ld :找不到-lc_nano:没有这样的文件或目录

  • 错误是如何发生的: 当编译器尝试运行它时(我想这是链接步骤):

arm-none-eabi-gcc -T lib/rpi3.ld -march=armv8-a+crc -mtune=cortex-a53 -mfpu=vfp -mfloat-abi=soft -ffunction-sections -fdata-sections -fno-common -g -std=gnu99 -Wall -Wextra -Os -Ilib -DRPI3=1 -DIOBPLUS=1 -static -nostartfiles -lc -lgcc -specs=nano.specs -Wl,--gc-sections -lm -u _printf_float -o a2p1.elf lib/piface.o lib/rpi-gpio.o lib/rpi-armtimer.o lib/rpi-interrupts .o lib/rpi-systimer.o lib/startup.o lib/syscalls.o a2p1.o

c macos makefile compiler-errors arm
2个回答
2
投票

我的端口也有同样的问题,请将其删除并使用:

brew install --cask gcc-arm-embedded

( https://formulae.brew.sh/cask/gcc-arm-embedded )


0
投票

您可以在以下位置下载独立的 ARM 工具链: https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads

© www.soinside.com 2019 - 2024. All rights reserved.