Index: trunk/firmware/App/CubeMX/Appli/Core/Inc/FreeRTOSConfig.h
===================================================================
--- trunk/firmware/App/CubeMX/Appli/Core/Inc/FreeRTOSConfig.h	(revision 30)
+++ trunk/firmware/App/CubeMX/Appli/Core/Inc/FreeRTOSConfig.h	(revision 30)
@@ -0,0 +1,193 @@
+/* USER CODE BEGIN Header */
+/*
+ * FreeRTOS Kernel V11.2.0
+ * Portion Copyright (C) 2017 Amazon.com, Inc. or its affiliates.  All Rights Reserved.
+ * Portion Copyright (C) 2019 StMicroelectronics, Inc.  All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+ * the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * http://www.FreeRTOS.org
+ * http://aws.amazon.com/freertos
+ *
+ * 1 tab == 4 spaces!
+ */
+/* USER CODE END Header */
+
+#ifndef __FREERTOS_CONFIG_H
+#define __FREERTOS_CONFIG_H
+
+/*-----------------------------------------------------------
+ * Application specific definitions.
+ *
+ * These definitions should be adjusted for your particular hardware and
+ * application requirements.
+ *
+ * These parameters and more are described within the 'configuration' section of the
+ * FreeRTOS API documentation available on the FreeRTOS.org web site.
+ *
+ * See http://www.freertos.org/a00110.html
+ *----------------------------------------------------------*/
+
+/* USER CODE BEGIN Includes */
+/* Section where include file can be added */
+/* USER CODE END Includes */
+
+/* Ensure definitions are only used by the compiler, and not by the assembler. */
+#if defined(__ICCARM__) || defined(__ARMCC_VERSION) || defined(__GNUC__)
+#include <stdint.h>
+extern uint32_t SystemCoreClock;
+void xPortSysTickHandler(void);
+#endif
+#ifndef CMSIS_device_header
+#define CMSIS_device_header "stm32n6xx.h"
+#endif /* CMSIS_device_header */
+
+/*-------------------- STM32N6 specific defines -------------------*/
+#define configENABLE_TRUSTZONE                   0
+#define configRUN_FREERTOS_SECURE_ONLY           1
+#define configENABLE_FPU                         1
+#define configENABLE_MPU                         0
+#define configENABLE_MVE                         1
+#define configUSE_PREEMPTION                     1
+#define configUSE_TIME_SLICING                   1
+#define configSUPPORT_STATIC_ALLOCATION          1
+#define configSUPPORT_DYNAMIC_ALLOCATION         1
+#define configUSE_IDLE_HOOK                      1
+#define configUSE_TICK_HOOK                      0
+#define configCPU_CLOCK_HZ                       ( SystemCoreClock )
+#define configTICK_RATE_HZ                       ((TickType_t)1000)
+#define configMAX_PRIORITIES                     ( 56 )
+#define configMINIMAL_STACK_SIZE                 ((uint16_t)128)
+#define configTOTAL_HEAP_SIZE                    ((size_t)8192)
+#define configSTACK_ALLOCATION_FROM_SEPARATE_HEAP 0
+#define configMAX_TASK_NAME_LEN                  ( 16 )
+#define configUSE_TRACE_FACILITY                 1
+#define configUSE_16_BIT_TICKS                   0
+#define configUSE_MUTEXES                        1
+#define configQUEUE_REGISTRY_SIZE                8
+#define configCHECK_FOR_STACK_OVERFLOW           2
+#define configUSE_RECURSIVE_MUTEXES              1
+#define configUSE_COUNTING_SEMAPHORES            1
+#define configENABLE_BACKWARD_COMPATIBILITY      0
+#define configUSE_PORT_OPTIMISED_TASK_SELECTION  0
+#define configUSE_TASK_NOTIFICATIONS             1
+#define configRECORD_STACK_HIGH_ADDRESS          1
+#define configHEAP_CLEAR_MEMORY_ON_FREE          0
+#define configUSE_MINI_LIST_ITEM                 1
+#define configUSE_SB_COMPLETED_CALLBACK          0
+#define configKERNEL_PROVIDED_STATIC_MEMORY      1
+#define configSTATS_BUFFER_MAX_LENGTH            0xFFFF
+#define configENABLE_HEAP_PROTECTOR              0
+#define configUSE_EVENT_GROUPS                   1
+#define configUSE_STREAM_BUFFERS                 1
+#define configCHECK_HANDLER_INSTALLATION         1
+#define configVALIDATE_HEAP_BLOCK_POINTER        0
+/* USER CODE BEGIN MESSAGE_BUFFER_LENGTH_TYPE */
+/* Defaults to size_t for backward compatibility, but can be changed
+   if lengths will always be less than the number of bytes in a size_t. */
+#define configMESSAGE_BUFFER_LENGTH_TYPE         size_t
+/* USER CODE END MESSAGE_BUFFER_LENGTH_TYPE */
+
+#define configRUN_TIME_COUNTER_TYPE              size_t
+
+#define configSTACK_DEPTH_TYPE                   size_t
+
+/* Co-routine definitions. */
+#define configUSE_CO_ROUTINES                    0
+#define configMAX_CO_ROUTINE_PRIORITIES          ( 2 )
+
+/* Software timer definitions. */
+#define configUSE_TIMERS                         1
+#define configTIMER_TASK_PRIORITY                ( 55 )
+#define configTIMER_QUEUE_LENGTH                 10
+#define configTIMER_TASK_STACK_DEPTH             128
+
+/* CMSIS-RTOS V2 flags */
+#define configUSE_OS2_THREAD_SUSPEND_RESUME  1
+#define configUSE_OS2_THREAD_ENUMERATE       1
+#define configUSE_OS2_EVENTFLAGS_FROM_ISR    1
+#define configUSE_OS2_THREAD_FLAGS           1
+#define configUSE_OS2_TIMER                  1
+#define configUSE_OS2_MUTEX                  1
+
+/* Set the following definitions to 1 to include the API function, or zero
+to exclude the API function. */
+#define INCLUDE_vTaskPrioritySet             1
+#define INCLUDE_uxTaskPriorityGet            1
+#define INCLUDE_vTaskDelete                  1
+#define INCLUDE_vTaskCleanUpResources        0
+#define INCLUDE_vTaskSuspend                 1
+#define INCLUDE_xTaskDelayUntil              1
+#define INCLUDE_vTaskDelay                   1
+#define INCLUDE_xTaskGetSchedulerState       1
+#define INCLUDE_xTimerPendFunctionCall       1
+#define INCLUDE_xQueueGetMutexHolder         1
+#define INCLUDE_xSemaphoreGetMutexHolder     1
+#define INCLUDE_pcTaskGetTaskName            1
+#define INCLUDE_uxTaskGetStackHighWaterMark  1
+#define INCLUDE_uxTaskGetStackHighWaterMark2 1
+#define INCLUDE_xTaskGetCurrentTaskHandle    1
+#define INCLUDE_eTaskGetState                1
+#define INCLUDE_xTaskAbortDelay              1
+#define INCLUDE_xTaskGetHandle               1
+
+/* Cortex-M specific definitions. */
+#ifdef __NVIC_PRIO_BITS
+ /* __NVIC_PRIO_BITS will be specified when CMSIS is being used. */
+ #define configPRIO_BITS         __NVIC_PRIO_BITS
+#else
+ #define configPRIO_BITS         4
+#endif
+
+/* The lowest interrupt priority that can be used in a call to a "set priority"
+function. */
+#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY   15
+
+/* The highest interrupt priority that can be used by any interrupt service
+routine that makes calls to interrupt safe FreeRTOS API functions.  DO NOT CALL
+INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER
+PRIORITY THAN THIS! (higher priorities are lower numeric values. */
+#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5
+
+/* Interrupt priorities used by the kernel port layer itself.  These are generic
+to all Cortex-M ports, and do not rely on any particular library functions. */
+#define configKERNEL_INTERRUPT_PRIORITY 		( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
+/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!
+See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
+#define configMAX_SYSCALL_INTERRUPT_PRIORITY 	( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
+
+/* Normal assert() semantics without relying on the provision of an assert.h
+header file. */
+/* USER CODE BEGIN 1 */
+#define configASSERT( x ) if ((x) == 0) {taskDISABLE_INTERRUPTS(); for( ;; );}
+/* USER CODE END 1 */
+
+/* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS
+standard names. */
+#define vPortSVCHandler     SVC_Handler
+#define xPortPendSVHandler  PendSV_Handler
+
+/* IMPORTANT: After 10.3.1 update, Systick_Handler comes from NVIC (if SYS timebase = systick), otherwise from cmsis_os2.c */
+
+#define USE_CUSTOM_SYSTICK_HANDLER_IMPLEMENTATION 1
+
+/* USER CODE BEGIN Defines */
+/* Section where parameter definitions can be added (for instance, to override default ones in FreeRTOS.h) */
+/* USER CODE END Defines */
+
+#endif /* __FREERTOS_CONFIG_H */
Index: trunk/firmware/App/CubeMX/Appli/Core/Inc/app_freertos.h
===================================================================
--- trunk/firmware/App/CubeMX/Appli/Core/Inc/app_freertos.h	(revision 30)
+++ trunk/firmware/App/CubeMX/Appli/Core/Inc/app_freertos.h	(revision 30)
@@ -0,0 +1,79 @@
+/* USER CODE BEGIN Header */
+/**
+  ******************************************************************************
+  * File Name          : app_freertos.h
+  * Description        : FreeRTOS applicative header file
+  ******************************************************************************
+  * @attention
+  *
+  * Copyright (c) 2026 STMicroelectronics.
+  * All rights reserved.
+  *
+  * This software is licensed under terms that can be found in the LICENSE file
+  * in the root directory of this software component.
+  * If no LICENSE file comes with this software, it is provided AS-IS.
+  *
+  ******************************************************************************
+  */
+/* USER CODE END Header */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __APP_FREERTOS_H
+#define __APP_FREERTOS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+/* Includes ------------------------------------------------------------------*/
+#include "FreeRTOS.h"
+#include "task.h"
+#include "main.h"
+#include "cmsis_os2.h"
+
+/* Private includes ----------------------------------------------------------*/
+/* USER CODE BEGIN Includes */
+
+/* USER CODE END Includes */
+
+/* Exported types ------------------------------------------------------------*/
+/* USER CODE BEGIN ET */
+
+/* USER CODE END ET */
+
+/* Exported constants --------------------------------------------------------*/
+/* USER CODE BEGIN EC */
+
+/* USER CODE END EC */
+
+/* Private define ------------------------------------------------------------*/
+/* USER CODE BEGIN PD */
+
+/* USER CODE END PD */
+
+/* Exported macro -------------------------------------------------------------*/
+/* USER CODE BEGIN EM */
+
+/* USER CODE END EM */
+extern osThreadId_t mainTaskHandle;
+
+/* Exported function prototypes -----------------------------------------------*/
+/* USER CODE BEGIN FunctionPrototypes */
+
+/* USER CODE END FunctionPrototypes */
+
+extern void StartMainTask(void *argument);
+
+void MX_FREERTOS_Init(void); /* (MISRA C 2004 rule 8.1) */
+
+/* Hook prototypes */
+void vApplicationIdleHook(void);
+void vApplicationStackOverflowHook(TaskHandle_t xTask, char *pcTaskName);
+/* Private application code --------------------------------------------------*/
+/* USER CODE BEGIN Application */
+
+/* USER CODE END Application */
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __APP_FREERTOS_H */
Index: trunk/firmware/App/CubeMX/Appli/Core/Inc/bsec.h
===================================================================
--- trunk/firmware/App/CubeMX/Appli/Core/Inc/bsec.h	(revision 30)
+++ trunk/firmware/App/CubeMX/Appli/Core/Inc/bsec.h	(revision 30)
@@ -0,0 +1,50 @@
+/* USER CODE BEGIN Header */
+/**
+  ******************************************************************************
+  * @file    bsec.h
+  * @brief   This file contains all the function prototypes for
+  *          the bsec.c file
+  ******************************************************************************
+  * @attention
+  *
+  * Copyright (c) 2026 STMicroelectronics.
+  * All rights reserved.
+  *
+  * This software is licensed under terms that can be found in the LICENSE file
+  * in the root directory of this software component.
+  * If no LICENSE file comes with this software, it is provided AS-IS.
+  *
+  ******************************************************************************
+  */
+/* USER CODE END Header */
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __BSEC_H__
+#define __BSEC_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "main.h"
+
+/* USER CODE BEGIN Includes */
+
+/* USER CODE END Includes */
+
+/* USER CODE BEGIN Private defines */
+
+/* USER CODE END Private defines */
+
+void MX_BSEC_Init(void);
+
+/* USER CODE BEGIN Prototypes */
+
+/* USER CODE END Prototypes */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __BSEC_H__ */
+
Index: trunk/firmware/App/CubeMX/Appli/Core/Inc/main.h
===================================================================
--- trunk/firmware/App/CubeMX/Appli/Core/Inc/main.h	(revision 29)
+++ trunk/firmware/App/CubeMX/Appli/Core/Inc/main.h	(revision 30)
@@ -79,6 +79,12 @@
 
 /* Private defines -----------------------------------------------------------*/
