STM32CubeF1 icon indicating copy to clipboard operation
STM32CubeF1 copied to clipboard

stm32f1xx_hal_sram.c: Fix that SRAM state not set correctly

Open Tetrahedrite opened this issue 1 year ago • 3 comments

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)

  • The Pull Request feature will be considered by STMicroelectronics after the signature of a Contributor License Agreement (CLA) by the submitter.
  • If you did not sign such agreement, please follow the steps mentioned in the CONTRIBUTING.md file.

Tetrahedrite avatar Aug 10 '23 12:08 Tetrahedrite

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,

RJMSTM avatar Aug 15 '23 10:08 RJMSTM

ST Internal Reference: 188784

TOUNSTM avatar Aug 15 '24 14:08 TOUNSTM

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

JRASTM avatar Aug 16 '24 09:08 JRASTM