Skip to content

Commit

Permalink
Merge pull request #164 from jrrk2/ariane-v0.7
Browse files Browse the repository at this point in the history
Main patch to update ariane to latest master branch
  • Loading branch information
jrrk authored Feb 17, 2020
2 parents 7fca746 + b81fef1 commit 3033b01
Show file tree
Hide file tree
Showing 17 changed files with 91 additions and 36 deletions.
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
[submodule "lowrisc-quickstart"]
path = lowrisc-quickstart
url = https://github.com/lowRISC/lowrisc-quickstart.git
[submodule "ariane"]
path = ariane
url = https://github.com/lowRISC/ariane.git
[submodule "buildroot-2019.11.1-lowrisc"]
path = buildroot-2019.11.1-lowrisc
url = https://github.com/lowrisc/buildroot.git
[submodule "ariane"]
path = ariane
url = https://github.com/pulp-platform/ariane.git
16 changes: 12 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ tftp: $(MAINKERNEL)
md5sum $<
echo -e bin \\n put $< $(MD5) \\n | tftp $(REMOTE)

$(MAINKERNEL): $(BUILDROOT)
cp $(BUILDROOT_VER)/rescuefs/images/bbl $@
$(MAINKERNEL): $(BUILDROOT_VER)/rescuefs/images/bbl
cp $< $@

$(BUILDROOT_VER)/rescuefs/images/bbl $(BUILDROOT_VER)/mainfs/images/bbl: $(BUILDROOT)

$(RESCUEKERNEL): $(BUILDROOT)
cp $(BUILDROOT_VER)/mainfs/images/bbl $@
$(RESCUEKERNEL): $(BUILDROOT_VER)/mainfs/images/bbl
cp $< $@

fpga/src/etherboot/$(BOARD)_$(CPU).sv: fpga/src/generic.dts
make -C fpga/src/etherboot BOARD=$(BOARD) CPU=$(CPU) VENDOR=$(VENDOR) MEMSIZE=$(MEMSIZE) PATH=$(RISCV)/bin:/usr/local/bin:/usr/bin:/bin
Expand Down Expand Up @@ -130,6 +132,12 @@ sdcard-install: $(ZROOT)
sdcard-install-debian: $(PWD)/lowrisc-quickstart/rootfs.tar.xz
make -C lowrisc-quickstart/ install-debian USB=$(USB) ROOTFS=$<

$(PWD)/lowrisc-quickstart/rootfs.tar.xz: debian-riscv64/work/makefile.inc
make -C debian-riscv64

debian-riscv64/work/makefile.inc:
git clone -b ariane-v0.7 https://github.com/lowRISC/debian-riscv64.git

firmware:
make -B -C fpga/src/etherboot BOARD=nexys4_ddr BITSIZE=0x400000 XILINX_PART=xc7a100tcsg324-1 XILINX_BOARD=digilentinc.com:nexys4_ddr:part0:1.1 CPU=rocket VENDOR=sifive MEMSIZE=0x8000000 CLK_PERIOD_NS="20" PATH=$(RISCV)/bin:/usr/local/bin:/usr/bin:/bin
make -B -C fpga/src/etherboot BOARD=nexys4_ddr BITSIZE=0x400000 XILINX_PART=xc7a100tcsg324-1 XILINX_BOARD=digilentinc.com:nexys4_ddr:part0:1.1 CPU=ariane VENDOR=ethz MEMSIZE=0x8000000 CLK_PERIOD_NS="20" PATH=$(RISCV)/bin:/usr/local/bin:/usr/bin:/bin
Expand Down
2 changes: 1 addition & 1 deletion ariane
2 changes: 1 addition & 1 deletion buildroot-2019.11.1-lowrisc
4 changes: 2 additions & 2 deletions buildroot-defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ BR2_LINUX_KERNEL_LATEST_VERSION=y
# BR2_LINUX_KERNEL_CUSTOM_HG is not set
# BR2_LINUX_KERNEL_CUSTOM_SVN is not set
BR2_LINUX_KERNEL_VERSION="5.3.18"
BR2_LINUX_KERNEL_PATCH="../rescue-5.3.8.patch"
BR2_LINUX_KERNEL_PATCH="../rescue-5.3.18.patch"
# BR2_LINUX_KERNEL_USE_DEFCONFIG is not set
BR2_LINUX_KERNEL_USE_ARCH_DEFAULT_CONFIG=y
# BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG is not set
Expand Down Expand Up @@ -908,7 +908,7 @@ BR2_PACKAGE_XAPP_XCONSOLE=y
# BR2_PACKAGE_XAPP_XCURSORGEN is not set
# BR2_PACKAGE_XAPP_XDBEDIZZY is not set
# BR2_PACKAGE_XAPP_XDITVIEW is not set
BR2_PACKAGE_XAPP_XDM=y
# BR2_PACKAGE_XAPP_XDM is not set
# BR2_PACKAGE_XAPP_XDPYINFO is not set

