mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
emulation: use BackingFile to make spi persistent
Use the `BackingFile` property of the SPI flash block in order to allow SPI flash writes to persist across runs. This will write out the SPI flash contents as data is written. Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
210d0c7fe3
commit
3c156f6ae4
2 changed files with 13 additions and 5 deletions
|
|
@ -83,6 +83,9 @@ sysbus SilenceRange <0xf0003000, 0xF0003FFF>
|
|||
# Silence POWER
|
||||
sysbus SilenceRange <0xF0014000 100>
|
||||
|
||||
# Attach the flash backing to the filesystem
|
||||
sysbus.spinor.flash BackingFile $ORIGIN/../tools/pddb-images/renode.bin
|
||||
|
||||
# Load the SPI flash into RAM
|
||||
sysbus LoadBinary @precursors/soc_csr.bin 0x20000000
|
||||
|
||||
|
|
@ -115,7 +118,7 @@ machine LoadPlatformDescription @ec/betrusted-ec.repl
|
|||
# logLevel -1 i2c
|
||||
# logLevel -1 i2c.bq27421
|
||||
# logLevel -1 wifi
|
||||
logLevel 0 wifi.wf200
|
||||
# logLevel 0 wifi.wf200
|
||||
# sysbus LogPeripheralAccess wifi true
|
||||
|
||||
machine StartGdbServer 3334 true
|
||||
|
|
|
|||
|
|
@ -174,14 +174,15 @@ namespace Antmicro.Renode.Peripherals.SPI
|
|||
{
|
||||
this.Log(LogLevel.Debug, "Trying to load or create backing file {0}", InternalBackingFileName);
|
||||
InternalBackingFile = new FileStream(InternalBackingFileName, FileMode.OpenOrCreate, FileAccess.ReadWrite);
|
||||
byte[] copyBuffer = new byte[4096];
|
||||
var currentOffset = 0;
|
||||
|
||||
// Assume that if the length is 0, then the file was just created and we need
|
||||
// to copy RAM into the newly-created file.
|
||||
if (InternalBackingFile.Length == 0)
|
||||
{
|
||||
this.Log(LogLevel.Debug, "Backing file {0} was created, dumping {1} bytes of ROM to backing file", InternalBackingFileName, underlyingMemory.Size);
|
||||
// 4096 is a safe size, since that is the page size.
|
||||
byte[] copyBuffer = new byte[4096];
|
||||
var currentOffset = 0;
|
||||
for (currentOffset = 0; currentOffset < underlyingMemory.Size; currentOffset += copyBuffer.Length)
|
||||
{
|
||||
underlyingMemory.ReadBytes(currentOffset, copyBuffer.Length, copyBuffer, 0);
|
||||
|
|
@ -193,9 +194,13 @@ namespace Antmicro.Renode.Peripherals.SPI
|
|||
{
|
||||
this.Log(LogLevel.Debug, "Backing file {0} was loaded, restoring {1} bytes (vs ROM: {2}) of ROM from file", InternalBackingFileName, InternalBackingFile.Length, underlyingMemory.Size);
|
||||
InternalBackingFile.Seek(0, SeekOrigin.Begin);
|
||||
if (InternalBackingFile.Length != underlyingMemory.Size)
|
||||
{
|
||||
this.Log(LogLevel.Warning, "Backing file {0} was a different size than ROM (file was {1} bytes, ROM is {2} bytes) -- resizing backing file to match ROM size", InternalBackingFileName, InternalBackingFile.Length, underlyingMemory.Size);
|
||||
InternalBackingFile.SetLength(underlyingMemory.Size);
|
||||
}
|
||||
|
||||
// 4096 is a safe size, since that is the page size.
|
||||
byte[] copyBuffer = new byte[4096];
|
||||
var currentOffset = 0;
|
||||
for (currentOffset = 0;
|
||||
(currentOffset < underlyingMemory.Size) && (currentOffset < InternalBackingFile.Length);
|
||||
currentOffset += copyBuffer.Length)
|
||||
|
|
|
|||
Loading…
Reference in a new issue