+#define PWR_SD_EN_Pin GPIO_PIN_7
+#define PWR_SD_EN_GPIO_Port GPIOQ
+#define LDO_SD_SEL_Pin GPIO_PIN_5
+#define LDO_SD_SEL_GPIO_Port GPIOO
 #define LED_GREEN_Pin GPIO_PIN_1
 #define LED_GREEN_GPIO_Port GPIOO
+#define DETECT_SD_Pin GPIO_PIN_12
+#define DETECT_SD_GPIO_Port GPION
 
 /* USER CODE BEGIN Private defines */
Index: trunk/firmware/App/CubeMX/Appli/Core/Inc/sdmmc.h
===================================================================
--- trunk/firmware/App/CubeMX/Appli/Core/Inc/sdmmc.h	(revision 30)
+++ trunk/firmware/App/CubeMX/Appli/Core/Inc/sdmmc.h	(revision 30)
@@ -0,0 +1,52 @@
+/* USER CODE BEGIN Header */
+/**
+  ******************************************************************************
+  * @file    sdmmc.h
+  * @brief   This file contains all the function prototypes for
+  *          the sdmmc.c file
+  ******************************************************************************
+  * @attention
+  *
+  * Copyright (c) 2026 STMicroelectronics.
+  * All rights reserved.
+  *
+  * This software is licensed under terms that can be found in the LICENSE file
+  * in the root directory of this software component.
+  * If no LICENSE file comes with this software, it is provided AS-IS.
+  *
+  ******************************************************************************
+  */
+/* USER CODE END Header */
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __SDMMC_H__
+#define __SDMMC_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "main.h"
+
+/* USER CODE BEGIN Includes */
+
+/* USER CODE END Includes */
+
+extern SD_HandleTypeDef hsd2;
+
+/* USER CODE BEGIN Private defines */
+
+/* USER CODE END Private defines */
+
+void MX_SDMMC2_SD_Init(void);
+
+/* USER CODE BEGIN Prototypes */
+
+/* USER CODE END Prototypes */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __SDMMC_H__ */
+
Index: trunk/firmware/App/CubeMX/Appli/Core/Inc/stm32n6xx_hal_conf.h
===================================================================
--- trunk/firmware/App/CubeMX/Appli/Core/Inc/stm32n6xx_hal_conf.h	(revision 29)
+++ trunk/firmware/App/CubeMX/Appli/Core/Inc/stm32n6xx_hal_conf.h	(revision 30)
@@ -72,5 +72,5 @@
 /*#define HAL_RTC_MODULE_ENABLED   */
 /*#define HAL_SAI_MODULE_ENABLED   */
-/*#define HAL_SD_MODULE_ENABLED   */
+#define HAL_SD_MODULE_ENABLED
 /*#define HAL_SDIO_MODULE_ENABLED   */
 /*#define HAL_SDRAM_MODULE_ENABLED   */
