Skip to content

Commit dd1da3d

Browse files
authored
Merge pull request #14469 from jeromecoutant/PR_FLASH_PROGRAM
STM32: remove critical sections in flash_program_page
2 parents bedd572 + d0ea046 commit dd1da3d

File tree

14 files changed

+49
-106
lines changed

14 files changed

+49
-106
lines changed

targets/TARGET_STM/TARGET_STM32F0/flash_api.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*/
1515

1616
#include "flash_api.h"
17-
#include "mbed_critical.h"
17+
#include "platform/mbed_critical.h"
1818

1919
#if DEVICE_FLASH
2020
#include "mbed_assert.h"
@@ -97,8 +97,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data,
9797
return -1;
9898
}
9999

100-
core_util_critical_section_enter();
101-
102100
/* Program the user Flash area word by word */
103101
StartAddress = address;
104102

@@ -129,8 +127,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data,
129127
}
130128
}
131129

132-
core_util_critical_section_exit();
133-
134130
if (HAL_FLASH_Lock() != HAL_OK) {
135131
return -1;
136132
}

targets/TARGET_STM/TARGET_STM32F1/flash_api.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*/
1818

1919
#include "flash_api.h"
20-
#include "mbed_critical.h"
20+
#include "platform/mbed_critical.h"
2121

2222
#if DEVICE_FLASH
2323
#include "mbed_assert.h"
@@ -100,8 +100,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data,
100100
return -1;
101101
}
102102

103-
core_util_critical_section_enter();
104-
105103
/* Program the user Flash area word by word */
106104
StartAddress = address;
107105

@@ -132,8 +130,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data,
132130
}
133131
}
134132

135-
core_util_critical_section_exit();
136-
137133
if (HAL_FLASH_Lock() != HAL_OK) {
138134
return -1;
139135
}

targets/TARGET_STM/TARGET_STM32F2/flash_api.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data,
8686
return -1;
8787
}
8888

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

114-
core_util_critical_section_exit();
115-
116112
if (HAL_FLASH_Lock() != HAL_OK) {
117113
return -1;
118114
}

targets/TARGET_STM/TARGET_STM32F3/flash_api.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*/
1818

1919
#include "flash_api.h"
20-
#include "mbed_critical.h"
20+
#include "platform/mbed_critical.h"
2121

2222
#if DEVICE_FLASH
2323
#include "mbed_assert.h"
@@ -100,8 +100,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data,
100100
return -1;
101101
}
102102

103-
core_util_critical_section_enter();
104-
105103
/* Program the user Flash area word by word */
106104
StartAddress = address;
107105

@@ -132,8 +130,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data,
132130
}
133131
}
134132

135-
core_util_critical_section_exit();
136-
137133
if (HAL_FLASH_Lock() != HAL_OK) {
138134
return -1;
139135
}

targets/TARGET_STM/TARGET_STM32F4/flash_api.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data,
8181
return -1;
8282
}
8383

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

109-
core_util_critical_section_exit();
110-
111107
if (HAL_FLASH_Lock() != HAL_OK) {
112108
return -1;
113109
}

targets/TARGET_STM/TARGET_STM32F7/flash_api.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data,
127127
return -1;
128128
}
129129

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

154-
core_util_critical_section_exit();
155-
156152
if (HAL_FLASH_Lock() != HAL_OK) {
157153
return -1;
158154
}

targets/TARGET_STM/TARGET_STM32G0/flash_api.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*/
1818

1919
#include "flash_api.h"
20-
#include "mbed_critical.h"
20+
#include "platform/mbed_critical.h"
2121

2222
#if DEVICE_FLASH
2323
#include "mbed_assert.h"
@@ -98,8 +98,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address,
9898
return -1;
9999
}
100100

101-
core_util_critical_section_enter();
102-
103101
/* Program the user Flash area word by word */
104102
StartAddress = address;
105103

@@ -130,8 +128,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address,
130128
}
131129
}
132130

133-
core_util_critical_section_exit();
134-
135131
if (HAL_FLASH_Lock() != HAL_OK) {
136132
return -1;
137133
}

targets/TARGET_STM/TARGET_STM32G4/flash_api.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*/
1515

