Skip to content

Commit 25a2244

Browse files
hal/nxp: mcux: flash_c40: add SoC features header and minor cleanups
Introduce fsl_c40_flash_features.h with S32K344 C40 array geometry (block sizes and counts). Signed-off-by: Sumit Batra <sumit.batra@nxp.com>
1 parent 96951d0 commit 25a2244

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

mcux/mcux-sdk-ng/drivers/flash_c40/fsl_c40_flash.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,20 @@
2121
#include "fsl_c40_flash.h"
2222
#include "fsl_common.h"
2323
#include "fsl_device_registers.h"
24+
#include "fsl_c40_flash_features.h"
2425

2526

2627
/*******************************************************************************
2728
* Definitions
2829
******************************************************************************/
2930

31+
#if !defined(FLASH) && defined(IP_FLASH)
32+
#define FLASH IP_FLASH /* Define a local alias for C40 flash memory */
33+
#endif
34+
#if !defined(PFLASH) && defined(IP_PFLASH)
35+
#define PFLASH IP_PFLASH /* Define a local alias for flash memory controller */
36+
#endif
37+
3038
/* Component ID definition, used by tools. */
3139
#ifndef FSL_COMPONENT_ID
3240
#define FSL_COMPONENT_ID "platform.drivers.flash_c40"
@@ -797,7 +805,7 @@ status_t FLASH_Erase(flash_config_t *config, uint32_t start, uint32_t lengthInBy
797805

798806
status_t FLASH_Program(flash_config_t *config, uint32_t start, uint32_t *src, uint32_t lengthInBytes)
799807
{
800-
status_t ret;
808+
status_t ret = kStatus_FLASH_Success;
801809
size_t chunkSize;
802810
size_t sizeLeft = lengthInBytes;
803811
uint8_t *src8 = (uint8_t *) src;
@@ -878,4 +886,4 @@ status_t FLASH_GetSectorProtection(flash_config_t *config, uint32_t address)
878886
}
879887

880888
return C40_SectorLockStatus(sectorNum);
881-
}
889+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright 2025 NXP
3+
* All rights reserved.
4+
*
5+
* SPDX-License-Identifier: BSD-3-Clause
6+
*
7+
*/
8+
9+
#ifndef FSL_C40_FLASH_FEATURES_H_
10+
#define FSL_C40_FLASH_FEATURES_H_
11+
12+
#include "fsl_common.h"
13+
14+
/* Differences in flash array for different S32K3 variants can be added in elif conditions */
15+
#if defined(CPU_S32K344)
16+
17+
/* Code flash: 4 MiB total => 4 blocks × 1 MiB each */
18+
#define FSL_FEATURE_FLASH_C40_BLOCK_SIZE_CODE (1024 * 1024)
19+
#define FSL_FEATURE_FLASH_C40_BLOCK_COUNT_CODE (4)
20+
/* Data flash: 256 KiB */
21+
#define FSL_FEATURE_FLASH_C40_BLOCK_SIZE_DATA (256 * 1024)
22+
#else
23+
#error "C40 feature macros not defined for this SoC."
24+
25+
#endif
26+
27+
#endif /* FSL_C40_FLASH_FEATURES_H_ */

0 commit comments

Comments
 (0)