Skip to content

Commit

Permalink
toolchain.mk: add RISC-V toolchain downloaded from official release
Browse files Browse the repository at this point in the history
Add "TARGET_ARCH" variable to download either ARM or RISC-V toolchains.
If "TARGET_ARCH" is specified as "riscv", the RISC-V 64-bit toolchain
will be downloaded from riscv-gnu-toolchain repository and decompressed
to toolchains/riscv64 folder.

Signed-off-by: Alvin Chang <[email protected]>
Acked-by: Jerome Forissier <[email protected]>
Acked-by: Jens Wiklander <[email protected]>
  • Loading branch information
gagachang authored and jforissier committed Jul 19, 2023
1 parent 4903234 commit 6902e46
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions toolchain.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ SHELL = /bin/bash
ROOT ?= $(CURDIR)/..
TOOLCHAIN_ROOT ?= $(ROOT)/toolchains
UNAME_M := $(shell uname -m)
TARGET_ARCH ?= arm

# Download toolchain macro for saving some repetition
# $(1) is $AARCH.._PATH : i.e., path to the destination
Expand Down Expand Up @@ -44,6 +45,7 @@ define build_toolchain
endef

ifeq ($(UNAME_M),x86_64)
ifeq ($(TARGET_ARCH),arm)
AARCH32_PATH ?= $(TOOLCHAIN_ROOT)/aarch32
AARCH32_CROSS_COMPILE ?= $(AARCH32_PATH)/bin/arm-linux-gnueabihf-
AARCH32_GCC_VERSION ?= arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-linux-gnueabihf
Expand Down Expand Up @@ -81,6 +83,22 @@ endef
clang-toolchains:
$(call dl-clang,$(CLANG_VER),$(CLANG_PATH))

else ifeq ($(TARGET_ARCH),riscv)
RISCV64_PATH ?= $(TOOLCHAIN_ROOT)/riscv64
RISCV64_CROSS_COMPILE ?= $(RISCV64_PATH)/bin/riscv64-unknown-linux-gnu-
RISCV64_GCC_RELEASE_DATE ?= 2023.07.07
RISCV64_GCC_VERSION ?= riscv64-glibc-ubuntu-22.04-gcc-nightly-$(RISCV64_GCC_RELEASE_DATE)-nightly
SRC_RISCV64_GCC ?= https://github.com/riscv-collab/riscv-gnu-toolchain/releases/download/$(RISCV64_GCC_RELEASE_DATE)/$(RISCV64_GCC_VERSION).tar.gz

.PHONY: toolchains
toolchains: riscv64

.PHONY: riscv64
riscv64:
$(call dltc,$(RISCV64_PATH),$(SRC_RISCV64_GCC),$(RISCV64_GCC_VERSION))

endif

else ifeq ($(UNAME_M),aarch64)

AARCH32_PATH ?= $(TOOLCHAIN_ROOT)/aarch32
Expand Down

0 comments on commit 6902e46

Please sign in to comment.