Skip to content

STM32: remove critical sections in flash_program_page #14469

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 14, 2021
Merged
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
6 changes: 1 addition & 5 deletions targets/TARGET_STM/TARGET_STM32F0/flash_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/

#include "flash_api.h"
#include "mbed_critical.h"
#include "platform/mbed_critical.h"

#if DEVICE_FLASH
#include "mbed_assert.h"
Expand Down Expand Up @@ -97,8 +97,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data,
return -1;
}

core_util_critical_section_enter();

/* Program the user Flash area word by word */
StartAddress = address;

Expand Down Expand Up @@ -129,8 +127,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data,
}
}

core_util_critical_section_exit();

if (HAL_FLASH_Lock() != HAL_OK) {
return -1;
}
Expand Down
6 changes: 1 addition & 5 deletions targets/TARGET_STM/TARGET_STM32F1/flash_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/

#include "flash_api.h"
#include "mbed_critical.h"
#include "platform/mbed_critical.h"

#if DEVICE_FLASH
#include "mbed_assert.h"
Expand Down Expand Up @@ -100,8 +100,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data,
return -1;
}

core_util_critical_section_enter();

/* Program the user Flash area word by word */
StartAddress = address;

Expand Down Expand Up @@ -132,8 +130,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data,
}
}

core_util_critical_section_exit();

if (HAL_FLASH_Lock() != HAL_OK) {
return -1;
}
Expand Down
4 changes: 0 additions & 4 deletions targets/TARGET_STM/TARGET_STM32F2/flash_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data,
return -1;
}

core_util_critical_section_enter();

/* Note: If an erase operation in Flash memory also concerns data in the data or instruction cache,
you have to make sure that these data are rewritten before they are accessed during code
execution. If this cannot be done safely, it is recommended to flush the caches by setting the
Expand All @@ -111,8 +109,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data,
}
}

core_util_critical_section_exit();

if (HAL_FLASH_Lock() != HAL_OK) {
return -1;
}
Expand Down
6 changes: 1 addition & 5 deletions targets/TARGET_STM/TARGET_STM32F3/flash_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/

#include "flash_api.h"
#include "mbed_critical.h"
#include "platform/mbed_critical.h"

#if DEVICE_FLASH
#include "mbed_assert.h"
Expand Down Expand Up @@ -100,8 +100,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data,
return -1;
}

core_util_critical_section_enter();

/* Program the user Flash area word by word */
StartAddress = address;

Expand Down Expand Up @@ -132,8 +130,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data,
}
}

core_util_critical_section_exit();

if (HAL_FLASH_Lock() != HAL_OK) {
return -1;
}
Expand Down
4 changes: 0 additions & 4 deletions targets/TARGET_STM/TARGET_STM32F4/flash_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data,
return -1;
}

core_util_critical_section_enter();

/* Note: If an erase operation in Flash memory also concerns data in the data or instruction cache,
you have to make sure that these data are rewritten before they are accessed during code
execution. If this cannot be done safely, it is recommended to flush the caches by setting the
Expand All @@ -106,8 +104,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data,
}
}

core_util_critical_section_exit();

if (HAL_FLASH_Lock() != HAL_OK) {
return -1;
}
Expand Down
4 changes: 0 additions & 4 deletions targets/TARGET_STM/TARGET_STM32F7/flash_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data,
return -1;
}

core_util_critical_section_enter();

/* Note: If an erase operation in Flash memory also concerns data in the data or instruction cache,
you have to make sure that these data are rewritten before they are accessed during code
execution. If this cannot be done safely, it is recommended to flush the caches by setting the
Expand All @@ -151,8 +149,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data,
SCB_CleanInvalidateDCache_by_Addr((uint32_t *)StartAddress, FullSize);
SCB_InvalidateICache();

core_util_critical_section_exit();

if (HAL_FLASH_Lock() != HAL_OK) {
return -1;
}
Expand Down
6 changes: 1 addition & 5 deletions targets/TARGET_STM/TARGET_STM32G0/flash_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/

#include "flash_api.h"
#include "mbed_critical.h"
#include "platform/mbed_critical.h"

#if DEVICE_FLASH
#include "mbed_assert.h"
Expand Down Expand Up @@ -98,8 +98,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address,
return -1;
}

core_util_critical_section_enter();

/* Program the user Flash area word by word */
StartAddress = address;

