tinyusb/hw/bsp/ch32v20x/family.mk
hathach 2a67ce773d
change default risv-gcc to riscv-none-elf- and add _zicsr extension
add cmake for ch32v20x, skip freertos examples for CH32V20X, also skip net webserver due to lack of RAM
update to use openocd with wlinke adapter
2024-05-16 19:18:43 +07:00

56 lines
1.7 KiB
Makefile

# https://www.embecosm.com/resources/tool-chain-downloads/#riscv-stable
#CROSS_COMPILE ?= riscv32-unknown-elf-
# Toolchain from https://nucleisys.com/download.php
#CROSS_COMPILE ?= riscv-nuclei-elf-
# Toolchain from https://github.com/xpack-dev-tools/riscv-none-elf-gcc-xpack
CROSS_COMPILE ?= riscv-none-elf-
# Submodules
CH32V20X_SDK = hw/mcu/wch/ch32v20x
DEPS_SUBMODULES += $(CH32V20X_SDK)
# WCH-SDK paths
CH32V20X_SDK_SRC = $(CH32V20X_SDK)/EVT/EXAM/SRC
include $(TOP)/$(BOARD_PATH)/board.mk
CPU_CORE ?= rv32imac-ilp32
CFLAGS += \
-mcmodel=medany \
-ffunction-sections \
-fdata-sections \
-ffat-lto-objects \
-flto \
-DCFG_TUSB_MCU=OPT_MCU_CH32V20X \
-DBOARD_TUD_MAX_SPEED=OPT_MODE_FULL_SPEED \
LDFLAGS_GCC += \
-Wl,--gc-sections \
-nostdlib -nostartfiles \
--specs=nosys.specs --specs=nano.specs \
LD_FILE = $(CH32V20X_SDK_SRC)/Ld/Link.ld
SRC_C += \
src/portable/wch/dcd_ch32_usbfs.c \
$(CH32V20X_SDK_SRC)/Core/core_riscv.c \
$(CH32V20X_SDK_SRC)/Peripheral/src/ch32v20x_gpio.c \
$(CH32V20X_SDK_SRC)/Peripheral/src/ch32v20x_misc.c \
$(CH32V20X_SDK_SRC)/Peripheral/src/ch32v20x_rcc.c \
$(CH32V20X_SDK_SRC)/Peripheral/src/ch32v20x_usart.c \
INC += \
$(TOP)/$(BOARD_PATH) \
$(TOP)/$(CH32V20X_SDK_SRC)/Peripheral/inc \
FREERTOS_PORTABLE_SRC = $(FREERTOS_PORTABLE_PATH)/RISC-V
# wch-link is not supported yet in official openOCD yet. We need to either use
# 1. download openocd as part of mounriver studio http://www.mounriver.com/download or
# 2. compiled from modified source https://github.com/dragonlock2/miscboards/blob/main/wch/SDK/riscv-openocd.tar.xz
OPENOCD ?= $(HOME)/app/riscv-openocd-wch/src/openocd
flash: $(BUILD)/$(PROJECT).elf
$(OPENOCD) -f $(TOP)/$(FAMILY_PATH)/wch-riscv.cfg -c init -c halt -c "flash write_image $<" -c reset -c exit