STMicroelectronics / STM32CubeF1

STM32Cube MCU Full Package for the STM32F1 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
506 stars 170 forks source link

stm32f1xx_hal_sram.c: Fix that SRAM state not set correctly #63

Closed Tetrahedrite closed 3 weeks ago

Tetrahedrite commented 1 year ago

Fixes SRAM HAL code always set State to HAL_SRAM_STATE_READY even WriteOperation is not set.

How does it make problem before?

If you initialize SRAM with WriteOperation disabled, It set State to HAL_SRAM_STATE_READY. Then try to write SRAM falls into HardFault_Handler. Even you can't enable WriteOperation via HAL_SRAM_WriteOperation_Enable function because the function tests State == HAL_SRAM_STATE_PROTECTED.

IMPORTANT INFORMATION

Contributor License Agreement (CLA)

RJMSTM commented 1 year ago

Hello @Tetrahedrite,

Thank you for this report. We will get back to you as soon as we analyze it further. This may take some time. Thank you for your comprehension.

With Regards,

TOUNSTM commented 1 month ago

ST Internal Reference: 188784

JRASTM commented 1 month ago

Hello @Tetrahedrite,

After check your sequence, it seems not inline with a real state, if you fully used HAL interface. As at reset, the write protection is not enabled, this mean that the writeoperation is enabled at reset.

This mean, that if you called the hal sram init, a the end with the status ready, the SRAM is ready to be written.

If you call the function HAL_SRAM_WriteOperation_Enable, a return code is set to error, as currently the write operation is already enabled.

If you call the functin HAL_SRAM_WritreOperation_Disable, at that stage the write protection will be enabled and so calling a function HAL_SRAM_Write_xxx will generate a return code error, as state is not ready, but protected.

So could describe more your usecase, by using HAL.

thx and Regards

TOUNSTM commented 3 weeks ago

Hello @Tetrahedrite,

Please allow me to close this thread as there is no activity. Thank you for your understanding.

With regards,