队伍名: 杰彬伟, 队伍编号: CICC3867
最近板子还没到, 就先试了试蜂鸟SDK, 在按照QuickStart进行操作时发现跑不通. 可能是因为版本迭代问题, 查了查错, 做了修改, 在这里分享一下. 我们使用的是riscv-nuclei-elf-gcc (GCC) 10.2.0和0.1.3版本的SDK.
按照Makefile variables passed by make command中给出来的参数列表, 我们用的是muc200t(对应的SOC是v2), 因此在Build Application一节中输入
$ make SOC=hbirdv2 BOARD=hbird_mcu_200t CORE=e203 all
之后, 会有如下报错
ab04@debian:~/hbird-sdk/application/baremetal/helloworld$ make SOC=hbirdv2 BOARD=hbird_mcu_200t CORE=e203 all
Obtaining addtional make variables from ../../../Build/Makefile.global
../../../SoC/hbirdv2/build.mk:14: *** The openocd configuration file ../../../SoC/hbirdv2/Board/hbird_mcu_200t/openocd_hbirdv2.cfg for hbirdv2 doesn't exist, please check!. Stop.
cd到Board目录下发现有个名为mcu200t的文件夹, 显然Makefile中是将BOARD参数作为路径的一部分进行路径查找了, 因此将BOARD改为mcu200t就解决了. 当然重新make还会有错误, 接下来会继续分析.
在QuickStart中, 让我们设置了$NUCLEI_TOOL_ROOT这一环境变量, 但经过第1节的改动会, 会出现如下报错:
Assembling : ../../../SoC/hbird/Common/Source/GCC/intexc_hbird.S
make: riscv-nuclei-elf-gcc: No such file or directory
经过对Makefile的一定分析后, 在Makefile.conf文件中发现了如下代码:
COMPILE_PREFIX ?= riscv-nuclei-elf-
NUCLEI_SDK_TOOL_ROOT ?= $(NUCLEI_SDK_ROOT)/prebuilt_tools
NUCLEI_RISCV_GCC_ROOT ?= $(NUCLEI_SDK_TOOL_ROOT)/gcc
NUCLEI_OPENOCD_ROOT ?= $(NUCLEI_SDK_TOOL_ROOT)/openocd
NUCLEI_SDK_TOOL_ROOT_EXIST = 0
ifneq ($(wildcard $(NUCLEI_RISCV_GCC_ROOT)),)
ifneq ($(wildcard $(NUCLEI_OPENOCD_ROOT)),)
NUCLEI_SDK_TOOL_ROOT_EXIST = 1
endif
endif
ifeq ($(NUCLEI_SDK_TOOL_ROOT_EXIST),1)
CC := $(abspath $(NUCLEI_RISCV_GCC_ROOT)/bin/$(COMPILE_PREFIX)gcc)
CXX := $(abspath $(NUCLEI_RISCV_GCC_ROOT)/bin/$(COMPILE_PREFIX)g++)
OBJDUMP := $(abspath $(NUCLEI_RISCV_GCC_ROOT)/bin/$(COMPILE_PREFIX)objdump)
OBJCOPY := $(abspath $(NUCLEI_RISCV_GCC_ROOT)/bin/$(COMPILE_PREFIX)objcopy)
GDB := $(abspath $(NUCLEI_RISCV_GCC_ROOT)/bin/$(COMPILE_PREFIX)gdb)
AR := $(abspath $(NUCLEI_RISCV_GCC_ROOT)/bin/$(COMPILE_PREFIX)ar)
SIZE := $(abspath $(NUCLEI_RISCV_GCC_ROOT)/bin/$(COMPILE_PREFIX)size)
OPENOCD := $(abspath $(NUCLEI_OPENOCD_ROOT)/bin/openocd)
else
CC := $(COMPILE_PREFIX)gcc
CXX := $(COMPILE_PREFIX)g++
OBJDUMP := $(COMPILE_PREFIX)objdump
OBJCOPY := $(COMPILE_PREFIX)objcopy
GDB := $(COMPILE_PREFIX)gdb
AR := $(COMPILE_PREFIX)ar
SIZE := $(COMPILE_PREFIX)size
说明新版本的SDK中使用了$NUCLEI_SDK_ROOT作为新的环境变量, 并且还可以根据上述代码发现软件目录组织也有所更改, 修改如下.
在教程的Nuclei基础下, 新建prebuilt_tools文件夹, 然后将gcc和openocd的软件目录都放进去, 然后$NUCLEI_SDK_ROOT依然设定为Nuclei文件夹的路径(按理说Makefile是支持~作为home目录的, 但不知道为什么没通过, 改为绝对路径后通过了)
lab04@debian:~/software/Nuclei/prebuilt_tools$ ls
gcc openocd
lab04@debian:~/software/Nuclei/prebuilt_tools$ pwd
/home/lab04/software/Nuclei/prebuilt_tools
然后重新用make命令来编译就通过了:
lab04@debian:~/hbird-sdk/application/baremetal/helloworld$ make SOC=hbirdv2 BOARD=mcu200t CORE=e203 all
Obtaining addtional make variables from ../../../Build/Makefile.global
Current Configuration: RISCV_ARCH=rv32imac RISCV_ABI=ilp32 SOC=hbirdv2 BOARD=mcu200t CORE=e203 DOWNLOAD=ilm
Assembling : ../../../SoC/hbirdv2/Common/Source/GCC/intexc_hbirdv2.S
Assembling : ../../../SoC/hbirdv2/Common/Source/GCC/startup_hbirdv2.S
Compiling : ../../../SoC/hbirdv2/Common/Source/Drivers/hbirdv2_gpio.c
Compiling : ../../../SoC/hbirdv2/Common/Source/Drivers/hbirdv2_i2c.c
Compiling : ../../../SoC/hbirdv2/Common/Source/Drivers/hbirdv2_pwm.c
Compiling : ../../../SoC/hbirdv2/Common/Source/Drivers/hbirdv2_spi.c
Compiling : ../../../SoC/hbirdv2/Common/Source/Drivers/hbirdv2_uart.c
Compiling : ../../../SoC/hbirdv2/Common/Source/Drivers/htif.c
Compiling : ../../../SoC/hbirdv2/Common/Source/Stubs/clock_getres.c
Compiling : ../../../SoC/hbirdv2/Common/Source/Stubs/clock_gettime.c
Compiling : ../../../SoC/hbirdv2/Common/Source/Stubs/clock_settime.c
Compiling : ../../../SoC/hbirdv2/Common/Source/Stubs/close.c
Compiling : ../../../SoC/hbirdv2/Common/Source/Stubs/execve.c
Compiling : ../../../SoC/hbirdv2/Common/Source/Stubs/exit.c
Compiling : ../../../SoC/hbirdv2/Common/Source/Stubs/fork.c
Compiling : ../../../SoC/hbirdv2/Common/Source/Stubs/fstat.c
Compiling : ../../../SoC/hbirdv2/Common/Source/Stubs/getpid.c
Compiling : ../../../SoC/hbirdv2/Common/Source/Stubs/gettimeofday.c
Compiling : ../../../SoC/hbirdv2/Common/Source/Stubs/isatty.c
Compiling : ../../../SoC/hbirdv2/Common/Source/Stubs/kill.c
Compiling : ../../../SoC/hbirdv2/Common/Source/Stubs/link.c
Compiling : ../../../SoC/hbirdv2/Common/Source/Stubs/lseek.c
Compiling : ../../../SoC/hbirdv2/Common/Source/Stubs/open.c
Compiling : ../../../SoC/hbirdv2/Common/Source/Stubs/read.c
Compiling : ../../../SoC/hbirdv2/Common/Source/Stubs/sbrk.c
Compiling : ../../../SoC/hbirdv2/Common/Source/Stubs/stat.c
Compiling : ../../../SoC/hbirdv2/Common/Source/Stubs/times.c
Compiling : ../../../SoC/hbirdv2/Common/Source/Stubs/unlink.c
Compiling : ../../../SoC/hbirdv2/Common/Source/Stubs/wait.c
Compiling : ../../../SoC/hbirdv2/Common/Source/Stubs/write.c
Compiling : ../../../SoC/hbirdv2/Common/Source/hbirdv2_common.c
Compiling : ../../../SoC/hbirdv2/Common/Source/system_hbirdv2.c
Linking : helloworld.elf
text data bss dec hex filename
9338 116 2388 11842 2e42 helloworld.elf
编译通过, 输出了helloworld.elf.