您尚未登录。

楼主 # 2021-07-21 13:39:56

March
会员
注册时间: 2021-05-28
已发帖子: 56
积分: 18

D1的windows交叉编译

Makefile :

#
# Top makefile
#

CROSS		?= riscv64-unknown-elf-
NAME		:= D1

#
# System environment variable.
#
#
# System environment variable.
#

HOSTOS	:= windows

#
# Load default variables.
#
ASFLAGS		:= -g -ggdb -Wall -O3
CFLAGS		:= -g -ggdb -Wall -O3
CXXFLAGS	:= -g -ggdb -Wall -O3
LDFLAGS		:= -T 03_MCU/Linker_file/link.ld -nostdlib
ARFLAGS		:= -rcs
OCFLAGS		:= -v -O binary
ODFLAGS		:=
MCFLAGS		:= -march=rv64gcvxthead -mabi=lp64d -mcmodel=medlow -fno-stack-protector

LIBDIRS		:=
LIBS 		:=
INCDIRS		:=
SRCDIRS		:=

ifeq ($(strip $(HOSTOS)), linux)
MKSUNXI		:= 00_boot0/tools/linux/mksunxi
endif
ifeq ($(strip $(HOSTOS)), windows)
MKSUNXI		:= 00_boot0/tools/windows/mksunxi
endif



#
# Add external library
#
INCDIRS		+= 00_boot0/include \
			   00_boot0 \
			   02_CPU \
			   03_MCU \
			   03_MCU/MCU_drivers \
			   03_MCU/startup \
			   04_GEC \
			   05_UserBoard \
			   06_SoftComponent \
			   07_APPprg
			   
SRCDIRS		+= 00_boot0 \
			   02_CPU \
			   03_MCU/MCU_drivers \
			   03_MCU/startup \
			   04_GEC \
			   05_UserBoard \
			   06_SoftComponent \
			   07_APPprg
			   

#
# You shouldn't need to change anything below this point.
#
AS			:= $(CROSS)gcc -x assembler-with-cpp
CC			:= $(CROSS)gcc
CXX			:= $(CROSS)g++
LD			:= $(CROSS)ld
AR			:= $(CROSS)ar
OC			:= $(CROSS)objcopy
OD			:= $(CROSS)objdump
MKDIR		:= mkdir
CP			:= cp -af
RM			:= rm -fr
CD			:= cd
FIND		:= find

#
# X variables
#
X_ASFLAGS	:= $(MCFLAGS) $(ASFLAGS)
X_CFLAGS	:= $(MCFLAGS) $(CFLAGS)
X_CXXFLAGS	:= $(MCFLAGS) $(CXXFLAGS)
X_LDFLAGS	:= $(LDFLAGS)
X_OCFLAGS	:= $(OCFLAGS)
X_LIBDIRS	:= $(LIBDIRS)
X_LIBS		:= $(LIBS) -lgcc

X_OUT		:= Debug
X_OBJ       := obj
X_NAME		:= $(patsubst %, $(X_OUT)/%, $(NAME))
X_INCDIRS	:= $(patsubst %, -I %, $(INCDIRS))
X_SRCDIRS	:= $(patsubst %, %, $(SRCDIRS))
X_OBJDIRS	:= $(patsubst %, obj/%, $(X_SRCDIRS))

X_SFILES	:= $(foreach dir, $(X_SRCDIRS), $(wildcard $(dir)/*.S))
X_CFILES	:= $(foreach dir, $(X_SRCDIRS), $(wildcard $(dir)/*.c))
X_CPPFILES	:= $(foreach dir, $(X_SRCDIRS), $(wildcard $(dir)/*.cpp))

SFILENDIR		:= $(notdir  $(X_SFILES))
CFILENDIR		:= $(notdir  $(X_CFILES))
CPPFILENDIR     := $(notdir  $(X_CPPFILES))



X_SDEPS		:= $(patsubst %, obj/%, $(SFILENDIR:.S=.o.d))
X_CDEPS		:= $(patsubst %, obj/%, $(CFILENDIR:.c=.o.d))
X_CPPDEPS	:= $(patsubst %, obj/%, $(CPPFILENDIR:.cpp=.o.d))
X_DEPS		:= $(X_SDEPS) $(X_CDEPS) $(X_CPPDEPS)

X_SOBJS		:= $(patsubst %, obj/%, $(SFILENDIR:.S=.o))
X_COBJS		:= $(patsubst %, obj/%, $(CFILENDIR:.c=.o))
X_CPPOBJS	:= $(patsubst %, obj/%, $(CPPFILENDIR:.cpp=.o)) 
X_OBJS		:= $(X_SOBJS) $(X_COBJS) $(X_CPPOBJS)

VPATH		:= $(SRCDIRS)



.PHONY:	all clean
all : $(X_NAME)

$(X_NAME) : $(X_OBJS)
	@echo [LD] Linking $@.elf
	@$(CC) $(X_LDFLAGS) $(X_LIBDIRS) -Wl,--cref,-Map=$@.map $^ -o $@.elf $(X_LIBS)
	@echo [OC] Objcopying $@.bin
	@$(OC) $(X_OCFLAGS) $@.elf $@.bin
	@$(OC) $@.elf -O ihex $@.hex
	@$(OD) -D $@.elf > $@.lst
	@echo Make header information for brom booting
	@$(MKSUNXI) $@.bin

$(X_SOBJS) : obj/%.o : %.S
	@echo [AS] $<
	@$(AS) $(X_ASFLAGS) -MD -MP -MF $@.d $(X_INCDIRS) -c -O0 $< -o $@

$(X_COBJS) : obj/%.o : %.c
	@echo [CC] $<
	@$(CC) $(X_CFLAGS) -MD -MP -MF $@.d $(X_INCDIRS) -c -O0 $< -o $@

$(X_CPPOBJS) : obj/%.o : %.cpp
	@echo [CXX] $<
	@$(CXX) $(X_CXXFLAGS) -MD -MP -MF $@.d $(X_INCDIRS) -c -O0 $< -o $@

clean:
	@$(RM) obj $(X_OUT)

#
# Include the dependency files, should be place the last of makefile
#
sinclude $(shell $(MKDIR) $(X_OBJ) $(X_OUT)) $(X_DEPS)

安装平头哥官网提供的riscv64 windows版的交叉编译工具链,通过cmd make命令编译工程,出现如下错误:
_20210721-1337.png
Makeflie如下:
Makefile.rar
求大佬解答

离线

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn