From 59a3b6c6ec1aa4ed11c2a4ba75f197f3b3a9c43d Mon Sep 17 00:00:00 2001 From: Sumit Batra Date: Sun, 16 Nov 2025 15:33:46 +0530 Subject: [PATCH] hal/nxp: s32K344: flash_c40: add C40 features, IP aliases; init ret MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - fsl_c40_flash.c: Initialize `ret` in FLASH_Erase() to `kStatus_FLASH_Success` to avoid potential use-before-set warnings on some toolchains/static analyzers (no functional change). - S32K344_features.h: Define C40 array geometry for S32K344 using unsigned constants: * 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) Note: erase/program granularities are controller-level and handled by driver. - S32K344_glue_mcux.h: Provide conditional aliases mapping FLASH↔IP_FLASH and PFLASH↔IP_PFLASH to harmonize SDK naming and improve build portability. Signed-off-by: Sumit Batra --- mcux/README | 7 +++++++ .../drivers/flash_c40/fsl_c40_flash.c | 2 +- s32/mcux/devices/S32K344/S32K344_features.h | 9 +++++++++ s32/mcux/devices/S32K344/S32K344_glue_mcux.h | 20 +++++++++++++++++++ 4 files changed, 37 insertions(+), 1 deletion(-) diff --git a/mcux/README b/mcux/README index f6aba901f0..8dca1b104f 100644 --- a/mcux/README +++ b/mcux/README @@ -244,6 +244,13 @@ Patch List: - PR: https://github.com/zephyrproject-rtos/hal_nxp/pull/597 - This patch is in hal_nxp but is not in mcux-sdk-ng 25.09.00. + - hal/nxp: s32K344: flash_c40: add C40 features, IP aliases + - Commit: https://github.com/zephyrproject-rtos/hal_nxp/pull/618/commits/64395f565184964bbf21e247df6ca88dc4d7cf83 + - This patch is in hal_nxp but is not in mcux-sdk-ng 25.09.00. + This patch was merged after PR https://github.com/zephyrproject-rtos/hal_nxp/pull/618/commits was created. + Also since the additions about C40 Flash geometry in S32K344_features.h and defining local Flash Aliases in + S32K344_glue_mcux.h, are for S32K344 SoC so they are not present in the mcusdk-core repo. + Note: - The SAI driver should not be updated during hal_nxp updates, since the latest SAI driver will cause runtime issues on MCXN947 for Zephyr I2S-related test cases. diff --git a/mcux/mcux-sdk-ng/drivers/flash_c40/fsl_c40_flash.c b/mcux/mcux-sdk-ng/drivers/flash_c40/fsl_c40_flash.c index 31395a57cf..133c19e8f9 100644 --- a/mcux/mcux-sdk-ng/drivers/flash_c40/fsl_c40_flash.c +++ b/mcux/mcux-sdk-ng/drivers/flash_c40/fsl_c40_flash.c @@ -818,7 +818,7 @@ status_t FLASH_Erase(flash_config_t *config, uint32_t start, uint32_t lengthInBy status_t FLASH_Program(flash_config_t *config, uint32_t start, uint32_t *src, uint32_t lengthInBytes) { - status_t ret; + status_t ret = kStatus_FLASH_Success; size_t chunkSize; size_t sizeLeft = lengthInBytes; uint8_t *src8 = (uint8_t *) src; diff --git a/s32/mcux/devices/S32K344/S32K344_features.h b/s32/mcux/devices/S32K344/S32K344_features.h index 6b2dd951df..92f64dd253 100644 --- a/s32/mcux/devices/S32K344/S32K344_features.h +++ b/s32/mcux/devices/S32K344/S32K344_features.h @@ -236,4 +236,13 @@ /* @brief Memory map has offset between subsystems. */ #define FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET (1) +/* FLASH Module features */ + +/* @brief Code flash (PFLASH) implemented as 1 MiB blocks */ +#define FSL_FEATURE_FLASH_C40_BLOCK_SIZE_CODE (1024u * 1024u) +/* @brief Code flash (PFLASH) has 4 blocks of 1 MiB each total size = 4 MiB */ +#define FSL_FEATURE_FLASH_C40_BLOCK_COUNT_CODE (4u) +/* @brief Data flash (DFLASH) window: 256 KiB */ +#define FSL_FEATURE_FLASH_C40_BLOCK_SIZE_DATA (256u * 1024u) + #endif /* _S32K344_FEATURES_H_ */ diff --git a/s32/mcux/devices/S32K344/S32K344_glue_mcux.h b/s32/mcux/devices/S32K344/S32K344_glue_mcux.h index fe58a8084c..ddb1675386 100644 --- a/s32/mcux/devices/S32K344/S32K344_glue_mcux.h +++ b/s32/mcux/devices/S32K344/S32K344_glue_mcux.h @@ -208,4 +208,24 @@ #define FLEXIO_BASE_PTRS IP_FLEXIO_BASE_PTRS /** Interrupt vectors for the FLEXIO peripheral type */ #define FLEXIO_IRQS { FLEXIO_IRQn } + +/* FLASH - Peripheral instance base addresses */ +/** Peripheral FLASH base address */ +#define FLASH_BASE IP_FLASH_BASE +/** Peripheral FLASH base pointer */ +#define FLASH IP_FLASH +/** Array initializer of FLASH peripheral base addresses */ +#define FLASH_BASE_ADDRS IP_FLASH_BASE_ADDRS +/** Array initializer of FLASH peripheral base pointers */ +#define FLASH_BASE_PTRS IP_FLASH_BASE_PTRS + +/* PFLASH - Peripheral instance base addresses */ +/** Peripheral PFLASH base address */ +#define PFLASH_BASE IP_PFLASH_BASE +/** Peripheral PFLASH base pointer */ +#define PFLASH IP_PFLASH +/** Array initializer of PFLASH peripheral base addresses */ +#define PFLASH_BASE_ADDRS IP_PFLASH_BASE_ADDRS +/** Array initializer of PFLASH peripheral base pointers */ +#define PFLASH_BASE_PTRS IP_PFLASH_BASE_PTRS #endif /* _S32K344_GLUE_MCUX_H_ */