drivers: flash: stm32 qspi driver correct device size
The find_lsb_set is giving the position of the first '1' found, starting from 1. "Bits are numbered starting at 1 from the least significant bit." So that the find_lsb_set(64MBytes) is 27. The HAL_QSPI_Init() accepts Init.FlashSize where "FlashSize+1 is effectively the number of address bits required to address the flash memory." To get 64MBytes = 2^26, the value of the Init.FlashSize must be 25. and bit written to the DCR = 25. Signed-off-by: Francois Ramu <francois.ramu@st.com>
This commit is contained in:
parent
4500dba078
commit
302983fd7d
1 changed files with 2 additions and 1 deletions
|
@ -1189,7 +1189,8 @@ static int flash_stm32_qspi_init(const struct device *dev)
|
|||
__ASSERT_NO_MSG(prescaler <= STM32_QSPI_CLOCK_PRESCALER_MAX);
|
||||
/* Initialize QSPI HAL */
|
||||
dev_data->hqspi.Init.ClockPrescaler = prescaler;
|
||||
dev_data->hqspi.Init.FlashSize = find_lsb_set(dev_cfg->flash_size);
|
||||
/* Give a bit position from 0 to 31 to the HAL init minus 1 for the DCR1 reg */
|
||||
dev_data->hqspi.Init.FlashSize = find_lsb_set(dev_cfg->flash_size) - 2;
|
||||
|
||||
HAL_QSPI_Init(&dev_data->hqspi);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue