Merge pull request #686 from haomjc/bpi-dumpflash-support

xilinx: add BPI parallel NOR support to dumpFlash()
This commit is contained in:
Gwenhael Goavec-Merou 2026-07-01 16:28:41 +02:00 committed by GitHub
commit 5de70adbc2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 34 additions and 0 deletions

View File

@ -841,6 +841,35 @@ void Xilinx::program_bpi(ConfigBitstreamParser *bit, unsigned int offset)
printInfo("BPI flash programming complete"); printInfo("BPI flash programming complete");
} }
bool Xilinx::dumpFlash_bpi(uint32_t base_addr, uint32_t len)
{
if (!_bpi_flash) {
if (!load_bpi_bridge())
return false;
}
if (!_bpi_flash->detect()) {
printError("BPI flash detection failed");
return false;
}
if (len == 0)
len = _bpi_flash->capacity();
std::vector<uint8_t> buf(len);
printInfo("Reading BPI flash (slow, one word per USB round-trip)...");
if (!_bpi_flash->read(buf.data(), base_addr, len)) {
printError("BPI Flash read failed");
return false;
}
FILE *fd = fopen(_filename.c_str(), "wb");
if (!fd) {
printError("Can't open dump file");
return false;
}
fwrite(buf.data(), 1, len, fd);
fclose(fd);
printSuccess("BPI dump DONE");
return post_flash_access();
}
float Xilinx::get_spiOverJtag_version() float Xilinx::get_spiOverJtag_version()
{ {
uint8_t jtx[6] = {0x01, 0x00, 0x00, 0x00, 0x00, 0x00}; uint8_t jtx[6] = {0x01, 0x00, 0x00, 0x00, 0x00, 0x00};
@ -1254,6 +1283,10 @@ void Xilinx::displayRegister(const std::string reg_name, const uint32_t reg_val)
bool Xilinx::dumpFlash(uint32_t base_addr, uint32_t len) bool Xilinx::dumpFlash(uint32_t base_addr, uint32_t len)
{ {
/* BPI parallel NOR dump (added: upstream dumpFlash lacks a BPI path) */
if (_is_bpi_board)
return dumpFlash_bpi(base_addr, len);
if (_fpga_family == XC95_FAMILY || _fpga_family == XCF_FAMILY) { if (_fpga_family == XC95_FAMILY || _fpga_family == XCF_FAMILY) {
std::string buffer; std::string buffer;
if (_fpga_family == XC95_FAMILY) { if (_fpga_family == XC95_FAMILY) {

View File

@ -39,6 +39,7 @@ class Xilinx: public Device, FlashInterface {
void program_bpi(ConfigBitstreamParser * bit, unsigned int offset); void program_bpi(ConfigBitstreamParser * bit, unsigned int offset);
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;
bool dumpFlash_bpi(uint32_t base_addr, uint32_t len);
bool read_register(const std::string reg_name) override { bool read_register(const std::string reg_name) override {
displayRegister(reg_name, dumpRegister(reg_name)); displayRegister(reg_name, dumpRegister(reg_name));