retrofit system to use the new device-based CSR image

This commit is contained in:
bunnie 2021-04-20 19:27:29 +08:00
parent 9be9d80c17
commit e5343bceb9
5 changed files with 20 additions and 57 deletions

View file

@ -6,10 +6,10 @@ UPDATE_FPGA=1
UPDATE_KERNEL=1
UPDATE_LOADER=1
USE_USB=1
FPGA_IMAGE=../betrusted-soc/build/gateware/encrypted.bin
FPGA_IMAGE=../betrusted-soc/build/gateware/soc_csr.bin
KERNEL_IMAGE=target/riscv32imac-unknown-none-elf/release/xous.img
LOADER_IMAGE=target/riscv32imac-unknown-none-elf/release/loader.bin
CSR_CSV=../betrusted-soc/build/csr.csv.1
CSR_CSV=
USE_IDENTITY=0
USE_NIGHTLY=
IMAGE=hw-image
@ -46,7 +46,7 @@ do
shift
;;
--current-csr)
CSR_CSV=../betrusted-soc/build/csr.csv
CSR_CSV="--csr-csv ../betrusted-soc/build/csr.csv"
shift
;;
-n|--nightly)
@ -119,19 +119,19 @@ then
if [ $UPDATE_FPGA -eq 1 ]
then
echo "Burning FPGA image"
sudo wishbone-tool --csr-csv $CSR_CSV --load-name $FPGA_IMAGE --load-address 0x0 --load-flash
sudo wishbone-tool $CSR_CSV --load-name $FPGA_IMAGE --load-address 0x0 --load-flash
echo "*** Manual power cycle required to reload SoC FPGA configuration ***"
echo " -> Either issue a power cycle command, or insert paper clip in the hole on the right hand side!"
fi
if [ $UPDATE_LOADER -eq 1 ]
then
echo "Burning loader"
sudo wishbone-tool --csr-csv $CSR_CSV --load-name $LOADER_IMAGE --load-address 0x500000 --load-flash
sudo wishbone-tool $CSR_CSV --load-name $LOADER_IMAGE --load-address 0x500000 --load-flash
fi
if [ $UPDATE_KERNEL -eq 1 ]
then
echo "Burning kernel"
sudo wishbone-tool --csr-csv $CSR_CSV --load-name $KERNEL_IMAGE --load-address 0x980000 --load-flash
sudo wishbone-tool $CSR_CSV --load-name $KERNEL_IMAGE --load-address 0x980000 --load-flash
fi
else

View file

@ -1,36 +0,0 @@
#!/usr/bin/python3
import argparse
import hashlib
def main():
parser = argparse.ArgumentParser(description="Convert csr.csv to binary image file")
parser.add_argument(
"-i", "--input-file", required=True, help="file containing CSV input", type=str
)
parser.add_argument(
"-o", "--output-file", required=True, help="destination file for binary data", type=str
)
args = parser.parse_args()
pad_to = 0x7FC0
with open(args.input_file, "rb") as ifile:
with open(args.output_file, "wb") as ofile:
data = ifile.read() # read in the whole block of CSV data
odata = bytearray()
odata += len(data).to_bytes(4, 'little')
odata += data
padding = bytes([0xff]) * (pad_to - len(data) - 4)
odata += padding
hasher = hashlib.sha512()
hasher.update(odata)
digest = hasher.digest()
odata += digest
ofile.write(odata)
if __name__ == "__main__":
main()

View file