#
Expand Down
2 changes: 1 addition & 1 deletion buildroot-rescueconfig
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ BR2_LINUX_KERNEL_LATEST_VERSION=y
# BR2_LINUX_KERNEL_CUSTOM_HG is not set
# BR2_LINUX_KERNEL_CUSTOM_SVN is not set
BR2_LINUX_KERNEL_VERSION="5.3.18"
BR2_LINUX_KERNEL_PATCH="../linux-5.3.8.patch"
BR2_LINUX_KERNEL_PATCH="../linux-5.3.18.patch"
# BR2_LINUX_KERNEL_USE_DEFCONFIG is not set
BR2_LINUX_KERNEL_USE_ARCH_DEFAULT_CONFIG=y
# BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG is not set
Expand Down
4 changes: 2 additions & 2 deletions fpga/src/ariane_soc_pkg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ package ariane_soc;
BTBEntries: 32,
BHTEntries: 128,
// idempotent region
NrNonIdempotentRules: 0,
NrNonIdempotentRules: 1,
NonIdempotentAddrBase: {64'b0},
NonIdempotentLength: {64'b0},
NonIdempotentLength: {DRAMBase},
NrExecuteRegionRules: 3,
ExecuteRegionAddrBase: {DRAMBase, BOOTBase, DebugBase},
ExecuteRegionLength: {DRAMLength, BOOTLength, DebugLength},
Expand Down
2 changes: 1 addition & 1 deletion fpga/src/ariane_xilinx.sv
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ logic [ariane_soc::NumSources-1:0] irq_sources;

`ifdef NEXYS4DDR
`ifdef ARIANE_SHELL
localparam graphmax = 18;
localparam graphmax = 17;
`elsif ROCKET_SHELL
localparam graphmax = 20;
`else
Expand Down
5 changes: 5 additions & 0 deletions fpga/src/etherboot/src/ariane.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ static inline void fence(void)
asm volatile ("fence" ::: "memory");
}

static inline void fence_io(void)
{
asm volatile ("fence io,io" ::: "memory");
}

void eth_main(void);
void sd_main(int sw);
void bt_main(int sw);
Expand Down
42 changes: 35 additions & 7 deletions fpga/src/etherboot/src/boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include "ariane.h"
#include "lowrisc_pitonsd.h"

#define DUMP_REGS

volatile uint64_t *const sd_base = (volatile uint64_t *)SDBase;
volatile uint64_t *const sd_bram = (volatile uint64_t *)(SDBase + 0x8000);

Expand Down Expand Up @@ -161,10 +163,11 @@ void free(void *ptr)

}

