mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #13848 from LDong-Arm/qspif_program_size_fix
Q/OSPIFBlockDevice: fix misconception in minimum program sizepull/13918/head
commit
b9daf3fb15
|
@ -23,7 +23,7 @@
|
||||||
"OSPI_POLARITY_MODE": 0,
|
"OSPI_POLARITY_MODE": 0,
|
||||||
"OSPI_FREQ": "40000000",
|
"OSPI_FREQ": "40000000",
|
||||||
"OSPI_MIN_READ_SIZE": "1",
|
"OSPI_MIN_READ_SIZE": "1",
|
||||||
"OSPI_MIN_PROG_SIZE": "256"
|
"OSPI_MIN_PROG_SIZE": "1"
|
||||||
},
|
},
|
||||||
"target_overrides": {
|
"target_overrides": {
|
||||||
"MX25LM51245G": {
|
"MX25LM51245G": {
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
"QSPI_POLARITY_MODE": 0,
|
"QSPI_POLARITY_MODE": 0,
|
||||||
"QSPI_FREQ": "40000000",
|
"QSPI_FREQ": "40000000",
|
||||||
"QSPI_MIN_READ_SIZE": "1",
|
"QSPI_MIN_READ_SIZE": "1",
|
||||||
"QSPI_MIN_PROG_SIZE": "256"
|
"QSPI_MIN_PROG_SIZE": "1"
|
||||||
},
|
},
|
||||||
"target_overrides": {
|
"target_overrides": {
|
||||||
"MX25R6435F": {
|
"MX25R6435F": {
|
||||||
|
@ -37,15 +37,18 @@
|
||||||
"MCU_NRF52840": {
|
"MCU_NRF52840": {
|
||||||
"QSPI_FREQ": "32000000",
|
"QSPI_FREQ": "32000000",
|
||||||
"QSPI_MIN_READ_SIZE": "4",
|
"QSPI_MIN_READ_SIZE": "4",
|
||||||
"QSPI_MIN_PROG_SIZE": "256"
|
"QSPI_MIN_PROG_SIZE": "4"
|
||||||
},
|
},
|
||||||
"MCU_PSOC6": {
|
"MCU_PSOC6": {
|
||||||
"QSPI_FREQ": "50000000",
|
"QSPI_FREQ": "50000000"
|
||||||
"QSPI_MIN_PROG_SIZE": "512"
|
|
||||||
},
|
},
|
||||||
"EFM32GG11_STK3701": {
|
"EFM32GG11_STK3701": {
|
||||||
"QSPI_MIN_READ_SIZE": "4",
|
"QSPI_MIN_READ_SIZE": "4",
|
||||||
"QSPI_MIN_PROG_SIZE": "256"
|
"QSPI_MIN_PROG_SIZE": "4"
|
||||||
|
},
|
||||||
|
"MCU_LPC546XX": {
|
||||||
|
"QSPI_MIN_READ_SIZE": "4",
|
||||||
|
"QSPI_MIN_PROG_SIZE": "4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -546,11 +546,18 @@ void test_contiguous_erase_write_read()
|
||||||
|
|
||||||
bd_size_t contiguous_erase_size = stop_address - start_address;
|
bd_size_t contiguous_erase_size = stop_address - start_address;
|
||||||
TEST_ASSERT(contiguous_erase_size > 0);
|
TEST_ASSERT(contiguous_erase_size > 0);
|
||||||
utest_printf("contiguous_erase_size=%d\n", contiguous_erase_size);
|
utest_printf("contiguous_erase_size=0x%" PRIx64 "\n", contiguous_erase_size);
|
||||||
|
|
||||||
bd_size_t write_read_buf_size = program_size;
|
bd_size_t write_read_buf_size = program_size;
|
||||||
if (contiguous_erase_size / program_size > 8 && contiguous_erase_size % (program_size * 8) == 0) {
|
|
||||||
write_read_buf_size = program_size * 8;
|
// Reading/writing in larger chunks reduces the number of operations,
|
||||||
|
// helping to avoid test timeouts. Try 256-byte chunks if contiguous_erase_size
|
||||||
|
// (which should be a power of 2) is greater than that. If it's less than
|
||||||
|
// that, the test finishes quickly anyway...
|
||||||
|
if ((program_size < 256) && (256 % program_size == 0)
|
||||||
|
&& (contiguous_erase_size >= 256) && (contiguous_erase_size % 256 == 0)) {
|
||||||
|
utest_printf("using 256-byte write/read buffer\n");
|
||||||
|
write_read_buf_size = 256;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allocate write/read buffer
|
// Allocate write/read buffer
|
||||||
|
|
|
@ -79,6 +79,7 @@ static void kvstore_init()
|
||||||
// be a close enough approximation to act as a guideline for how much of the block device we
|
// be a close enough approximation to act as a guideline for how much of the block device we
|
||||||
// need to erase in order to ensure a stable initial condition.
|
// need to erase in order to ensure a stable initial condition.
|
||||||
const size_t PAGES_ESTIMATE = 40;
|
const size_t PAGES_ESTIMATE = 40;
|
||||||
|
const size_t MIN_TDBSTORE_SIZE = 2 * 8 * 1024; // two areas, minimum 8KB per area
|
||||||
|
|
||||||
int res;
|
int res;
|
||||||
size_t program_size, erase_size, ul_bd_size, rbp_bd_size;
|
size_t program_size, erase_size, ul_bd_size, rbp_bd_size;
|
||||||
|
@ -133,8 +134,12 @@ static void kvstore_init()
|
||||||
erase_size = sec_bd->get_erase_size();
|
erase_size = sec_bd->get_erase_size();
|
||||||
// We must be able to hold at least 10 small keys (20 program sectors) and master record + internal data
|
// We must be able to hold at least 10 small keys (20 program sectors) and master record + internal data
|
||||||
// but minimum of 2 erase sectors, so that the garbage collection way work
|
// but minimum of 2 erase sectors, so that the garbage collection way work
|
||||||
ul_bd_size = align_up(program_size * PAGES_ESTIMATE, erase_size * 2);
|
// Also, the total size needs to be large enough for set_add_data_set_key_value_five_Kbytes (5KB value)
|
||||||
rbp_bd_size = align_up(program_size * PAGES_ESTIMATE, erase_size * 2);
|
// and to allow for overheads, we require at least 2 * 8KB for two areas per TDBStore
|
||||||
|
ul_bd_size = program_size * PAGES_ESTIMATE;
|
||||||
|
ul_bd_size = ul_bd_size > MIN_TDBSTORE_SIZE ? ul_bd_size : MIN_TDBSTORE_SIZE;
|
||||||
|
ul_bd_size = align_up(ul_bd_size, erase_size * 2);
|
||||||
|
rbp_bd_size = ul_bd_size;
|
||||||
|
|
||||||
res = sec_bd->deinit();
|
res = sec_bd->deinit();
|
||||||
TEST_ASSERT_EQUAL_ERROR_CODE(MBED_SUCCESS, res);
|
TEST_ASSERT_EQUAL_ERROR_CODE(MBED_SUCCESS, res);
|
||||||
|
|
Loading…
Reference in New Issue