Ignore:
Timestamp:
Oct 20, 2026, 2:17:01 PM (2 weeks ago)
Author:
Zed
Message:

Commiting the project to add SDMMC2 device into FSBL to be able to deal with it correctly in debugger.

Location:
trunk/firmware/App/CubeMX/Appli/Core
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/firmware/App/CubeMX/Appli/Core/Inc/FreeRTOSConfig.h

    r30 r36  
    5252#include <stdint.h>
    5353extern uint32_t SystemCoreClock;
    54 void xPortSysTickHandler(void);
    5554#endif
    5655#ifndef CMSIS_device_header
  • trunk/firmware/App/CubeMX/Appli/Core/Inc/app_freertos.h

    r33 r36  
    5757extern osThreadId_t mainTaskHandle;
    5858extern osThreadId_t sdmmcTaskHandle;
     59extern osMessageQueueId_t sdmmcCmdQueueHandle;
    5960
    6061/* Exported function prototypes -----------------------------------------------*/
  • trunk/firmware/App/CubeMX/Appli/Core/Inc/stm32n6xx_hal_conf.h

    r30 r36  
    8080/*#define HAL_SPI_MODULE_ENABLED   */
    8181/*#define HAL_SRAM_MODULE_ENABLED   */
    82 /*#define HAL_TIM_MODULE_ENABLED   */
     82#define HAL_TIM_MODULE_ENABLED
    8383/*#define HAL_UART_MODULE_ENABLED   */
    8484/*#define HAL_USART_MODULE_ENABLED   */
    … …  
    163163  */
    164164#define  VDD_VALUE                  3300UL /*!< Value of VDD in mv */
    165 #define  TICK_INT_PRIORITY          0U  /*!< tick interrupt priority */
     165#define  TICK_INT_PRIORITY          15U  /*!< tick interrupt priority (lowest by default) */
    166166#define  USE_RTOS                   0U
    167167
  • trunk/firmware/App/CubeMX/Appli/Core/Inc/stm32n6xx_it.h

    r31 r36  
    5454void SecureFault_Handler(void);
    5555void DebugMon_Handler(void);
     56void TIM18_IRQHandler(void);
    5657void SDMMC2_IRQHandler(void);
    5758/* USER CODE BEGIN EFP */
  • trunk/firmware/App/CubeMX/Appli/Core/Src/app_freertos.c

    r33 r36  
    2424/* USER CODE BEGIN Includes */
    2525
     26#include "sdmmcTask.h"
     27
    2628/* USER CODE END Includes */
    2729
    2830/* Private typedef -----------------------------------------------------------*/
    2931typedef StaticTask_t osStaticThreadDef_t;
     32typedef StaticQueue_t osStaticMessageQDef_t;
    3033/* USER CODE BEGIN PTD */
    3134
    … …  
    6063/* Definitions for sdmmcTask */
    6164osThreadId_t sdmmcTaskHandle;
    62 uint32_t sdmmcTaskBuff[ 128 ];
     65uint32_t sdmmcTaskBuff[ 1024 ];
    6366osStaticThreadDef_t sdmmcTaskCtrlBlock;
    6467const osThreadAttr_t sdmmcTask_attributes = {
    … …  
    6972  .cb_size = sizeof(sdmmcTaskCtrlBlock),
    7073  .priority = (osPriority_t) osPriorityBelowNormal7,
     74};
     75/* Definitions for sdmmcCmdQueue */
     76osMessageQueueId_t sdmmcCmdQueueHandle;
     77uint8_t sdmmcQueueBuff[ 8 * sizeof( SdCardCmd_t ) ];
     78osStaticMessageQDef_t sdmmcQueueCtrlBlock;
     79const osMessageQueueAttr_t sdmmcCmdQueue_attributes = {
     80  .name = "sdmmcCmdQueue",
     81  .cb_mem = &sdmmcQueueCtrlBlock,
     82  .cb_size = sizeof(sdmmcQueueCtrlBlock),
     83  .mq_mem = &sdmmcQueueBuff,
     84  .mq_size = sizeof(sdmmcQueueBuff)
    7185};
    7286
    … …  
    121135  /* start timers, add new ones, ... */
    122136  /* USER CODE END RTOS_TIMERS */
     137  /* creation of sdmmcCmdQueue */
     138  sdmmcCmdQueueHandle = osMessageQueueNew (8, sizeof(SdCardCmd_t), &sdmmcCmdQueue_attributes);
    123139
    124140  /* USER CODE BEGIN RTOS_QUEUES */
  • trunk/firmware/App/CubeMX/Appli/Core/Src/main.c

    r32 r36  
    8282  /* USER CODE BEGIN 1 */
    8383
    84   SEGGER_RTT_Init();
     84  //SEGGER_RTT_Init();
    8585
    8686  /* System clock already configured, simply SystemCoreClock init */
    87   SystemCoreClockUpdate();
     87  //SystemCoreClockUpdate();
    8888
    8989  /* USER CODE END 1 */
    … …  
    161161  RIMC_MasterConfig_t RIMC_master = {0};
    162162  RIMC_master.MasterCID = RIF_CID_1;
    163   RIMC_master.SecPriv = RIF_ATTRIBUTE_SEC | RIF_ATTRIBUTE_NPRIV;
     163  RIMC_master.SecPriv = RIF_ATTRIBUTE_SEC | RIF_ATTRIBUTE_PRIV;
    164164  HAL_RIF_RIMC_ConfigMasterAttributes(RIF_MASTER_INDEX_SDMMC2, &RIMC_master);
     165  HAL_RIF_RISC_SetSlaveSecureAttributes(RIF_RISC_PERIPH_INDEX_SDMMC2 , RIF_ATTRIBUTE_SEC | RIF_ATTRIBUTE_PRIV);
    165166
    166167  /* RIF-Aware IPs Config */
    … …  
    168169  /* set up GPIO configuration */
    169170  HAL_GPIO_ConfigPinAttributes(GPIOC,GPIO_PIN_0,GPIO_PIN_SEC|GPIO_PIN_NPRIV);
     171  HAL_GPIO_ConfigPinAttributes(GPIOC,GPIO_PIN_2,GPIO_PIN_SEC|GPIO_PIN_NPRIV);
    170172  HAL_GPIO_ConfigPinAttributes(GPIOC,GPIO_PIN_3,GPIO_PIN_SEC|GPIO_PIN_NPRIV);
    171173  HAL_GPIO_ConfigPinAttributes(GPIOC,GPIO_PIN_4,GPIO_PIN_SEC|GPIO_PIN_NPRIV);
    172174  HAL_GPIO_ConfigPinAttributes(GPIOC,GPIO_PIN_5,GPIO_PIN_SEC|GPIO_PIN_NPRIV);
    173   HAL_GPIO_ConfigPinAttributes(GPIOD,GPIO_PIN_2,GPIO_PIN_SEC|GPIO_PIN_NPRIV);
    174175  HAL_GPIO_ConfigPinAttributes(GPIOE,GPIO_PIN_4,GPIO_PIN_SEC|GPIO_PIN_NPRIV);
    175176  HAL_GPIO_ConfigPinAttributes(GPION,GPIO_PIN_12,GPIO_PIN_SEC|GPIO_PIN_NPRIV);
    … …  
    236237
    237238/**
     239  * @brief  Period elapsed callback in non blocking mode
     240  * @note   This function is called  when TIM18 interrupt took place, inside
     241  * HAL_TIM_IRQHandler(). It makes a direct call to HAL_IncTick() to increment
     242  * a global variable "uwTick" used as application time base.
     243  * @param  htim : TIM handle
     244  * @retval None
     245  */
     246void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
     247{
     248  /* USER CODE BEGIN Callback 0 */
     249
     250  /* USER CODE END Callback 0 */
     251  if (htim->Instance == TIM18)
     252  {
     253    HAL_IncTick();
     254  }
     255  /* USER CODE BEGIN Callback 1 */
     256
     257  /* USER CODE END Callback 1 */
     258}
     259
     260/**
    238261  * @brief  This function is executed in case of error occurrence.
    239262  * @param None
    … …  
    244267  /* USER CODE BEGIN Error_Handler_Debug */
    245268  /* User can add his own implementation to report the HAL error return state */
    246   __disable_irq();
     269  //__disable_irq();
    247270  while (1)
    248271  {
     272          printf("Unknown error!\n");
     273          HAL_Delay(1000U);
    249274  }
    250275  /* USER CODE END Error_Handler_Debug */
  • trunk/firmware/App/CubeMX/Appli/Core/Src/sdmmc.c

    r31 r36  
    4242  hsd2.Init.ClockEdge = SDMMC_CLOCK_EDGE_RISING;
    4343  hsd2.Init.ClockPowerSave = SDMMC_CLOCK_POWER_SAVE_DISABLE;
    44   hsd2.Init.BusWide = SDMMC_BUS_WIDE_4B;
     44  hsd2.Init.BusWide = SDMMC_BUS_WIDE_1B;
    4545  hsd2.Init.HardwareFlowControl = SDMMC_HARDWARE_FLOW_CONTROL_DISABLE;
    46   hsd2.Init.ClockDiv = 0;
     46  hsd2.Init.ClockDiv = 2;
    4747  if (HAL_SD_Init(&hsd2) != HAL_OK)
    4848  {
    … …  
    8989    PC3     ------> SDMMC2_CMD
    9090    */
    91     GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_0|GPIO_PIN_3;
     91    GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5;
    9292    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
    93     GPIO_InitStruct.Pull = GPIO_NOPULL;
    94     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM;
     93    GPIO_InitStruct.Pull = GPIO_PULLUP;
     94    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
    9595    GPIO_InitStruct.Alternate = GPIO_AF11_SDMMC2;
    9696    HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
    9797
    98     GPIO_InitStruct.Pin = GPIO_PIN_2;
     98    /*GPIO_InitStruct.Pin = GPIO_PIN_2;
    9999    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
    100100    GPIO_InitStruct.Pull = GPIO_NOPULL;
    101101    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
    102102    GPIO_InitStruct.Alternate = GPIO_AF11_SDMMC2;
    103     HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
     103    HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);*/
    104104
    105105    GPIO_InitStruct.Pin = GPIO_PIN_4;
    106106    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
    107     GPIO_InitStruct.Pull = GPIO_NOPULL;
    108     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM;
     107    GPIO_InitStruct.Pull = GPIO_PULLUP;
     108    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
    109109    GPIO_InitStruct.Alternate = GPIO_AF11_SDMMC2;
    110110    HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
  • trunk/firmware/App/CubeMX/Appli/Core/Src/stm32n6xx_it.c

    r31 r36  
    2323/* Private includes ----------------------------------------------------------*/
    2424/* USER CODE BEGIN Includes */
     25
     26#include <stdio.h>
     27
    2528/* USER CODE END Includes */
    2629
    … …  
    5760/* External variables --------------------------------------------------------*/
    5861extern SD_HandleTypeDef hsd2;
     62extern TIM_HandleTypeDef htim18;
     63
    5964/* USER CODE BEGIN EV */
    6065
    … …  
    8590{
    8691  /* USER CODE BEGIN HardFault_IRQn 0 */
     92
     93        uint32_t cfsr  = SCB->CFSR;
     94    uint32_t hfsr  = SCB->HFSR;
     95    uint32_t dfsr  = SCB->DFSR;
     96    uint32_t mmfar = SCB->MMFAR;
     97    uint32_t bfar  = SCB->BFAR;
     98
     99    printf("CFSR  = 0x%08lX\r\n", (unsigned long)cfsr);
     100    printf("HFSR  = 0x%08lX\r\n", (unsigned long)hfsr);
     101    printf("DFSR  = 0x%08lX\r\n", (unsigned long)dfsr);
     102    printf("MMFAR = 0x%08lX\r\n", (unsigned long)mmfar);
     103    printf("BFAR  = 0x%08lX\r\n", (unsigned long)bfar);
    87104
    88105  /* USER CODE END HardFault_IRQn 0 */
    … …  
    175192
    176193/**
     194  * @brief This function handles TIM18 global interrupt.
     195  */
     196void TIM18_IRQHandler(void)
     197{
     198  /* USER CODE BEGIN TIM18_IRQn 0 */
     199
     200  /* USER CODE END TIM18_IRQn 0 */
     201  HAL_TIM_IRQHandler(&htim18);
     202  /* USER CODE BEGIN TIM18_IRQn 1 */
     203
     204  /* USER CODE END TIM18_IRQn 1 */
     205}
     206
     207/**
    177208  * @brief This function handles SDMMC2 global interrupt.
    178209  */
Note: See TracChangeset for help on using the changeset viewer.