Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions drivers/flash/Kconfig.stm32
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,20 @@ config FLASH_STM32_ACCEPT_UNALIGNED_WRITES
addresses being written to are expected to be erased before writing to them. Contens of the flash
after unaligned writes depend on the flash hardware details. The operation may fault.

if SOC_SERIES_STM32WBAX

config STM32WBA_FLASH_MNGR_THREAD_STACK_SIZE
int "Stack size of the Flash Manager thread for STM32WBAx"
default 1024
help
Flash Manager thread stack size in bytes.

config STM32WBA_FLASH_MNGR_THREAD_PRIO
int "Flash Manager thread priority"
default 14
help
This option sets the cooperative priority of the Flash Manager thread.

endif # SOC_SERIES_STM32WBAX

endif # SOC_FLASH_STM32
13 changes: 11 additions & 2 deletions drivers/flash/flash_stm32wba_fm.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ LOG_MODULE_REGISTER(flash_stm32wba, CONFIG_FLASH_LOG_LEVEL);
*/
#define STM32_FLASH_TIMEOUT (2 * DT_PROP(DT_INST(0, st_stm32_nv_flash), max_erase_time))

extern struct k_work_q ble_ctlr_work_q;
struct k_work_q flash_mngr_work_q;
struct k_work fm_work;
K_THREAD_STACK_DEFINE(flash_mngr_work_area, CONFIG_STM32WBA_FLASH_MNGR_THREAD_STACK_SIZE);

static const struct flash_parameters flash_stm32_parameters = {
.write_block_size = FLASH_STM32_WRITE_BLOCK_SIZE,
Expand All @@ -46,7 +47,7 @@ struct FM_CallbackNode cb_ptr = {.Callback = flash_callback};

void FM_ProcessRequest(void)
{
k_work_submit_to_queue(&ble_ctlr_work_q, &fm_work);
k_work_submit_to_queue(&flash_mngr_work_q, &fm_work);
}

void FM_BackgroundProcess_Entry(struct k_work *work)
Expand Down Expand Up @@ -304,10 +305,18 @@ static DEVICE_API(flash, flash_stm32_api) = {

static int stm32_flash_init(const struct device *dev)
{
struct k_work_queue_config flash_mngr_cfg = {.name = "flash manager thread"};

k_sem_init(&FLASH_STM32_PRIV(dev)->sem, 1, 1);

LOG_DBG("Flash initialized. BS: %zu", flash_stm32_parameters.write_block_size);

k_work_queue_init(&flash_mngr_work_q);
k_work_queue_start(&flash_mngr_work_q, flash_mngr_work_area,
K_THREAD_STACK_SIZEOF(flash_mngr_work_area),
K_PRIO_COOP(CONFIG_STM32WBA_FLASH_MNGR_THREAD_PRIO),
&flash_mngr_cfg);

k_work_init(&fm_work, &FM_BackgroundProcess_Entry);

/* Init the Flash Manager module */
Expand Down
Loading