Skip to content
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

Added architecture detection #90

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 5 additions & 15 deletions firmware/chipignite/blink/Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@

#TOOLCHAIN_PATH=/usr/bin/
TOOLCHAIN_PATH=/usr/local/bin/
#TOOLCHAIN_PATH=/opt/riscv32imc/bin/
# TOOLCHAIN_PATH=/ef/apps/bin/

# Set the prefix for `riscvXX-unknown-elf-*`
# On installations using `multilib`, this will be `riscv64` even for compiling to 32-bit targets
TOOLCHAIN_PREFIX=riscv64-unknown-elf
#TOOLCHAIN_PREFIX=riscv32
ARCH=rv32i
#ARCH=rv32i_zicsr
# Set compilation variables
include ../../environment.mk

# ---- Test patterns for project raven ----

Expand All @@ -20,9 +10,9 @@ PATTERN = blink
hex: ${PATTERN:=.hex}

%.elf: %.c ../sections.lds ../crt0_vex.S
#$(TOOLCHAIN_PATH)riscv32-unknown-elf-gcc -O0 -march=rv32i -Wl,-Bstatic,-T,../sections.lds,--strip-debug -ffreestanding -nostdlib -o $@ ../start.s ../print_io.c $<
$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)-gcc -I../ -I../generated/ -O0 -mabi=ilp32 -march=$(ARCH) -D__vexriscv__ -Wl,-Bstatic,-T,../sections.lds,--strip-debug -ffreestanding -nostdlib -o $@ ../crt0_vex.S ../isr.c ../stub.c $<
${TOOLCHAIN_PATH}$(TOOLCHAIN_PREFIX)-objdump -D blink.elf > blink.lst
#$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)-unknown-elf-gcc -O0 -march=$(TARGET_ARCH) -Wl,-Bstatic,-T,../sections.lds,--strip-debug -ffreestanding -nostdlib -o $@ ../start.s ../print_io.c $<
$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)-unknown-elf-gcc -I../ -I../generated/ -O0 -mabi=ilp32 -march=$(TARGET_ARCH) -D__vexriscv__ -Wl,-Bstatic,-T,../sections.lds,--strip-debug -ffreestanding -nostdlib -o $@ ../crt0_vex.S ../isr.c ../stub.c $<
${TOOLCHAIN_PATH}$(TOOLCHAIN_PREFIX)-unknown-elf-objdump -D blink.elf > blink.lst

%.hex: %.elf
$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)-objcopy -O verilog $< $@
Expand Down
28 changes: 28 additions & 0 deletions firmware/environment.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#======================================
# environment.mk
#======================================
# Sets environment variables for
# RISCV compilation

# USERS: CHANGE BELOW FOLLOWING LINE
#----------------------------------------------------

# Set path to RISCV toolchain
TOOLCHAIN_PATH=/usr/local/bin/

# Set prefix of RISCV toolchain
TOOLCHAIN_PREFIX=riscv64
#----------------------------------------------------
# USERS: CHANGE ABOVE PREVIOUS LINE

# Set architecture target based on version
RV_GCC=$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)-unknown-elf-gcc

# Get version, and see if it's greater than 11.1.0
NEED_ZICSR=$(shell expr `$(RV_GCC) -dumpversion | sed -e 's/\.\([0-9][0-9]\)/\1/g' -e 's/\.\([0-9]\)/0\1/g' -e 's/^[0-9]\{3,4\}$$/&00/'` \>= 110100)

ifeq "$(NEED_ZICSR)" "1"
TARGET_ARCH=rv32i_zicsr
else
TARGET_ARCH=rv32i
endif
23 changes: 8 additions & 15 deletions firmware/gf180/blink/Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@

#TOOLCHAIN_PATH=/usr/bin/
TOOLCHAIN_PATH=/usr/local/bin/
#TOOLCHAIN_PATH=/opt/riscv32imc/bin/
# TOOLCHAIN_PATH=/ef/apps/bin/