Index: trunk/firmware/App/CubeMX/Appli/Core/Src/app_freertos.c
===================================================================
--- trunk/firmware/App/CubeMX/Appli/Core/Src/app_freertos.c	(revision 30)
+++ trunk/firmware/App/CubeMX/Appli/Core/Src/app_freertos.c	(revision 30)
@@ -0,0 +1,132 @@
+/* USER CODE BEGIN Header */
+/**
+  ******************************************************************************
+  * File Name          : app_freertos.c
+  * Description        : FreeRTOS applicative file
+  ******************************************************************************
+  * @attention
+  *
+  * Copyright (c) 2026 STMicroelectronics.
+  * All rights reserved.
+  *
+  * This software is licensed under terms that can be found in the LICENSE file
+  * in the root directory of this software component.
+  * If no LICENSE file comes with this software, it is provided AS-IS.
+  *
+  ******************************************************************************
+  */
+/* USER CODE END Header */
+
+/* Includes ------------------------------------------------------------------*/
+#include "app_freertos.h"
+
+/* Private includes ----------------------------------------------------------*/
+/* USER CODE BEGIN Includes */
+
+/* USER CODE END Includes */
+
+/* Private typedef -----------------------------------------------------------*/
+typedef StaticTask_t osStaticThreadDef_t;
+/* USER CODE BEGIN PTD */
+
+/* USER CODE END PTD */
+
+/* Private define ------------------------------------------------------------*/
+/* USER CODE BEGIN PD */
+
+/* USER CODE END PD */
+
+/* Private macro -------------------------------------------------------------*/
+/* USER CODE BEGIN PM */
+
+/* USER CODE END PM */
+
+/* Private variables ---------------------------------------------------------*/
+/* USER CODE BEGIN Variables */
+
+/* USER CODE END Variables */
+/* Definitions for mainTask */
+osThreadId_t mainTaskHandle;
+uint32_t mainTaskBuffer[ 1024 ];
+osStaticThreadDef_t mainTaskControlBlock;
+const osThreadAttr_t mainTask_attributes = {
+  .name = "mainTask",
+  .stack_mem = &mainTaskBuffer[0],
+  .stack_size = sizeof(mainTaskBuffer),
+  .cb_mem = &mainTaskControlBlock,
+  .cb_size = sizeof(mainTaskControlBlock),
+  .priority = (osPriority_t) osPriorityNormal,
+};
+
+/* Private function prototypes -----------------------------------------------*/
+/* USER CODE BEGIN FunctionPrototypes */
+
+/* USER CODE END FunctionPrototypes */
+
+/* USER CODE BEGIN 2 */
+void vApplicationIdleHook( void )
+{
+   /* vApplicationIdleHook() will only be called if configUSE_IDLE_HOOK is set
+   to 1 in FreeRTOSConfig.h. It will be called on each iteration of the idle
+   task. It is essential that code added to this hook function never attempts
+   to block in any way (for example, call xQueueReceive() with a block time
+   specified, or call vTaskDelay()). If the application makes use of the
+   vTaskDelete() API function (as this demo application does) then it is also
+   important that vApplicationIdleHook() is permitted to return to its calling
+   function, because it is the responsibility of the idle task to clean up
+   memory allocated by the kernel to any task that has since been deleted. */
+}
+/* USER CODE END 2 */
+
+/* USER CODE BEGIN 4 */
+void vApplicationStackOverflowHook(TaskHandle_t xTask, char *pcTaskName)
+{
+   /* Run time stack overflow checking is performed if
+   configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook function is
+   called if a stack overflow is detected. */
+}
+/* USER CODE END 4 */
+
+/**
+  * @brief  FreeRTOS initialization
+  * @param  None
+  * @retval None
+  */
+void MX_FREERTOS_Init(void) {
+  /* USER CODE BEGIN Init */
+
+  /* USER CODE END Init */
+
+  /* USER CODE BEGIN RTOS_MUTEX */
+  /* add mutexes, ... */
+  /* USER CODE END RTOS_MUTEX */
+
+  /* USER CODE BEGIN RTOS_SEMAPHORES */
+  /* add semaphores, ... */
+  /* USER CODE END RTOS_SEMAPHORES */
+
+  /* USER CODE BEGIN RTOS_TIMERS */
+  /* start timers, add new ones, ... */
+  /* USER CODE END RTOS_TIMERS */
+
+  /* USER CODE BEGIN RTOS_QUEUES */
+  /* add queues, ... */
+  /* USER CODE END RTOS_QUEUES */
+  /* creation of mainTask */
+  mainTaskHandle = osThreadNew(StartMainTask, NULL, &mainTask_attributes);
+
+  /* USER CODE BEGIN RTOS_THREADS */
+  /* add threads, ... */
+  /* USER CODE END RTOS_THREADS */
+
+  /* USER CODE BEGIN RTOS_EVENTS */
+  /* add events, ... */
+  /* USER CODE END RTOS_EVENTS */
+
+}
+
+/* Private application code --------------------------------------------------*/
+/* USER CODE BEGIN Application */
+
+/* USER CODE END Application */
+
Index: trunk/firmware/App/CubeMX/Appli/Core/Src/bsec.c
===================================================================
--- trunk/firmware/App/CubeMX/Appli/Core/Src/bsec.c	(revision 30)
+++ trunk/firmware/App/CubeMX/Appli/Core/Src/bsec.c	(revision 30)
@@ -0,0 +1,60 @@
+/* USER CODE BEGIN Header */
+/**
+  ******************************************************************************
+  * @file    bsec.c
+  * @brief   This file provides code for the configuration
+  *          of the BSEC instances.
+  ******************************************************************************
+  * @attention
+  *
+  * Copyright (c) 2026 STMicroelectronics.
+  * All rights reserved.
+  *
+  * This software is licensed under terms that can be found in the LICENSE file
+  * in the root directory of this software component.
+  * If no LICENSE file comes with this software, it is provided AS-IS.
+  *
+  ******************************************************************************
+  */
+/* USER CODE END Header */
+/* Includes ------------------------------------------------------------------*/
+#include "bsec.h"
+
+/* USER CODE BEGIN 0 */
+
+BSEC_HandleTypeDef hbsec = { .Instance = BSEC };
+
+/* USER CODE END 0 */
+
+/* BSEC init function */
+void MX_BSEC_Init(void)
+{
+
+  /* USER CODE BEGIN BSEC_Init 0 */
+
+  /*__HAL_RCC_BSEC_CLK_ENABLE();
+
+  //BSEC_S->AP_UNLOCK = BSEC_AP_UNLOCK_UNLOCK;
+  uint32_t status = 0;
+  if (HAL_OK != HAL_BSEC_GetStatus(&hbsec, &status)) return;
+  if (status == 0) return;
+  if (HAL_OK != HAL_BSEC_GetGlobalLockStatus(&hbsec, &status)) return;
+  if (status)
+	  if (HAL_OK != HAL_BSEC_UnlockDebug(&hbsec))
+		  return;*/
+
+  /* USER CODE END BSEC_Init 0 */
+
+  /* USER CODE BEGIN BSEC_Init 1 */
+
+  /* USER CODE END BSEC_Init 1 */
+  /* USER CODE BEGIN BSEC_Init 2 */
+
+  /* USER CODE END BSEC_Init 2 */
+
+}
+
+/* USER CODE BEGIN 1 */
+
+/* USER CODE END 1 */
+
Index: trunk/firmware/App/CubeMX/Appli/Core/Src/gpio.c
===================================================================
--- trunk/firmware/App/CubeMX/Appli/Core/Src/gpio.c	(revision 29)
+++ trunk/firmware/App/CubeMX/Appli/Core/Src/gpio.c	(revision 30)
@@ -44,17 +44,38 @@
 
   /* GPIO Ports Clock Enable */
+  __HAL_RCC_GPIOC_CLK_ENABLE();
+  __HAL_RCC_GPIOD_CLK_ENABLE();
+  __HAL_RCC_GPIOE_CLK_ENABLE();
+  __HAL_RCC_GPIOQ_CLK_ENABLE();
   __HAL_RCC_GPIOO_CLK_ENABLE();
+  __HAL_RCC_GPION_CLK_ENABLE();
   __HAL_RCC_GPIOA_CLK_ENABLE();
   __HAL_RCC_GPIOB_CLK_ENABLE();
 
   /*Configure GPIO pin Output Level */
-  HAL_GPIO_WritePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin, GPIO_PIN_RESET);
+  HAL_GPIO_WritePin(PWR_SD_EN_GPIO_Port, PWR_SD_EN_Pin, GPIO_PIN_RESET);
 
-  /*Configure GPIO pin : LED_GREEN_Pin */
-  GPIO_InitStruct.Pin = LED_GREEN_Pin;
+  /*Configure GPIO pin Output Level */
+  HAL_GPIO_WritePin(GPIOO, LDO_SD_SEL_Pin|LED_GREEN_Pin, GPIO_PIN_RESET);
+
+  /*Configure GPIO pin : PWR_SD_EN_Pin */
+  GPIO_InitStruct.Pin = PWR_SD_EN_Pin;
   GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
   GPIO_InitStruct.Pull = GPIO_NOPULL;
   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
-  HAL_GPIO_Init(LED_GREEN_GPIO_Port, &GPIO_InitStruct);
+  HAL_GPIO_Init(PWR_SD_EN_GPIO_Port, &GPIO_InitStruct);
+
+  /*Configure GPIO pins : LDO_SD_SEL_Pin LED_GREEN_Pin */
+  GPIO_InitStruct.Pin = LDO_SD_SEL_Pin|LED_GREEN_Pin;
+  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
+  GPIO_InitStruct.Pull = GPIO_NOPULL;
+  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
+  HAL_GPIO_Init(GPIOO, &GPIO_InitStruct);
+
+  /*Configure GPIO pin : DETECT_SD_Pin */
+  GPIO_InitStruct.Pin = DETECT_SD_Pin;
+  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
+  GPIO_InitStruct.Pull = GPIO_NOPULL;
+  HAL_GPIO_Init(DETECT_SD_GPIO_Port, &GPIO_InitStruct);
 
 }
Index: trunk/firmware/App/CubeMX/Appli/Core/Src/main.c
===================================================================
--- trunk/firmware/App/CubeMX/Appli/Core/Src/main.c	(revision 29)
+++ trunk/firmware/App/CubeMX/Appli/Core/Src/main.c	(revision 30)
@@ -21,4 +21,6 @@
 #include "app_freertos.h"
 #include "bsec.h"
+#include "app_filex.h"
+#include "sdmmc.h"
 #include "gpio.h"
 
@@ -109,4 +111,6 @@
   MX_GPIO_Init();
   MX_BSEC_Init();
+  MX_SDMMC2_SD_Init();
+  MX_FileX_Init();
   SystemIsolation_Config();
   /* USER CODE BEGIN 2 */
@@ -150,8 +154,23 @@
   __HAL_RCC_RIFSC_CLK_ENABLE();
 
+  /*RIMC configuration*/
+  RIMC_MasterConfig_t RIMC_master = {0};
+  RIMC_master.MasterCID = RIF_CID_1;
+  RIMC_master.SecPriv = RIF_ATTRIBUTE_SEC | RIF_ATTRIBUTE_NPRIV;
+  HAL_RIF_RIMC_ConfigMasterAttributes(RIF_MASTER_INDEX_SDMMC2, &RIMC_master);
+
   /* RIF-Aware IPs Config */
 
   /* set up GPIO configuration */