#ifdef BIGROM
#ifdef DUMP_REGS
static void pitonsd_dump_regs(void)
{
const char *init_state, *tran_state;
static char init_state_num[10], tran_state_num[10];
const char *init_state = init_state_num, *tran_state = tran_state_num;
char status[99];
int stat = sd_base[_piton_sd_STATUS];
*status = 0;
Expand All @@ -176,6 +179,7 @@ static void pitonsd_dump_regs(void)
if (stat&32) strcat(status," INIT_DONE");
if (stat&64) strcat(status," HCXC");
if (stat&128) strcat(status," DETECT");
#ifdef DUMP_REGS_VERBOSE
switch(sd_base[_piton_sd_INIT_STATE])
{
case 0x0: init_state = "ST_CI_EN_SW_RST"; break;
Expand Down Expand Up @@ -272,6 +276,10 @@ static void pitonsd_dump_regs(void)
case 0xff: init_state = "ST_INIT_ERR"; break;
default: init_state = "UNKNOWN";
}
#else
sprintf(init_state_num, "0x%x", sd_base[_piton_sd_INIT_STATE]);
#endif
#ifdef DUMP_REGS_VERBOSE
switch(sd_base[_piton_sd_TRAN_STATE])
{
case 0x3f: tran_state = "ST_RST"; break;
Expand Down Expand Up @@ -303,6 +311,9 @@ static void pitonsd_dump_regs(void)
case 0x28: tran_state = "ST_CMD24_RD_DATA_ISR"; break;
default: tran_state = "UNKNOWN";
}
#else
sprintf(tran_state_num, "0x%x", sd_base[_piton_sd_TRAN_STATE]);
#endif
printf(
" sd_f: 0x%lx dma_f: 0x%lx status: %s\n"
" resp_vec: 0x%lx init_state: %s counter: 0x%lx\n"
Expand Down Expand Up @@ -335,17 +346,21 @@ DSTATUS disk_initialize (uint8_t pdrv)

/* reset HW state machine */
sd_base[ _piton_sd_SYS_RST ] = 1;

while (_piton_sd_STATUS_INIT_DONE & ~sd_base[_piton_sd_STATUS])
fence_io();
do
{
int init_state = sd_base[_piton_sd_INIT_STATE];
#ifdef BIGROM
#ifdef DUMP_REGS_VERBOSE
printf("init_state = 0x%x\n", init_state);
#endif
#ifdef DUMP_REGS
if (old_init_state != init_state)
pitonsd_dump_regs();
#endif
old_init_state = init_state;
}
#ifdef BIGROM
while (old_init_state != 0xf0);
#ifdef DUMP_REGS
pitonsd_dump_regs();
#endif
return 0;
Expand Down Expand Up @@ -382,6 +397,9 @@ void *memalign(size_t alignment, size_t size)
DRESULT disk_read (uint8_t pdrv, uint8_t *buff, uint32_t sector, uint32_t count)
{
uint64_t vec;
#ifdef DUMP_REGS_VERBOSE
uint64_t stat2;
#endif
uint64_t stat = 0xDEADBEEF;
uint64_t mask = (1 << count) - 1;
/* SD sector address */
Expand All @@ -391,18 +409,28 @@ DRESULT disk_read (uint8_t pdrv, uint8_t *buff, uint32_t sector, uint32_t count)
/* set sector count */
sd_base[ _piton_sd_BLKCNT ] = count;
sd_base[ _piton_sd_REQ_RD ] = 1;
fence_io();
#ifdef DUMP_REGS_VERBOSE
printf("disk_read(0x%x, 0x%x, 0x%x, 0x%x);\n", pdrv, buff, sector, count);
#endif
do
{
#ifdef ISSUE_356
fence(); /* This is needed for a suspected Ariane bug */
#endif
stat = sd_base[_piton_sd_STATUS];
#ifdef DUMP_REGS_VERBOSE
stat2 = sd_base[_piton_sd_STATUS+32];
printf("stat = 0x%x, stat2 = 0x%x\n", stat, stat2);
#endif
}
while (_piton_sd_STATUS_REQ_RDY & ~stat);
sd_base[ _piton_sd_REQ_RD ] = 0;
vec = sd_base[ _piton_sd_ERROR ] & mask;
memcpy(buff, (void *)sd_bram, count*512);
if (vec==mask)
return FR_OK;
#ifdef BIGROM
#ifdef DUMP_REGS
pitonsd_dump_regs();
#endif
return FR_INT_ERR;
Expand Down
3 changes: 2 additions & 1 deletion fpga/src/etherboot/src/dhcp-client.c
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ udp_output(struct udphdr *udp_header, int *len, uint16_t client, uint16_t server
static void
dhcp_output(dhcp_t *dhcp, u_int8_t *mac, int *len)
{
uint32_t mag = __htonl(DHCP_MAGIC_COOKIE);
*len += sizeof(dhcp_t);
memset(dhcp, 0, sizeof(dhcp_t));

Expand All @@ -373,7 +374,7 @@ dhcp_output(dhcp_t *dhcp, u_int8_t *mac, int *len)
dhcp->hlen = 6;
memcpy(dhcp->chaddr, mac, DHCP_CHADDR_LEN);

dhcp->magic_cookie = __htonl(DHCP_MAGIC_COOKIE);
memcpy(&(dhcp->magic_cookie), &mag, sizeof(uint32_t));
}

/*
Expand Down
7 changes: 5 additions & 2 deletions fpga/src/etherboot/src/hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ volatile uint64_t *const bt_base = (volatile uint64_t *)BTBase;

static int addr_int = 0;

enum {lines=30};

void hid_console_putchar(unsigned char ch)
{
enum {lines=30};
int blank = ' '|0x0A00;
uint16_t *hid_vga_ptr = (uint16_t *)hid_fb_ptr;
switch(ch)
Expand Down Expand Up @@ -60,13 +61,15 @@ void uart_console_putchar(unsigned char ch)
write_serial(UARTBase, ch);
}


void hid_init(uint32_t sw)
{
#ifdef ZIFU
int i;
#endif
hid_reg_ptr[LOWRISC_REGS_MODE] = 0x00;
hid_reg_ptr[LOWRISC_REGS_HPIX ] = 6;
hid_reg_ptr[LOWRISC_REGS_VPIX ] = 9;
memset((void *)hid_fb_ptr, 0, lines*256);
#ifdef ZIFU
if (sw&16)
{
Expand Down
2 changes: 1 addition & 1 deletion fpga/src/etherboot/src/lowrisc_pitonsd.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ enum {
_piton_sd_SYS_RST };

enum {
_piton_sd_ADDR_SD_F=32,
_piton_sd_ADDR_SD_F ,
_piton_sd_ADDR_DMA_F ,
_piton_sd_STATUS ,
_piton_sd_ERROR ,
Expand Down
3 changes: 0 additions & 3 deletions fpga/src/etherboot/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
#include "elfriscv.h"
#include "eth.h"

static const uint8_t pattern[] = {0x55, 0xAA, 0x33, 0xcc};

void gpio_leds(uint32_t arg)
{
volatile uint64_t *swp = (volatile uint64_t *)GPIOBase;
Expand Down Expand Up @@ -153,7 +151,6 @@ void qspi_main(int sw)

int main()
{
uint32_t i;
uint32_t sw = gpio_sw();
uint32_t sw2 = gpio_sw();
init_uart(UARTBase, 0x001B);
Expand Down
1 change: 1 addition & 0 deletions fpga/src/etherboot/src/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#define __NEED_MEMCPY
#define __NEED_STRLEN
#define __NEED_STRCPY
#define __NEED_STRCAT

/*
* linux/lib/string.c
Expand Down
25 changes: 18 additions & 7 deletions fpga/src/etherboot/startup.S
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,24 @@ _clr:
trap_entry:
csrr t0, mcause
csrr t1, mepc
la a0, trap_msg
call hid_send_string
mv a0, t1
li a1, 8
call puthex
la a0, cause_msg
call hid_send_string
mv a0, t0
li a1, 2
call puthex
la a0, stars
call hid_send_string
1:
wfi
j 1b
hello:
.ascii "Hello from lowRISC! Please wait a moment...\n\000"
relocmsg:
.ascii "Relocating to DDR memory\n\000"
skiprelocmsg:
.ascii "Skip relocating to DDR memory\n\000"

trap_msg:
.ascii "Trapped to machine mode, PC = \000"
cause_msg:
.ascii ", Cause = \000"
stars:
.ascii " ******** \000"
1 change: 1 addition & 0 deletions sources.inc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ root-dir := $(dir $(mkfile_path))
ariane_pkg := ariane/include/riscv_pkg.sv \
ariane/src/riscv-dbg/src/dm_pkg.sv \
ariane/include/ariane_pkg.sv \
ariane/include/std_cache_pkg.sv \
ariane/include/wt_cache_pkg.sv \
ariane/src/axi/src/axi_pkg.sv \
ariane/src/register_interface/src/reg_intf.sv \
Expand Down

0 comments on commit 3033b01

Please sign in to comment.