@ -3,7 +3,7 @@
<device schemaVersion="1.1" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="CMSIS-SVD.xsd" >
<vendor>litex</vendor>
<name>SOC</name>
<description><![CDATA[Litex SoC 2021-04-16 05:30:18]]></description>
<description><![CDATA[Litex SoC 2021-04-20 17:25:58]]></description>
<addressUnitBits>8</addressUnitBits>
<width>32</width>
@ -1070,10 +1070,10 @@ register to disable individual events.]]></description>
<register>
<name>GIT_GITREV</name>
<description><![CDATA[First 32-bits of the git revision. This documentation was built from git rev
``06285e59``, so this value is 103308889, which should be enough to check out
``68988db7``, so this value is 1754828215, which should be enough to check out
the exact git version used to build this firmware.]]></description>
<addressOffset>0x0014</addressOffset>
<resetValue>0x6285e59</resetValue>
<resetValue>0x68988db7</resetValue>
<size>32</size>
<fields>
<field>
@ -1090,7 +1090,7 @@ the exact git version used to build this firmware.]]></description>
is ``1``, then the repository this was built from has one additional commit
beyond the tag indicated in `MAJOR`, `MINOR`, and `REVISION`.]]></description>
<addressOffset>0x0018</addressOffset>
<resetValue>0x18</resetValue>
<resetValue>0x1a</resetValue>
<size>32</size>
<fields>
<field>
@ -2882,7 +2882,7 @@ inject too fast.]]></description>
<name>SEED1</name>
<description><![CDATA[Bits 32-63 of `SEED_SEED`. Seed used for the build]]></description>
<addressOffset>0x0000</addressOffset>
<resetValue>0x2c625d10</resetValue>
<resetValue>0x35b643e1</resetValue>
<size>32</size>
<fields>
<field>
@ -2897,7 +2897,7 @@ inject too fast.]]></description>
<name>SEED0</name>
<description><![CDATA[Bits 0-31 of `SEED_SEED`.]]></description>
<addressOffset>0x0004</addressOffset>
<resetValue>0x3ac8fff5</resetValue>
<resetValue>0x1262af67</resetValue>
<size>32</size>
<fields>
<field>

View file

@ -354,9 +354,8 @@ fn xmain() -> ! {
#[cfg(not(target_os = "none"))]
let mut trng = Trng::new();
if cfg!(feature = "avalanchetest") || cfg!(feature = "ringosctest") {
xous::create_thread_1(tester_thread, trng.get_trng_csr() as usize).expect("couldn't create test thread");
}
#[cfg(any(feature = "avalanchetest", feature="ringosctest"))]
xous::create_thread_1(tester_thread, trng.get_trng_csr() as usize).expect("couldn't create test thread");
// pump the TRNG hardware to clear the first number out, sometimes it is 0 due to clock-sync issues on the fifo
trng.get_trng(2);

View file

@ -3,7 +3,7 @@
<device schemaVersion="1.1" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="CMSIS-SVD.xsd" >
<vendor>litex</vendor>
<name>SOC</name>
<description><![CDATA[Litex SoC 2021-04-16 05:30:18]]></description>
<description><![CDATA[Litex SoC 2021-04-20 17:25:58]]></description>
<addressUnitBits>8</addressUnitBits>
<width>32</width>
@ -1070,10 +1070,10 @@ register to disable individual events.]]></description>
<register>
<name>GIT_GITREV</name>
<description><![CDATA[First 32-bits of the git revision. This documentation was built from git rev
``06285e59``, so this value is 103308889, which should be enough to check out
``68988db7``, so this value is 1754828215, which should be enough to check out
the exact git version used to build this firmware.]]></description>
<addressOffset>0x0014</addressOffset>
<resetValue>0x6285e59</resetValue>
<resetValue>0x68988db7</resetValue>
<size>32</size>
<fields>
<field>
@ -1090,7 +1090,7 @@ the exact git version used to build this firmware.]]></description>
is ``1``, then the repository this was built from has one additional commit
beyond the tag indicated in `MAJOR`, `MINOR`, and `REVISION`.]]></description>
<addressOffset>0x0018</addressOffset>
<resetValue>0x18</resetValue>
<resetValue>0x1a</resetValue>
<size>32</size>
<fields>
<field>
@ -2882,7 +2882,7 @@ inject too fast.]]></description>
<name>SEED1</name>
<description><![CDATA[Bits 32-63 of `SEED_SEED`. Seed used for the build]]></description>
<addressOffset>0x0000</addressOffset>
<resetValue>0x2c625d10</resetValue>
<resetValue>0x35b643e1</resetValue>
<size>32</size>
<fields>
<field>
@ -2897,7 +2897,7 @@ inject too fast.]]></description>
<name>SEED0</name>
<description><![CDATA[Bits 0-31 of `SEED_SEED`.]]></description>
<addressOffset>0x0004</addressOffset>
<resetValue>0x3ac8fff5</resetValue>
<resetValue>0x1262af67</resetValue>
<size>32</size>
<fields>
<field>