+  HAL_GPIO_ConfigPinAttributes(GPIOC,GPIO_PIN_0,GPIO_PIN_SEC|GPIO_PIN_NPRIV);
+  HAL_GPIO_ConfigPinAttributes(GPIOC,GPIO_PIN_3,GPIO_PIN_SEC|GPIO_PIN_NPRIV);
+  HAL_GPIO_ConfigPinAttributes(GPIOC,GPIO_PIN_4,GPIO_PIN_SEC|GPIO_PIN_NPRIV);
+  HAL_GPIO_ConfigPinAttributes(GPIOC,GPIO_PIN_5,GPIO_PIN_SEC|GPIO_PIN_NPRIV);
+  HAL_GPIO_ConfigPinAttributes(GPIOD,GPIO_PIN_2,GPIO_PIN_SEC|GPIO_PIN_NPRIV);
+  HAL_GPIO_ConfigPinAttributes(GPIOE,GPIO_PIN_4,GPIO_PIN_SEC|GPIO_PIN_NPRIV);
+  HAL_GPIO_ConfigPinAttributes(GPION,GPIO_PIN_12,GPIO_PIN_SEC|GPIO_PIN_NPRIV);
   HAL_GPIO_ConfigPinAttributes(GPIOO,GPIO_PIN_1,GPIO_PIN_SEC|GPIO_PIN_NPRIV);
+  HAL_GPIO_ConfigPinAttributes(GPIOO,GPIO_PIN_5,GPIO_PIN_SEC|GPIO_PIN_NPRIV);
+  HAL_GPIO_ConfigPinAttributes(GPIOQ,GPIO_PIN_7,GPIO_PIN_SEC|GPIO_PIN_NPRIV);
 
 /* USER CODE BEGIN RIF_Init 1 */
Index: trunk/firmware/App/CubeMX/Appli/Core/Src/sdmmc.c
===================================================================
--- trunk/firmware/App/CubeMX/Appli/Core/Src/sdmmc.c	(revision 30)
+++ trunk/firmware/App/CubeMX/Appli/Core/Src/sdmmc.c	(revision 30)
@@ -0,0 +1,152 @@
+/* USER CODE BEGIN Header */
+/**
+  ******************************************************************************
+  * @file    sdmmc.c
+  * @brief   This file provides code for the configuration
+  *          of the SDMMC instances.
+  ******************************************************************************
+  * @attention
+  *
+  * Copyright (c) 2026 STMicroelectronics.
+  * All rights reserved.
+  *
+  * This software is licensed under terms that can be found in the LICENSE file
+  * in the root directory of this software component.
+  * If no LICENSE file comes with this software, it is provided AS-IS.
+  *
+  ******************************************************************************
+  */
+/* USER CODE END Header */
+/* Includes ------------------------------------------------------------------*/
+#include "sdmmc.h"
+
+/* USER CODE BEGIN 0 */
+
+/* USER CODE END 0 */
+
+SD_HandleTypeDef hsd2;
+
+/* SDMMC2 init function */
+
+void MX_SDMMC2_SD_Init(void)
+{
+
+  /* USER CODE BEGIN SDMMC2_Init 0 */
+
+  /* USER CODE END SDMMC2_Init 0 */
+
+  /* USER CODE BEGIN SDMMC2_Init 1 */
+
+  /* USER CODE END SDMMC2_Init 1 */
+  hsd2.Instance = SDMMC2;
+  hsd2.Init.ClockEdge = SDMMC_CLOCK_EDGE_RISING;
+  hsd2.Init.ClockPowerSave = SDMMC_CLOCK_POWER_SAVE_DISABLE;
+  hsd2.Init.BusWide = SDMMC_BUS_WIDE_4B;
+  hsd2.Init.HardwareFlowControl = SDMMC_HARDWARE_FLOW_CONTROL_DISABLE;
+  hsd2.Init.ClockDiv = 0;
+  if (HAL_SD_Init(&hsd2) != HAL_OK)
+  {
+    Error_Handler();
+  }
+  /* USER CODE BEGIN SDMMC2_Init 2 */
+
+  /* USER CODE END SDMMC2_Init 2 */
+
+}
+
+void HAL_SD_MspInit(SD_HandleTypeDef* sdHandle)
+{
+
+  GPIO_InitTypeDef GPIO_InitStruct = {0};
+  RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};
+  if(sdHandle->Instance==SDMMC2)
+  {
+  /* USER CODE BEGIN SDMMC2_MspInit 0 */
+
+  /* USER CODE END SDMMC2_MspInit 0 */
+
+  /** Initializes the peripherals clock
+  */
+    PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_SDMMC2;
+    PeriphClkInitStruct.Sdmmc2ClockSelection = RCC_SDMMC2CLKSOURCE_HCLK;
+    if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
+    {
+      Error_Handler();
+    }
+
+    /* SDMMC2 clock enable */
+    __HAL_RCC_SDMMC2_CLK_ENABLE();
+
+    __HAL_RCC_GPIOC_CLK_ENABLE();
+    __HAL_RCC_GPIOD_CLK_ENABLE();
+    __HAL_RCC_GPIOE_CLK_ENABLE();
+    /**SDMMC2 GPIO Configuration
+    PC4     ------> SDMMC2_D0
+    PC5     ------> SDMMC2_D1
+    PC0     ------> SDMMC2_D2
+    PD2     ------> SDMMC2_CK
+    PE4     ------> SDMMC2_D3
+    PC3     ------> SDMMC2_CMD
+    */
+    GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_0|GPIO_PIN_3;
+    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+    GPIO_InitStruct.Pull = GPIO_NOPULL;
+    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM;
+    GPIO_InitStruct.Alternate = GPIO_AF11_SDMMC2;
+    HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
+
+    GPIO_InitStruct.Pin = GPIO_PIN_2;
+    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+    GPIO_InitStruct.Pull = GPIO_NOPULL;
+    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
+    GPIO_InitStruct.Alternate = GPIO_AF11_SDMMC2;
+    HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
+
+    GPIO_InitStruct.Pin = GPIO_PIN_4;
+    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+    GPIO_InitStruct.Pull = GPIO_NOPULL;
+    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM;
+    GPIO_InitStruct.Alternate = GPIO_AF11_SDMMC2;
+    HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
+
+  /* USER CODE BEGIN SDMMC2_MspInit 1 */
+
+  /* USER CODE END SDMMC2_MspInit 1 */
+  }
+}
+
+void HAL_SD_MspDeInit(SD_HandleTypeDef* sdHandle)
+{
+
+  if(sdHandle->Instance==SDMMC2)
+  {
+  /* USER CODE BEGIN SDMMC2_MspDeInit 0 */
+
+  /* USER CODE END SDMMC2_MspDeInit 0 */
+    /* Peripheral clock disable */
+    __HAL_RCC_SDMMC2_CLK_DISABLE();
+
+    /**SDMMC2 GPIO Configuration
+    PC4     ------> SDMMC2_D0
+    PC5     ------> SDMMC2_D1
+    PC0     ------> SDMMC2_D2
+    PD2     ------> SDMMC2_CK
+    PE4     ------> SDMMC2_D3
+    PC3     ------> SDMMC2_CMD
+    */
+    HAL_GPIO_DeInit(GPIOC, GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_0|GPIO_PIN_3);
+
+    HAL_GPIO_DeInit(GPIOD, GPIO_PIN_2);
+
+    HAL_GPIO_DeInit(GPIOE, GPIO_PIN_4);
+
+  /* USER CODE BEGIN SDMMC2_MspDeInit 1 */
+
+  /* USER CODE END SDMMC2_MspDeInit 1 */
+  }
+}
+
+/* USER CODE BEGIN 1 */
+
+/* USER CODE END 1 */
+
Index: trunk/firmware/App/CubeMX/Appli/Core/Src/stm32n6xx_hal_msp.c
===================================================================
--- trunk/firmware/App/CubeMX/Appli/Core/Src/stm32n6xx_hal_msp.c	(revision 29)
+++ trunk/firmware/App/CubeMX/Appli/Core/Src/stm32n6xx_hal_msp.c	(revision 30)
@@ -71,4 +71,8 @@
   HAL_PWREx_EnableVddIO2();
 
+  HAL_PWREx_EnableVddIO3();
+
+  HAL_PWREx_EnableVddIO5();
+
   /* USER CODE BEGIN MspInit 1 */
 