# Set the prefix for `riscvXX-unknown-elf-*`
# On installations using `multilib`, this will be `riscv64` even for compiling to 32-bit targets
TOOLCHAIN_PREFIX=riscv64-unknown-elf
#TOOLCHAIN_PREFIX=riscv32
# Set compilation variables
include ../../environment.mk

# ---- Test patterns for project raven ----

Expand All @@ -18,17 +11,17 @@ PATTERN = blink
hex: ${PATTERN:=.hex}

%.elf: %.c ../sections.lds ../crt0_vex.S
#$(TOOLCHAIN_PATH)riscv32-unknown-elf-gcc -O0 -march=rv32i_zicsr -Wl,-Bstatic,-T,../sections.lds,--strip-debug -ffreestanding -nostdlib -o $@ ../start.s ../print_io.c $<
#$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)-gcc -I../ -I../generated/ -O0 -mabi=ilp32 -march=rv32i_zicsr -D__vexriscv__ -Wl,-Bstatic,-T,../sections.lds,--strip-debug -ffreestanding -nostdlib -o $@ ../crt0_vex.S ../isr.c ../stub.c $<
$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)-gcc -I../ -I../generated/ -O0 -mabi=ilp32 -march=rv32i_zicsr -D__vexriscv__ -Wl,-Bstatic,-T,../sections.lds,--strip-debug -ffreestanding -nostdlib -o $@ ../crt0_vex.S ../isr.c $<
${TOOLCHAIN_PATH}$(TOOLCHAIN_PREFIX)-objdump -D blink.elf > blink.lst
#$(TOOLCHAIN_PATH)riscv32-unknown-elf-gcc -O0 -march=$(TARGET_ARCH) -Wl,-Bstatic,-T,../sections.lds,--strip-debug -ffreestanding -nostdlib -o $@ ../start.s ../print_io.c $<
#$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)-gcc -I../ -I../generated/ -O0 -mabi=ilp32 -march=$(TARGET_ARCH) -D__vexriscv__ -Wl,-Bstatic,-T,../sections.lds,--strip-debug -ffreestanding -nostdlib -o $@ ../crt0_vex.S ../isr.c ../stub.c $<
$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)-unknown-elf-gcc -I../ -I../generated/ -O0 -mabi=ilp32 -march=$(TARGET_ARCH) -D__vexriscv__ -Wl,-Bstatic,-T,../sections.lds,--strip-debug -ffreestanding -nostdlib -o $@ ../crt0_vex.S ../isr.c $<
${TOOLCHAIN_PATH}$(TOOLCHAIN_PREFIX)-unknown-elf-objdump -D blink.elf > blink.lst

%.hex: %.elf
$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)-objcopy -O verilog $< $@
$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)-unknown-elf-objcopy -O verilog $< $@
sed -ie 's/@1000/@0000/g' $@

%.bin: %.elf
$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)-objcopy -O binary $< $@
$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)-unknown-elf-objcopy -O binary $< $@

client: client.c
gcc client.c -o client
Expand Down
12 changes: 3 additions & 9 deletions firmware/mpw1/blink/Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@

TOOLCHAIN_PATH=
# TOOLCHAIN_PATH=/opt/riscv32imc/bin/
# TOOLCHAIN_PATH=/ef/apps/bin/

# Set the prefix for `riscvXX-unknown-elf-*`
# On installations using `multilib`, this will be `riscv64` even for compiling to 32-bit targets
TOOLCHAIN_PREFIX?=riscv32
# Set compilation variables
include ../../environment.mk

# ---- Test patterns for project raven ----

Expand All @@ -16,7 +10,7 @@ PATTERN = blink
hex: ${PATTERN:=.hex}

