Skip to content

Commit

Permalink
Move from riscv64-sifive-mee to riscv64-sifive-elf
Browse files Browse the repository at this point in the history
I've added support to our ELF toolchain that replaces the various
features of the MEE toolchain we used to have in a cleaner way.  This
allows us to both ship a single toolchain binary as well as remove some
command line arguments that were required by the MEE toolchain.

This simplifies the MEE's build scripts, and should also simplify users
build scripts as well.

Signed-off-by: Palmer Dabbelt <[email protected]>
  • Loading branch information
palmer-dabbelt committed Aug 15, 2018
1 parent b715980 commit 650d1c3
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 25 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@
*.mk
/return_pass
/return_fail
*.specs
57 changes: 33 additions & 24 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,39 @@
%.c: mee/machine/@[email protected]
%.S: mee/machine/@[email protected]
%.o: mee/machine/@[email protected]
%.c: riscv__menv__mee.specs
%.S: riscv__menv__mee.specs
%.o: riscv__menv__mee.specs
%.c: riscv__mmachine__@[email protected]
%.S: riscv__mmachine__@[email protected]
%.o: riscv__mmachine__@[email protected]

# Every test depends on the generated linker script.
$(check_PROGRAMS): mee-@[email protected]
$(check_PROGRAMS): riscv__mmachine__@[email protected]

# Every test depends on the freshly-compiled library.
$(check_PROGRAMS): libmee-@[email protected]
$(check_PROGRAMS): libriscv__mmachine__@[email protected]

# Generates a linker script that's more reasonable that whatever GCC's default
# is.
ldsdir = $(libdir)
lds_DATA = mee-@[email protected]
mee-@[email protected]: @LDSCRIPT_GENERATOR@ @[email protected]
lds_DATA = riscv__mmachine__@[email protected]
riscv__mmachine__@[email protected]: @LDSCRIPT_GENERATOR@ @[email protected]
$< --dtb $(filter %.dtb,$^) --linker $@

# Generates a SPEC file that sets a reasonable set of default options for this
# build.
specdir = $(libdir)
spec_DATA =

spec_DATA += riscv__mmachine__@[email protected]
riscv__mmachine__@[email protected]: @SPECS_GENERATOR@ @[email protected]
$< --dtb $(filter %.dtb,$^) --specs $@ --prefix @prefix@ --machine @MACHINE_NAME@

spec_DATA += riscv__menv__mee.specs
riscv__menv__mee.specs: riscv__menv__mee.specs.in
cat $^ > $@

# In order to generate code that's actually compatible with a machine we must
# pass the march and mabi arguments to GCC that coorespond to the hardware.
# This is handled by generating a makefile fragment, including it, and then
Expand All @@ -45,6 +64,7 @@ nobase_include_HEADERS = \
mee/compiler.h \
mee/clock.h \
mee/io.h \
mee/machine.h \
mee/shutdown.h \
mee/tty.h \
mee/uart.h
Expand All @@ -64,14 +84,12 @@ mee/machine/@[email protected]: @MEE_HEADER_GENERATOR@ @[email protected]
# Everything in here is compiled into a single library, which contains all the
# source files in the project. It's named for one specific machine, which GCC
# uses to select the target machine that this MEE implementation points at.
lib_LIBRARIES = libmee-@[email protected]
lib_LIBRARIES = libriscv__mmachine__@[email protected]

libmee_@MACHINE_NAME@_a_CFLAGS = -mmee-machine=@MACHINE_NAME@
libmee_@MACHINE_NAME@_a_CFLAGS += -ffunction-sections -fdata-sections
libmee_@MACHINE_NAME@_a_CFLAGS += -march=$(FRAMEWORK_BOARD_DTS_MARCH) -mabi=$(FRAMEWORK_BOARD_DTS_MABI)
libmee_@MACHINE_NAME@_a_CCASFLAGS = $(libmee_@MACHINE_NAME@_a_CFLAGS) -DASSEMBLY
libriscv__mmachine__@MACHINE_NAME@_a_CFLAGS = -menv=mee -mmachine=@MACHINE_NAME@
libriscv__mmachine__@MACHINE_NAME@_a_CCASFLAGS = -menv=mee -mmachine=@MACHINE_NAME@

libmee_@MACHINE_NAME@_a_SOURCES = \
libriscv__mmachine__@MACHINE_NAME@_a_SOURCES = \
src/drivers/fixed-clock.c \
src/drivers/sifive,fe310-g000,hfrosc.c \
src/drivers/sifive,fe310-g000,hfxosc.c \
Expand All @@ -92,37 +110,28 @@ check_PROGRAMS =
# The simplest possible pair of tests: one that passes and one that fails
check_PROGRAMS += return_pass
return_pass_SOURCES = test/return_pass.c
return_pass_CFLAGS = -mmee-machine=@MACHINE_NAME@
return_pass_CFLAGS += -ffunction-sections -fdata-sections
return_pass_CFLAGS += -march=$(FRAMEWORK_BOARD_DTS_MARCH) -mabi=$(FRAMEWORK_BOARD_DTS_MABI)
return_pass_CFLAGS = -menv=mee -mmachine=@MACHINE_NAME@
return_pass_LDFLAGS = -L. -Wl,--gc-sections -Wl,-Map=return_pass.map

