Skip to content

Commit

Permalink
sfdp: Pass the parameter table header into displayBasicParameterTable…
Browse files Browse the repository at this point in the history
…() and handle table versioning for the page size properly
  • Loading branch information
dragonmux committed Sep 28, 2023
1 parent 76f14b2 commit 8b0a45c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/sfdp.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,21 @@ namespace bmpflash::sfdp
console.info("-> table SFDP address: "sv, uint32_t{header.tableAddress});
}

[[nodiscard]] bool displayBasicParameterTable(const bmp_t &probe, const uint32_t address, const size_t length)
[[nodiscard]] bool displayBasicParameterTable(const bmp_t &probe, const parameterTableHeader_t &header)

Check warning on line 57 in src/sfdp.cxx

View check run for this annotation

Codecov / codecov/patch

src/sfdp.cxx#L57

Added line #L57 was not covered by tests
{
basicParameterTable_t parameterTable{};
if (!sfdpRead(probe, address, &parameterTable, std::min(sizeof(basicParameterTable_t), length)))
if (!sfdpRead(probe, header.tableAddress, &parameterTable,
std::min(sizeof(basicParameterTable_t), header.tableLength())))
return false;

console.info("Basic parameter table:");
const auto [capacityValue, capacityUnits] =
humanReadableSize(static_cast<size_t>(parameterTable.flashMemoryDensity.capacity()));
console.info("-> capacity "sv, capacityValue, capacityUnits);
console.info("-> program page size: "sv, parameterTable.programmingAndChipEraseTiming.pageSize());
if (header.versionMajor > 1U || (header.versionMajor == 1U && header.versionMinor >= 5U))
console.info("-> program page size: "sv, parameterTable.programmingAndChipEraseTiming.pageSize());

Check warning on line 69 in src/sfdp.cxx

View check run for this annotation

Codecov / codecov/patch

src/sfdp.cxx#L69

Added line #L69 was not covered by tests
else
console.info("-> program page size: default (256)"sv);

Check warning on line 71 in src/sfdp.cxx

View check run for this annotation

Codecov / codecov/patch

src/sfdp.cxx#L71

Added line #L71 was not covered by tests
console.info("-> sector erase opcode: "sv, asHex_t<2, '0'>(parameterTable.sectorEraseOpcode));
console.info("-> supported erase types:"sv);
for (const auto &[idx, eraseType] : indexedIterator_t{parameterTable.eraseTypes})
Expand Down Expand Up @@ -107,7 +111,7 @@ namespace bmpflash::sfdp
displayTableHeader(tableHeader, idx + 1U);
if (tableHeader.jedecParameterID() == basicSPIParameterTable)
{
if (!displayBasicParameterTable(probe, tableHeader.tableAddress, tableHeader.tableLength()))
if (!displayBasicParameterTable(probe, tableHeader))
return false;
}
}
Expand Down

0 comments on commit 8b0a45c

Please sign in to comment.