%.elf: %.c ../sections.lds ../start.s
$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)-unknown-elf-gcc -O0 -mabi=ilp32 -march=rv32i_zicsr -Wl,-Bstatic,-T,../sections.lds,--strip-debug -ffreestanding -nostdlib -o $@ ../start.s $<
$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)-unknown-elf-gcc -O0 -mabi=ilp32 -march=$(TARGET_ARCH) -Wl,-Bstatic,-T,../sections.lds,--strip-debug -ffreestanding -nostdlib -o $@ ../start.s $<
${TOOLCHAIN_PATH}$(TOOLCHAIN_PREFIX)-unknown-elf-objdump -D blink.elf > blink.lst

%.hex: %.elf
Expand Down
12 changes: 5 additions & 7 deletions firmware/mpw1/blink2/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@
#
# SPDX-License-Identifier: Apache-2.0

TOOLCHAIN_PATH = /opt/riscv32imc/bin
# TOOLCHAIN_PATH = /ef/apps/bin/
# Set compilation variables
include ../../environment.mk

FIRMWARE_PATH = ..
GCC_PATH?=/ef/apps/bin
GCC_PREFIX?=riscv32-unknown-elf

.SUFFIXES:

Expand All @@ -30,11 +28,11 @@ all: ${PATTERN:=.hex}
hex: ${PATTERN:=.hex}

%.elf: %.s $(FIRMWARE_PATH)/sections.lds
${TOOLCHAIN_PATH}/${GCC_PREFIX}-gcc -O0 -march=rv32i_zicsr -mabi=ilp32 -Wl,-Bstatic,-T,$(FIRMWARE_PATH)/sections.lds,--strip-debug -ffreestanding -nostdlib -o $@ $<
${TOOLCHAIN_PATH}/riscv32-unknown-elf-objdump -D blink2.elf > blink2.lst
${TOOLCHAIN_PATH}${TOOLCHAIN_PREFIX}-unknown-elf-gcc -O0 -march=$(TARGET_ARCH) -mabi=ilp32 -Wl,-Bstatic,-T,$(FIRMWARE_PATH)/sections.lds,--strip-debug -ffreestanding -nostdlib -o $@ $<
${TOOLCHAIN_PATH}${TOOLCHAIN_PREFIX}-unknown-elf-objdump -D blink2.elf > blink2.lst

%.hex: %.elf
${TOOLCHAIN_PATH}/${GCC_PREFIX}-objcopy -O verilog $< $@
${TOOLCHAIN_PATH}${TOOLCHAIN_PREFIX}-unknown-elf-objcopy -O verilog $< $@
# to fix flash base address
sed -i '.orig' -e 's/@10000000/@00000000/g' $@

Expand Down
12 changes: 6 additions & 6 deletions firmware/mpw1/gpio_test/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
TOOLCHAIN_PATH = /opt/riscv32imc/bin/
# TOOLCHAIN_PATH = /ef/apps/bin/
# Set compilation variables
include ../../environment.mk

# ---- Test patterns for project raven ----

Expand All @@ -10,15 +10,15 @@ PATTERN = gpio_test
hex: ${PATTERN:=.hex}

%.elf: %.c ../sections.lds ../start.s ../print_io.c ../print_io.h
$(TOOLCHAIN_PATH)riscv32-unknown-elf-gcc -O0 -march=rv32i_zicsr -Wl,-Bstatic,-T,../sections.lds,--strip-debug -ffreestanding -nostdlib -o $@ ../start.s ../print_io.c $<
${TOOLCHAIN_PATH}/riscv32-unknown-elf-objdump -D gpio_test.elf > gpio_test.lst
$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)-unknown-elf-gcc -O0 -march=$(TARGET_ARCH) -Wl,-Bstatic,-T,../sections.lds,--strip-debug -ffreestanding -nostdlib -o $@ ../start.s ../print_io.c $<
$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)-unknown-elf-objdump -D gpio_test.elf > gpio_test.lst

%.hex: %.elf
$(TOOLCHAIN_PATH)riscv32-unknown-elf-objcopy -O verilog $< $@
$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)-unknown-elf-objcopy -O verilog $< $@
sed -i '.orig' -e 's/@10000000/@00000000/g' $@

