Skip to content

Commit

Permalink
sfdp: Only read page size when basic table is 11+ DWORDs
Browse files Browse the repository at this point in the history
  • Loading branch information
tannewt committed Aug 10, 2023
1 parent 718c3ae commit 3d4d633
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/target/sfdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ static spi_parameters_s sfdp_read_basic_parameter_table(
sfdp_basic_parameter_table_s parameter_table;
const size_t table_length = MIN(sizeof(sfdp_basic_parameter_table_s), length);
spi_read(target, SPI_FLASH_CMD_READ_SFDP, address, &parameter_table, table_length);
sfdp_debug_print(address, &parameter_table, table_length);

spi_parameters_s result = {0};
result.capacity = sfdp_memory_density_to_capacity_bits(parameter_table.memory_density) >> 3U;
Expand All @@ -82,7 +83,14 @@ static spi_parameters_s sfdp_read_basic_parameter_table(
break;
}
}
result.page_size = SFDP_PAGE_SIZE(parameter_table);
// The timing and page size DWORD was added in JESD216A. Before then, the
// table is 9 DWORDs and we default to page size 256.
if (length >= 4 * 11) {
result.page_size = SFDP_PAGE_SIZE(parameter_table);
} else {
result.page_size = 256;
}

return result;
}

Expand Down

0 comments on commit 3d4d633

Please sign in to comment.