An RV32IMF implementation w/ migen/LiteX
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
Risq5/software/testloader.sh

97 lines
4.8 KiB

#!/bin/bash
#
# testloader.sh
# Test data for instruction processing
#
# History:
# --------
# 12.01.21/KQ Initial version
#
PROJECTNAME="risq5" # Adjust w/ local path
if [ -z $1 ]; then
echo "usage: ./testloader.sh <file_w/o_extension>"
echo "example: ./testloader.sh test1 (loaded absolute @40190000h)"
exit
fi
# Adjust these paths according to your local installation !!!
MY_LOCAL_LITEX_PATH=$HOME"/fpga/litex"
MY_LOCAL_FOMU_PATH=$HOME"/Fomu"
# If you don't use a virtual environment, comment out next line ...
source $HOME/fpga/bin/activate
# Make sure, we use the right compiler version ...
export PATH=$PATH:$MY_LOCAL_LITEX_PATH/riscv64-unknown-elf-gcc-8.3.0-2019.08.0-x86_64-linux-ubuntu14/bin/
TRIPLE="riscv64-unknown-elf"
CPU="vexriscv"
CPUFLAGS="-march=rv32im -mabi=ilp32 -D__vexriscv__"
CPUENDIANNESS="little"
CPU_DIRECTORY="$MY_LOCAL_LITEX_PATH/litex/litex/soc/cores/cpu/vexriscv"
COMPILER_RT_DIRECTORY="$MY_LOCAL_LITEX_PATH/pythondata-software-compiler_rt/pythondata_software_compiler_rt/data"
SOC_DIRECTORY="$MY_LOCAL_LITEX_PATH/litex/litex/soc"
#export BUILDINC_DIRECTORY
BUILDINC_DIRECTORY="/mnt/a30054ad-3fe6-444a-8d93-16df937e448e/projects/fpga/$PROJECTNAME/build/colorlight_5a_75b/software/include"
LIBCOMPILER_RT_DIRECTORY="$MY_LOCAL_LITEX_PATH/litex/litex/soc/software/libcompiler_rt"
LIBBASE_DIRECTORY="$MY_LOCAL_LITEX_PATH/litex/litex/soc/software/libbase"
LIBLITEDRAM_DIRECTORY="$MY_LOCAL_LITEX_PATH/litex/litex/soc/software/liblitedram"
LIBLITEETH_DIRECTORY="$MY_LOCAL_LITEX_PATH/litex/litex/soc/software/libliteeth"
LIBLITESPI_DIRECTORY="$MY_LOCAL_LITEX_PATH/litex/litex/soc/software/liblitespi"
LIBLITESDCARD_DIRECTORY="$MY_LOCAL_LITEX_PATH/litex/litex/soc/software/liblitesdcard"
BIOS_DIRECTORY="$MY_LOCAL_LITEX_PATH/litex/litex/soc/software/bios"
BIOSPATH="/mnt/a30054ad-3fe6-444a-8d93-16df937e448e/projects/fpga/$PROJECTNAME/build/colorlight_5a_75b/software/bios"
OBJECTS="$BIOSPATH/isr.o $BIOSPATH/boot-helper.o $BIOSPATH/boot.o $BIOSPATH/helpers.o $BIOSPATH/cmd_bios.o $BIOSPATH/cmd_mem.o $BIOSPATH/cmd_boot.o $BIOSPATH/cmd_i2c.o $BIOSPATH/cmd_spiflash.o $BIOSPATH/cmd_litedram.o $BIOSPATH/cmd_liteeth.o $BIOSPATH/cmd_litesdcard.o $BIOSPATH/complete.o $BIOSPATH/readline.o"
LXP="../build/colorlight_5a_75b/software"
CRT0="$LXP/libbase/crt0.o"
LXR="-L$LXP/libcompiler_rt -L$LXP/libbase -L$LXP/liblitedram -L$LXP/libliteeth -L$LXP/liblitespi -L$LXP/liblitesdcard -llitedram -lliteeth -llitespi -llitesdcard -lbase-nofloat -lcompiler_rt"
INCLUDES="-I$SOC_DIRECTORY/software/include/base -I$SOC_DIRECTORY/software/include -I$SOC_DIRECTORY/software -I$BUILDINC_DIRECTORY -I$CPU_DIRECTORY -I$BIOS_DIRECTORY"
# -Os optimize for size
#COMMONFLAGS="-Os $CPUFLAGS -g3 -fomit-frame-pointer -Wall -fno-builtin -nostdinc $INCLUDES"
COMMONFLAGS="-O0 $CPUFLAGS -g3 -fomit-frame-pointer -Wall -fno-builtin -nostdinc $INCLUDES"
CFLAGS="-fexceptions -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes"
LDFLAGS="-nostdlib -nodefaultlibs -L$BUILDINC_DIRECTORY"
echo "Compiling ..."
$MY_LOCAL_LITEX_PATH/riscv64-unknown-elf-gcc-8.3.0-2019.08.0-x86_64-linux-ubuntu14/bin/riscv64-unknown-elf-gcc -c $COMMONFLAGS $CFLAGS -Wa,-fPIC source/$1.c -o build/$1.o
if [ $? -ne 0 ];
then
echo "*** gcc for $1.c failed!"
exit $?
fi
echo "Linking ..."
$MY_LOCAL_LITEX_PATH/riscv64-unknown-elf-gcc-8.3.0-2019.08.0-x86_64-linux-ubuntu14/bin/riscv64-unknown-elf-ld $LDFLAGS -T linker/ram0x40190000.ld -N build/$1.o -o build/$1.elf
if [ $? -ne 0 ];
then
echo "*** Link/Loader for build/$1.elf failed!"
exit $?
fi
$MY_LOCAL_LITEX_PATH/riscv64-unknown-elf-gcc-8.3.0-2019.08.0-x86_64-linux-ubuntu14/riscv64-unknown-elf/bin/objcopy -O binary -S --image-base 0x40190000 build/$1.elf build/$1.bin
echo "--"
echo "creating disassembly dump build/$1.dis"
#$MY_LOCAL_LITEX_PATH/riscv64-unknown-elf-gcc-8.3.0-2019.08.0-x86_64-linux-ubuntu14/bin/riscv64-unknown-elf-objdump -D -b binary build/$1.o -m riscv >build/$1.dis
$MY_LOCAL_LITEX_PATH/riscv64-unknown-elf-gcc-8.3.0-2019.08.0-x86_64-linux-ubuntu14/bin/riscv64-unknown-elf-objdump -D -b binary build/$1.bin -m riscv >build/$1.dis
echo "--"
echo "Loading build/$1.bin @40190000h via wishbone-tool (make sure, other terminal has stopped!)"
$MY_LOCAL_FOMU_PATH/fomu-toolchain-linux_x86_64-v1.5.6/bin/wishbone-tool --ethernet-host 192.168.1.20 --server load-file --csr-csv ../build/csr.csv --load-address 0x40190000 --load-name build/$1.bin
if [ $? -ne 0 ];
then
echo "*** wishbone-tool load failed!"
exit $?
fi
#echo "--"
#echo "Connecting to remote terminal w/ wishbone-tool (press ESC to terminate ...)"
#$MY_LOCAL_FOMU_PATH/fomu-toolchain-linux_x86_64-v1.5.6/bin/wishbone-tool --ethernet-host 192.168.1.20 --server terminal --csr-csv ../build/csr.csv
# alternatively use:
# screen /dev/ttyUSB0 115200
# Press 'Ctrl-A k' to terminate ...
echo "Done (don't worry about the download 'error' in red!)."
echo "Loaded project $1 @ RAM address 40190000h <---"