-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Riscv ecp5 #12
Open
mubes
wants to merge
11
commits into
arturo182:master
Choose a base branch
from
mubes:riscv_ecp5
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Riscv ecp5 #12
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
07d1d30
Initial ecp5 uf2 support
mubes 490898b
Print cleanup
mubes 97c2063
Working system using PROGRAMN to enter application
mubes 2df372b
Addition of two-image booting (application or uf2 booter)
mubes 234ec3c
Resync with master
mubes d2f98a7
Addition of hf2 support for ecp5 from kbeckmann
mubes c678f6d
Various tidying
mubes 54c5064
Various small changes as a result of integration test
mubes 35427ac
Edits for release following integration test
mubes da78847
Tidy and update of project cross-reference
mubes ad6eef6
Fix silly isr issue
mubes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,254 @@ | ||
TINYUSB_PATH ?= lib/tinyusb | ||
# This is the root makefile. It calls in the following files; | ||
# | ||
# 1) hw/bsp/ <BOARD> /board.mk | ||
# Configuration of the board details. | ||
# (Sets details of the family, member and variant, and compiler to use) | ||
# | ||
# 2) hw/chip/ <FAMILY> / <MEMBER> / <VARIANT>.mk | ||
# Configuration of the specific chip details. | ||
# Sets external directories if these were not set on the command line | ||
# Includes specific files and link options for that variant | ||
# | ||
# 3) hw/chip/ <FAMILY> /family.mk | ||
# Configuration of the chip family details. | ||
# | ||
# In general, things go in this file if they are generic to the whole of tinyufs, | ||
# into the family makefile if they are generic across a family, and the variant | ||
# file for chip specifics. | ||
# | ||
# All of the configuration for a specific board is stored in the board file. | ||
|
||
# Force using the local board directory | ||
TOP := $(shell realpath `pwd`) | ||
include $(TINYUSB_PATH)/examples/make.mk | ||
TOP := ./ | ||
TINYUSB_PATH ?= $(TOP)/lib/tinyusb | ||
|
||
INC += \ | ||
hw \ | ||
hw/bsp \ | ||
hw/bsp/$(BOARD) \ | ||
src \ | ||
lib/tinyusb/tools \ | ||
_build/build-$(BOARD) | ||
# Set to 1 to get noisy makefile output | ||
V ?= 0 | ||
|
||
SRC_C = \ | ||
$(addprefix $(CURRENT_PATH)/, $(wildcard src/*.c)) | ||
#-------------- Select the board to build for. ------------ | ||
|
||
CFLAGS += -Wno-unused-parameter | ||
BOARD_LIST = $(sort $(subst /.,,$(subst $(TOP)/hw/bsp/,,$(wildcard $(TOP)/hw/bsp/*/.)))) | ||
|
||
ifeq ($(filter $(BOARD),$(BOARD_LIST)),) | ||
$(info You must provide a BOARD parameter with 'BOARD=', supported boards are:) | ||
$(foreach b,$(BOARD_LIST),$(info - $(b))) | ||
$(error Invalid BOARD specified) | ||
endif | ||
|
||
# Handy check parameter function | ||
check_defined = \ | ||
$(strip $(foreach 1,$1, \ | ||
$(call __check_defined,$1,$(strip $(value 2))))) | ||
__check_defined = \ | ||
$(if $(value $1),, \ | ||
$(error Undefined make flag: $1$(if $2, ($2)))) | ||
|
||
# Build directory | ||
BUILD = _build/$(BOARD) | ||
|
||
# Get Board identifier and specific defines | ||
include $(TOP)/hw/bsp/$(BOARD)/board.mk | ||
|
||
#-------------- Source files generic across all targets -------------- | ||
|
||
SRC_C += $(subst $(TOP)/,,$(wildcard $(TOP)/hw/bsp/$(BOARD)/*.c)) | ||
SRC_C += $(subst $(TOP)/,,$(wildcard $(TOP)/src/*.c)) | ||
SRC_C += $(subst $(TOP)/,,$(wildcard $(TOP)/hw/chip/$(TUF2_CHIP_FAMILY)/*.c)) | ||
|
||
# TinyUSB Stack source | ||
SRC_C += \ | ||
$(TINYUSB_PATH)/src/tusb.c \ | ||
$(TINYUSB_PATH)/src/common/tusb_fifo.c \ | ||
$(TINYUSB_PATH)/src/device/usbd.c \ | ||
$(TINYUSB_PATH)/src/device/usbd_control.c \ | ||
$(TINYUSB_PATH)/src/class/cdc/cdc_device.c \ | ||
$(TINYUSB_PATH)/src/class/dfu/dfu_rt_device.c \ | ||
$(TINYUSB_PATH)/src/class/hid/hid_device.c \ | ||
$(TINYUSB_PATH)/src/class/midi/midi_device.c \ | ||
$(TINYUSB_PATH)/src/class/msc/msc_device.c \ | ||
$(TINYUSB_PATH)/src/class/net/net_device.c \ | ||
$(TINYUSB_PATH)/src/class/usbtmc/usbtmc_device.c \ | ||
$(TINYUSB_PATH)/src/class/vendor/vendor_device.c \ | ||
$(TINYUSB_PATH)/src/portable/$(VENDOR)/$(CHIP_FAMILY)/dcd_$(CHIP_FAMILY).c | ||
|
||
# Compiler Flags which are generic across all targets | ||
CFLAGS += \ | ||
-fdata-sections \ | ||
-ffunction-sections \ | ||
-fsingle-precision-constant \ | ||
-fno-strict-aliasing \ | ||
-Wdouble-promotion \ | ||
-Wstrict-prototypes \ | ||
-Wall \ | ||
-Wextra \ | ||
-Werror \ | ||
-Werror-implicit-function-declaration \ | ||
-Wfloat-equal \ | ||
-Wundef \ | ||
-Wshadow \ | ||
-Wwrite-strings \ | ||
-Wsign-compare \ | ||
-Wmissing-format-attribute \ | ||
-Wno-unused-parameter \ | ||
-Wunreachable-code \ | ||
-ffreestanding | ||
|
||
# Compiler flags for defining UF2 configuration | ||
CFLAGS += \ | ||
-DAPP_START_ADDRESS=$(APP_START_ADDRESS) \ | ||
-DBOARD_FLASH_BASE=$(BOARD_FLASH_BASE) \ | ||
-DUF2_FAMILY=$(UF2_FAMILY) \ | ||
-DCFG_TUSB_MCU=$(TUSB_MCU) | ||
|
||
LDFLAGS += $(CFLAGS) -fshort-enums -Wl,$(LD_FILE) -Wl,[email protected] -Wl,-cref -Wl,-gc-sections | ||
|
||
# Debugging/Optimization | ||
ifeq ($(DEBUG), 1) | ||
LDFLAGS += specs=rdimon.specs | ||
else | ||
LDFLAGS += -specs=nosys.specs -specs=nano.specs | ||
endif | ||
|
||
ASFLAGS += $(CFLAGS) | ||
|
||
# Include directories which are generic across all targets | ||
INC += -I$(TOP)/hw \ | ||
-I$(TOP)/hw/bsp \ | ||
-I$(TOP)/hw/bsp/$(BOARD) \ | ||
-I$(TOP)/src \ | ||
-I$(BUILD) \ | ||
-I$(TOP)/hw/chip/$(TUF2_CHIP_FAMILY)/$(TUF2_CHIP_MEMBER) \ | ||
-I$(TINYUSB_PATH)/tools \ | ||
-I$(TINYUSB_PATH)/src | ||
|
||
# Bring in the chip and family files | ||
|
||
include $(TOP)/hw/chip/$(TUF2_CHIP_FAMILY)/$(TUF2_CHIP_MEMBER)/$(TUF2_CHIP_VARIANT).mk | ||
include $(TOP)/hw/chip/$(TUF2_CHIP_FAMILY)/family.mk | ||
|
||
# Can be set by board, default to ARM GCC (done after chip and family in case it's set there) | ||
CROSS_COMPILE ?= arm-none-eabi- | ||
|
||
LIBS += | ||
|
||
############################################################################################### | ||
# Shouldn't be too much to mess with below here... | ||
############################################################################################### | ||
|
||
# Tool selection | ||
CC = $(CROSS_COMPILE)gcc | ||
CXX = $(CROSS_COMPILE)g++ | ||
OBJCOPY = $(CROSS_COMPILE)objcopy | ||
SIZE = $(CROSS_COMPILE)size | ||
MKDIR = mkdir | ||
SED = sed | ||
CP = cp | ||
RM = rm | ||
|
||
# Debugging/Optimization | ||
ifeq ($(DEBUG), 1) | ||
CFLAGS += -g3 -Og -ggdb | ||
else | ||
CFLAGS += -Os | ||
endif | ||
|
||
# TUSB Logging option | ||
ifneq ($(LOG),) | ||
CFLAGS += -DCFG_TUSB_DEBUG=$(LOG) | ||
endif | ||
|
||
UF2_VERSION_BASE = $(shell git describe --always --tags) | ||
$(BUILD)/uf2_version.h: Makefile | ||
@echo "#define UF2_VERSION_BASE \"$(UF2_VERSION_BASE)\""> $@ | ||
|
||
# Assembly files can be name with upper case .S, convert it to .s | ||
SRC_S := $(SRC_S:.S=.s) | ||
|
||
# Due to GCC LTO bug https://bugs.launchpad.net/gcc-arm-embedded/+bug/1747966 | ||
# assembly file should be placed first in linking order | ||
OBJ += $(addprefix $(BUILD)/obj/, $(SRC_S:.s=.o)) | ||
OBJ += $(BUILD)/uf2_version.h | ||
OBJ += $(addprefix $(BUILD)/obj/, $(SRC_C:.c=.o)) | ||
|
||
include $(TOP)/hw/chip/$(TUF2_CHIP_FAMILY)/$(TUF2_CHIP_MEMBER)/$(TUF2_CHIP_VARIANT).mk | ||
include $(TINYUSB_PATH)/tools/top.mk | ||
include $(TINYUSB_PATH)/examples/rules.mk | ||
# Verbose mode | ||
ifeq ("$(V)","1") | ||
QUIET= | ||
else | ||
QUIET=@ | ||
endif | ||
|
||
# Set all as default goal | ||
.DEFAULT_GOAL := all | ||
all: $(BUILD)/$(BOARD)-firmware.bin $(BUILD)/$(BOARD)-firmware.hex size | ||
|
||
uf2: $(BUILD)/$(BOARD)-firmware.uf2 | ||
|
||
OBJ_DIRS = $(sort $(dir $(OBJ))) | ||
$(OBJ): | $(OBJ_DIRS) | ||
$(OBJ_DIRS): | ||
$(QUIET)$(MKDIR) -p $@ | ||
|
||
$(BUILD)/$(BOARD)-firmware.elf: $(OBJ) | ||
$(QUIET)echo LINK $@ | ||
$(QUIET)$(CC) -o $@ $(LDFLAGS) $^ -Wl,--start-group $(LIBS) -Wl,--end-group -Wl,-Map=$(BUILD)/$(BOARD)-firmware.map | ||
|
||
$(BUILD)/$(BOARD)-firmware.bin: $(BUILD)/$(BOARD)-firmware.elf | ||
$(QUIET)echo CREATE $@ | ||
$(QUIET)$(OBJCOPY) -O binary $^ $@ | ||
|
||
$(BUILD)/$(BOARD)-firmware.hex: $(BUILD)/$(BOARD)-firmware.elf | ||
$(QUIET)echo CREATE $@ | ||
$(QUIET)$(OBJCOPY) -O ihex $^ $@ | ||
|
||
$(BUILD)/$(BOARD)-firmware.uf2: $(BUILD)/$(BOARD)-firmware.hex | ||
$(QUIET)echo CREATE $@ | ||
$(PYTHON) $(MFTOP)/tools/uf2/utils/uf2conv.py -f $(UF2_FAMILY) -c -o $@ $^ | ||
|
||
# We set vpath to point to the top of the tree so that the source files | ||
# can be located. By following this scheme, it allows a single build rule | ||
# to be used to compile all .c files. | ||
vpath %.c . $(MFTOP) | ||
$(BUILD)/obj/%.o: %.c | ||
$(QUIET)echo CC $(notdir $@) | ||
$(QUIET)$(CC) $(CFLAGS) $(INC) -c -MD -o $@ $< | ||
$(QUIET)# The following fixes the dependency file. | ||
$(QUIET)# See http://make.paulandlesley.org/autodep.html for details. | ||
$(QUIET)# Regex adjusted from the above to play better with Windows paths, etc. | ||
$(QUIET)$(CP) $(@:.o=.d) $(@:.o=.P); \ | ||
$(SED) -e 's/#.*//' -e 's/^.*: *//' -e 's/ *\\$$//' \ | ||
-e '/^$$/ d' -e 's/$$/ :/' < $(@:.o=.d) >> $(@:.o=.P); \ | ||
$(RM) $(@:.o=.d) | ||
|
||
# ASM sources lower case .s | ||
vpath %.s . $(MFTOP) | ||
$(BUILD)/obj/%.o: %.s | ||
$(QUIET)echo AS $(notdir $@) | ||
$(QUIET)$(CC) -x assembler-with-cpp $(ASFLAGS) -c -o $@ $< | ||
|
||
# ASM sources upper case .S | ||
vpath %.S . $(MFTOP) | ||
$(BUILD)/obj/%.o: %.S | ||
$(QUIET)echo AS $(notdir $@) | ||
$(QUIET)$(CC) -x assembler-with-cpp $(ASFLAGS) -c -o $@ $< | ||
|
||
size: $(BUILD)/$(BOARD)-firmware.elf | ||
-$(QUIET)echo '' | ||
$(QUIET)$(SIZE) $< | ||
-$(QUIET)echo '' | ||
|
||
clean: | ||
$(QUIET)rm -rf $(BUILD) | ||
|
||
$(BUILD)/$(BOARD)-firmware-padded.bin: $(BUILD)/$(BOARD)-firmware.bin | ||
$(QUIET)dd if=/dev/zero of=$(BUILD)/$(BOARD)-firmware-padded.bin bs=1 count=1024 | ||
$(QUIET)cat $(BUILD)/$(BOARD)-firmware.bin >> $(BUILD)/$(BOARD)-firmware-padded.bin | ||
|
||
$(BUILD)/$(BOARD)-firmware-padded.uf2: $(BUILD)/$(BOARD)-firmware-padded.bin | ||
@echo CREATE $@ | ||
$(QUIET)$(PYTHON) $(TOP)/tools/uf2/utils/uf2conv.py -b $(BOARD_FLASH_BASE) -f $(UF2_FAMILY) -c -o $@ $^ | ||
|
||
padded-bin: $(BUILD)/$(BOARD)-firmware-padded.bin | ||
|
||
padded-uf2: $(BUILD)/$(BOARD)-firmware-padded.uf2 | ||
|
||
print-%: | ||
@echo $* is $($*) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
To deploy on colorlight this can be integrated as a replacement bios. | ||
|
||
Simply call up the compiled application as the bios file, as follows; | ||
|
||
./colorlight_5a_75b.py --revision=7.0m --integrated-rom-size=32000 --integrated-sram-size=8192 --uart-baudrate=115200 --with-debug=usb --csr-csv soc_basesoc_colorlight_5a_75b/csr.csv --integrated-sram-size=16384 --ecppack-bootaddr=0x80000 --integrated-rom-file=tinyuf2/_build/colorlight_5a_75b/colorlight_5a_75b-firmware.bin | ||
|
||
...this will then boot by default and spin up a USB drive to copy firmware to. | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
TUF2_CHIP_FAMILY = ecp5 | ||
TUF2_CHIP_MEMBER = vexriscv | ||
TUF2_CHIP_VARIANT = default | ||
APP_START_ADDRESS ?= 0x20080000 | ||
BOARD_FLASH_BASE ?= 0x20080000 | ||
UF2_FAMILY ?= 0x35504345 | ||
TUSB_MCU = OPT_MCU_VALENTYUSB_EPTRI |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#ifndef _BOARD_CONFIG_H_ | ||
#define _BOARD_CONFIG_H_ | ||
#include "mem.h" | ||
|
||
// Basic Data | ||
#define VENDOR_NAME "Orbcode" | ||
#define PRODUCT_NAME "Colorlight_5a_75b" | ||
#define BOARD_ID "Colorlight_5a_75b" | ||
|
||
// Board flash | ||
#define BOARD_FLASH_SIZE SPIFLASH_SIZE | ||
#define BOARD_FLASH_PAGE_SIZE 256 | ||
#include "mem.h" | ||
|
||
// LED | ||
#define LED_STATE_ON 0 | ||
|
||
#endif |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This causes
arm-none-eabi-gcc: error: specs=rdimon.specs: No such file or directory
for me. Sorry but what does this do? never seen this before :). I'm on gcc 9.3.0.