From 8dace3e2a948915d3ccfe2793df84b8d58a7ed22 Mon Sep 17 00:00:00 2001 From: Gwenhael Goavec-Merou Date: Sat, 5 Sep 2020 07:55:20 +0200 Subject: [PATCH] lattice: support writing arbitrary raw binary data somewhere in external flash --- src/lattice.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/lattice.cpp b/src/lattice.cpp index 18aeeca..602bc1e 100644 --- a/src/lattice.cpp +++ b/src/lattice.cpp @@ -29,6 +29,7 @@ #include "latticeBitParser.hpp" #include "mcsParser.hpp" #include "progressBar.hpp" +#include "rawParser.hpp" #include "display.hpp" #include "spiFlash.hpp" @@ -77,13 +78,14 @@ Lattice::Lattice(Jtag *jtag, const string filename, _mode = Device::FLASH_MODE; else _mode = Device::MEM_MODE; + } else if (flash_wr) { // for raw bin to flash at offset != 0 + _mode = Device::FLASH_MODE; } else { throw std::exception(); } } } - void displayFeabits(uint16_t _featbits) { uint8_t boot_sequence = (_featbits >> 12) & 0x03; @@ -389,8 +391,15 @@ bool Lattice::program_extFlash(unsigned int offset) ConfigBitstreamParser *_bit; if (_file_extension == "mcs") _bit = new McsParser(_filename, true, _verbose); - else + else if (_file_extension == "bit") _bit = new LatticeBitParser(_filename, _verbose); + else { + if (offset == 0) { + printError("Error: can't write raw data at the beginning of the flash"); + throw std::exception(); + } + _bit = new RawParser(_filename, false); + } printInfo("Open file " + _filename + " ", false); printSuccess("DONE");