Skip to content

Commit 4a2dbba

Browse files
committed
Reduce the number of flash operation related veneer table entries
Signed-off-by: Mahesh Mahadevan <[email protected]>
1 parent 162425b commit 4a2dbba

File tree

1 file changed

+49
-45
lines changed
  • targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_LPC55S69

1 file changed

+49
-45
lines changed

targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_LPC55S69/TARGET_M33_S/flash_api.c renamed to targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_LPC55S69/flash_api.c

Lines changed: 49 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,18 @@
1919

2020
#if DEVICE_FLASH
2121

22-
#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
23-
24-
#include <arm_cmse.h>
2522
#include "fsl_iap.h"
2623
#include "partition/region_defs.h"
24+
#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
25+
#include <arm_cmse.h>
26+
#endif
27+
28+
#define LPC55S69_SECURE_FLASH_START (PSA_SECURE_ROM_START - S_ROM_ALIAS_BASE)
29+
#define LPC55S69_SECURE_FLASH_SIZE (PSA_SECURE_ROM_SIZE + FLASH_SST_AREA_SIZE)
2730

2831
static flash_config_t flash_config;
2932

33+
#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
3034
/* Check if address range [start_addr, end_addr] is in non-secure flash
3135
*
3236
* @param obj The flash object
@@ -43,15 +47,15 @@ static int32_t flash_check_nonsecure(flash_t *obj, uint32_t start_addr, uint32_t
4347
}
4448

4549
/* Check if start address is in non-secure flash */
46-
if ((start_addr < FLASH_AREA_IMAGE_1_OFFSET) ||
47-
(start_addr >= (FLASH_AREA_IMAGE_1_OFFSET + NS_CODE_SIZE))) {
50+
if ((start_addr < PSA_NON_SECURE_ROM_START) ||
51+
(start_addr >= (PSA_NON_SECURE_ROM_START + PSA_NON_SECURE_ROM_SIZE))) {
4852
return -1;
4953
}
5054

5155
/* Check if end address is in non-secure flash */
5256
if (end_addr != start_addr) {
53-
if ((end_addr < FLASH_AREA_IMAGE_1_OFFSET) ||
54-
(end_addr >= (FLASH_AREA_IMAGE_1_OFFSET + NS_CODE_SIZE))) {
57+
if ((end_addr < PSA_NON_SECURE_ROM_START) ||
58+
(end_addr >= (PSA_NON_SECURE_ROM_START + PSA_NON_SECURE_ROM_SIZE))) {
5559
return -1;
5660
}
5761
}
@@ -68,11 +72,6 @@ MBED_NONSECURE_ENTRY int32_t flash_init(flash_t *obj)
6872
}
6973
}
7074

71-
MBED_NONSECURE_ENTRY int32_t flash_free(flash_t *obj)
72-
{
73-
return 0;
74-
}
75-
7675
MBED_NONSECURE_ENTRY int32_t flash_erase_sector(flash_t *obj, uint32_t address)
7776
{
7877
if (cmse_nonsecure_caller()) {
@@ -127,25 +126,6 @@ MBED_NONSECURE_ENTRY int32_t flash_program_page(flash_t *obj, uint32_t address,
127126
}
128127
}
129128

130-
MBED_NONSECURE_ENTRY uint32_t flash_get_sector_size(const flash_t *obj, uint32_t address)
131-
{
132-
if (cmse_nonsecure_caller()) {
133-
if ((address >= FLASH_AREA_IMAGE_1_OFFSET) &&
134-
(address < (FLASH_AREA_IMAGE_1_OFFSET + NS_CODE_SIZE))) {
135-
return flash_config.PFlashPageSize;
136-
}
137-
138-
return MBED_FLASH_INVALID_SIZE;
139-
}
140-
141-
if ((address >= FLASH_AREA_IMAGE_0_OFFSET) &&
142-
(address < (FLASH_AREA_IMAGE_0_OFFSET + 0x40000))) {
143-
return flash_config.PFlashPageSize;
144-
}
145-
146-
return MBED_FLASH_INVALID_SIZE;
147-
}
148-
149129
MBED_NONSECURE_ENTRY int32_t flash_read(flash_t *obj, uint32_t address, uint8_t *data, uint32_t size)
150130
{
151131
if (cmse_nonsecure_caller()) {
@@ -164,37 +144,61 @@ MBED_NONSECURE_ENTRY int32_t flash_read(flash_t *obj, uint32_t address, uint8_t
164144
memcpy(data, (const void *)address, size);
165145
return 0;
166146
}
147+
#endif // #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
167148

168-
MBED_NONSECURE_ENTRY uint32_t flash_get_page_size(const flash_t *obj)
149+
int32_t flash_free(flash_t *obj)
169150
{
170-
return flash_config.PFlashPageSize;
151+
return 0;
171152
}
172153

173-
MBED_NONSECURE_ENTRY uint32_t flash_get_start_address(const flash_t *obj)
154+
uint32_t flash_get_sector_size(const flash_t *obj, uint32_t address)
174155
{
175-
if (cmse_nonsecure_caller()) {
176-
return FLASH_AREA_IMAGE_1_OFFSET;
156+
#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
157+
if ((address >= LPC55S69_SECURE_FLASH_START) &&
158+
(address < (LPC55S69_SECURE_FLASH_START + LPC55S69_SECURE_FLASH_SIZE))) {
159+
return FSL_FEATURE_SYSCON_FLASH_PAGE_SIZE_BYTES;
177160
}
178161

179-
return FLASH_AREA_IMAGE_0_OFFSET;
162+
return MBED_FLASH_INVALID_SIZE;
163+
#else
164+
if ((address >= PSA_NON_SECURE_ROM_START) &&
165+
(address < (PSA_NON_SECURE_ROM_START + PSA_NON_SECURE_ROM_SIZE))) {
166+
return FSL_FEATURE_SYSCON_FLASH_PAGE_SIZE_BYTES;
167+
}
168+
169+
return MBED_FLASH_INVALID_SIZE;
170+
#endif
180171
}
181172

182-
MBED_NONSECURE_ENTRY uint32_t flash_get_size(const flash_t *obj)
173+
uint32_t flash_get_page_size(const flash_t *obj)
183174
{
184-
if (cmse_nonsecure_caller()) {
185-
return NS_CODE_SIZE;
186-
}
175+
return FSL_FEATURE_SYSCON_FLASH_PAGE_SIZE_BYTES;
176+
}
177+
178+
uint32_t flash_get_start_address(const flash_t *obj)
179+
{
180+
#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
181+
return LPC55S69_SECURE_FLASH_START;
182+
#else
183+
return PSA_NON_SECURE_ROM_START;
184+
#endif
185+
}
187186

188-
return 0x40000;
187+
uint32_t flash_get_size(const flash_t *obj)
188+
{
189+
#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
190+
return LPC55S69_SECURE_FLASH_SIZE;
191+
#else
192+
return PSA_NON_SECURE_ROM_SIZE;
193+
#endif
189194
}
190195

191-
MBED_NONSECURE_ENTRY uint8_t flash_get_erase_value(const flash_t *obj)
196+
uint8_t flash_get_erase_value(const flash_t *obj)
192197
{
193198
(void)obj;
194199

195200
return 0x0;
196201
}
197202

198-
#endif // #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
199-
#endif
203+
#endif //DEVICE_FLASH
200204

0 commit comments

Comments
 (0)