1616
#include "flash_api.h"
17-
#include "mbed_critical.h"
17+
#include "platform/mbed_critical.h"
1818

1919
#if DEVICE_FLASH
2020
#include "mbed_assert.h"
@@ -177,8 +177,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address,
177177
return -1;
178178
}
179179

180-
core_util_critical_section_enter();
181-
182180
/* Clear error programming flags */
183181
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_ALL_ERRORS);
184182

@@ -215,8 +213,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address,
215213
}
216214
}
217215

218-
core_util_critical_section_exit();
219-
220216
if (HAL_FLASH_Lock() != HAL_OK) {
221217
return -1;
222218
}

targets/TARGET_STM/TARGET_STM32H7/flash_api.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data,
134134
return -1;
135135
}
136136

137-
core_util_critical_section_enter();
138-
139137
StartAddress = address;
140138
while ((address < (StartAddress + size)) && (status == 0)) {
141139
if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_FLASHWORD, address, (uint32_t)data) == HAL_OK) {
@@ -156,8 +154,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data,
156154
SCB_InvalidateICache();
157155
#endif /* DUAL_CORE */
158156

159-
core_util_critical_section_exit();
160-
161157
if (HAL_FLASH_Lock() != HAL_OK) {
162158
return -1;
163159
}

targets/TARGET_STM/TARGET_STM32L0/flash_api.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*/
1818

1919
#include "flash_api.h"
20-
#include "mbed_critical.h"
20+
#include "platform/mbed_critical.h"
2121

2222
#if DEVICE_FLASH
2323
#include "mbed_assert.h"
@@ -100,8 +100,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address,
100100
return -1;
101101
}
102102

103-
core_util_critical_section_enter();
104-
105103
/* Program the user Flash area word by word */
106104
StartAddress = address;
107105

@@ -132,8 +130,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address,
132130
}
133131
}
134132

135-
core_util_critical_section_exit();
136-
137133
if (HAL_FLASH_Lock() != HAL_OK) {
138134
return -1;
139135
}

targets/TARGET_STM/TARGET_STM32L1/flash_api.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*/
1515

1616
#include "flash_api.h"
17-
#include "mbed_critical.h"
17+
#include "platform/mbed_critical.h"
1818

1919
#if DEVICE_FLASH
2020
#include "mbed_assert.h"
@@ -95,8 +95,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address,
9595
return -1;
9696
}
9797

98-
core_util_critical_section_enter();
99-
10098
/* Program the user Flash area word by word */
10199
StartAddress = address;
102100

@@ -127,8 +125,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address,
127125
}
128126
}
129127

130-
core_util_critical_section_exit();
131-
132128
if (HAL_FLASH_Lock() != HAL_OK) {
133129
return -1;
134130
}

targets/TARGET_STM/TARGET_STM32L4/flash_api.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717

1818
#include "flash_api.h"
19-
#include "mbed_critical.h"
19+
#include "platform/mbed_critical.h"
2020

2121
#if DEVICE_FLASH
2222
#include "mbed_assert.h"
@@ -181,8 +181,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address,
181181
return -1;
182182
}
183183

184-
core_util_critical_section_enter();
185-
186184
/* Clear error programming flags */
187185
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_ALL_ERRORS);
188186

@@ -219,8 +217,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address,
219217
}
220218
}
221219

222-
core_util_critical_section_exit();
223-
224220
if (HAL_FLASH_Lock() != HAL_OK) {
225221
return -1;
226222
}

targets/TARGET_STM/TARGET_STM32L5/flash_api.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
*/
1515

1616
#include "flash_api.h"
17+
#include "platform/mbed_critical.h"
1718

1819
#if DEVICE_FLASH
1920

@@ -173,8 +174,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address,
173174
return -1;
174175
}
175176

176-
core_util_critical_section_enter();
177-
178177
/* Clear error programming flags */
179178
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_ALL_ERRORS);
180179

@@ -215,8 +214,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address,
215214
return -1;
216215
}
217216

218-
core_util_critical_section_enter();
219-
220217
return status;
221218
}
222219

0 commit comments

Comments
 (0)