check_PROGRAMS += return_fail
return_fail_SOURCES = test/return_fail.c
return_fail_CFLAGS = -mmee-machine=@MACHINE_NAME@
return_fail_CFLAGS += -ffunction-sections -fdata-sections
return_fail_CFLAGS += -march=$(FRAMEWORK_BOARD_DTS_MARCH) -mabi=$(FRAMEWORK_BOARD_DTS_MABI)
return_fail_CFLAGS = -menv=mee -mmachine=@MACHINE_NAME@
return_fail_LDFLAGS = -L. -Wl,--gc-sections -Wl,-Map=return_fail.map

# A simple "Hello, World!" program that directly uses the MEE interface to
# print to the serial terminal.
check_PROGRAMS += hello
hello_SOURCES = test/hello.c
hello_CFLAGS = -mmee-machine=@MACHINE_NAME@
hello_CFLAGS += -ffunction-sections -fdata-sections
hello_CFLAGS += -march=$(FRAMEWORK_BOARD_DTS_MARCH) -mabi=$(FRAMEWORK_BOARD_DTS_MABI)
hello_CFLAGS = -menv=mee -mmachine=@MACHINE_NAME@
hello_LDFLAGS = -L. -Wl,--gc-sections -Wl,-Map=hello.map

check_PROGRAMS += pll_set_hz
pll_set_hz_SOURCES = test/pll_set_hz.c
pll_set_hz_CFLAGS = -mmee-machine=@MACHINE_NAME@
pll_set_hz_CFLAGS += -ffunction-sections -fdata-sections
pll_set_hz_CFLAGS += -march=$(FRAMEWORK_BOARD_DTS_MARCH) -mabi=$(FRAMEWORK_BOARD_DTS_MABI)
pll_set_hz_CFLAGS = -menv=mee -mmachine=@MACHINE_NAME@
pll_set_hz_LDFLAGS = -L. -Wl,--gc-sections -Wl,-Map=pll_set_hz.map

# Extra clean targets
clean-local:
-rm -rf @[email protected]
-rm -rf mee/machine/@[email protected] @[email protected] mee-@[email protected]
-rm -rf return_pass.map return_fail.map
-rm -rf hello.map
-rm -rf *.map *.specs
18 changes: 18 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,24 @@ AS_IF([test "x$MAKEATTRIBUTES_GENERATOR" != "xno"],
[AC_MSG_ERROR([Unable to find freedom-makeattributes-generator, either place it in PATH or try the --with-makeattributes-generator argument.])]
)

# Allows users to specify a path to freedom-mee_specs-generator, which
# generates GCC spec files to control the compilation of MEE based targets.
AC_ARG_WITH([mee_specs-generator],
[AS_HELP_STRING([--with-mee_specs-generator=PATH], [Use the given path to freedom-mee_specs-generator])],
[],
[with_mee_specs_generator=check]
)

AC_ARG_VAR(SPECS_GENERATOR, [The absolute path of the freedom-mee_specs-generator])
AS_IF([test "x$with_mee_specs_generator" == "xcheck"],
[AC_PATH_PROG(SPECS_GENERATOR, freedom-mee_specs-generator, [no])],
[SPECS_GENERATOR=$with_mee_specs_generator]
)
AS_IF([test "x$SPECS_GENERATOR" != "xno"],
[AC_SUBST([SPECS_GENERATOR], "$SPECS_GENERATOR")],
[AC_MSG_ERROR([Unable to find freedom-mee_specs-generator, either place it in PATH or try the --with-mee_specs-generator argument.])]
)

# Generates the remainder of the build system.
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
8 changes: 8 additions & 0 deletions mee/machine.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/* SPDX-License-Identifier: Apache-2.0 */
/* Copyright 2018 SiFive, Inc */

#ifndef __MEE_MACHINE_HEADER
#error "The toolchain must define __MEE_MACHINE_HEADER"
#endif

#include __MEE_MACHINE_HEADER
1 change: 1 addition & 0 deletions riscv__menv__mee.specs.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions src/tty.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/* SPDX-License-Identifier: Apache-2.0 */

#include <mee/uart.h>
#include <mee/machine.h>

#if defined(__MEE_DT_STDOUT_UART_HANDLE)
/* This implementation serves as a small shim that interfaces with the first
Expand Down
2 changes: 1 addition & 1 deletion test/pll_set_hz.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#define PLL_MAX_OUT 320000000

void main() {
#ifdef __ME_DT_SIFIVE_FE310_G000_PLL_HANDLE
#ifdef __MEE_DT_SIFIVE_FE310_G000_PLL_HANDLE
struct mee_clock * pll = __ME_DT_SIFIVE_FE310_G000_PLL_HANDLE;

printf("Test harness for FE310-G000 PLL Set Frequency\n\n");
Expand Down

0 comments on commit 650d1c3

Please sign in to comment.