From 816e54f4510cd5256970dd0e310dda2692e55f72 Mon Sep 17 00:00:00 2001 From: Rose Thompson Date: Mon, 14 Oct 2024 21:29:02 -0500 Subject: [PATCH 1/4] Revert "Revmoed file from fpga zbbl which should not have been added." This reverts commit d6944cdaa46aeacfa095a2da1926d0974efb369e. --- fpga/zsbl/bios.S | 102 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 fpga/zsbl/bios.S diff --git a/fpga/zsbl/bios.S b/fpga/zsbl/bios.S new file mode 100644 index 000000000..a7283b38d --- /dev/null +++ b/fpga/zsbl/bios.S @@ -0,0 +1,102 @@ +#include "system.h" + +PERIOD = (SYSTEMCLOCK / 2) + +.section .init +.global _start +.type _start, @function + + +_start: + # Initialize global pointer + .option push + .option norelax + 1:auipc gp, %pcrel_hi(__global_pointer$) + addi gp, gp, %pcrel_lo(1b) + .option pop + + li x1, 0 + li x2, 0 + li x4, 0 + li x5, 0 + li x6, 0 + li x7, 0 + li x8, 0 + li x9, 0 + li x10, 0 + li x11, 0 + li x12, 0 + li x13, 0 + li x14, 0 + li x15, 0 + li x16, 0 + li x17, 0 + li x18, 0 + li x19, 0 + li x20, 0 + li x21, 0 + li x22, 0 + li x23, 0 + li x24, 0 + li x25, 0 + li x26, 0 + li x27, 0 + li x28, 0 + li x29, 0 + li x30, 0 + li x31, 0 + + + # set the stack pointer to the top of memory - 8 bytes (pointer size) + li sp, (EXT_MEM_END - 8) + + li a0, 0x00000000 + li a1, EXT_MEM_BASE + #li a2, 128*1024*1024/512 # copy 128MB + li a2, 127*1024*1024/512 # copy 127MB upper 1MB contains the return address (ra) + #li a2, 800 # copy 400KB + jal ra, copyFlash + + fence.i + # now toggle led so we know the copy completed. + + # write to gpio + li t2, 0xFF + la t3, 0x1006000C + li t4, 5 + +loop: + + # delay + li t0, PERIOD/2 +delay1: + addi t0, t0, -1 + bge t0, x0, delay1 + sw t2, 0x0(t3) + + li t0, PERIOD/2 +delay2: + addi t0, t0, -1 + bge t0, x0, delay2 + sw x0, 0x0(t3) + + addi t4, t4, -1 + bgt t4, x0, loop + + + # now that the card is copied and the led toggled we + # jump to the copied contents of the sd card. + +jumpToLinux: + csrrs a0, 0xF14, x0 # copy hart ID to a0 + li a1, FDT_ADDRESS # This is the device tree address + la a2, end_of_bios + li t0, EXT_MEM_BASE # start of code + + jalr x0, t0, 0 + +end_of_bios: + + + + From 86ec7f609b1ae9d3f0c6323f34cc9d54f0deef4a Mon Sep 17 00:00:00 2001 From: Rose Thompson Date: Mon, 14 Oct 2024 22:06:38 -0500 Subject: [PATCH 2/4] Updated FPGA readme. --- fpga/README.md | 71 +++++++++++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 32 deletions(-) diff --git a/fpga/README.md b/fpga/README.md index dfa27479e..fbe9876cc 100644 --- a/fpga/README.md +++ b/fpga/README.md @@ -1,46 +1,53 @@ -The FPGA currently only targets the VCU118 board. +Wally supports the following boards -* Build Process +ArtyA7 +vcu108 +vcu118 + +* Quick Start + +** build FPGA cd generator -make +make -* Description +example +make vcu108 -The generator makefile creates 4 IP blocks; proc_sys_reset, ddr4, -axi_clock_converter, and ahblite_axi_bridge. Then it reads in the 4 IP blocks -and builds wally. fpga/src/fpgaTop.v is the top level which instanciates -wallypipelinedsoc.sv and the 4 IP blocks. The FPGA include and ILA (In logic -analyzer) which provides the current instruction PCM, instrM, etc along with -a large number of debuging signals. +** Make flash card image +ls /dev/sd* or ls /dev/mmc* to see which flash card devices you have. +Insert the flash card into the reader and ls /dev/sd* or /dev/mmc* again. The new device is the one you want to use. Make sure you select the root device (i.e. /dev/sdb) not the partition (i.e. /dev/sdb1). +cd $WALLY/linux/sd-card +This following script requires root. +./flash-sd.sh -b -d -* Programming the flash card -You'll need to write the linux image to the flash card. Use the convert2bin.py -script in linux-testgen/linux-testvectors/ [*** moved?] to convert the ram.txt -file from QEMU's preload to generate the binary. Then to copy - sudo dd if=ram.bin of=. +example with vcu108, buildroot installed to /opt/riscv/buildroot, and the flash card is device /dev/sdc +./flash-sd.sh -b /opt/riscv/buildroot -d /opt/riscv/buildroot/output/images/wally-vcu108.dtb /dev/sdc -* Loading the FPGA +Wait until the the script completes then remove the car. -After the build process is complete about 2 hrs on an i9-7900x. Launch vivado's -gui and open the WallyFPGA.xpr project file. Open the hardware manager under -program and debug. Open target and then program with the bit file. +** FPGA setup -* Test Run +For the Arty A7 insert the PMOD daughter board into the right most slot and insert the sd card. -Once the FPGA is programed the 3 MSB LEDs in the upper right corner provide -status of the reset and ddr4 calibration. LED 7 should always be lit. -LED 6 will light if the DDR4 is not calibrated. LED 6 will be lit once -wally begins running. +For the VCU108 and VCU118 boards insert the PMOD daughter board into the only PMOD slot on the right side of the boards. -Next the bootloader program will copy the flash card into the DDR4 memory. -When this done the lower 5 LEDs will blink 5 times and then try to boot -the program loaded in the DDR4 memory at physical address 0x8000_0000. +Power on the boards. Arty A7 just plug in the USB connector. For the VCU boards make sure the power supply is connected and the two usb cables are connected. Flip on the switch. +The VCU118's on board UART converter does not work. Use a spark fun FTDI usb to UART adapter and plug into the mail PMOD on the right side of the board. Also the level sifters on the +VCU118 do not work correctly with the digilent sd PMOD board. We have a custom board which works instead. -* Connecting uart -You'll need to connect both usb cables. The first connects the FPGA programer -while the connect connects UART. UART is configured to use 57600 baud with -no parity, 8 data bits, and 1 stop bit. sudo screen /dev/ttyUSB1 57600 should -let you view the com port. +cd $WALLY/fpga/generator +vivado & +open the design in the current directory WallyFPGA.xpr. + +Then click "Open Target" under "PROGRAM AND DEBUG". Then Program the device. + +** Connect to UART + +In another terminal ls /dev/ttyUSB*. One of these devices will be the UART connected to Wally. You may have to experiment by the running the following command multiple times. + +screen /dev/ttyUSB1 115200 + +Swap out the USB1 for USB0 or USB1 as needed. From cdc0ecc87c2c0a03bd005f00f93c23a5d40799a8 Mon Sep 17 00:00:00 2001 From: Rose Thompson Date: Mon, 14 Oct 2024 22:08:09 -0500 Subject: [PATCH 3/4] FPGA readme now in markdown. --- fpga/README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fpga/README.md b/fpga/README.md index fbe9876cc..3651661f0 100644 --- a/fpga/README.md +++ b/fpga/README.md @@ -4,9 +4,9 @@ ArtyA7 vcu108 vcu118 -* Quick Start +# Quick Start -** build FPGA +## build FPGA cd generator make @@ -14,7 +14,7 @@ make example make vcu108 -** Make flash card image +## Make flash card image ls /dev/sd* or ls /dev/mmc* to see which flash card devices you have. Insert the flash card into the reader and ls /dev/sd* or /dev/mmc* again. The new device is the one you want to use. Make sure you select the root device (i.e. /dev/sdb) not the partition (i.e. /dev/sdb1). cd $WALLY/linux/sd-card @@ -26,7 +26,7 @@ example with vcu108, buildroot installed to /opt/riscv/buildroot, and the flash Wait until the the script completes then remove the car. -** FPGA setup +## FPGA setup For the Arty A7 insert the PMOD daughter board into the right most slot and insert the sd card. @@ -43,7 +43,7 @@ open the design in the current directory WallyFPGA.xpr. Then click "Open Target" under "PROGRAM AND DEBUG". Then Program the device. -** Connect to UART +## Connect to UART In another terminal ls /dev/ttyUSB*. One of these devices will be the UART connected to Wally. You may have to experiment by the running the following command multiple times. From fed88f6b175a0ee537f69651655c4950a6368cac Mon Sep 17 00:00:00 2001 From: Rose Thompson Date: Mon, 14 Oct 2024 22:10:28 -0500 Subject: [PATCH 4/4] Better formatting for readme. --- fpga/README.md | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/fpga/README.md b/fpga/README.md index 3651661f0..236bc7ddb 100644 --- a/fpga/README.md +++ b/fpga/README.md @@ -1,28 +1,32 @@ Wally supports the following boards -ArtyA7 -vcu108 -vcu118 +1. ArtyA7 +2. vcu108 +3. vcu118 (Do not recommend.) # Quick Start ## build FPGA -cd generator -make +`cd generator +make ` example -make vcu108 +`make vcu108` ## Make flash card image ls /dev/sd* or ls /dev/mmc* to see which flash card devices you have. Insert the flash card into the reader and ls /dev/sd* or /dev/mmc* again. The new device is the one you want to use. Make sure you select the root device (i.e. /dev/sdb) not the partition (i.e. /dev/sdb1). -cd $WALLY/linux/sd-card + +`cd $WALLY/linux/sd-card` + This following script requires root. -./flash-sd.sh -b -d + +`./flash-sd.sh -b -d ` example with vcu108, buildroot installed to /opt/riscv/buildroot, and the flash card is device /dev/sdc -./flash-sd.sh -b /opt/riscv/buildroot -d /opt/riscv/buildroot/output/images/wally-vcu108.dtb /dev/sdc + +`./flash-sd.sh -b /opt/riscv/buildroot -d /opt/riscv/buildroot/output/images/wally-vcu108.dtb /dev/sdc` Wait until the the script completes then remove the car. @@ -36,8 +40,8 @@ Power on the boards. Arty A7 just plug in the USB connector. For the VCU boards The VCU118's on board UART converter does not work. Use a spark fun FTDI usb to UART adapter and plug into the mail PMOD on the right side of the board. Also the level sifters on the VCU118 do not work correctly with the digilent sd PMOD board. We have a custom board which works instead. -cd $WALLY/fpga/generator -vivado & +`cd $WALLY/fpga/generator +vivado &` open the design in the current directory WallyFPGA.xpr. @@ -47,7 +51,7 @@ Then click "Open Target" under "PROGRAM AND DEBUG". Then Program the device. In another terminal ls /dev/ttyUSB*. One of these devices will be the UART connected to Wally. You may have to experiment by the running the following command multiple times. -screen /dev/ttyUSB1 115200 +`screen /dev/ttyUSB1 115200` Swap out the USB1 for USB0 or USB1 as needed.