STMicroelectronics / STM32CubeL4

STM32Cube MCU Full Package for the STM32L4 series - (HAL + LL Drivers, CMSIS Core, CMSIS Device, MW libraries plus a set of Projects running on all boards provided by ST (Nucleo, Evaluation and Discovery Kits))
Other
262 stars 153 forks source link

STM32L431 with X-CUBE-EEPROM_V3.0.0. Problem writing to flash memory. #23

Closed christophemonmon closed 3 years ago

christophemonmon commented 3 years ago

I use Keil v5.33 and STM32Cube_FW_L4_V1.16.0

The project uses a STM32L431 with X-CUBE-EEPROM.

First, the X-CUBE-EEPROM extension cannot be integrated automatically in STM32CubeMX (v6.1.0). The application answers that the zip is not compliant. So you have to manually add the files you need in the project. It's not complicated but a bit long to identify the few files you need in all directories.

Second problem already encountered with the STM32F405 for a booloader function: before you can write in flash, you have to delete several configuration bits of the flash even if they are already at 0 (seen in debug mode with keil).

Addition of : __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR|FLASH_FLAG_PGSERR); in the ProgramFlash function on line function 103

For the STM32L431 with EEPROM emulation, I added this line in the eeprom_emul.c function: __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | FLASH_FLAG_PGAERR | FLASH_FLAG_PGSERR); before the FI_WriteDoubleWord on line 1560.

Hoping to help people.

RKOUSTM commented 3 years ago

Hi @christophemonmon,

Thank you for contribution. It has been transferred to our technical teams for deeper analysis. We will be back to you as soon as we get an answer. Thank you for you again for your contribution.

With regards

RKOUSTM commented 3 years ago

Hi @christophemonmon,

Thank you for your report. For the first point, our development team have started to work on making X-CUBE-EEPROM package compatible with CubeMX. We cannot share a date for the moment, but we will do our best to have such a global update deployed and released soon. Concerning the second point, the HAL_FLASH_Program function already clears all the error flags if at least one has been raised, before each operation (as for the L4 HAL it is done in FLASH_WaitForLastOperation -> FLASH_SetErrorCode ->__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_ALL_ERRORS)). This corresponds to the flash programming procedure exposed in the reference manual. In order to allow a better analysis of this point, could you please give us more details about the problem you encountered without resetting the error flags again, so that our development teams can give you an answer.

Thank you for your contribution.

with regards,

RKOUSTM commented 3 years ago

Hi @christophemonmon,

I hope you are doing well. Any new comments to move this discussion forward?

With regards,

christophemonmon commented 3 years ago

Hi @RKOUSTM ,

I'm sorry for the late response, the messages were going as spam. To answer your question, if I don't clear the flags, the program goes into hard fault, it's crashed! If I look at the flags with the debugger (with keil ulink pro probe), they are already at 0! So I don't understand this behavior.

Best regards.

RKOUSTM commented 3 years ago

Hi @christophemonmon,

Thank you for your feedback. Please allow me to introduce @ASASTM who will look deeper into the subject.

With regards,

ASASTM commented 3 years ago

Hi @christophemonmon,

What does your program going in hardfault do exactly ? When you run the STM32Cube_FW_L4_V1.16.0\Projects\NUCLEO-L412RB-P\Examples\FLASH\FLASH_EraseProgram\MDK-ARM project, the flash programming operations are done without problem.

Best regards, Adam

RKOUSTM commented 3 years ago

Hi @christophemonmon,

I hope you are fine. Any new feedback regarding the request of my colleague @ASASTM ?

With regards,

RKOUSTM commented 3 years ago

Hi @christophemonmon,

Please allow me to close this thread. You can reopen it at any time if you have details to provide us to help you.

Thank you for your comprehension and thank you once more for your contribution

With regards,