Skip to content

Commit

Permalink
difftest: restore difftest_load_flash and add v2 (#76)
Browse files Browse the repository at this point in the history
The initial API accepts a string for the flash image file. To maintain
compatibility with prior versions, we restore it.

We also rename the new API to v2.
  • Loading branch information
poemonsense authored Dec 26, 2024
1 parent 0fa6cee commit 2db991e
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion difftest/difftest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -643,10 +643,23 @@ void debug_mem_sync(reg_t addr, void* buf, size_t n) {
ref->debug_memcpy_from_dut(addr, buf, n);
}

void difftest_load_flash(const uint8_t *flash_bin, size_t size) {
void difftest_load_flash_v2(const uint8_t *flash_bin, size_t size) {
ref->flash_cpy_from_dut(flash_bin, size);
}

void difftest_load_flash(const char *flash_bin_file, size_t size) {
if (flash_bin_file) {
std::ifstream file(flash_bin_file, std::ios::binary);
if (!file) {
std::cout << "Error loading flash file " << flash_bin_file << std::endl;
assert(0);
}
std::vector<uint8_t> flash_data(size);
file.read(reinterpret_cast<char*>(flash_data.data()), size);
difftest_load_flash_v2(flash_data.data(), size);
}
}

void difftest_set_mhartid(int mhartid) {
overrided_mhartid = mhartid;
}
Expand Down

0 comments on commit 2db991e

Please sign in to comment.