diff --git a/app/commands.hh b/app/commands.hh index 86bfd80..5d7d3fa 100644 --- a/app/commands.hh +++ b/app/commands.hh @@ -33,10 +33,9 @@ struct ReadJedec : public Commands { if (auto jedec = this->flash.jedec()) { std::println("{}", *jedec); return 0; - } else { - std::println("Jedec failed"); - return 1; } + std::println("Jedec failed"); + return 1; } }; @@ -63,10 +62,9 @@ struct ReadPage : public Commands { int run() override { if (auto page = this->flash.single_read_page(addr)) { std::println("Single read {:#x} : {}", addr, *page); - } else { - std::println("page failed"); + return 0; } - + std::println("page failed"); return 1; } }; @@ -257,9 +255,8 @@ struct LoadFile : public Commands { if (bootstrap) { this->flash.reset(); return 1; - } else { - return commands::VerifyFile(this->flash, filename, start_addr, quad).run(); } + return commands::VerifyFile(this->flash, filename, start_addr, quad).run(); } }; diff --git a/app/main.cc b/app/main.cc index dd73453..2237fce 100644 --- a/app/main.cc +++ b/app/main.cc @@ -33,11 +33,6 @@ static std::vector scan() { exit(0); } - // for (auto &device: devices) { - // if (device.type == ftdi::DeviceType::Ftdi_unknown) { - // std::println("Warning: device not {}"); - // } - // } return devices; } @@ -117,7 +112,7 @@ int main(int argc, char* argv[]) { return 0; }; - auto jedec_cmd = new_flash_command("jedec", "Test the ftdi connection."); + auto jedec_cmd = new_flash_command("jedec", "Read the JEDEC identifier."); program.add_subparser(*jedec_cmd); commands["jedec"] = [&]() -> int { auto spih = handle_flash_command(jedec_cmd); @@ -126,7 +121,7 @@ int main(int argc, char* argv[]) { return 0; }; - auto sfdp_cmd = new_flash_command("sfdp", "Test the ftdi connection."); + auto sfdp_cmd = new_flash_command("sfdp", "Read serial flash description."); program.add_subparser(*sfdp_cmd); commands["sfdp"] = [&]() -> int { auto spih = handle_flash_command(sfdp_cmd); @@ -135,7 +130,7 @@ int main(int argc, char* argv[]) { return 0; }; - auto read_page_cmd = new_flash_command("read-page", "Read a specific page"); + auto read_page_cmd = new_flash_command("read-page", "Read a specific page."); read_page_cmd->add_argument("--addr").help("The page address").scan<'x', std::size_t>(); program.add_subparser(*read_page_cmd); commands["read-page"] = [&]() -> int { @@ -146,7 +141,7 @@ int main(int argc, char* argv[]) { return 0; }; - auto test_page_cmd = new_flash_command("test-page", "Write a pattern to a page and read it back"); + auto test_page_cmd = new_flash_command("test-page", "Write a pattern to a page and read it back."); test_page_cmd->add_argument("--addr") .help("The address to be loaded") .default_value(std::size_t{0}) @@ -184,7 +179,7 @@ int main(int argc, char* argv[]) { }; auto verify_file_cmd = new_flash_command( - "verify-file", "Compare the hash if a file to hash of the flash content at the address."); + "verify-file", "Compare the hash of a file to the hash of the flash content at the address."); verify_file_cmd->add_argument("filename").help("The file path."); verify_file_cmd->add_argument("--addr") .help("The address to be loaded") @@ -207,7 +202,7 @@ int main(int argc, char* argv[]) { }; auto bootstrap_cmd = new_flash_command( - "bootstrap", "Write the content of a binary file to a address and reset the target"); + "bootstrap", "Write the content of a binary file to an address and reset the target."); bootstrap_cmd->add_argument("filename").help("The file path."); bootstrap_cmd->add_argument("--addr") .help("The address to be loaded") diff --git a/doc/img/deps.png b/doc/img/deps.png index 2090082..2f47a43 100644 Binary files a/doc/img/deps.png and b/doc/img/deps.png differ diff --git a/lib/ftdi/spi_host.cc b/lib/ftdi/spi_host.cc index 5d72281..15c267b 100644 --- a/lib/ftdi/spi_host.cc +++ b/lib/ftdi/spi_host.cc @@ -53,7 +53,7 @@ SpiHost::transfer(std::span write, std::span read) { FT4222_STATUS status; status = FT4222_SPIMaster_SingleWrite(handle, write.data(), write.size(), &transfered, false); - status = FT4222_SPIMaster_SingleRead(handle, read.data(), write.size(), &transfered, true); + status = FT4222_SPIMaster_SingleRead(handle, read.data(), read.size(), &transfered, true); if (FT4222_OK != status) { std::cerr << std::format("SingleReadWrite:{}\n", status); return embeddedpp::Code::Generic; diff --git a/lib/ftdi/spi_host.hh b/lib/ftdi/spi_host.hh index 51d282f..b1f071c 100644 --- a/lib/ftdi/spi_host.hh +++ b/lib/ftdi/spi_host.hh @@ -29,9 +29,6 @@ class SpiHost { explicit SpiHost(FT_HANDLE handle, bool mpsse = false) noexcept : handle(handle), mpsse(mpsse), traces(false) {} ~SpiHost() { - // std::println("destructor"); - // TODO: fix copy elision. - // close(); } void close() {