Skip to content

Commit

Permalink
core: added option/methods to enable/disable quad mode on SPI Flash
Browse files Browse the repository at this point in the history
  • Loading branch information
trabucayre committed Aug 23, 2024
1 parent baa9edd commit 7b5c818
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ class Device {
printError("dump flash not supported"); return false;}
virtual bool protect_flash(uint32_t len) = 0;
virtual bool unprotect_flash() = 0;
virtual bool set_quad_bit(bool set_quad) {
(void)set_quad;
printError("Error: SPI Flash Quad mode configuration unsupported"); return false;}
virtual bool bulk_erase_flash() = 0;

virtual uint32_t idCode() = 0;
Expand Down
26 changes: 25 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ struct arguments {
string ip_adr;
uint32_t protect_flash;
bool unprotect_flash;
bool enable_quad;
bool disable_quad;
bool bulk_erase_flash;
string flash_sector;
bool skip_load_bridge;
Expand Down Expand Up @@ -123,7 +125,7 @@ int main(int argc, char **argv)
-1, 0, "primary", false, -1,
/* vid, pid, index bus_addr, device_addr */
0, 0, -1, 0, 0,
"127.0.0.1", 0, false, false, "", false, false,
"127.0.0.1", 0, false, false, false, false, "", false, false,
/* xvc server */
false, 3721, "-",
"", false, {}, // mcufw conmcu, user_misc_dev_list
Expand Down Expand Up @@ -636,6 +638,24 @@ int main(int argc, char **argv)
fpga->protect_flash(args.protect_flash);
}

/* Enable/disable SPI Flash quad mode */
if (args.enable_quad || args.disable_quad) {
bool ret = true;
if (args.enable_quad && args.disable_quad) {
printError("Error: can't set enable and disable Quad mode at same time");
ret = false;
} else if (!fpga->set_quad_bit(args.enable_quad)) {
printError("Error: Failed to enable/disable Quad mode");
ret = false;
}

if (!ret) {
delete(fpga);
delete(jtag);
return EXIT_FAILURE;
}
}

/* detect/display flash */
if (args.detect_flash != 0) {
fpga->detect_flash();
Expand Down Expand Up @@ -769,6 +789,10 @@ int parse_opt(int argc, char **argv, struct arguments *args,
("dump-flash", "Dump flash mode")
("bulk-erase", "Bulk erase flash",
cxxopts::value<bool>(args->bulk_erase_flash))
("enable-quad", "Enable quad mode for SPI Flash",
cxxopts::value<bool>(args->enable_quad))
("disable-quad", "Disable quad mode for SPI Flash",
cxxopts::value<bool>(args->disable_quad))
("target-flash",
"for boards with multiple flash chips (some Xilinx UltraScale"
" boards), select the target flash: primary (default), secondary or both",
Expand Down

0 comments on commit 7b5c818

Please sign in to comment.