%.bin: %.elf
$(TOOLCHAIN_PATH)riscv32-unknown-elf-objcopy -O binary $< $@
$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)-unknown-elf-objcopy -O binary $< $@

client: client.c
gcc client.c -o client
Expand Down
12 changes: 6 additions & 6 deletions firmware/mpw1/hello/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
TOOLCHAIN_PATH = /opt/riscv32imc/bin/
# TOOLCHAIN_PATH = /ef/apps/bin/
# Set compilation variables
include ../../environment.mk

# ---- Test patterns for project raven ----

Expand All @@ -11,15 +11,15 @@ hex: ${PATTERN:=.hex}

#%.elf: %.c ../sections.lds ../start.s spi_io.c spi_io.h ../print_io.c ../print_io.h
%.elf: %.c ../sections.lds ../start.s ../print_io.c ../print_io.h
$(TOOLCHAIN_PATH)riscv32-unknown-elf-gcc -O0 -march=rv32i_zicsr -Wl,-Bstatic,-T,../sections.lds,--strip-debug -ffreestanding -nostdlib -o $@ ../start.s ../print_io.c $<
${TOOLCHAIN_PATH}/riscv32-unknown-elf-objdump -D hello.elf > hello.lst
$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)-unknown-elf-gcc -O0 -march=$(TARGET_ARCH) -Wl,-Bstatic,-T,../sections.lds,--strip-debug -ffreestanding -nostdlib -o $@ ../start.s ../print_io.c $<
$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)-unknown-elf-objdump -D hello.elf > hello.lst

%.hex: %.elf
$(TOOLCHAIN_PATH)riscv32-unknown-elf-objcopy -O verilog $< $@
$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)-unknown-elf-objcopy -O verilog $< $@
sed -i '.orig' -e 's/@10000000/@00000000/g' $@

%.bin: %.elf
$(TOOLCHAIN_PATH)riscv32-unknown-elf-objcopy -O binary $< $@
$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)-unknown-elf-objcopy -O binary $< $@

client: client.c
gcc client.c -o client
Expand Down
12 changes: 5 additions & 7 deletions firmware/mpw1/io_config/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@
#
# SPDX-License-Identifier: Apache-2.0

TOOLCHAIN_PATH = /opt/riscv32imc/bin
# TOOLCHAIN_PATH = /ef/apps/bin/
# Set compilation variables
include ../../environment.mk

FIRMWARE_PATH = ..
GCC_PATH?=/ef/apps/bin
GCC_PREFIX?=riscv32-unknown-elf

.SUFFIXES:

Expand All @@ -30,11 +28,11 @@ all: ${PATTERN:=.hex}
hex: ${PATTERN:=.hex}

%.elf: %.s $(FIRMWARE_PATH)/sections.lds
${TOOLCHAIN_PATH}/${GCC_PREFIX}-gcc -O0 -march=rv32i_zicsr -mabi=ilp32 -Wl,-Bstatic,-T,$(FIRMWARE_PATH)/sections.lds,--strip-debug -ffreestanding -nostdlib -o $@ $<
${TOOLCHAIN_PATH}/riscv32-unknown-elf-objdump -D io_config.elf > io_config.lst
$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)-unknown-elf-gcc -O0 -march=$(TARGET_ARCH) -mabi=ilp32 -Wl,-Bstatic,-T,$(FIRMWARE_PATH)/sections.lds,--strip-debug -ffreestanding -nostdlib -o $@ $<
$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)-unknown-elf-objdump -D io_config.elf > io_config.lst

%.hex: %.elf
${TOOLCHAIN_PATH}/${GCC_PREFIX}-objcopy -O verilog $< $@
$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)-unknown-elf-objcopy -O verilog $< $@
# to fix flash base address
sed -i '.orig' -e 's/@10000000/@00000000/g' $@