Expand Down Expand Up @@ -130,8 +128,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address,
}
}

core_util_critical_section_exit();

if (HAL_FLASH_Lock() != HAL_OK) {
return -1;
}
Expand Down
6 changes: 1 addition & 5 deletions targets/TARGET_STM/TARGET_STM32G4/flash_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/

#include "flash_api.h"
#include "mbed_critical.h"
#include "platform/mbed_critical.h"

#if DEVICE_FLASH
#include "mbed_assert.h"
Expand Down Expand Up @@ -177,8 +177,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address,
return -1;
}

core_util_critical_section_enter();

/* Clear error programming flags */
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_ALL_ERRORS);

Expand Down Expand Up @@ -215,8 +213,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address,
}
}

core_util_critical_section_exit();

if (HAL_FLASH_Lock() != HAL_OK) {
return -1;
}
Expand Down
4 changes: 0 additions & 4 deletions targets/TARGET_STM/TARGET_STM32H7/flash_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data,
return -1;
}

core_util_critical_section_enter();

StartAddress = address;
while ((address < (StartAddress + size)) && (status == 0)) {
if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_FLASHWORD, address, (uint32_t)data) == HAL_OK) {
Expand All @@ -156,8 +154,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data,
SCB_InvalidateICache();
#endif /* DUAL_CORE */

core_util_critical_section_exit();

if (HAL_FLASH_Lock() != HAL_OK) {
return -1;
}
Expand Down
6 changes: 1 addition & 5 deletions targets/TARGET_STM/TARGET_STM32L0/flash_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/

#include "flash_api.h"
#include "mbed_critical.h"
#include "platform/mbed_critical.h"

#if DEVICE_FLASH
#include "mbed_assert.h"
Expand Down Expand Up @@ -100,8 +100,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address,
return -1;
}

core_util_critical_section_enter();

/* Program the user Flash area word by word */
StartAddress = address;

Expand Down Expand Up @@ -132,8 +130,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address,
}
}

core_util_critical_section_exit();

if (HAL_FLASH_Lock() != HAL_OK) {
return -1;
}
Expand Down
6 changes: 1 addition & 5 deletions targets/TARGET_STM/TARGET_STM32L1/flash_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/

#include "flash_api.h"
#include "mbed_critical.h"
#include "platform/mbed_critical.h"

#if DEVICE_FLASH
#include "mbed_assert.h"
Expand Down Expand Up @@ -95,8 +95,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address,
return -1;
}

core_util_critical_section_enter();

/* Program the user Flash area word by word */
StartAddress = address;

Expand Down Expand Up @@ -127,8 +125,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address,
}
}

core_util_critical_section_exit();

if (HAL_FLASH_Lock() != HAL_OK) {
return -1;
}
Expand Down
6 changes: 1 addition & 5 deletions targets/TARGET_STM/TARGET_STM32L4/flash_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

#include "flash_api.h"
#include "mbed_critical.h"
#include "platform/mbed_critical.h"

#if DEVICE_FLASH
#include "mbed_assert.h"
Expand Down Expand Up @@ -181,8 +181,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address,
return -1;
}

core_util_critical_section_enter();

/* Clear error programming flags */
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_ALL_ERRORS);

Expand Down Expand Up @@ -219,8 +217,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address,
}
}

core_util_critical_section_exit();

if (HAL_FLASH_Lock() != HAL_OK) {
return -1;
}
Expand Down
5 changes: 1 addition & 4 deletions targets/TARGET_STM/TARGET_STM32L5/flash_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/

#include "flash_api.h"
#include "platform/mbed_critical.h"

#if DEVICE_FLASH

Expand Down Expand Up @@ -173,8 +174,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address,
return -1;
}

core_util_critical_section_enter();

/* Clear error programming flags */
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_ALL_ERRORS);

Expand Down Expand Up @@ -215,8 +214,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address,
return -1;
}

core_util_critical_section_enter();

return status;
}

Expand Down
Loading