Index: trunk/firmware/App/CubeMX/Appli/FileX/App/app_filex.c
===================================================================
--- trunk/firmware/App/CubeMX/Appli/FileX/App/app_filex.c	(revision 30)
+++ trunk/firmware/App/CubeMX/Appli/FileX/App/app_filex.c	(revision 30)
@@ -0,0 +1,79 @@
+/* USER CODE BEGIN Header */
+/**
+  ******************************************************************************
+  * @file    app_filex.c
+  * @author  MCD Application Team
+  * @brief   FileX applicative file
+  ******************************************************************************
+  * @attention
+  *
+  * Copyright (c) 2026 STMicroelectronics.
+  * All rights reserved.
+  *
+  * This software is licensed under terms that can be found in the LICENSE file
+  * in the root directory of this software component.
+  * If no LICENSE file comes with this software, it is provided AS-IS.
+  *
+  ******************************************************************************
+  */
+/* USER CODE END Header */
+
+/* Includes ------------------------------------------------------------------*/
+#include "app_filex.h"
+
+/* Private includes ----------------------------------------------------------*/
+/* USER CODE BEGIN Includes */
+
+/* USER CODE END Includes */
+
+/* Private typedef -----------------------------------------------------------*/
+/* USER CODE BEGIN PTD */
+
+/* USER CODE END PTD */
+
+/* Private define ------------------------------------------------------------*/
+/* USER CODE BEGIN PD */
+
+/* USER CODE END PD */
+
+/* Private macro -------------------------------------------------------------*/
+/* USER CODE BEGIN PM */
+
+/* USER CODE END PM */
+
+/* Private variables ---------------------------------------------------------*/
+
+/* USER CODE BEGIN PV */
+
+/* USER CODE END PV */
+
+/* Private function prototypes -----------------------------------------------*/
+
+/* USER CODE BEGIN PFP */
+
+/* USER CODE END PFP */
+/**
+  * @brief  Application FileX Initialization.
+  * @param  None
+  * @retval int
+  */
+UINT MX_FileX_Init(void)
+{
+  UINT ret = FX_SUCCESS;
+  /* USER CODE BEGIN MX_FileX_Init */
+
+  /* USER CODE END MX_FileX_Init */
+
+  /* Initialize FileX.  */
+  fx_system_initialize();
+
+  /* USER CODE BEGIN MX_FileX_Init 1*/
+
+  /* USER CODE END MX_FileX_Init 1*/
+
+  return ret;
+}
+
+/* USER CODE BEGIN 1 */
+
+/* USER CODE END 1 */
Index: trunk/firmware/App/CubeMX/Appli/FileX/App/app_filex.h
===================================================================
--- trunk/firmware/App/CubeMX/Appli/FileX/App/app_filex.h	(revision 30)
+++ trunk/firmware/App/CubeMX/Appli/FileX/App/app_filex.h	(revision 30)
@@ -0,0 +1,72 @@
+
+/* USER CODE BEGIN Header */
+/**
+  ******************************************************************************
+  * @file    app_filex.h
+  * @author  MCD Application Team
+  * @brief   FileX applicative header file
+  ******************************************************************************
+  * @attention
+  *
+  * Copyright (c) 2026 STMicroelectronics.
+  * All rights reserved.
+  *
+  * This software is licensed under terms that can be found in the LICENSE file
+  * in the root directory of this software component.
+  * If no LICENSE file comes with this software, it is provided AS-IS.
+  *
+  ******************************************************************************
+  */
+/* USER CODE END Header */
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __APP_FILEX_H__
+#define __APP_FILEX_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "fx_api.h"
+#include "fx_stm32_sd_driver.h"
+#include "fx_stm32_custom_driver.h"
+/* Private includes ----------------------------------------------------------*/
+/* USER CODE BEGIN Includes */
+
+/* USER CODE END Includes */
+
+/* Exported types ------------------------------------------------------------*/
+/* USER CODE BEGIN ET */
+
+/* USER CODE END ET */
+
+/* Exported constants --------------------------------------------------------*/
+/* USER CODE BEGIN EC */
+
+/* USER CODE END EC */
+
+/* Exported macro ------------------------------------------------------------*/
+/* USER CODE BEGIN EM */
+
+/* USER CODE END EM */
+
+/* Exported functions prototypes ---------------------------------------------*/
+UINT MX_FileX_Init(void);
+
+/* USER CODE BEGIN EFP */
+
+/* USER CODE END EFP */
+
+/* Private defines -----------------------------------------------------------*/
+
+/* USER CODE BEGIN PD */
+
+/* USER CODE END PD */
+
+/* USER CODE BEGIN 1 */
+
+/* USER CODE END 1 */
+#ifdef __cplusplus
+}
+#endif
+#endif /* __APP_FILEX_H__ */
Index: trunk/firmware/App/CubeMX/Appli/FileX/App/fx_user.h
===================================================================
--- trunk/firmware/App/CubeMX/Appli/FileX/App/fx_user.h	(revision 30)
+++ trunk/firmware/App/CubeMX/Appli/FileX/App/fx_user.h	(revision 30)
@@ -0,0 +1,236 @@
+/**************************************************************************/
+/*                                                                        */
+/*       Copyright (c) Microsoft Corporation. All rights reserved.        */
+/*                                                                        */
+/*       This software is licensed under the Microsoft Software License   */
+/*       Terms for Microsoft Azure RTOS. Full text of the license can be  */
+/*       found in the LICENSE file at https://aka.ms/AzureRTOS_EULA       */
+/*       and in the root directory of this software.                      */
+/*                                                                        */
+/**************************************************************************/
+
+/**************************************************************************/
+/**************************************************************************/
+/**                                                                       */
+/** FileX Component                                                       */
+/**                                                                       */
+/**   User Specific                                                       */
+/**                                                                       */
+/**************************************************************************/
+/**************************************************************************/
+
+/**************************************************************************/
+/*                                                                        */
+/*  PORT SPECIFIC C INFORMATION                            RELEASE        */
+/*                                                                        */
+/*    fx_user.h                                           PORTABLE C      */
+/*                                                           6.1.10       */
+/*                                                                        */
+/*  AUTHOR                                                                */
+/*                                                                        */
+/*    William E. Lamie, Microsoft Corporation                             */
+/*                                                                        */
+/*  DESCRIPTION                                                           */
+/*                                                                        */
+/*    This file contains user defines for configuring FileX in specific   */
+/*    ways. This file will have an effect only if the application and     */
+/*    FileX library are built with FX_INCLUDE_USER_DEFINE_FILE defined.   */
+/*    Note that all the defines in this file may also be made on the      */
+/*    command line when building FileX library and application objects.   */
+/*                                                                        */
+/*  RELEASE HISTORY                                                       */
+/*                                                                        */
+/*    DATE              NAME                      DESCRIPTION             */
+/*                                                                        */
+/*  05-19-2020     William E. Lamie         Initial Version 6.0           */
+/*  09-30-2020     William E. Lamie         Modified comment(s), and      */
+/*                                            added product constants     */
+/*                                            to enable code              */
+/*                                            size optimization,          */
+/*                                            resulting in version 6.1    */
+/*  03-02-2021     William E. Lamie         Modified comment(s), and      */
+/*                                            added standalone support,   */
+/*                                            resulting in version 6.1.5  */
+/*  01-31-2022     Bhupendra Naphade        Modified comment(s), and      */
+/*                                            added product constant to   */
+/*                                            support variable sector     */
+/*                                            size in exFAT,              */
+/*                                            resulting in version 6.1.10 */
+/*                                                                        */
+/**************************************************************************/
+
+#ifndef FX_USER_H
+#define FX_USER_H
+
+/* USER CODE BEGIN 1 */
+
+/* USER CODE END 1 */
+
+/* Define various build options for the FileX port.  The application should either make changes
+   here by commenting or un-commenting the conditional compilation defined OR supply the defines though the compiler's equivalent of the -D option.  */
+
+/* Override various options with default values already assigned in fx_api.h or fx_port.h.
+  Please also refer to fx_port.h for descriptions on each of these options.  */
+
+/* Defined, the direct read sector update of cache is disabled.  */
+
+/* #define FX_DISABLE_DIRECT_DATA_READ_CACHE_FILL */
+
+/* Determine if error checking is desired.  If so, map API functions
+   to the appropriate error checking front-ends.  Otherwise, map API
+   functions to the core functions that actually perform the work.
+   Note: error checking is enabled by default.  */
+
+/* #define FX_DISABLE_ERROR_CHECKING */
+
+/* Defined, FileX does not update already opened files.  */
+
+/* #define FX_DONT_UPDATE_OPEN_FILES */
+
+/* Defined, enables 64-bits sector addresses used in I/O driver.  */
+
+/* #define FX_DRIVER_USE_64BIT_LBA */
+
+/* Defined, FileX is able to access exFAT file system.
+
+   FileX supports the Microsoft exFAT file system format.
+   Your use of exFAT technology in your products requires a separate
+   license from Microsoft. Please see the following link for further
+   details on exFAT licensing:
+
+   https://www.microsoft.com/en-us/legal/intellectualproperty/mtl/exfat-licensing.aspx
+*/
+
+/* #define FX_ENABLE_EXFAT */
+
+/* Defined, enables FileX fault tolerant service.  */
+
+/* #define FX_ENABLE_FAULT_TOLERANT */
+
+/* Defines the size in bytes of the bit map used to update the secondary FAT sectors.
+   The larger the value the less unnecessary secondary FAT sector writes.   */
+
+/* #define FX_FAT_MAP_SIZE         128 */
+
+/* Defined, data sector write requests are flushed immediately to the driver.  */
+
+/* #define FX_FAULT_TOLERANT */
+
+/* Define byte offset in boot sector where the cluster number of the Fault Tolerant Log file is.
+   Note that this field (byte 116 to 119) is marked as reserved by FAT 12/16/32/exFAT specification. */
+
+/* #define FX_FAULT_TOLERANT_BOOT_INDEX         116 */
+
+/* Defined, data sector write requests are flushed immediately to the driver.  */
+
+/* #define FX_FAULT_TOLERANT_DATA */
+
+/* Defines the number of entries in the FAT cache.  */
+
+/* #define FX_MAX_FAT_CACHE         16 */
+
+/* Defines the maximum size of long file names supported by FileX.
+   The minimum value is 13 and the maximum value is 256.  */
+
+/* #define FX_MAX_LAST_NAME_LEN         256 */
+
+/* #define FX_MAX_LONG_NAME_LEN         256 */
+
+/* Defines the maximum number of logical sectors that can be cached by FileX. The cache memory
+   supplied to FileX at fx_media_open determines how many sectors can actually be cached.  */
+
+/* #define FX_MAX_SECTOR_CACHE         256 */
+
+/* Defined, the file search cache optimization is disabled.  */
+
+/* #define FX_MEDIA_DISABLE_SEARCH_CACHE */
+
+/* Defined, gathering of media statistics is disabled.  */
+
+/* #define FX_MEDIA_STATISTICS_DISABLE */
+
+/* Defined, local path logic is disabled.  */
+
+#define FX_NO_LOCAL_PATH
+
+/* Defined, FileX is built without update to the time parameters.  */
+
+#define FX_NO_TIMER
+
+/* Defined, renaming inherits path information.  */
+
+/* #define FX_RENAME_PATH_INHERIT */
+
+/* Defined, legacy single open logic for the same file is enabled.  */
+
+/* #define FX_SINGLE_OPEN_LEGACY */
+
+/* Define FileX internal protection macros.  If FX_SINGLE_THREAD is defined,
+   these protection macros are effectively disabled.  However, for multi-thread
+   uses, the macros are setup to utilize a ThreadX mutex for multiple thread
+   access control into an open media.  */
+
+#define FX_SINGLE_THREAD
+
+/* Defined, FileX will be used in standalone mode (without ThreadX) */
+
+#define FX_STANDALONE_ENABLE
+
+/* Defines the number of seconds the time parameters are updated in FileX.  */
+
+/* #define FX_UPDATE_RATE_IN_SECONDS         10 */
+
+/* Defines the number of ThreadX timer ticks required to achieve the update rate specified by
+   FX_UPDATE_RATE_IN_SECONDS defined previously. By default, the ThreadX timer tick is 10ms,
+   so the default value for this constant is 1000.  */
+
+/* #define FX_UPDATE_RATE_IN_TICKS         1000 */
+
+/* If defined, cache is disabled.  */
+
+/*#define FX_DISABLE_CACHE   */
+
+/* If defined, file close is disabled.  */
+
+/* #define FX_DISABLE_FILE_CLOSE */
+
+/* If defined, fast open is disabled.  */
+
+/* #define FX_DISABLE_FAST_OPEN */
+
+/* If defined, force memory operations are disabled.  */
+
+/* #define FX_DISABLE_FORCE_MEMORY_OPERATION */
+
+/* If defined, build options is disabled.  */
+
+/* #define FX_DISABLE_BUILD_OPTIONS */
+
+/* If defined, one line function is disabled.  */
+
+/* #define FX_DISABLE_ONE_LINE_FUNCTION */
+
+/* If defined, FAT entry refresh is disabled.  */
+
+/* #define FX_DISABLE_FAT_ENTRY_REFRESH */
+
+/* If defined, consecutive detect is disabled.  */
+
+/* #define FX_DISABLE_CONSECUTIVE_DETECT */
+
+/* Define bitmap cache size for exFAT. Size should be minimum one sector size and maximum 4096.
+   For applications using multiple media devices with varying sector size, the value should be set to the
+   size of largest sector size. */
+
+/* #define FX_EXFAT_MAX_CACHE_SIZE            512 */
+
+/* Define the size of fault tolerant cache, which is used when freeing FAT chain.
+	The FX_FAULT_TOLERANT_CACHE_SIZE is 2 power of FX_FAULT_TOLERANT_CACHE_SIZE_NB_SIZE.  */
+
+/* #define FX_FAULT_TOLERANT_CACHE_SIZE            1024 */
+
+/* USER CODE BEGIN 2 */
+
+/* USER CODE END 2 */
+
+#endif
Index: trunk/firmware/App/CubeMX/Appli/FileX/Target/fx_stm32_custom_driver.c
===================================================================
--- trunk/firmware/App/CubeMX/Appli/FileX/Target/fx_stm32_custom_driver.c	(revision 30)
+++ trunk/firmware/App/CubeMX/Appli/FileX/Target/fx_stm32_custom_driver.c	(revision 30)
@@ -0,0 +1,182 @@
+/**************************************************************************/
+/*                                                                        */
+/*       Copyright (c) Microsoft Corporation. All rights reserved.        */
+/*                                                                        */
+/*       This software is licensed under the Microsoft Software License   */
+/*       Terms for Microsoft Azure RTOS. Full text of the license can be  */
+/*       found in the LICENSE file at https://aka.ms/AzureRTOS_EULA       */
+/*       and in the root directory of this software.                      */
+/*                                                                        */
+/**************************************************************************/
+
+/* Private includes ----------------------------------------------------------*/
+#include "fx_stm32_custom_driver.h"
+
+/* USER CODE BEGIN Includes */
+
+/* USER CODE END Includes */
+
+/* Private typedef -----------------------------------------------------------*/
+/* USER CODE BEGIN PTD */
+
+/* USER CODE END PTD */
+
+/* Private define ------------------------------------------------------------*/
+/* USER CODE BEGIN PD */
+
+/* USER CODE END PD */
+
+/* Private macro -------------------------------------------------------------*/
+/* USER CODE BEGIN PM */
+
+/* USER CODE END PM */
+
+/* Private variables ---------------------------------------------------------*/
+/* USER CODE BEGIN PV */
+
+/* USER CODE END PV */
+
+/* Private function prototypes -----------------------------------------------*/
+/* USER CODE BEGIN PFP */
+
+/* USER CODE END PFP */
+
+/* USER CODE BEGIN USER_CODE_SECTION_0 */
+
+/* USER CODE END USER_CODE_SECTION_0 */
+
+VOID  fx_stm32_custom_driver(FX_MEDIA *media_ptr)
+{
+  /* USER CODE BEGIN USER_CODE_SECTION_1 */
+
+  /* USER CODE END USER_CODE_SECTION_1 */
+
+  switch (media_ptr->fx_media_driver_request)
+  {
+    case FX_DRIVER_INIT:
+    {
+
+     /* USER CODE BEGIN DRIVER_INIT */
+
+     /* USER CODE END DRIVER_INIT */
+
+      media_ptr->fx_media_driver_status = FX_SUCCESS;
+
+     /* USER CODE BEGIN POST_DRIVER_INIT */
+
+     /* USER CODE END POST_DRIVER_INIT */
+      break;
+    }
+
+    case FX_DRIVER_UNINIT:
+    {
+     /* USER CODE BEGIN DRIVER_UNINIT */
+
+     /* USER CODE END DRIVER_UNINIT */
+
+      media_ptr->fx_media_driver_status = FX_SUCCESS;
+
+    /* USER CODE BEGIN POST_DRIVER_UNINIT */
+
+     /* USER CODE END POST_DRIVER_UNINIT */
+      break;
+    }
+
+    case FX_DRIVER_BOOT_READ:
+    {
+    /* USER CODE BEGIN DRIVER_BOOT_READ */
+
+     /* USER CODE END DRIVER_BOOT_READ */
+
+      media_ptr->fx_media_driver_status = FX_SUCCESS;
+
+    /* USER CODE BEGIN POST_DRIVER_BOOT_READ */
+
+     /* USER CODE END POST_DRIVER_BOOT_READ */
+      break;
+    }
+
+    case FX_DRIVER_READ:
+    {
+    /* USER CODE BEGIN DRIVER_READ */
+
+     /* USER CODE END DRIVER_READ */
+
+      media_ptr->fx_media_driver_status = FX_SUCCESS;
+
+    /* USER CODE BEGIN POST_DRIVER_READ */
+
+     /* USER CODE END POST_DRIVER_READ */
+      break;
+    }
+
+    case FX_DRIVER_BOOT_WRITE:
+    {
+    /* USER CODE BEGIN DRIVER_BOOT_WRITE */
+
+     /* USER CODE END DRIVER_BOOT_WRITE */
+
+      media_ptr->fx_media_driver_status = FX_SUCCESS;
+
+    /* USER CODE BEGIN POST_DRIVER_BOOT_WRITE */
+
+     /* USER CODE END POST_DRIVER_BOOT_WRITE */
+      break;
+    }
+
+    case FX_DRIVER_WRITE:
+    {
+
+    /* USER CODE BEGIN DRIVER_WRITE */
+
+     /* USER CODE END DRIVER_WRITE */
+
+      media_ptr->fx_media_driver_status = FX_SUCCESS;
+
+     /* USER CODE BEGIN POST_DRIVER_WRITE */
+
+     /* USER CODE END POST_DRIVER_WRITE */
+      break;
+    }
+
+    case FX_DRIVER_FLUSH:
+    {
+    /* USER CODE BEGIN DRIVER_FLUSH */
+
+     /* USER CODE END DRIVER_FLUSH */
+
+      media_ptr->fx_media_driver_status = FX_SUCCESS;
+
+    /* USER CODE BEGIN POST_DRIVER_FLUSH */
+
+     /* USER CODE END POST_DRIVER_FLUSH */
+      break;
+    }
+
+    case FX_DRIVER_ABORT:
+    {
+
+    /* USER CODE BEGIN DRIVER_ABORT */
+
+     /* USER CODE END DRIVER_ABORT */
+
+      media_ptr->fx_media_driver_status = FX_SUCCESS;
+
+    /* USER CODE BEGIN POST_DRIVER_ABORT */
+
+     /* USER CODE END POST_DRIVER_ABORT */
+      break;
+    }
+
+    default:
+    {
+        media_ptr->fx_media_driver_status = FX_IO_ERROR;
+        break;
+    }
+  }
+}
+
+/* USER CODE BEGIN USER_CODE_SECTION_2 */
+
+/* USER CODE END USER_CODE_SECTION_2 */
+
Index: trunk/firmware/App/CubeMX/Appli/FileX/Target/fx_stm32_custom_driver.h
===================================================================
--- trunk/firmware/App/CubeMX/Appli/FileX/Target/fx_stm32_custom_driver.h	(revision 30)
+++ trunk/firmware/App/CubeMX/Appli/FileX/Target/fx_stm32_custom_driver.h	(revision 30)
@@ -0,0 +1,61 @@
+/**************************************************************************/
+/*                                                                        */
+/*       Copyright (c) Microsoft Corporation. All rights reserved.        */
+/*                                                                        */
+/*       This software is licensed under the Microsoft Software License   */
+/*       Terms for Microsoft Azure RTOS. Full text of the license can be  */
+/*       found in the LICENSE file at https://aka.ms/AzureRTOS_EULA       */
+/*       and in the root directory of this software.                      */
+/*                                                                        */
+/**************************************************************************/
+
+#ifndef FX_STM32_CUSTOM_DRIVER_H
+#define FX_STM32_CUSTOM_DRIVER_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "fx_api.h"
+
+/* USER CODE BEGIN Includes */
+
+/* USER CODE END Includes */
+
+/* Exported types ------------------------------------------------------------*/
+/* USER CODE BEGIN ET */
+
+/* USER CODE END ET */
+
+/* Exported constants --------------------------------------------------------*/
+/* USER CODE BEGIN EC */
+
+/* USER CODE END EC */
+
+/* Exported macro ------------------------------------------------------------*/
+/* USER CODE BEGIN EM */
+
+/* USER CODE END EM */
+
+/* Exported functions prototypes ---------------------------------------------*/
+
+VOID fx_stm32_custom_driver(FX_MEDIA *media_ptr);
+
+/* USER CODE BEGIN EFP */
+
+/* USER CODE END EFP */
+
+/* Private defines -----------------------------------------------------------*/
+/* USER CODE BEGIN PD */
+
+/* USER CODE END PD */
+
+/* USER CODE BEGIN 1 */
+
+/* USER CODE END 1 */
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* FX_STM32_CUSTOM_DRIVER_H */
Index: trunk/firmware/App/CubeMX/Appli/FileX/Target/fx_stm32_sd_driver.h
===================================================================
--- trunk/firmware/App/CubeMX/Appli/FileX/Target/fx_stm32_sd_driver.h	(revision 30)
+++ trunk/firmware/App/CubeMX/Appli/FileX/Target/fx_stm32_sd_driver.h	(revision 30)
@@ -0,0 +1,214 @@
+/**************************************************************************/
+/*                                                                        */
+/*       Copyright (c) Microsoft Corporation. All rights reserved.        */
+/*                                                                        */
+/*       This software is licensed under the Microsoft Software License   */
+/*       Terms for Microsoft Azure RTOS. Full text of the license can be  */
+/*       found in the LICENSE file at https://aka.ms/AzureRTOS_EULA       */
+/*       and in the root directory of this software.                      */
+/*                                                                        */
+/**************************************************************************/
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef FX_STM32_SD_DRIVER_H
+#define FX_STM32_SD_DRIVER_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "fx_api.h"
+
+#include "stm32n6xx_hal.h"
+/* USER CODE BEGIN Includes */
+
+/* USER CODE END Includes */
+
+/* Exported types ------------------------------------------------------------*/
+/* USER CODE BEGIN ET */
+
+/* USER CODE END ET */
+
+extern __IO UINT sd_rx_cplt;
+extern __IO UINT sd_tx_cplt;
+
+/* Exported constants --------------------------------------------------------*/
+/* USER CODE BEGIN EC */
+
+/* USER CODE END EC */
+/* Default timeout used to wait for fx operations */
+#define FX_STM32_SD_DEFAULT_TIMEOUT                           (10 * 1000)
+
+/* let the filex low-level driver initialize the SD driver */
+#define FX_STM32_SD_INIT                                      0
+
+/* Enable the cache maintenance, needed when using SD DMA
+ * and accessing buffers in cacheable area
+ * this is valid only for CM7 based products or those
+ * with dedicated cache IP.
+ * For STM32N6 this flag should be always set to 0 unless external
+ * memories are being used.
+ */
+#define FX_STM32_SD_CACHE_MAINTENANCE                         1
+
+/* Use the SD DMA API */
+#define FX_STM32_SD_DMA_API                                   1
+
+/* SDIO instance to be used by FileX */
+#define FX_STM32_SD_INSTANCE                                  1
+
+/* Default sector size, used by the driver */
+#define FX_STM32_SD_DEFAULT_SECTOR_SIZE                       512
+
+/* Exported macro ------------------------------------------------------------*/
+/* USER CODE BEGIN EM */
+
+/* USER CODE END EM */
+
+/* Define the CPU Cache maintenance macros */
+#if (FX_STM32_SD_CACHE_MAINTENANCE == 1)
+#define invalidate_cache_by_addr(__ptr__, __size__)  SCB_InvalidateDCache_by_Addr((void *)__ptr__, (int32_t)__size__)
+#define clean_cache_by_addr(__ptr__, __size__)       SCB_CleanDCache_by_Addr((uint32_t *)__ptr__, (int32_t)__size__)
+#endif
+
+/* Define the macro to get the current time in ticks */
+/* USER CODE BEGIN FX_STM32_SD_CURRENT_TIME */
+#define FX_STM32_SD_CURRENT_TIME()                            HAL_GetTick()
+/* USER CODE END FX_STM32_SD_CURRENT_TIME */
+
+/* Macro called before initializing the SD driver
+ * e.g. create a semaphore used for transfer notification */
+
+/* USER CODE BEGIN FX_STM32_SD_PRE_INIT */
+
+ #define FX_STM32_SD_PRE_INIT(_media_ptr)
+
+ /* USER CODE END FX_STM32_SD_PRE_INIT*/
+
+/* Macro called after initializing the SD driver */
+/* USER CODE BEGIN FX_STM32_SD_POST_INIT */
+
+#define FX_STM32_SD_POST_INIT(_media_ptr)
+
+/* USER CODE END FX_STM32_SD_POST_INIT */
+
+/* Macro called after the SD deinit */
+
+/* Macro called after the SD deinit */
+/* USER CODE BEGIN FX_STM32_SD_POST_DEINIT */
+
+ #define FX_STM32_SD_POST_DEINIT(_media_ptr)
+
+/* USER CODE END FX_STM32_SD_POST_DEINIT */
+
+/* Macro called after the abort request */
+/* USER CODE BEGIN FX_STM32_SD_POST_ABORT */
+
+#define FX_STM32_SD_POST_ABORT(_media_ptr)
+
+/* USER CODE END FX_STM32_SD_POST_ABORT */
+
+/* Macro called before performing read operation */
+/* USER CODE BEGIN FX_STM32_SD_PRE_READ_TRANSFER */
+
+#define FX_STM32_SD_PRE_READ_TRANSFER(_media_ptr)
+/* USER CODE END FX_STM32_SD_PRE_READ_TRANSFER */
+
+/* Macro called after performing read operation */
+/* USER CODE BEGIN FX_STM32_SD_POST_READ_TRANSFER */
+
+#define FX_STM32_SD_POST_READ_TRANSFER(_media_ptr)
+
+/* USER CODE END FX_STM32_SD_POST_READ_TRANSFER */
+
+/* Macro for read error handling */
+/* USER CODE BEGIN FX_STM32_SD_READ_TRANSFER_ERROR */
+
+#define FX_STM32_SD_READ_TRANSFER_ERROR(_status_)
+
+/* USER CODE END FX_STM32_SD_READ_TRANSFER_ERROR */
+
+/* Define how to notify about Read completion operation */
+/* USER CODE BEGIN FX_STM32_SD_READ_CPLT_NOTIFY */
+
+#define FX_STM32_SD_READ_CPLT_NOTIFY()     do { \
+                                              UINT start = HAL_GetTick(); \
+                                              while (HAL_GetTick() - start < FX_STM32_SD_DEFAULT_TIMEOUT) \
+                                              {\
+                                                if (sd_rx_cplt == 1) \
+                                                  break;\
+                                              }\
+                                              if (sd_rx_cplt == 0) \
+                                                return FX_IO_ERROR; \
+                                           } while(0)
+
+/* USER CODE END FX_STM32_SD_READ_CPLT_NOTIFY */
+
+/* Define how to notify about write completion operation */
+/* USER CODE BEGIN FX_STM32_SD_WRITE_CPLT_NOTIFY */
+
+#define FX_STM32_SD_WRITE_CPLT_NOTIFY()      do { \
+                                              UINT start = HAL_GetTick(); \
+                                              while (HAL_GetTick() - start < FX_STM32_SD_DEFAULT_TIMEOUT) \
+                                              {\
+                                                if (sd_tx_cplt == 1) \
+                                                  break;\
+                                              }\
+                                              if (sd_tx_cplt == 0) \
+                                                return FX_IO_ERROR;\
+                                           } while(0)
+
+/* USER CODE END FX_STM32_SD_WRITE_CPLT_NOTIFY */
+
+/* Macro called before performing write operation */
+/* USER CODE BEGIN FX_STM32_SD_PRE_WRITE_TRANSFER */
+
+#define FX_STM32_SD_PRE_WRITE_TRANSFER(_media_ptr)
+
+/* USER CODE END FX_STM32_SD_PRE_WRITE_TRANSFER */
+
+/* Macro called after performing write operation */
+/* USER CODE BEGIN FX_STM32_SD_POST_WRITE_TRANSFER */
+
+#define FX_STM32_SD_POST_WRITE_TRANSFER					FX_STM32_SD_POST_READ_TRANSFER
+
+/* USER CODE END FX_STM32_SD_POST_WRITE_TRANSFER */
+
+/* Macro for write error handling */
+/* USER CODE BEGIN FX_STM32_SD_WRITE_TRANSFER_ERROR */
+
+#define FX_STM32_SD_WRITE_TRANSFER_ERROR				FX_STM32_SD_READ_TRANSFER_ERROR
+
+/* USER CODE END FX_STM32_SD_WRITE_TRANSFER_ERROR */
+
+/* Exported functions prototypes ---------------------------------------------*/
+
+INT fx_stm32_sd_init(UINT instance);
+INT fx_stm32_sd_deinit(UINT instance);
+
+INT fx_stm32_sd_get_status(UINT instance);
+
+INT fx_stm32_sd_read_blocks(UINT instance, UINT *buffer, UINT start_block, UINT total_blocks);
+INT fx_stm32_sd_write_blocks(UINT instance, UINT *buffer, UINT start_block, UINT total_blocks);
+
+VOID fx_stm32_sd_driver(FX_MEDIA *media_ptr);
+
+/* USER CODE BEGIN EFP */
+
+/* USER CODE END EFP */
+
+/* Private defines -----------------------------------------------------------*/
+/* USER CODE BEGIN PD */
+
+/* USER CODE END PD */
+
+/* USER CODE BEGIN 1 */
+
+/* USER CODE END 1 */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* FX_STM32_SD_DRIVER_H */
Index: trunk/firmware/App/CubeMX/Appli/FileX/Target/fx_stm32_sd_driver_glue.c
===================================================================
--- trunk/firmware/App/CubeMX/Appli/FileX/Target/fx_stm32_sd_driver_glue.c	(revision 30)
+++ trunk/firmware/App/CubeMX/Appli/FileX/Target/fx_stm32_sd_driver_glue.c	(revision 30)
@@ -0,0 +1,199 @@
+/**************************************************************************/
+/*                                                                        */
+/*       Copyright (c) Microsoft Corporation. All rights reserved.        */
+/*                                                                        */
+/*       This software is licensed under the Microsoft Software License   */
+/*       Terms for Microsoft Azure RTOS. Full text of the license can be  */
+/*       found in the LICENSE file at https://aka.ms/AzureRTOS_EULA       */
+/*       and in the root directory of this software.                      */
+/*                                                                        */
+/**************************************************************************/
+
+#include "fx_stm32_sd_driver.h"
+
+extern SD_HandleTypeDef hsd2;
+#if (FX_STM32_SD_INIT == 1)
+extern void MX_SDMMC2_SD_Init(void);
+#endif
+
+/* USER CODE BEGIN  0 */
+
+/* USER CODE END  0 */
+
+__IO UINT sd_rx_cplt;
+__IO UINT sd_tx_cplt;
+
+/**
+* @brief Initializes the SD IP instance
+* @param UINT instance SD instance to initialize
+* @retval 0 on success error value otherwise
+*/
+INT fx_stm32_sd_init(UINT instance)
+{
+  INT ret = 0;
+
+  /* USER CODE BEGIN PRE_FX_SD_INIT */
+  UNUSED(instance);
+  /* USER CODE END PRE_FX_SD_INIT */
+
+#if (FX_STM32_SD_INIT == 1)
+	MX_SDMMC2_SD_Init();
+#endif
+
+  /* USER CODE BEGIN POST_FX_SD_INIT */
+
+  /* USER CODE END POST_FX_SD_INIT */
+
+  return ret;
+}
+
+/**
+* @brief Deinitializes the SD IP instance
+* @param UINT instance SD instance to deinitialize
+* @retval 0 on success error value otherwise
+*/
+INT fx_stm32_sd_deinit(UINT instance)
+{
+  INT ret = 0;
+
+  /* USER CODE BEGIN PRE_FX_SD_DEINIT */
+  UNUSED(instance);
+  /* USER CODE END PRE_FX_SD_DEINIT */
+
+#if (FX_STM32_SD_INIT == 1)
+  if(HAL_SD_DeInit(&hsd2) != HAL_OK)
+  {
+    ret = 1;
+  }
+#endif
+
+  /* USER CODE BEGIN POST_FX_SD_DEINIT */
+
+  /* USER CODE END POST_FX_SD_DEINIT */
+
+  return ret;
+}
+
+/**
+* @brief Check the SD IP status.
+* @param UINT instance SD instance to check
+* @retval 0 when ready 1 when busy
+*/
+INT fx_stm32_sd_get_status(UINT instance)
+{
+  INT ret = 0;
+
+  /* USER CODE BEGIN PRE_GET_STATUS */
+  UNUSED(instance);
+  /* USER CODE END PRE_GET_STATUS */
+
+  if(HAL_SD_GetCardState(&hsd2) != HAL_SD_CARD_TRANSFER)
+  {
+    ret = 1;
+  }
+
+  /* USER CODE BEGIN POST_GET_STATUS */
+
+  /* USER CODE END POST_GET_STATUS */
+
+  return ret;
+}
+
+/**
+* @brief Read Data from the SD device into a buffer.
+* @param UINT instance SD IP instance to read from.
+* @param UINT *buffer buffer into which the data is to be read.
+* @param UINT start_block the first block to start reading from.
+* @param UINT total_blocks total number of blocks to read.
+* @retval 0 on success error code otherwise
+*/
+INT fx_stm32_sd_read_blocks(UINT instance, UINT *buffer, UINT start_block, UINT total_blocks)
+{
+  INT ret = 0;
+
+  /* USER CODE BEGIN PRE_READ_BLOCKS */
+  /* USER CODE END PRE_READ_BLOCKS */
+
+  sd_rx_cplt = 0;
+
+  if(HAL_SD_ReadBlocks_DMA(&hsd2, (uint8_t *)buffer, start_block, total_blocks) != HAL_OK)
+  {
+    ret = 1;
+  }
+
+  /* USER CODE BEGIN POST_READ_BLOCKS */
+
+  /* USER CODE END POST_READ_BLOCKS */
+
+  return ret;
+}
+
+/**
+* @brief Write data buffer into the SD device.
+* @param UINT instance SD IP instance to write into.
+* @param UINT *buffer buffer to write into the SD device.
+* @param UINT start_block the first block to start writing into.
+* @param UINT total_blocks total number of blocks to write.
+* @retval 0 on success error code otherwise
+*/
+INT fx_stm32_sd_write_blocks(UINT instance, UINT *buffer, UINT start_block, UINT total_blocks)
+{
+  INT ret = 0;
+
+  /* USER CODE BEGIN PRE_WRITE_BLOCKS */
+  /* USER CODE END PRE_WRITE_BLOCKS */
+
+  sd_tx_cplt = 0;
+
+  if(HAL_SD_WriteBlocks_DMA(&hsd2, (uint8_t *)buffer, start_block, total_blocks) != HAL_OK)
+  {
+    ret = 1;
+  }
+
+  /* USER CODE BEGIN POST_WRITE_BLOCKS */
+
+  /* USER CODE END POST_WRITE_BLOCKS */
+
+  return ret;
+}
+
+/**
+* @brief SD DMA Tx Transfer completed callbacks
+* @param SD_HandleTypeDef *hsd the SD_HandleTypeDef handle
+* @retval None
+*/
+void HAL_SD_TxCpltCallback(SD_HandleTypeDef *hsd)
+{
+/* USER CODE BEGIN TX_COMPLETED_0 */
+
+/* USER CODE END TX_COMPLETED_0 */
+
+  sd_tx_cplt = 1;
+
+/* USER CODE BEGIN TX_COMPLETED_1 */
+
+/* USER CODE END TX_COMPLETED_1 */
+
+}
+
+/**
+* @brief SD DMA Rx Transfer completed callbacks
+* @param SD_HandleTypeDef *hsd the SD_HandleTypeDef handle
+* @retval None
+*/
+void HAL_SD_RxCpltCallback(SD_HandleTypeDef *hsd)
+{
+  /* USER CODE BEGIN RX_COMPLETED_0 */
+
+/* USER CODE END RX_COMPLETED_0 */
+  sd_rx_cplt = 1;
+
+/* USER CODE BEGIN RX_COMPLETED_1 */
+
+/* USER CODE END RX_COMPLETED_1 */
+
+}
+
+/* USER CODE BEGIN 1 */
+
+/* USER CODE END 1 */
