Skip to content

Commit 9f2c421

Browse files
hal/nxp: mcux: flash_c40: add IP aliases; init ret; S32K344: define C40 features
- Add conditional aliases (FLASH↔IP_FLASH, PFLASH↔IP_PFLASH) so the driver builds across MCUX SDK variants that name the C40 IP differently. No functional change; improves portability. - Initialize `ret` to `kStatus_FLASH_Success` in FLASH_Program() to avoid potential use-before-set warnings and satisfy static analyzers on edge paths. - Define S32K344 C40 flash geometry in S32K344_features.h: * FSL_FEATURE_FLASH_C40_BLOCK_SIZE_CODE (1 MiB) * FSL_FEATURE_FLASH_C40_BLOCK_COUNT_CODE (4) * FSL_FEATURE_FLASH_C40_BLOCK_SIZE_DATA (256 KiB) * aggregate total code flash size macro Values use unsigned constants for toolchain robustness. Min erase/program granularities remain controller-level (handled in the driver). Tested on S32K344 (XIP) alongside Zephyr C40 on-chip flash driver integration. Signed-off-by: Sumit Batra <sumit.batra@nxp.com>
1 parent 18a86af commit 9f2c421

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@
3030
* Definitions
3131
******************************************************************************/
3232

33+
/* Define local flash IP aliases */
34+
#if !defined(FLASH) && defined(IP_FLASH)
35+
#define FLASH IP_FLASH /* Define a local alias for C40 flash memory */
36+
#endif
37+
#if !defined(PFLASH) && defined(IP_PFLASH)
38+
#define PFLASH IP_PFLASH /* Define a local alias for flash memory controller */
39+
#endif
40+
3341
/* Component ID definition, used by tools. */
3442
#ifndef FSL_COMPONENT_ID
3543
#define FSL_COMPONENT_ID "platform.drivers.flash_c40"
@@ -818,7 +826,7 @@ status_t FLASH_Erase(flash_config_t *config, uint32_t start, uint32_t lengthInBy
818826

819827
status_t FLASH_Program(flash_config_t *config, uint32_t start, uint32_t *src, uint32_t lengthInBytes)
820828
{
821-
status_t ret;
829+
status_t ret = kStatus_FLASH_Success;
822830
size_t chunkSize;
823831
size_t sizeLeft = lengthInBytes;
824832
uint8_t *src8 = (uint8_t *) src;

s32/mcux/devices/S32K344/S32K344_features.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,4 +236,25 @@
236236
/* @brief Memory map has offset between subsystems. */
237237
#define FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET (1)
238238

239+
/* C40 flash features (S32K344)
240+
*
241+
* These describe the on-chip C40 flash array geometry for the S32K344.
242+
* Values are expressed in bytes and use unsigned constants to avoid
243+
* toolchain sign/overflow surprises across GCC/ARMCLANG/IAR.
244+
*
245+
* Code flash (PFLASH): 4 MiB total implemented as 4 × 1 MiB blocks.
246+
* Data flash (DFLASH) window: 256 KiB.
247+
*
248+
* Note: Min erase/program granularities are controller-level properties
249+
* (8 KiB erase, 8 bytes program) and are handled by the driver; they are
250+
* not expressed as SoC features here.
251+
*/
252+
#define FSL_FEATURE_FLASH_C40_BLOCK_SIZE_CODE (1024u * 1024u)
253+
#define FSL_FEATURE_FLASH_C40_BLOCK_COUNT_CODE (4u)
254+
#define FSL_FEATURE_FLASH_C40_BLOCK_SIZE_DATA (256u * 1024u)
255+
256+
/* (Optional) aggregate for convenience: total code flash size */
257+
#define FSL_FEATURE_FLASH_C40_CODE_TOTAL_SIZE \
258+
(FSL_FEATURE_FLASH_C40_BLOCK_SIZE_CODE * FSL_FEATURE_FLASH_C40_BLOCK_COUNT_CODE)
259+
239260
#endif /* _S32K344_FEATURES_H_ */

0 commit comments

Comments
 (0)