xilinx: rework program_spi method to uses new mcsParser features when extension == mcs

This commit is contained in:
Gwenhael Goavec-Merou 2025-12-17 20:01:11 +01:00
parent f349377f5f
commit 3706236b43
2 changed files with 14 additions and 9 deletions

View File

@ -656,11 +656,11 @@ void Xilinx::program(unsigned int offset, bool unprotect_flash)
if (_mode == Device::SPI_MODE) { if (_mode == Device::SPI_MODE) {
if (_flash_chips & PRIMARY_FLASH) { if (_flash_chips & PRIMARY_FLASH) {
select_flash_chip(PRIMARY_FLASH); select_flash_chip(PRIMARY_FLASH);
program_spi(bit, offset, unprotect_flash); program_spi(bit, _file_extension, offset, unprotect_flash);
} }
if (_flash_chips & SECONDARY_FLASH) { if (_flash_chips & SECONDARY_FLASH) {
select_flash_chip(SECONDARY_FLASH); select_flash_chip(SECONDARY_FLASH);
program_spi(secondary_bit, offset, unprotect_flash); program_spi(secondary_bit, _secondary_file_extension, offset, unprotect_flash);
} }
reset(); reset();
@ -766,14 +766,19 @@ float Xilinx::get_spiOverJtag_version()
return version; return version;
} }
void Xilinx::program_spi(ConfigBitstreamParser * bit, unsigned int offset, void Xilinx::program_spi(ConfigBitstreamParser * bit, std::string extention,
bool unprotect_flash) unsigned int offset, bool unprotect_flash)
{ {
if (!bit) if (!bit)
throw std::runtime_error("called with null bitstream"); throw std::runtime_error("called with null bitstream");
const uint8_t *data = bit->getData(); if (extention == "mcs") {
int length = bit->getLength() / 8; McsParser *parser = (McsParser *)bit;
SPIInterface::write(offset, data, length, unprotect_flash); SPIInterface::write(parser->getRecords(), unprotect_flash, true);
} else {
const uint8_t *data = bit->getData();
int length = bit->getLength() / 8;
SPIInterface::write(offset, data, length, unprotect_flash);
}
} }
void Xilinx::program_mem(ConfigBitstreamParser *bitfile) void Xilinx::program_mem(ConfigBitstreamParser *bitfile)

View File

@ -31,8 +31,8 @@ class Xilinx: public Device, SPIInterface {
~Xilinx(); ~Xilinx();
void program(unsigned int offset, bool unprotect_flash) override; void program(unsigned int offset, bool unprotect_flash) override;
void program_spi(ConfigBitstreamParser * bit, unsigned int offset, void program_spi(ConfigBitstreamParser * bit, std::string extention,
bool unprotect_flash); unsigned int offset, bool unprotect_flash);
void program_mem(ConfigBitstreamParser *bitfile); void program_mem(ConfigBitstreamParser *bitfile);
bool dumpFlash(uint32_t base_addr, uint32_t len) override; bool dumpFlash(uint32_t base_addr, uint32_t len) override;