Open ClovisCorde opened 7 months ago
@ClovisCorde Have you tried enabling the debug logs for the stm32 flash driver? There are several possibilities for why it would return -EIO
so knowing which one it is could be helpful.
Hi, thanks for your reply. Is there a config to enable the debug logs for stm32 flash driver? I don't know how to do so I tried to trace my code's execution to have more details on the problem. I'll try to explain the process as clearly as possible.
Here's what's happening in my code:
When the function flash_area_erase(flash_area, 0, FIXED_PARTITION_SIZE(slot1_partition))
is called, it triggers the flash_stm32_erase
function in the flash_stm32.c
file.
Then in this function it calls flash_stm32_block_erase_loop
from flash_stm32g0x.c
which then calls erase_page
.
The erase_page
function then calls flash_stm32_wait_flash_idle
from flash_stm32.c
file.
Within flash_stm32_wait_flash_idle
there is a call to flash_stm32_check_status
.
Then it's the function flash_stm32_check_status
that returns the -EIO error :
static int flash_stm32_check_status(const struct device *dev)
{
if (FLASH_STM32_REGS(dev)->FLASH_STM32_SR & FLASH_STM32_SR_ERRORS) {
LOG_DBG("Status: 0x%08lx",
FLASH_STM32_REGS(dev)->FLASH_STM32_SR &
FLASH_STM32_SR_ERRORS);
/* Clear errors to unblock usage of the flash */
FLASH_STM32_REGS(dev)->FLASH_STM32_SR = FLASH_STM32_REGS(dev)->FLASH_STM32_SR &
FLASH_STM32_SR_ERRORS;
return -EIO;
}
return 0;
}
I hope this information is helpful. If you could advise on how to enable logs for the STM32 flash driver, it might make diagnosing the problem easier.
If you could advise on how to enable logs for the STM32 flash driver, it might make diagnosing the problem easier.
CONFIG_FLASH_LOG_LEVEL_DBG=y
Anyway, the link between k_msgq_get
and flash status errors is not obvious. I would be curious to know if problem is specific to this target or could be reproduced more widely.
Here are the logs. I will try to find another board to reproduce the problem.
Update, I tried on nucleo_l4azg and same problem, just the Status is different : 0x00000080 for l4azg and 0x000000a0 for g0b1re
Hi guys, any updates on this problem?
Sorry we had no time to have a look recently. We'll try to give it a shot in coming month.
This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time.
Update, I tried on nucleo_l4azg and same problem, just the Status is different : 0x00000080 for l4azg and 0x000000a0 for g0b1re
Unfortunately, I cannot find an application causing (see the log neither) the error, on stm32g0b1 nucleo. The samples/drivers/flash_shell does not. According to the status error : PGAERR and PGSERR are reported. The sequence for erasing a page of the stm32g0b1 is described in the refman RM0444 3.3.7FLASH Main memory erase sequences
Hello guys :smile:
Describe the bug I'm trying to erase the flash memory from a thread (with priority 1). But when in another thread (priority 7) I have a
k_msgq_get
with a timeout ofK_MSEC(100)
I have a -5 error when trying to erase. However, when I remove thek_msgq_get
from my thread and put ak_sleep(K_MSEC(100))
it works great. (see the detailed code below).I am working on a STM32 nucleoG0B1RE. The erase function is called from a command shell.
To Reproduce
This is my full source code :
This is my prj.conf :
My error happens when I have this code in the thread :
I have then in logs :
But it works the moment I remove the
k_msgq_get
:And this is the logs (and the flash is successfully erased) :
Expected behavior I want to be able to erase the flash memory by keeping the
k_msgq_get
function in my thread.Impact I can't have my both threads working together.
Environment (please complete the following information):
Thanks in advance for your help!