Expand Down
12 changes: 3 additions & 9 deletions firmware/mpw2-5/bitbang/Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@

TOOLCHAIN_PATH=
# TOOLCHAIN_PATH=/opt/riscv32imc/bin/
# TOOLCHAIN_PATH=/ef/apps/bin/

# Set the prefix for `riscvXX-unknown-elf-*`
# On installations using `multilib`, this will be `riscv64` even for compiling to 32-bit targets
TOOLCHAIN_PREFIX?=riscv64
# Set compilation variables
include ../../environment.mk

# ---- Test patterns for project raven ----

Expand All @@ -16,7 +10,7 @@ PATTERN = bitbang
hex: ${PATTERN:=.hex}

%.elf: %.c ../sections.lds ../crt0_vex.S
$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)-unknown-elf-gcc -I../ -I../generated/ -O0 -mabi=ilp32 -march=rv32i_zicsr -D__vexriscv__ -Wl,-Bstatic,-T,../sections.lds,--strip-debug -ffreestanding -nostdlib -o $@ ../crt0_vex.S ../isr.c $<
$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)-unknown-elf-gcc -I../ -I../generated/ -O0 -mabi=ilp32 -march=$(TARGET_ARCH) -D__vexriscv__ -Wl,-Bstatic,-T,../sections.lds,--strip-debug -ffreestanding -nostdlib -o $@ ../crt0_vex.S ../isr.c $<
${TOOLCHAIN_PATH}$(TOOLCHAIN_PREFIX)-unknown-elf-objdump -D bitbang.elf > bitbang.lst

%.hex: %.elf
Expand Down
15 changes: 4 additions & 11 deletions firmware/mpw2-5/blink/Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@

TOOLCHAIN_PATH=/usr/local/bin/
#TOOLCHAIN_PATH=/opt/riscv32imc/bin/
# TOOLCHAIN_PATH=/ef/apps/bin/

# Set the prefix for `riscvXX-unknown-elf-*`
# On installations using `multilib`, this will be `riscv64` even for compiling to 32-bit targets
TOOLCHAIN_PREFIX=riscv64
#TOOLCHAIN_PREFIX=riscv32
# Set compilation variables
include ../../environment.mk

VOLTAGE?=$(shell python3 -c "from gpio_config_def import voltage; print(voltage)")

Expand All @@ -19,8 +12,8 @@ PATTERN = blink
hex: ${PATTERN:=.hex}

%.elf: %.c ../sections.lds ../crt0_vex.S
#$(TOOLCHAIN_PATH)riscv32-unknown-elf-gcc -O0 -march=rv32i_zicsr -Wl,-Bstatic,-T,../sections.lds,--strip-debug -ffreestanding -nostdlib -o $@ ../start.s ../print_io.c $<
$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)-unknown-elf-gcc -I../ -I../generated/ -O0 -mabi=ilp32 -march=rv32i_zicsr -D__vexriscv__ -Wl,-Bstatic,-T,../sections.lds,--strip-debug -ffreestanding -nostdlib -o $@ ../crt0_vex.S ../isr.c $<
#$(TOOLCHAIN_PATH)riscv32-unknown-elf-gcc -O0 -march=$(TARGET_ARCH) -Wl,-Bstatic,-T,../sections.lds,--strip-debug -ffreestanding -nostdlib -o $@ ../start.s ../print_io.c $<
$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)-unknown-elf-gcc -I../ -I../generated/ -O0 -mabi=ilp32 -march=$(TARGET_ARCH) -D__vexriscv__ -Wl,-Bstatic,-T,../sections.lds,--strip-debug -ffreestanding -nostdlib -o $@ ../crt0_vex.S ../isr.c $<
${TOOLCHAIN_PATH}$(TOOLCHAIN_PREFIX)-unknown-elf-objdump -D blink.elf > blink.lst

%.hex: %.elf
Expand Down
Loading