diff options
| author | Uros Majstorovic <majstor@majstor.org> | 2022-09-04 18:09:35 +0200 | 
|---|---|---|
| committer | Uros Majstorovic <majstor@majstor.org> | 2022-09-04 18:09:35 +0200 | 
| commit | 92e6731824cf4286136cb343d538aae4f772fe13 (patch) | |
| tree | 21c12cfbb98f065e1a3fdf527250d178758948df | |
| parent | 4db0527c16502103e04c4091dbd803c55538b52f (diff) | |
upload script fixed for jlink
| -rw-r--r-- | fw/fe310/bsp/metal/Makefile | 13 | ||||
| -rw-r--r-- | fw/fe310/bsp/metal/entry.S | 106 | ||||
| -rw-r--r-- | fw/fe310/bsp/metal/metal.c | 25 | ||||
| -rw-r--r-- | fw/fe310/bsp/openocd.cfg | 2 | ||||
| -rwxr-xr-x | fw/fe310/bsp/upload | 9 | 
5 files changed, 6 insertions, 149 deletions
| diff --git a/fw/fe310/bsp/metal/Makefile b/fw/fe310/bsp/metal/Makefile deleted file mode 100644 index 962d3bc..0000000 --- a/fw/fe310/bsp/metal/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -include ../../common.mk -CFLAGS += -I$(bsp_dir)/include -I$(bsp_dir)/drivers - -%.o: %.c -	$(CC) $(CFLAGS) -c $< - -%.o: %.S -	$(CC) $(CFLAGS) -c $< - -all: entry.o metal.o - -clean: -	rm -f *.o diff --git a/fw/fe310/bsp/metal/entry.S b/fw/fe310/bsp/metal/entry.S deleted file mode 100644 index 97da3fd..0000000 --- a/fw/fe310/bsp/metal/entry.S +++ /dev/null @@ -1,106 +0,0 @@ -/* Copyright 2018 SiFive, Inc */ -/* SPDX-License-Identifier: Apache-2.0 */ - -/* This code executes before _start, which is contained inside the C library. - * In embedded systems we want to ensure that _enter, which contains the first - * code to be executed, can be loaded at a specific address.  To enable this - * feature we provide the '.text.metal.init.enter' section, which is - * defined to have the first address being where execution should start. */ -.section .text.metal.init.enter -.global _enter -_enter: -    .cfi_startproc - -    /* Inform the debugger that there is nowhere to backtrace past _enter. */ -    .cfi_undefined ra - -    /* The absolute first thing that must happen is configuring the global -     * pointer register, which must be done with relaxation disabled because -     * it's not valid to obtain the address of any symbol without GP -     * configured.  The C environment might go ahead and do this again, but -     * that's safe as it's a fixed register. */ -.option push -.option norelax -    la gp, __global_pointer$ -.option pop - -    /* Set up a simple trap vector to catch anything that goes wrong early in -     * the boot process. */ -    la t0, early_trap_vector -    csrw mtvec, t0 -    /* enable chicken bit if core is bullet series*/ -    la t0, __metal_chicken_bit -    beqz t0, 1f -    csrwi 0x7C1, 0 -1: - -    /* There may be pre-initialization routines inside the MBI code that run in -     * C, so here we set up a C environment.  First we set up a stack pointer, -     * which is left as a weak reference in order to allow initialization -     * routines that do not need a stack to be set up to transparently be -     * called. */ -    .weak __metal_stack_pointer -    la sp, __metal_stack_pointer - -    /* Check for an initialization routine and call it if one exists, otherwise -     * just skip over the call entirely.   Note that __metal_initialize isn't -     * actually a full C function, as it doesn't end up with the .bss or .data -     * segments having been initialized.  This is done to avoid putting a -     * burden on systems that can be initialized without having a C environment -     * set up. */ -    .weak __metal_before_start -    la ra, __metal_before_start -    beqz ra, 1f -    jalr ra -1: - -    /* At this point we can enter the C runtime's startup file.  The arguments -     * to this function are designed to match those provided to the SEE, just -     * so we don't have to write another ABI. */ -    csrr a0, mhartid -    li a1, 0 -    li a2, 0 -    call _start - -    /* If we've made it back here then there's probably something wrong.  We -     * allow the METAL to register a handler here. */ -    .weak __metal_after_main -    la ra, __metal_after_main -    beqz ra, 1f -    jalr ra -1: - -    /* If that handler returns then there's not a whole lot we can do.  Just -     * try to make some noise. */ -     la t0, 1f -     csrw mtvec, t0 -1: -     lw t1, 0(x0) -     j 1b - -    .cfi_endproc - -/* For sanity's sake we set up an early trap vector that just does nothing.  If - * you end up here then there's a bug in the early boot code somewhere. */ -.section .text.metal.init.trapvec -.align 2 -early_trap_vector: -    .cfi_startproc -    csrr t0, mcause -    csrr t1, mepc -    csrr t2, mtval -    j early_trap_vector -    .cfi_endproc - -/* The GCC port might not emit a __register_frame_info symbol, which eventually - * results in a weak undefined reference that eventually causes crash when it - * is dereference early in boot.  We really shouldn't need to put this here, - * but to deal with what I think is probably a bug in the linker script I'm - * going to leave this in for now.  At least it's fairly cheap :) */ -.weak __register_frame_info -.global __register_frame_info -.section .text.metal.init.__register_frame_info -__register_frame_info: -    .cfi_startproc -    ret -    .cfi_endproc diff --git a/fw/fe310/bsp/metal/metal.c b/fw/fe310/bsp/metal/metal.c deleted file mode 100644 index 9e1bb3f..0000000 --- a/fw/fe310/bsp/metal/metal.c +++ /dev/null @@ -1,25 +0,0 @@ -#include <sys/cdefs.h> - -#include "encoding.h" -#include "platform.h" -#include "prci_driver.h" - -extern void eos_trap_entry(); - -__attribute__((constructor)) -void metal_init(void) { -    SPI0_REG(SPI_REG_SCKDIV) = 8; - -    PRCI_use_default_clocks(); -    PRCI_use_pll(PLL_REFSEL_HFXOSC, 0, 1, 31, 1, -1, -1, -1); - -    write_csr(mtvec, &eos_trap_entry); -    if (read_csr(misa) & (1 << ('F' - 'A'))) { // if F extension is present -        write_csr(mstatus, MSTATUS_FS); // allow FPU instructions without trapping -        write_csr(fcsr, 0); // initialize rounding mode, undefined at reset -    } -} - -__attribute__((section(".init"))) -void __metal_synchronize_harts() { -} diff --git a/fw/fe310/bsp/openocd.cfg b/fw/fe310/bsp/openocd.cfg index 1205cbd..3e1b40a 100644 --- a/fw/fe310/bsp/openocd.cfg +++ b/fw/fe310/bsp/openocd.cfg @@ -26,7 +26,7 @@ init  if {[ info exists pulse_srst]} {  	ftdi_set_signal nSRST 0  	ftdi_set_signal nSRST z -sleep 1500 +	sleep 1500  }  halt diff --git a/fw/fe310/bsp/upload b/fw/fe310/bsp/upload index a52fc0a..120a72a 100755 --- a/fw/fe310/bsp/upload +++ b/fw/fe310/bsp/upload @@ -14,7 +14,8 @@ do      case "$1"      in      --elf)                 elf="$2";     shift 2;; -    --hex)                 hex="$2";     shift 2;; +    --bin)                 bin="$2";     shift 2;; +    --addr)                addr="$2";    shift 2;;      --openocd)             openocd="$2"; shift 2;;      --openocd-config)      cfg="$2";     shift 2;;      --jlink)               jlink="$2";   shift 2;; @@ -23,9 +24,9 @@ do      esac  done -if [ "$elf" == "" -a "$hex" == "" ] +if [ "$elf" == "" -a "$bin" == "" ]  then -    echo "$0: --elf or --hex is required" >&2 +    echo "$0: --elf or --bin is required" >&2      exit 1  fi @@ -34,7 +35,7 @@ export GDB_PORT=3333  if [ "$jlink" != "" ]  then -echo -e "loadfile $hex\nrnh\nexit" | $jlink -device FE310 -if JTAG -speed 4000 -jtagconf -1,-1 -autoconnect 1 +echo -e "loadfile $bin $addr\nrnh\nexit" | $jlink -device FE310 -if JTAG -speed 4000 -jtagconf -1,-1 -autoconnect 1  else | 
