Giter Club home page Giter Club logo

stmicroelectronics / stm32cubeh7 Goto Github PK

View Code? Open in Web Editor NEW
477.0 56.0 298.0 736.92 MB

STM32Cube MCU Full Package for the STM32H7 series - (HAL + LL Drivers, CMSIS Core, CMSIS Device, MW libraries plus a set of Projects running on all boards provided by ST (Nucleo, Evaluation and Discovery Kits))

Home Page: https://www.st.com/en/embedded-software/stm32cubeh7.html

License: Other

HTML 8.22% C 59.47% C++ 0.02% Assembly 31.40% Python 0.01% JavaScript 0.53% CSS 0.32% Batchfile 0.01% CMake 0.02%
stm32cube-mcu-package stm32 stm32h7

stm32cubeh7's Introduction

STM32CubeH7 MCU Firmware Package

latest tag

Important

This repository has been created using the git submodule command. Please refer to the "How to use" section for more details.

Overview

STM32Cube is an STMicroelectronics original initiative to ease developers' life by reducing efforts, time and cost.

STM32Cube covers the overall STM32 products portfolio. It includes a comprehensive embedded software platform delivered for each STM32 series.

  • The CMSIS modules (core and device) corresponding to the ARM(tm) core implemented in this STM32 product.
  • The STM32 HAL-LL drivers, an abstraction layer offering a set of APIs ensuring maximized portability across the STM32 portfolio.
  • The BSP drivers of each evaluation, demonstration or nucleo board provided for this STM32 series.
  • A consistent set of middleware libraries such as RTOS, USB, FatFS, graphics, touch sensing library...
  • A full set of software projects (basic examples, applications, and demonstrations) for each board provided for this STM32 series.

The STM32CubeH7 MCU Package projects are directly running on the STM32H7 series boards. You can find in each Projects/Board name directories a set of software projects (Applications/Demonstration/Examples).

Note

Some middleware libraries and projects are unavailable in this repository

In this repository, the middleware libraries listed below along with this list of projects (demos, applications, and examples) using them, are not available as they (the middleware libraries) are subject to some restrictive license terms requiring the user's approval via a "click thru" procedure.

  • ./Middlewares/ST/STM32_Audio
  • ./Middlewares/ST/STemWin
  • ./Middlewares/ST/TouchGFX

If needed, they can be found inside the full firmware package available on our website st.com and downloadable from here. You will be prompted to login or to register in case you have no account.

Release note

Details about the content of this release are available in the release note here.

How to use

This repository has been created using the git submodule command. Please check the instructions below for proper use. Please check also the notes at the end of this section for further information.

  1. To clone this repository along with the linked submodules, option --recursive has to be specified as shown below.
git clone --recursive https://github.com/STMicroelectronics/STM32CubeH7.git
  1. To get the latest updates, in case this repository is already on your local machine, issue the following two commands (with this repository as the current working directory).
git pull
git submodule update --init --recursive
  1. To use the same firmware version as the one available on st.com, issue the command below after specifying the targeted vX.Y.Z version. This should be done after the command(s) indicated in instruction (1) or in instruction (2) above have been successfully executed.
git checkout vX.Y.Z # Specify the targeted vX.Y.Z version
  1. To avoid going through the above instructions and directly clone the same firmware version as the one available on st.com, issue the command below after specifying the targeted vX.Y.Z version.
git clone --recursive  --depth 1 --branch vX.Y.Z https://github.com/STMicroelectronics/STM32CubeH7.git

Note

  • The latest version of this firmware available on GitHub may be ahead of the one available on st.com or via STM32CubeMX. This is due to the rolling release process deployed on GitHub. Please refer to this post for more details.
  • Option --depth 1 specified in instruction (4) above is not mandatory. It may be useful to skip downloading all previous commits up to the one corresponding to the targeted version.
  • If GitHub "Download ZIP" option is used instead of the git clone command, then the different submodules have to be collected and added manually.

Boards available

Troubleshooting

Please refer to the CONTRIBUTING.md guide.

stm32cubeh7's People

Contributors

alabstm avatar aselstm avatar ccastm avatar cperera-aud avatar edouardmalot avatar engycz avatar hehaorui avatar kakstm avatar nouirakh avatar rjmstm avatar rkoustm avatar seatrix avatar tombana avatar tounstm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

stm32cubeh7's Issues

Missing CMakeLists

  • Please can you add a CMakeLists for this project. At the moment all of my projects have to create a CMakeLists for the HAL whereas I think it should be added into the library as it's very much the standard for C/C++ projects.

SDMMC_BASE is undefined

Describe the set-up

  • arm-none-eabi-gcc
  • #include <stm32h7xx.h>

Describe the bug

This line is wrong, since there is no SDMMC peripheral on the device.

#define SDMMC               ((SDMMC_TypeDef *) SDMMC_BASE)

The correct peripherals are called SDMMC1 and SDMMC2 and they are correctly defined.

How To Reproduce

Try to call SDMMC in your code, which will fail since SDMMC_BASE is undefined.

Additional context

-#define SDMMC               ((SDMMC_TypeDef *) SDMMC_BASE)

Full patch

Also note that there is a use of a signed 32-bit integer in the ETH_TypeDef struct (around line 762):

   uint32_t      RESERVED15[14];
   __IO uint32_t MMCTSCGPR;
   __IO uint32_t MMCTMCGPR;
-  int32_t       RESERVED16[5];
+  uint32_t      RESERVED16[5];
   __IO uint32_t MMCTPCGR;
   uint32_t      RESERVED17[10];
   __IO uint32_t MMCRCRCEPR;

Cannot read Audio Data(MP34DT05TR Mic) based on DFSDM

  • Board: STM32H747I-DISO

  • SDK: STM32Cube_FW_H7_V1.6.0

  • Pin: PD3(CLK), PC7(DATAIN3)

  • Problem: Filter->DMA bufer OK. HAL_DFSDM_FilterRegConvCpltCallback and HAL_DFSDM_FilterRegConvHalfCpltCallback function enter normally, but the data is wrong(always the same number).
    I monitor the DFSDM registers, the RDATAR register no change.

  • Header file


/* DFSDM Configuration defines */
#define AUDIO_DFSDMx_RIGHT_CHANNEL      DFSDM_CHANNEL_2
#define AUDIO_DFSDMx_LEFT_CHANNEL       DFSDM_CHANNEL_3

#define AUDIO_DFSDMx_LEFT_FILTER        DFSDM1_Filter0
#define AUDIO_DFSDMx_RIGHT_FILTER       DFSDM1_Filter1

   
#define AUDIO_DFSDMx_CLK_ENABLE()                       __HAL_RCC_DFSDM1_CLK_ENABLE()
#define AUDIO_DFSDMx_CKOUT_PIN                          GPIO_PIN_3
#define AUDIO_DFSDMx_CKOUT_DMIC_GPIO_PORT               GPIOD
#define AUDIO_DFSDMx_CKOUT_AF                           GPIO_AF3_DFSDM1
#define AUDIO_DFSDMx_CKOUT_DMIC_GPIO_CLK_ENABLE()       __HAL_RCC_GPIOD_CLK_ENABLE()


#define AUDIO_DFSDMx_DMIC_DATIN_PIN                     GPIO_PIN_7
#define AUDIO_DFSDMx_DMIC_DATIN_GPIO_PORT               GPIOC
#define AUDIO_DFSDMx_DMIC_DATIN_AF                      GPIO_AF4_DFSDM1
#define AUDIO_DFSDMx_DMIC_DATIN_GPIO_CLK_ENABLE()       __HAL_RCC_GPIOC_CLK_ENABLE()
    
/* DFSDM DMA Right and Left channels definitions */
#define AUDIO_DFSDMx_DMAx_CLK_ENABLE()          __HAL_RCC_DMA2_CLK_ENABLE()

#define AUDIO_DFSDMx_DMAx_LEFT_REQUEST          DMA_REQUEST_DFSDM1_FLT0
#define AUDIO_DFSDMx_DMAx_RIGHT_REQUEST         DMA_REQUEST_DFSDM1_FLT1

#define AUDIO_DFSDMx_DMAx_PERIPH_DATA_SIZE      DMA_PDATAALIGN_WORD
#define AUDIO_DFSDMx_DMAx_MEM_DATA_SIZE         DMA_MDATAALIGN_WORD

#define AUDIO_DFSDMx_DMAx_LEFT_STREAM           DMA2_Stream3
#define AUDIO_DFSDMx_DMAx_LEFT_IRQ              DMA2_Stream3_IRQn   
#define AUDIO_DFSDMx_DMAx_LEFT_IRQHandler       DMA2_Stream3_IRQHandler

#define AUDIO_DFSDMx_DMAx_RIGHT_STREAM          DMA2_Stream2
#define AUDIO_DFSDMx_DMAx_RIGHT_IRQ             DMA2_Stream2_IRQn
#define AUDIO_DFSDMx_DMAx_RIGHT_IRQHandler      DMA2_Stream2_IRQHandler

/* Select the interrupt preemption priority and subpriority for the DMA interrupt */
#define AUDIO_IRQ_PREPRIO                    ((uint32_t)0x0E)
  • Source file
#include "main.h"

#define SaturaLH(N, L, H) (((N) < (L)) ? (L) : (((N) > (H)) ? (H) : (N)))

/* Private variables ---------------------------------------------------------*/
DFSDM_Channel_HandleTypeDef DfsdmLeftChannelHandle;
DFSDM_Channel_HandleTypeDef DfsdmRightChannelHandle;
DFSDM_Filter_HandleTypeDef DfsdmLeftFilterHandle;
DFSDM_Filter_HandleTypeDef DfsdmRightFilterHandle;

DMA_HandleTypeDef DfsdmLeftDmaHandle;
DMA_HandleTypeDef DfsdmRightDmaHandle;

AUDIO_Drv_t *Audio_Drv = NULL;
WM8994_Init_t codec_init;

/*Buffer location and size should aligned to cache line size (32 bytes) */
ALIGN_32BYTES(int32_t LeftRecBuff[2048]);
ALIGN_32BYTES(int32_t RightRecBuff[2048]);
uint32_t DmaLeftRecHalfBuffCplt = 0;
uint32_t DmaLeftRecBuffCplt = 0;
uint32_t DmaRightRecHalfBuffCplt = 0;
uint32_t DmaRightRecBuffCplt = 0;

static void DFSDM_Init(void)
{
  /* Initialize channel 1 (left channel)*/
  __HAL_DFSDM_CHANNEL_RESET_HANDLE_STATE(&DfsdmLeftChannelHandle);
  DfsdmLeftChannelHandle.Instance = DFSDM1_Channel3;
  DfsdmLeftChannelHandle.Init.OutputClock.Activation = ENABLE;
  DfsdmLeftChannelHandle.Init.OutputClock.Selection = DFSDM_CHANNEL_OUTPUT_CLOCK_AUDIO;
  DfsdmLeftChannelHandle.Init.OutputClock.Divider = 24; /* 49.142MHz/24 = 2.047MHz */
  DfsdmLeftChannelHandle.Init.Input.Multiplexer = DFSDM_CHANNEL_EXTERNAL_INPUTS;
  DfsdmLeftChannelHandle.Init.Input.DataPacking = DFSDM_CHANNEL_STANDARD_MODE; /* N.U. */
  DfsdmLeftChannelHandle.Init.Input.Pins = DFSDM_CHANNEL_SAME_CHANNEL_PINS;
  DfsdmLeftChannelHandle.Init.SerialInterface.Type = DFSDM_CHANNEL_SPI_RISING;
  DfsdmLeftChannelHandle.Init.SerialInterface.SpiClock = DFSDM_CHANNEL_SPI_CLOCK_INTERNAL;
  DfsdmLeftChannelHandle.Init.Awd.FilterOrder = DFSDM_CHANNEL_FASTSINC_ORDER; /* N.U. */
  DfsdmLeftChannelHandle.Init.Awd.Oversampling = 10;                          /* N.U. */
  DfsdmLeftChannelHandle.Init.Offset = 0;
  DfsdmLeftChannelHandle.Init.RightBitShift = 3;
  if (HAL_OK != HAL_DFSDM_ChannelInit(&DfsdmLeftChannelHandle))
  {
    Error_Handler();
  }

  /* Initialize channel 0 (right channel)*/
  __HAL_DFSDM_CHANNEL_RESET_HANDLE_STATE(&DfsdmRightChannelHandle);
  DfsdmRightChannelHandle.Instance = DFSDM1_Channel2;
  DfsdmRightChannelHandle.Init.OutputClock.Activation = ENABLE;
  DfsdmRightChannelHandle.Init.OutputClock.Selection = DFSDM_CHANNEL_OUTPUT_CLOCK_AUDIO;
  DfsdmRightChannelHandle.Init.OutputClock.Divider = 24; /* 49.142MHz/24 = 2.047MHz */
  DfsdmRightChannelHandle.Init.Input.Multiplexer = DFSDM_CHANNEL_EXTERNAL_INPUTS;
  DfsdmRightChannelHandle.Init.Input.DataPacking = DFSDM_CHANNEL_STANDARD_MODE; /* N.U. */
  DfsdmRightChannelHandle.Init.Input.Pins = DFSDM_CHANNEL_FOLLOWING_CHANNEL_PINS;
  DfsdmRightChannelHandle.Init.SerialInterface.Type = DFSDM_CHANNEL_SPI_FALLING;
  DfsdmRightChannelHandle.Init.SerialInterface.SpiClock = DFSDM_CHANNEL_SPI_CLOCK_INTERNAL;
  DfsdmRightChannelHandle.Init.Awd.FilterOrder = DFSDM_CHANNEL_FASTSINC_ORDER; /* N.U. */
  DfsdmRightChannelHandle.Init.Awd.Oversampling = 10;                          /* N.U. */
  DfsdmRightChannelHandle.Init.Offset = 0;
  DfsdmRightChannelHandle.Init.RightBitShift = 3;
  if (HAL_OK != HAL_DFSDM_ChannelInit(&DfsdmRightChannelHandle))
  {
    Error_Handler();
  }

  /* Initialize filter 0 (left channel) */
  __HAL_DFSDM_FILTER_RESET_HANDLE_STATE(&DfsdmLeftFilterHandle);
  DfsdmLeftFilterHandle.Instance = DFSDM1_Filter0;
  DfsdmLeftFilterHandle.Init.RegularParam.Trigger = DFSDM_FILTER_SW_TRIGGER;
  DfsdmLeftFilterHandle.Init.RegularParam.FastMode = ENABLE;
  DfsdmLeftFilterHandle.Init.RegularParam.DmaMode = ENABLE;
  DfsdmLeftFilterHandle.Init.InjectedParam.Trigger = DFSDM_FILTER_SW_TRIGGER;                  /* N.U. */
  DfsdmLeftFilterHandle.Init.InjectedParam.ScanMode = ENABLE;                                  /* N.U. */
  DfsdmLeftFilterHandle.Init.InjectedParam.DmaMode = DISABLE;                                  /* N.U. */
  DfsdmLeftFilterHandle.Init.InjectedParam.ExtTrigger = DFSDM_FILTER_EXT_TRIG_TIM1_TRGO;       /* N.U. */
  DfsdmLeftFilterHandle.Init.InjectedParam.ExtTriggerEdge = DFSDM_FILTER_EXT_TRIG_RISING_EDGE; /* N.U. */
  DfsdmLeftFilterHandle.Init.FilterParam.SincOrder = DFSDM_FILTER_SINC3_ORDER;
  DfsdmLeftFilterHandle.Init.FilterParam.Oversampling = 128; /* 49.142MHz/(24*128) = 16KHz */
  DfsdmLeftFilterHandle.Init.FilterParam.IntOversampling = 1;
  if (HAL_OK != HAL_DFSDM_FilterInit(&DfsdmLeftFilterHandle))
  {
    Error_Handler();
  }

  /* Initialize filter 1 (right channel) */
  __HAL_DFSDM_FILTER_RESET_HANDLE_STATE(&DfsdmRightFilterHandle);
  DfsdmRightFilterHandle.Instance = DFSDM1_Filter1;
  DfsdmRightFilterHandle.Init.RegularParam.Trigger = DFSDM_FILTER_SYNC_TRIGGER;
  DfsdmRightFilterHandle.Init.RegularParam.FastMode = ENABLE;
  DfsdmRightFilterHandle.Init.RegularParam.DmaMode = ENABLE;
  DfsdmRightFilterHandle.Init.InjectedParam.Trigger = DFSDM_FILTER_SW_TRIGGER;                  /* N.U. */
  DfsdmRightFilterHandle.Init.InjectedParam.ScanMode = ENABLE;                                  /* N.U. */
  DfsdmRightFilterHandle.Init.InjectedParam.DmaMode = DISABLE;                                  /* N.U. */
  DfsdmRightFilterHandle.Init.InjectedParam.ExtTrigger = DFSDM_FILTER_EXT_TRIG_TIM1_TRGO;       /* N.U. */
  DfsdmRightFilterHandle.Init.InjectedParam.ExtTriggerEdge = DFSDM_FILTER_EXT_TRIG_RISING_EDGE; /* N.U. */
  DfsdmRightFilterHandle.Init.FilterParam.SincOrder = DFSDM_FILTER_SINC3_ORDER;
  DfsdmRightFilterHandle.Init.FilterParam.Oversampling = 128; /* 49.142MHz/(24*128) = 16KHz */
  DfsdmRightFilterHandle.Init.FilterParam.IntOversampling = 1;
  if (HAL_OK != HAL_DFSDM_FilterInit(&DfsdmRightFilterHandle))
  {
    Error_Handler();
  }

  /* Configure regular channel and continuous mode for filter 0 (left channel) */
  if (HAL_OK != HAL_DFSDM_FilterConfigRegChannel(&DfsdmLeftFilterHandle, DFSDM_CHANNEL_3, DFSDM_CONTINUOUS_CONV_ON))
  {
    Error_Handler();
  }

  /* Configure regular channel and continuous mode for filter 1 (right channel) */
  if (HAL_OK != HAL_DFSDM_FilterConfigRegChannel(&DfsdmRightFilterHandle, DFSDM_CHANNEL_2, DFSDM_CONTINUOUS_CONV_ON))
  {
    Error_Handler();
  }
}

/**
  * @brief  Initialize the DFSDM channel MSP.
  * @param  hdfsdm_channel : DFSDM channel handle.
  * @retval None
  */
static void MX_DFSDM_ChannelMspInit(DFSDM_Channel_HandleTypeDef *hdfsdm_channel)
{
  UNUSED(hdfsdm_channel);
  GPIO_InitTypeDef GPIO_InitStruct;

  /* Enable DFSDM clock */
  AUDIO_DFSDMx_CLK_ENABLE();

  /* Enable GPIO clock */
  AUDIO_DFSDMx_DMIC_DATIN_GPIO_CLK_ENABLE();
  AUDIO_DFSDMx_CKOUT_DMIC_GPIO_CLK_ENABLE();

  /* DFSDM pins configuration: DFSDM_CKOUT, DMIC_DATIN1 pins ------------------*/
  GPIO_InitStruct.Pin = AUDIO_DFSDMx_CKOUT_PIN;
  GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  GPIO_InitStruct.Alternate = AUDIO_DFSDMx_CKOUT_AF;
  HAL_GPIO_Init(AUDIO_DFSDMx_CKOUT_DMIC_GPIO_PORT, &GPIO_InitStruct);

  /* DFSDM pin configuration: DMIC_DATIN1 pin --------------------------------*/
  GPIO_InitStruct.Pin = AUDIO_DFSDMx_DMIC_DATIN_PIN;
  GPIO_InitStruct.Alternate = AUDIO_DFSDMx_DMIC_DATIN_AF;
  HAL_GPIO_Init(AUDIO_DFSDMx_DMIC_DATIN_GPIO_PORT, &GPIO_InitStruct);
}

/**
  * @brief  DeInitialize the DFSDM channel MSP.
  * @param  hdfsdm_channel : DFSDM channel handle.
  * @retval None
  */
static void MX_DFSDM_ChannelMspDeInit(DFSDM_Channel_HandleTypeDef *hdfsdm_channel)
{
  UNUSED(hdfsdm_channel);
  GPIO_InitTypeDef GPIO_InitStruct;

  /* DFSDM pin configuration: DMIC_DATIN1 pin --------------------------------*/
  GPIO_InitStruct.Pin = AUDIO_DFSDMx_CKOUT_PIN;
  HAL_GPIO_DeInit(AUDIO_DFSDMx_CKOUT_DMIC_GPIO_PORT, GPIO_InitStruct.Pin);
  GPIO_InitStruct.Pin = AUDIO_DFSDMx_DMIC_DATIN_PIN;
  HAL_GPIO_DeInit(AUDIO_DFSDMx_DMIC_DATIN_GPIO_PORT, GPIO_InitStruct.Pin);
}

/**
  * @brief  Initialize the DFSDM filter MSP.
  * @param  hdfsdm_filter : DFSDM filter handle.
  * @retval None
  */
static void MX_DFSDM_FilterMspInit(DFSDM_Filter_HandleTypeDef *hdfsdm_filter)
{
  /* Enable DFSDM clock */
  AUDIO_DFSDMx_CLK_ENABLE();

  /* Enable the DMA clock */
  AUDIO_DFSDMx_DMAx_CLK_ENABLE();

  /*********** Configure DMA stream for LEFT microphone *******************/
  DfsdmLeftDmaHandle.Init.Direction = DMA_PERIPH_TO_MEMORY;
  DfsdmLeftDmaHandle.Init.PeriphInc = DMA_PINC_DISABLE;
  DfsdmLeftDmaHandle.Init.MemInc = DMA_MINC_ENABLE;
  DfsdmLeftDmaHandle.Init.PeriphDataAlignment = AUDIO_DFSDMx_DMAx_PERIPH_DATA_SIZE;
  DfsdmLeftDmaHandle.Init.MemDataAlignment = AUDIO_DFSDMx_DMAx_MEM_DATA_SIZE;
  DfsdmLeftDmaHandle.Init.Mode = DMA_CIRCULAR;
  DfsdmLeftDmaHandle.Init.Priority = DMA_PRIORITY_HIGH;
  DfsdmLeftDmaHandle.Instance = AUDIO_DFSDMx_DMAx_LEFT_STREAM;
  DfsdmLeftDmaHandle.Init.Request = AUDIO_DFSDMx_DMAx_LEFT_REQUEST;

  /* Associate the DMA handle */
  __HAL_LINKDMA(&DfsdmLeftFilterHandle, hdmaReg, DfsdmLeftDmaHandle);

  /* Reset DMA handle state */
  __HAL_DMA_RESET_HANDLE_STATE(&DfsdmLeftDmaHandle);

  /* Configure the DMA Channel */
  HAL_DMA_Init(&DfsdmLeftDmaHandle);

  /* DMA IRQ Channel configuration */
  HAL_NVIC_SetPriority(AUDIO_DFSDMx_DMAx_LEFT_IRQ, AUDIO_IRQ_PREPRIO, 0);
  HAL_NVIC_EnableIRQ(AUDIO_DFSDMx_DMAx_LEFT_IRQ);

  /*********** Configure DMA stream for RIGHT microphone ******************/
  DfsdmRightDmaHandle.Init.Direction = DMA_PERIPH_TO_MEMORY;
  DfsdmRightDmaHandle.Init.PeriphInc = DMA_PINC_DISABLE;
  DfsdmRightDmaHandle.Init.MemInc = DMA_MINC_ENABLE;
  DfsdmRightDmaHandle.Init.PeriphDataAlignment = AUDIO_DFSDMx_DMAx_PERIPH_DATA_SIZE;
  DfsdmRightDmaHandle.Init.MemDataAlignment = AUDIO_DFSDMx_DMAx_MEM_DATA_SIZE;
  DfsdmRightDmaHandle.Init.Mode = DMA_CIRCULAR;
  DfsdmRightDmaHandle.Init.Priority = DMA_PRIORITY_HIGH;
  DfsdmRightDmaHandle.Instance = AUDIO_DFSDMx_DMAx_RIGHT_STREAM;
  DfsdmRightDmaHandle.Init.Request = AUDIO_DFSDMx_DMAx_RIGHT_REQUEST;

  /* Associate the DMA handle */
  __HAL_LINKDMA(&DfsdmRightFilterHandle, hdmaReg, DfsdmRightDmaHandle);

  /* Reset DMA handle state */
  __HAL_DMA_RESET_HANDLE_STATE(&DfsdmRightDmaHandle);

  /* Configure the DMA Channel */
  HAL_DMA_Init(&DfsdmRightDmaHandle);

  /* DMA IRQ Channel configuration */
  HAL_NVIC_SetPriority(AUDIO_DFSDMx_DMAx_RIGHT_IRQ, AUDIO_IRQ_PREPRIO, 0);
  HAL_NVIC_EnableIRQ(AUDIO_DFSDMx_DMAx_RIGHT_IRQ);
}

/**
  * @brief  DeInitialize the DFSDM filter MSP.
  * @param  hdfsdm_filter : DFSDM filter handle.
  * @retval None
  */
static void MX_DFSDM_FilterMspDeInit(DFSDM_Filter_HandleTypeDef *hdfsdm_filter)
{
  HAL_DMA_DeInit(&DfsdmLeftDmaHandle);
  HAL_DMA_DeInit(&DfsdmRightDmaHandle);
}

/**
  * @brief  Clock Config.
  * @param  hDfsdmChannel  DFSDM Channel Handle
  * @param  SampleRate     Audio frequency to be configured for the DFSDM Channel.
  * @note   This API is called by BSP_AUDIO_IN_Init()
  *         Being __weak it can be overwritten by the application
  * @retval HAL_status
  */
__weak HAL_StatusTypeDef MX_DFSDM1_ClockConfig(DFSDM_Channel_HandleTypeDef *hDfsdmChannel, uint32_t SampleRate)
{
  /* Prevent unused argument(s) compilation warning */
  UNUSED(hDfsdmChannel);

  HAL_StatusTypeDef ret = HAL_OK;
#if 1
  RCC_PeriphCLKInitTypeDef rcc_ex_clk_init_struct;

  HAL_RCCEx_GetPeriphCLKConfig(&rcc_ex_clk_init_struct);

  /* Set the PLL configuration according to the audio frequency */
  if ((SampleRate == AUDIO_FREQUENCY_11K) || (SampleRate == AUDIO_FREQUENCY_22K) || (SampleRate == AUDIO_FREQUENCY_44K))
  {
    /* 429/38 = 11.289 Mhz */
    rcc_ex_clk_init_struct.PLL2.PLL2P = 38;
    rcc_ex_clk_init_struct.PLL2.PLL2N = 429;
  }
  else /* AUDIO_FREQUENCY_8K, AUDIO_FREQUENCY_16K, AUDIO_FREQUENCY_32K, AUDIO_FREQUENCY_48K, AUDIO_FREQUENCY_96K */
  {
    /* 344/7 = 49.142 Mhz */
    rcc_ex_clk_init_struct.PLL2.PLL2P = 7;
    rcc_ex_clk_init_struct.PLL2.PLL2N = 344;
  }
  /* Configure prescalers */
  rcc_ex_clk_init_struct.PeriphClockSelection = RCC_PERIPHCLK_SAI1;
  rcc_ex_clk_init_struct.Sai1ClockSelection = RCC_SAI1CLKSOURCE_PLL2;
  rcc_ex_clk_init_struct.PLL2.PLL2Q = 1;
  rcc_ex_clk_init_struct.PLL2.PLL2R = 1;
  rcc_ex_clk_init_struct.PLL2.PLL2M = 25;
  rcc_ex_clk_init_struct.PLL2.PLL2FRACN = 0;
  rcc_ex_clk_init_struct.PLL2.PLL2RGE = RCC_PLL2VCIRANGE_0;
  rcc_ex_clk_init_struct.PLL2.PLL2VCOSEL = RCC_PLL2VCOMEDIUM;

  if (HAL_RCCEx_PeriphCLKConfig(&rcc_ex_clk_init_struct) != HAL_OK)
  {
    ret = HAL_ERROR;
  }
#else
  RCC_PeriphCLKInitTypeDef RCC_PeriphCLKInitStruct;

  /* Configure PLLSAI prescalers */
  /* PLL2SAI_VCO: VCO_429M 
     SAI_CLK(first level) = PLLSAI_VCO/PLLSAIP = 429/38 = 11.289 Mhz */
  RCC_PeriphCLKInitStruct.PeriphClockSelection = RCC_PERIPHCLK_SAI1;
  RCC_PeriphCLKInitStruct.Sai1ClockSelection = RCC_SAI1CLKSOURCE_PLL2;
  RCC_PeriphCLKInitStruct.PLL2.PLL2P = 38;
  RCC_PeriphCLKInitStruct.PLL2.PLL2Q = 1;
  RCC_PeriphCLKInitStruct.PLL2.PLL2R = 1;
  RCC_PeriphCLKInitStruct.PLL2.PLL2N = 429;
  RCC_PeriphCLKInitStruct.PLL2.PLL2FRACN = 0;
  RCC_PeriphCLKInitStruct.PLL2.PLL2M = 25;
  RCC_PeriphCLKInitStruct.PLL2.PLL2RGE = RCC_PLL2VCIRANGE_0;
  RCC_PeriphCLKInitStruct.PLL2.PLL2VCOSEL = RCC_PLL2VCOMEDIUM;

  if (HAL_RCCEx_PeriphCLKConfig(&RCC_PeriphCLKInitStruct) != HAL_OK)
  {
    Error_Handler();
  }
#endif
  return ret;
}

/**
  * @brief  Half regular conversion complete callback. 
  * @param  hdfsdm_filter : DFSDM filter handle.
  * @retval None
  */
void HAL_DFSDM_FilterRegConvHalfCpltCallback(DFSDM_Filter_HandleTypeDef *hdfsdm_filter)
{
  if (hdfsdm_filter == &DfsdmLeftFilterHandle)
  {
    DmaLeftRecHalfBuffCplt = 1;
    /* Invalidate Data Cache to get the updated content of the SRAM*/
    SCB_InvalidateDCache_by_Addr((uint32_t *)&LeftRecBuff[0], sizeof(LeftRecBuff) / 2);
  }
  else
  {
    DmaRightRecHalfBuffCplt = 1;
    /* Invalidate Data Cache to get the updated content of the SRAM*/
    SCB_InvalidateDCache_by_Addr((uint32_t *)&RightRecBuff[0], sizeof(RightRecBuff) / 2);
  }
}

/**
  * @brief  Regular conversion complete callback. 
  * @note   In interrupt mode, user has to read conversion value in this function
            using HAL_DFSDM_FilterGetRegularValue.
  * @param  hdfsdm_filter : DFSDM filter handle.
  * @retval None
  */
void HAL_DFSDM_FilterRegConvCpltCallback(DFSDM_Filter_HandleTypeDef *hdfsdm_filter)
{
  if (hdfsdm_filter == &DfsdmLeftFilterHandle)
  {
    DmaLeftRecBuffCplt = 1;
    /* Invalidate Data Cache to get the updated content of the SRAM*/
    SCB_InvalidateDCache_by_Addr((uint32_t *)&LeftRecBuff[1024], sizeof(LeftRecBuff) / 2);
  }
  else
  {
    DmaRightRecBuffCplt = 1;
    /* Invalidate Data Cache to get the updated content of the SRAM*/
    SCB_InvalidateDCache_by_Addr((uint32_t *)&RightRecBuff[1024], sizeof(RightRecBuff) / 2);
  }
}

int Audio_Record_Start(void)
{
  /* Start DFSDM conversions */
  if (HAL_OK != HAL_DFSDM_FilterRegularStart_DMA(&DfsdmRightFilterHandle, RightRecBuff, 2048))
  {
    printf("HAL_DFSDM_FilterRegularStart_DMA failed!! DfsdmRightFilterHandle\r\n");
    return (-1);
  }
  if (HAL_OK != HAL_DFSDM_FilterRegularStart_DMA(&DfsdmLeftFilterHandle, LeftRecBuff, 2048))
  {
    printf("HAL_DFSDM_FilterRegularStart_DMA failed!! DfsdmLeftFilterHandle\r\n");
    return (-1);
  }

  return 0;
}

int Audio_Record_Stop(void)
{
  MX_DFSDM_ChannelMspDeInit(&DfsdmLeftChannelHandle);
	MX_DFSDM_FilterMspDeInit(&DfsdmLeftFilterHandle);
  return 0;
}

void Audio_Record_Config(void)
{
  MX_DFSDM1_ClockConfig(&DfsdmLeftChannelHandle, 16000U);
  MX_DFSDM_FilterMspInit(&DfsdmLeftFilterHandle);
  MX_DFSDM_ChannelMspInit(&DfsdmLeftChannelHandle);
  DFSDM_Init();
}

/******************************************************************************************************************/
/******************************************************************************************************************/
/******************************************************************************************************************/
typedef enum
{
  AUDIO_RECORD_MESSAGE_EVENT_PROCESS = 0,
  AUDIO_RECORD_MESSAGE_EVENT_STOP
} AudioRecordMessageEventTypeDef;

#define AUDIO_RECORD_MAX_TIME_MS 10000

osMessageQId AudioRecordEvent;
uint32_t AudioRecordCount = 0;

void AudioRecordTick(void)
{
  if (AudioRecordCount)
  {
    AudioRecordCount--;
    osMessagePut(AudioRecordEvent, AUDIO_RECORD_MESSAGE_EVENT_STOP, 0);
  }
}

void AudioRecordThread(void const *argument)
{
  UNUSED(argument);
  osEvent event;
  printf("AudioRecordThread start ...\r\n");

  osMessageQDef(AUDIO_Record_Queue, 10, uint16_t);
  AudioRecordEvent = osMessageCreate(osMessageQ(AUDIO_Record_Queue), NULL);
  if (0 == AudioRecordEvent)
  {
    printf("Audio thread osMessageCreate failed\r\n");
    Error_Handler();
  }

  Audio_Record_Config();
  Audio_Record_Start();
  //AudioRecordCount =  AUDIO_RECORD_MAX_TIME_MS;

  while (1)
  {
    event = osMessageGet(AudioRecordEvent, osWaitForever); //osWaitForever
    if (event.status == osEventMessage)
    {
      switch (event.value.v)
      {
      case AUDIO_RECORD_MESSAGE_EVENT_PROCESS:
        printf("AUDIO_RECORD_MESSAGE_EVENT_PROCESS\r\n");
        break;

      case AUDIO_RECORD_MESSAGE_EVENT_STOP:
        Audio_Record_Stop();
        break;

      default:
        break;
      }
    }
  }
}

__HAL_RCC_AHB3_FORCE_RESET() sometime causes microprocessor to reset

Setup
Hardware: Proprietary hardware containing STM32H743 and external FLASH and external SDRAM.
IDE: VisualGDB with GCC 9.2.1

Bug Description
When the HAL_DeInit() function calls the __HAL_RCC_AHB3_FORCE_RESET() function the microprocessor sometimes resets.

#define __HAL_RCC_AHB3_FORCE_RESET()          (RCC->AHB3RSTR = 0xFFFFFFFFU)

How To Reproduce

  1. Indicate the global behavior of your application project
    A small FLASH programmer is running in internal RAM (DTCMRAM @ 0x20000000). After it programs the external flash it unloads itself and calls HAL_DeInit() which calls __HAL_RCC_AHB3_FORCE_RESET(). At this point the microprocessor resets.

  2. The modules that you suspect to be the cause of the problem (Driver, BSP, MW ...)
    The __HAL_RCC_AHB3_FORCE_RESET() resides in stm32h7xx_hal_rcc.h

  3. The use case that generates the problem
    Calling the HAL_DeInit() when the program prepares to unload itself.

  4. How we can reproduce the problem
    I don't know all conditions which makes the function fail. I suspect it has something to do with calling the function from internal RAM. I don't think you need to reproduce the problem. It is clearly a bug (see below) which should be rectified.

Additional context
The code writes all 1's to the AHB3RSTR register. However, the STM32H7 reference manual says the reserved bits in that register must remain at the reset value (i.e. 0's)

This code:

#define __HAL_RCC_AHB3_FORCE_RESET()          (RCC->AHB3RSTR = 0xFFFFFFFFU)

should be replaced by:

#define __HAL_RCC_AHB3_RESET_ALL               (RCC_AHB3RSTR_MDMARST |       \
                                                RCC_AHB3RSTR_DMA2DRST |      \
                                                RCC_AHB3RSTR_JPGDECRST |     \
                                                RCC_AHB3RSTR_FMCRST |        \
                                                RCC_AHB3RSTR_QSPIRST |       \
                                                RCC_AHB3RSTR_SDMMC1RST)

#define __HAL_RCC_AHB3_FORCE_RESET()          (RCC->AHB3RSTR = __HAL_RCC_AHB3_RESET_ALL)    

Screenshots
None

STM32CubeMX code generator is calling ethernetif_input instead of ethernet_link_thread.

Describe the set-up

  • Hardware: Proprietary hardware containing STM32H743 and external FLASH and external SDRAM.
  • IDE: VisualGDB with GCC 9.2.1
  • FreeRTOS: V10.1.2
  • CMSIS: V2.0
  • Package: STM32Cube FW_H7 V1.6.0

Describe the bug
When LWIP_NETIF_LINK_CALLBACK is enable in the STM32CubeMX LWIP middleware, it generates the following code from the FW_H7 V1.6.0 package:

/* Set the link callback function, this function is called on change of link status*/
  netif_set_link_callback(&gnetif, ethernet_link_status_updated);
 
  /* Create the Ethernet link handler thread */
  memset(&attributes, 0x0, sizeof(osThreadAttr_t));
  attributes.name = "EthLink";
  attributes.stack_size = INTERFACE_THREAD_STACK_SIZE;
  attributes.priority = osPriorityRealtime;
  osThreadNew(ethernetif_input, &gnetif, &attributes);

In the last line, it is starting a thread with an entry function of ethernetif_input. However, that function has nothing to do with the ethernet link status. Previous versions of this package used an entry function for the thread called ethernet_link_thread.

How To Reproduce

  1. Indicate the global behavior of your application project
    Proprietary application with Ethernet port and LWIP as the TCP/IP stack.

  2. The modules that you suspect to be the cause of the problem (Driver, BSP, MW ...)
    The MX_LWIP_Init() function in the file lwip.c.

  3. The use case that generates the problem
    See (4)

  4. How we can reproduce the problem
    Create an STM32CubeMX project that uses the FW_H7 V1.6.0 package and includes LWIP middleware with the LWIP_NETIF_LINK_CALLBACK option enabled. The code that initiates the thread that monitors the Ethernet link uses the wrong start function.

Additional context
This code in MX_LWIP_Init():
osThreadNew(ethernetif_input, &gnetif, &attributes);
should be changed to:
osThreadNew(ethernet_link_thread, &gnetif, &attributes);

Screenshots
If applicable, add screenshots to help explain your problem.

CMSIS_OS.C

Hello,

C:\STM32CubeMX\Repository\STM32Cube_FW_H7_V1.8.0\Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS\CMSIS_OS.C

Line number 214
Code:

     if (xTaskCreate((TaskFunction_t)thread_def->pthread,(const portCHAR *)thread_def->name,
              thread_def->stacksize, argument, makeFreeRtosPriority(thread_def->tpriority),
              &handle) != pdPASS)  {

warning C4244: 'function': conversion from 'const uint32_t' to 'const uint16_t', possible loss of data

Other similar reporting:
Similar issue link

Regards,
@rxa1031

Dual Core boot up example

Describe the set-up

  • STM32H757I-EVAL
  • STM32CubeIDE 1.3.1

Additional context
I'm following the templates for the Dual Core bootup examples, when both cores boot at the same time (OB set accordingly, both checked).

The CPU2 boots-up, gets into Stop mode. I can't see how it gets out of Stop mode. I can see that CPU1 releases HSEM 0 but is this producing an event? There are no interrupts generated and checking the documentation I can't see HSEM generating events.

I can't make the code to work. Is the example correct?

Use BSP_SD_ReadBlocks_DMA() fail, SDMMC1_IRQHandler() interrupt cannot occur

usb_device MSC project st driver version 1.9.0

st sd card driver,Use BSP_SD_ReadBlocks_DMA() fail, SDMMC1_IRQHandler() interrupt cannot occur!!!

Use the non dma mode is working.

the sram is Axi-sram,non-cacheable,4 byte anlign.

what's strange is fatfs sd card working with dma mode!!! Same driver!!! Same Board!!!

Debug shows no sdmmc1 error,SDMMC1 just cannot occur๏ผ๏ผ๏ผ

FreeRTOS-MPU does not use the MPU on M7 cores

I've reported this bug through your forums and the support portal. Feel free to close the issue if it's already been escalated/solved internally.

  • Hardware: Nucleo-H743ZI2
  • IDE: IAR for Arm v8.32.1

All M7 cores are affected, regardless of the compiler used.

The bug

The FreeRTOS-MPU ports provided for M7 cores (ARM_CM4_MPU and ARM_CM7_MPU), and possibly others, do not actually use the MPU.

From ARM_CM4_MPU/port.c:

    #define portEXPECTED_MPU_TYPE_VALUE             ( 8UL << 8UL ) /* 8 regions, unified. */

M7 cores support 16 MPU regions, so that MPU->TYPE value is incorrect. As a result, the port silently fails to initialize the memory protection unit.

The fix:

    #if defined(CORE_CM4)
        #define portEXPECTED_MPU_TYPE_VALUE         ( 8UL << 8UL ) /* 8 regions, unified. */
    #else
        #define portEXPECTED_MPU_TYPE_VALUE         ( 16UL << 8UL ) /* 16 regions, unified. */
    #endif /* defined(CORE_CM4) */

That #if defined(CORE_CM4) is in line with the implementation at stm32h7xx_hal_cortex.h

How to reproduce

  1. Run the FreeRTOS-MPU example from the SDK on an M7 MCU
  2. Use your debugger of choice to check the MPU->CTRL register. It will show that the MPU is disabled
  3. Implement the fix mentioned above, and MPU->CTRL will show the MPU is now enabled, as expected

After this fix

After fixing this bug, a different one came up. When I try to use FreeRTOS-MPU and the MPU HAL on the same app, I run into a crash within the assembly routine vPortRestoreContextOfFirstTask of the ARM_CM4_MPU port. I'm still debugging that new one, and awaiting response from your support guys.

If you'd like any more info, let me know.

ADC example on stm32H745ZI gives DMA error

When I test the ADC DMA demo's on stm32H745 I only get a DMA error. Transfer error. I tried all kind of changes but do not get it working. Also other simple adc with dma fail on the same error. HAL_ADC_ConvCpltCallback is not called. I don't use the drivers from supplied by this example but the one's generated by cubemx in stm32CubeIDE.

image

I have to change the clock frequency to 200 Mhz because of the power restriction with USB.

USART Receive timeout interrupt not enabled.

Describe the set-up
Hardware: Proprietary hardware containing STM32H743 and external FLASH and external SDRAM.
IDE: VisualGDB with GCC 9.2.1

Additional context
Setting up the UART receive timeout involves calling these functions:
HAL_UART_ReceiverTimeout_Config(mHuart, mBitsPerCharacter); HAL_UART_EnableReceiverTimeout(mHuart);

However, that does not enable the receive timeout interrupt. The timeout detection is enabled, but not the interrupt. The following line should be added to the 'enable' routine, or placed in a separate call:

SET_BIT(mHuart->Instance->CR1, USART_CR1_RTOIE);

Also, after the receive completes, the interrupt should be disabled.

CLEAR_BIT(mHuart->Instance->CR1, USART_CR1_RTOIE);

Screenshots
None

OB_USER_SWAP_BANK Undeclared on H750 Target

Describe the set-up
Custom STM32H750 Board
arm-none-eabi-gcc (GNU Arm Embedded Toolchain 9-2020-q2-update) 9.3.1 20200408 (release)

Describe the bug
OB_USER_SWAP_BANK is Undeclared in expansion of OB_USER_ALL, OB_USER_SWAP_BANK is only declared when DUAL_BANK is defined and since the H750 does not declare DUAL_CORE, FLASH_OPTSR_VDDMMC_HSLV, or FLASH_OPTSR2_TCM_AXI_SHARED the H750 uses the default Declaration of OB_USER_ALL which includes OB_USER_SWAP_BANK
see https://github.com/STMicroelectronics/STM32CubeH7/blob/master/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_flash_ex.h#L656

Missing source codes in this repository

Repository not as described

STM32Cube MCU Full Package for the STM32H7 series - (HAL + LL Drivers, CMSIS Core, CMSIS Device, MW libraries plus a set of Projects running on all boards provided by ST (Nucleo, Evaluation and Discovery Kits))

Missing source codes.

Issue with chosen MAX value (i.e. 56) of configMAX_PRIORITIES

Hello,

I was reviewing the FreeRTOS code and the CMSIS_OS2.C file and the macro configMAX_PRIORITIES

I assume the below statement is incorrect and I have a reason for it:

/*  CMSIS-RTOSv2 defines 56 levels of priorities. To be able to use them
 *  all and avoid application misbehavior, configUSE_PORT_OPTIMISED_TASK_SELECTION
 *  must be set to 0 and configMAX_PRIORITIES to 56
 *
 */

Even the declarations like below are incorrect:
#define configMAX_PRIORITIES ( 56 )

Observation 1:
The FreeRTOS code version 10.3.1 (and maybe earlier) have a file named blocktim.c at location FreeRTOSv10.3.1\FreeRTOS\Demo\Common\Minimal\blocktim.c
The file declares the macro:

#ifndef bktSECONDARY_PRIORITY
	#define bktSECONDARY_PRIORITY	( configMAX_PRIORITIES - 4 )
#endif

I am not sure whether STM32CubeMX is aware of the above file or whether it has a different file in which above macro is created.

Observation 2:
File CMSIS_OS2.C declares the enum named osPriority_t, with the last three enumerated values as:

  osPriorityISR           = 56,         ///< Reserved for ISR deferred thread.
  osPriorityError         = -1,         ///< System cannot determine priority or illegal priority.
  osPriorityReserved      = 0x7FFFFFFF  ///< Prevents enum down-size compiler optimization.

Conclusion:

In order to allow code being ported to other microcontrollers (maybe non ST Microcontrollers) or debugged using MSVC, changes must be made to code.

From observation 1, I believe all user implementations should only be allowed to use MAXIMUM PRIORITY value which is one less than bktSECONDARY_PRIORITY i.e. configMAX_PRIORITIES - 5

From observation 2 and above conclusion, I believe the value assigned to configMAX_PRIORITIES should be osPriorityISR + 5

Please share your opinion.

Regards,
@rxa1031

HAL_RCCEx_PeriphCLKConfig not setting the HRTIM1 clock source

STM32 Nucleo-144 for STM32H743
Cube IDE 1.3.0 with STM32CubeH7 1.7.0

Description:
Using HAL_RCCEx_PeriphCLKConfig with PeriphClkInitStruct.Hrtim1ClockSelection = RCC_HRTIM1CLK_CPUCLK; with the intent of setting the clock source for HRTIM1 peripheral to the CPU clock has no effect.

The problem seems to originate in stm32h7xx_hal_rcc_ex.c in line 1474. The function tries to check if the HRTIM1 peripheral does exist but it uses the wrong non-existing define HRTIM for that purpose:

#if defined(HRTIM)
  /*------------------------------ HRTIM1 clock Configuration ----------------*/
  if(((PeriphClkInit->PeriphClockSelection) & RCC_PERIPHCLK_HRTIM1) == RCC_PERIPHCLK_HRTIM1)
  {
    /* Check the parameters */
    assert_param(IS_RCC_HRTIM1CLKSOURCE(PeriphClkInit->Hrtim1ClockSelection));

    /* Configure the HRTIM1 clock source */
    __HAL_RCC_HRTIM1_CONFIG(PeriphClkInit->Hrtim1ClockSelection);
  }
#endif  /*HRTIM*/

The file stm32h743xx.h defines HRTIM1 in line 2393. Changing the above code to use this define instead fixes the problem. The right clock source gets applied by HAL_RCCEx_PeriphCLKConfig.

#if defined(HRTIM1)
  /*------------------------------ HRTIM1 clock Configuration ----------------*/
  if(((PeriphClkInit->PeriphClockSelection) & RCC_PERIPHCLK_HRTIM1) == RCC_PERIPHCLK_HRTIM1)
  {
    /* Check the parameters */
    assert_param(IS_RCC_HRTIM1CLKSOURCE(PeriphClkInit->Hrtim1ClockSelection));

    /* Configure the HRTIM1 clock source */
    __HAL_RCC_HRTIM1_CONFIG(PeriphClkInit->Hrtim1ClockSelection);
  }
#endif  /*HRTIM1*/

Broken I2S extension module when using the 1.5.0 version.

It appears that the current stm32h7xx_hal_i2s_ex.c file is broken due to undeclared identifiers and CMSIS register usage. This can be verified by doing a recursive search for the identifiers in the repository.

These are the errors that occur when simply including the stm32h7xx_hal_i2s_ex.h file after defining SPI_I2S_FULLDUPLEX_SUPPORT:

../STM32Cube/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2s_ex.c:243:17: error: 'HAL_I2S_STATE_BUSY_TX_RX' undeclared (first use in this function); did you mean 'HAL_SPI_STATE_BUSY_TX_RX'?
../STM32Cube/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2s_ex.c:250:21: error: 'SPI_TypeDef' {aka 'struct <anonymous>'} has no member named 'DR'; did you mean 'SR'?
../STM32Cube/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_i2s_ex.h:46:74: error: 'I2S2ext_BASE' undeclared (first use in this function); did you mean 'I2C2_BASE'?
../STM32Cube/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_i2s_ex.h:46:105: error: 'I2S3ext_BASE' undeclared (first use in this function); did you mean 'I2C3_BASE'?
../STM32Cube/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_i2s_ex.h:52:86: error: 'SPI_I2SCFGR_I2SE' undeclared (first use in this function); did you mean 'SPI_I2SCFGR_I2SDIV'?
../STM32Cube/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2s_ex.c:280:25: error: 'SPI_TypeDef' {aka 'struct <anonymous>'} has no member named 'DR'; did you mean 'SR'?
../STM32Cube/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2s_ex.c:377:40: error: 'SPI_TypeDef' {aka 'struct <anonymous>'} has no member named 'DR'; did you mean 'SR'?
../STM32Cube/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2s_ex.c:463:21: error: 'HAL_I2S_STATE_BUSY_TX_RX' undeclared (first use in this function); did you mean 'HAL_SPI_STATE_BUSY_TX_RX'?
../STM32Cube/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_i2s_ex.h:46:74: error: 'I2S2ext_BASE' undeclared (first use in this function); did you mean 'I2C2_BASE'?
../STM32Cube/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_i2s_ex.h:46:105: error: 'I2S3ext_BASE' undeclared (first use in this function); did you mean 'I2C3_BASE'?
../STM32Cube/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2s_ex.c:475:21: error: 'SPI_TypeDef' {aka 'struct <anonymous>'} has no member named 'DR'; did you mean 'SR'?
../STM32Cube/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_i2s_ex.h:52:86: error: 'SPI_I2SCFGR_I2SE' undeclared (first use in this function); did you mean 'SPI_I2SCFGR_I2SDIV'?
../STM32Cube/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2s_ex.c:574:21: error: 'HAL_I2S_STATE_BUSY_TX_RX' undeclared (first use in this function); did you mean 'HAL_SPI_STATE_BUSY_TX_RX'?
../STM32Cube/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_i2s_ex.h:46:74: error: 'I2S2ext_BASE' undeclared (first use in this function); did you mean 'I2C2_BASE'?
../STM32Cube/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_i2s_ex.h:46:105: error: 'I2S3ext_BASE' undeclared (first use in this function); did you mean 'I2C3_BASE'?
../STM32Cube/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2s_ex.c:603:43: error: 'SPI_CR2_RXDMAEN' undeclared (first use in this function); did you mean 'SPI_CFG1_RXDMAEN'?
../STM32Cube/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2s_ex.c:607:81: error: 'SPI_TypeDef' {aka 'struct <anonymous>'} has no member named 'DR'; did you mean 'SR'?
../STM32Cube/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2s_ex.c:610:34: error: 'SPI_CR2_TXDMAEN' undeclared (first use in this function); did you mean 'SPI_CFG1_TXDMAEN'?
../STM32Cube/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2s_ex.c:613:36: error: 'SPI_I2SCFGR_I2SE' undeclared (first use in this function); did you mean 'SPI_I2SCFGR_I2SDIV'?
../STM32Cube/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2s_ex.c:640:63: error: 'SPI_TypeDef' {aka 'struct <anonymous>'} has no member named 'DR'; did you mean 'SR'?
../STM32Cube/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_i2s_ex.h:46:74: error: 'I2S2ext_BASE' undeclared (first use in this function); did you mean 'I2C2_BASE'?
../STM32Cube/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_i2s_ex.h:46:105: error: 'I2S3ext_BASE' undeclared (first use in this function); did you mean 'I2C3_BASE'?
../STM32Cube/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_i2s_ex.h:46:74: error: 'I2S2ext_BASE' undeclared (first use in this function); did you mean 'I2C2_BASE'?
../STM32Cube/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_i2s_ex.h:46:105: error: 'I2S3ext_BASE' undeclared (first use in this function); did you mean 'I2C3_BASE'?
../STM32Cube/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2s_ex.c:885:49: error: 'SPI_CR2_RXDMAEN' undeclared (first use in this function); did you mean 'SPI_CFG1_RXDMAEN'?
../STM32Cube/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2s_ex.c:913:40: error: 'SPI_CR2_TXDMAEN' undeclared (first use in this function); did you mean 'SPI_CFG1_TXDMAEN'?
../STM32Cube/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2s_ex.c:947:35: error: 'SPI_CR2_RXDMAEN' undeclared (first use in this function); did you mean 'SPI_CFG1_RXDMAEN'?
../STM32Cube/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2s_ex.c:947:53: error: 'SPI_CR2_TXDMAEN' undeclared (first use in this function); did you mean 'SPI_CFG1_TXDMAEN'?
../STM32Cube/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_i2s_ex.h:46:74: error: 'I2S2ext_BASE' undeclared (first use in this function); did you mean 'I2C2_BASE'?
../STM32Cube/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_i2s_ex.h:46:105: error: 'I2S3ext_BASE' undeclared (first use in this function); did you mean 'I2C3_BASE'?
../STM32Cube/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2s_ex.c:973:19: error: 'SPI_TypeDef' {aka 'struct <anonymous>'} has no member named 'DR'; did you mean 'SR'?
../STM32Cube/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_i2s_ex.h:46:74: error: 'I2S2ext_BASE' undeclared (first use in this function); did you mean 'I2C2_BASE'?
../STM32Cube/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_i2s_ex.h:46:105: error: 'I2S3ext_BASE' undeclared (first use in this function); did you mean 'I2C3_BASE'?
../STM32Cube/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2s_ex.c:1031:43: error: 'SPI_TypeDef' {aka 'struct <anonymous>'} has no member named 'DR'; did you mean 'SR'?
../STM32Cube/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_i2s_ex.h:46:74: error: 'I2S2ext_BASE' undeclared (first use in this function); did you mean 'I2C2_BASE'?
../STM32Cube/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_i2s_ex.h:46:105: error: 'I2S3ext_BASE' undeclared (first use in this function); did you mean 'I2C3_BASE'?
../STM32Cube/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_i2s_ex.h:46:74: error: 'I2S2ext_BASE' undeclared (first use in this function); did you mean 'I2C2_BASE'?
../STM32Cube/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_i2s_ex.h:46:105: error: 'I2S3ext_BASE' undeclared (first use in this function); did you mean 'I2C3_BASE'?

Here is a simplified list of the errors after removing duplicates and paths:

'HAL_I2S_STATE_BUSY_TX_RX' undeclared
'SPI_TypeDef' has no member named 'DR'
'I2S2ext_BASE' undeclared
'I2S3ext_BASE' undeclared
'SPI_I2SCFGR_I2SE' undeclared
'SPI_CR2_RXDMAEN' undeclared
'SPI_CR2_TXDMAEN' undeclared

Here are the results of running relevant rgreps in the repository's root:

rgrep HAL_I2S_STATE_BUSY_TX_RX
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2s_ex.c:  hi2s->State = HAL_I2S_STATE_BUSY_TX_RX;
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2s_ex.c:  hi2s->State     = HAL_I2S_STATE_BUSY_TX_RX;
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2s_ex.c:  hi2s->State     = HAL_I2S_STATE_BUSY_TX_RX;


rgrep I2S2ext_BASE
Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_i2s_ex.h:#define I2SxEXT(__INSTANCE__) ((__INSTANCE__) == (SPI2)? (SPI_TypeDef *)(I2S2ext_BASE): (SPI_TypeDef *)(I2S3ext_BASE))


rgrep I2S3ext_BASE
Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_i2s_ex.h:#define I2SxEXT(__INSTANCE__) ((__INSTANCE__) == (SPI2)? (SPI_TypeDef *)(I2S2ext_BASE): (SPI_TypeDef *)(I2S3ext_BASE))


rgrep SPI_I2SCFGR_I2SE
Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_i2s_ex.h:#define __HAL_I2SEXT_ENABLE(__HANDLE__) (I2SxEXT((__HANDLE__)->Instance)->I2SCFGR |= SPI_I2SCFGR_I2SE)
Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_i2s_ex.h:#define __HAL_I2SEXT_DISABLE(__HANDLE__) (I2SxEXT((__HANDLE__)->Instance)->I2SCFGR &= ~SPI_I2SCFGR_I2SE)
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2s_ex.c:    if ((hi2s->Instance->I2SCFGR & SPI_I2SCFGR_I2SE) != SPI_I2SCFGR_I2SE)
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2s_ex.c:    if ((hi2s->Instance->I2SCFGR & SPI_I2SCFGR_I2SE) != SPI_I2SCFGR_I2SE)


rgrep SPI_CR2_RXDMAEN
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2s_ex.c:    SET_BIT(I2SxEXT(hi2s->Instance)->CR2, SPI_CR2_RXDMAEN);
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2s_ex.c:    SET_BIT(hi2s->Instance->CR2, SPI_CR2_RXDMAEN);
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2s_ex.c:        CLEAR_BIT(I2SxEXT(hi2s->Instance)->CR2, SPI_CR2_RXDMAEN);
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2s_ex.c:        CLEAR_BIT(hi2s->Instance->CR2, SPI_CR2_RXDMAEN);
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2s_ex.c:  CLEAR_BIT(hi2s->Instance->CR2, (SPI_CR2_RXDMAEN | SPI_CR2_TXDMAEN));
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2s_ex.c:  CLEAR_BIT(I2SxEXT(hi2s->Instance)->CR2, (SPI_CR2_RXDMAEN | SPI_CR2_TXDMAEN));


rgrep SPI_CR2_TXDMAEN
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2s_ex.c:    SET_BIT(hi2s->Instance->CR2, SPI_CR2_TXDMAEN);
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2s_ex.c:    SET_BIT(I2SxEXT(hi2s->Instance)->CR2, SPI_CR2_TXDMAEN);
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2s_ex.c:        CLEAR_BIT(hi2s->Instance->CR2, SPI_CR2_TXDMAEN);
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2s_ex.c:        CLEAR_BIT(I2SxEXT(hi2s->Instance)->CR2, SPI_CR2_TXDMAEN);
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2s_ex.c:  CLEAR_BIT(hi2s->Instance->CR2, (SPI_CR2_RXDMAEN | SPI_CR2_TXDMAEN));
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2s_ex.c:  CLEAR_BIT(I2SxEXT(hi2s->Instance)->CR2, (SPI_CR2_RXDMAEN | SPI_CR2_TXDMAEN));

As you can see there are indeed no definitions of these identifiers.
There is also the issue of 'SPI_TypeDef' has no member named 'DR'. I assume this is a leftover
from some other driver version. There is no such member in the SPI_TypeDef structure.
We are working with the STM32H743 line so the relevant header is Drivers/CMSIS/Device/ST/STM32H7xx/Include/stm32h743xx.h.

Bug in USB implementation

Hello.
I have found a bug in USB implementation in STM32CubeH7 (1.4.0 - 1.6.0). Steps to reproduce:

  1. Open the project from STM32H743I-EVAL\Applications\USB_Device\MSC_Standalone\MDK-ARM directory
  2. Apply HEAP fix from #16
  3. Build the project and download it to STM32H743I-EVAL board
  4. Wait for STM driver letter to appear
  5. Copy a file with approx size 20MB to STM drive
  6. Start copying above file from STM drive
  7. In the middle of copying unplug the USB cable
  8. Plug USB cable back
  9. From this time USB is not recognized by the operating system anymore
    obrazek

The issue is not present in STM32CubeH7 1.3.2

The HAL_NOR_ProgramBuffer() has a few defects

Describe the set-up
Hardware: Proprietary hardware containing STM32H743 and external FLASH and external SDRAM.
IDE: VisualGDB with GCC 9.2.1

Describe the bug

  1. The calculation for p_endaddress is incorrect. It adds uwBufferSize to uwAddress to create the pointer, but uwBufferSize is the word count, not the byte count. Therefore uwBufferSize should be multiplied by 2 to give the byte count. Alternatively, uwAddress could be turned into a word pointer prior to adding uwBufferSize to it.
  2. The local variables p_currentaddress and lastloadedaddress are used incorrectly in some parts of the code. The variables contain the internal address of the FLASH, but they are sometimes used as if they are offsets from the device location. When they are used as pointers to the FLASH they should have the FLASH device address added to them beforehand.

How To Reproduce

  1. Indicate the global behavior of your application project
    The bootloader is writing an application to external FLASH.

  2. The modules that you suspect to be the cause of the problem (Driver, BSP, MW ...)
    The HAL_NOR_ProgramBuffer() function in the file stm32h7xx_hal_nor.c

  3. The use case that generates the problem
    Write a buffer to the external NOR FLASH.

  4. How we can reproduce the problem
    Call it.

Additional context
The whole function needs to be cleaned up. I would replace p_endaddress with a count down counter. However, if you are just interested in fixing it:

The code:

p_endaddress      = (const uint16_t *)(uwAddress + (uwBufferSize - 1U));

Should be changed to:

p_endaddress      = (const uint16_t *)(uwAddress + (2 * (uwBufferSize - 1U)));

or alternatively

p_endaddress      = ((const uint16_t *)uwAddress) + (uwBufferSize - 1U);

Later in the function, the code:

while (p_currentaddress <= p_endaddress)
{
  /* Store last loaded address & data value (for polling) */
  lastloadedaddress = (uint32_t)p_currentaddress;

  NOR_WRITE(p_currentaddress, *data);

  data++;
  p_currentaddress ++;
}

NOR_WRITE((uint32_t)(lastloadedaddress), NOR_CMD_DATA_BUFFER_AND_PROG_CONFIRM);

Should be changed to:

while (p_currentaddress <= p_endaddress)
{
  /* Store last loaded address & data value (for polling) */
  lastloadedaddress = (uint32_t)p_currentaddress;

  NOR_WRITE(deviceaddress + (uint32_t)p_currentaddress, *data);

  data++;
  p_currentaddress ++;
}

  NOR_WRITE((uint32_t)(deviceaddress + lastloadedaddress), NOR_CMD_DATA_BUFFER_AND_PROG_CONFIRM);

Screenshots
None

Stalling at the DataOutStage in usbd_core.c leads to enumeration issues under Windows 10/7

Hi,

enumeration fails for a lot of users because of stalling of the endpoint during the usb configuration stage. The issue seems to occure with pretty much every STM32, I can confirm it for the STM32L4, STM32H7 and STM32F7 series. The effects can easily be seen by using a USB protocol analyzer like USBTrace. A quick fix is to remove the line USBD_LL_StallEP(pdev, 0U); completely which does not interfere with the USB functionality in any way. The folowing thread describes the bug in more detail where I also recently posted the solution: https://community.st.com/s/question/0D50X00009XkiIASAZ/stm32f405rg-vcp-error-this-device-cannot-startcode-10

Kind regards

fstap

Unable to import CDC Device Examples for CubeH7.

Step 1 - Install STM32 Cube IDE

Step 2 - Install (this package) for the STM32H7, installed via the IDE - it downloads the software package.

Step 3 - Attempt to install ANY USB Device Project, there are two, named "CDC_Standalone" -

SELECT: Import STM32 Cube Example

Under MCU, select STM32H7
Under Board, select Evaluation board
Under middleware, select: USB_Device

Select project name: CDC_Standalone,
Location states: Projects/STM32H743I-EVAL/Applications/USB_Device/CDC_Standalone
Description states: This application is part of the USB Device Library Package

Step 4: Click NEXT... project imports...

EXPECTED RESULT: Source code would speak about "USB Device"

ACTUAL RESULT: The HOST application is imported.

Step 5: Examine the project, you find that you have the HOST version instead.

NOTE: I do not think it matters, but I am running this on a MAC using the MAC version of tools.

HAL_RTC_Init() looses time

Describe the set-up
I'm using a STM32H743 on a custom board with 32768 Hz LSE crystal and battery-backed up RTC.

Describe the bug
Every time HAL_RTC_Init() is called, the RTC looses some sub-seconds.

HAL_RTC_Init should check if the RTC is already initializied (year != 0) and/or matches the desired configuration, and skip unnecessary stopping of the clock. According to the data sheet 45.3.8, the library should also check the INITS flag in the RTC_ISR register.

This is big a problem, because CubeMX5 will emit code that calls HAL_RTC_Init on each reset, without checking if it's already initialized. On each reset, you will loose up to 1s.

How To Reproduce

  1. Read time with HAL_RTC_GetTime &HAL_RTC_GetDate and print to console
  2. Call HAL_RTC_Init
  3. Repeat

While doing this, the clock will gradually loose seconds.

Wrong timer identifiers on some HRTIM functions doc

The HRTIM header contains the following definitions as timer identifiers

/** @defgroup HRTIM_Timer_identifier HRTIM Timer identifier
  * @{
  * @brief Constants defining timer identifiers
  */
#define HRTIM_TIMERID_MASTER  (HRTIM_MCR_MCEN)   /*!< Master identifier  */
#define HRTIM_TIMERID_TIMER_A (HRTIM_MCR_TACEN)  /*!< Timer A identifier */
#define HRTIM_TIMERID_TIMER_B (HRTIM_MCR_TBCEN)  /*!< Timer B identifier */
#define HRTIM_TIMERID_TIMER_C (HRTIM_MCR_TCCEN)  /*!< Timer C identifier */
#define HRTIM_TIMERID_TIMER_D (HRTIM_MCR_TDCEN)  /*!< Timer D identifier */
#define HRTIM_TIMERID_TIMER_E (HRTIM_MCR_TECEN)  /*!< Timer E identifier */

Some HRTIM functions (e.g. HAL_HRTIM_WaveformCountStop) incorrectly have those definitions documented as

  * @param  Timers Timer counter(s) to stop
  *                   This parameter can be any combination of the following values:
  *                   @arg HRTIM_TIMERID_MASTER
  *                   @arg HRTIM_TIMERID_A
  *                   @arg HRTIM_TIMERID_B
  *                   @arg HRTIM_TIMERID_C
  *                   @arg HRTIM_TIMERID_D
  *                   @arg HRTIM_TIMERID_E

As far as I can tell those don't exist, not even as legacy definitions.

bug in HAL_ETH_GetRxDataBuffer function

verision๏ผš1.8.0
file ๏ผšstm32h7xx_hal_eth.c
function๏ผšHAL_ETH_GetRxDataBuffer
line ๏ผš1257

  /* get total length until this descriptor */
    accumulatedlen = READ_BIT(dmarxdesc->DESC3, ETH_DMARXNDESCWBF_PL);

I think the code maybe lost a + before the = ,the correct code should like this

 /* get total length until this descriptor */
   accumulatedlen += READ_BIT(dmarxdesc->DESC3, ETH_DMARXNDESCWBF_PL);

SDMMC: Hard-coded clock dividers only work for 200MHz MMCCLK

For MMC and SD-Card operation, the clock dividers are hard-coded and work for 200 MHz sdmmc_clk only:

/* SDMMC Initialization Frequency (400KHz max) for Peripheral CLK 200MHz*/
#define SDMMC_INIT_CLK_DIV ((uint8_t)0xFA)
/* SDMMC Default Speed Frequency (25Mhz max) for Peripheral CLK 200MHz*/
#define SDMMC_NSpeed_CLK_DIV ((uint8_t)0x4)
/* SDMMC High Speed Frequency (50Mhz max) for Peripheral CLK 200MHz*/
#define SDMMC_HSpeed_CLK_DIV ((uint8_t)0x2)

CubeMX5 allows to configure the SDMMC peripheral with up to 480 MHz, so the clocks will be much to fast (e.g. 960 kHz during init instead of 400 kHz).

-> The dividers should be re-calculated according to the peripheral clock in stm32h7xx_hal_sd.c and stm32h7xx_hal_mmc.c.

(stm32h7xx_hal_sd.c already uses HAL_RCCEx_GetPeriphCLKFreq(RCC_PERIPHCLK_SDMMC) to calculate some delays. This must also be done for the divisors).

HRTIM_TIM_TypeDef is undefined

Describe the set-up

  • arm-none-eabi-gcc
  • #include <stm32h7xx.h>

Describe the bug

HRTIM_TIM_TypeDef is undefined. After cross referencing this with the RM you probably meant to use HRTIM_Timerx_TypeDef.

How To Reproduce

Trying to access HRTIM1_TIMA in any code will fail, since HRTIM_TIM_TypeDef is undefined:

#include <stm32h7xx.h>
HRTIM1_TIMA->TIMxCR = 0;

Additional context

-#define HRTIM1_TIMA         ((HRTIM_TIM_TypeDef *) HRTIM1_TIMA_BASE)
-#define HRTIM1_TIMB         ((HRTIM_TIM_TypeDef *) HRTIM1_TIMB_BASE)
-#define HRTIM1_TIMC         ((HRTIM_TIM_TypeDef *) HRTIM1_TIMC_BASE)
-#define HRTIM1_TIMD         ((HRTIM_TIM_TypeDef *) HRTIM1_TIMD_BASE)
-#define HRTIM1_TIME         ((HRTIM_TIM_TypeDef *) HRTIM1_TIME_BASE)
+#define HRTIM1_TIMA         ((HRTIM_Timerx_TypeDef *) HRTIM1_TIMA_BASE)
+#define HRTIM1_TIMB         ((HRTIM_Timerx_TypeDef *) HRTIM1_TIMB_BASE)
+#define HRTIM1_TIMC         ((HRTIM_Timerx_TypeDef *) HRTIM1_TIMC_BASE)
+#define HRTIM1_TIMD         ((HRTIM_Timerx_TypeDef *) HRTIM1_TIMD_BASE)
+#define HRTIM1_TIME         ((HRTIM_Timerx_TypeDef *) HRTIM1_TIME_BASE)

Complete patch

USB MSC Stack: Can't enumerate when disk is not ready

Describe the set-up

  • The board: STM32H747I-EVAL
  • IDE: Iar 8.30

Describe the bug

  • Windows can't enumerate device when SD card is not ready

How To Reproduce

  • Suspected modules: USB Device Stack, MSC class
  • The use case that generates the problem: SD Card is not inserted
  • How we can reproduce the problem:
    • Remove sd card from sd slot
    • Run STM32Cube_FW_H7_V1.5.0\Projects\STM32H747I-EVAL\Applications\USB_Device\MSC_Standalone\EWARM\USBD_MSC.eww
    • Plug USB to Windows PC

Additional context

  • The returning value in int8_t SCSI_ProcessCmd(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *cmd) is not handled
  • Ref #11 for the fix.

will we add cmsis driver support like cmsis uart?

Caution
The Issues are strictly limited for the reporting of problem encountered with the software provided in this project.
For any other problem related to the STM32 product, the performance, the hardware characteristics and boards, the tools the environment in general, please post a topic in the ST Community/STM32 MCUs forum

Describe the set-up

  • The board (either ST RPN reference or your custom board)
  • IDE or at least the compiler and its version
    Cube IDE
    Additional context
    If you have a first analysis or a patch proposal, thank you to share your proposal.

Screenshots
If applicable, add screenshots to help explain your problem.

register storage class specifier is incompatible with C++17

Hi!

The register storage class specifier was deprecated in C++11 and removed in C++17.

There are a few register keywords in some inline functions in stm32h7xx_ll_adc.h:

register uint32_t data_reg_addr;

So, if I include the stm32h7xx_ll_adc.h header file from C++, gcc will complain:

Libraries/STM32Cube_FW_H7_V1.5.0/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_adc.h: In function 'uint32_t LL_ADC_DMA_GetRegAddr(ADC_TypeDef*, uint32_t)':                                                                                                                                                                                                                                 
Libraries/STM32Cube_FW_H7_V1.5.0/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_adc.h:2264:21: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]                                                                                                                                                                                                             
 2264 |   register uint32_t data_reg_addr;                                                                                                                                                                                                                                                                                                                                                  
      |                     ^~~~~~~~~~~~~                                                                                                                                                                                                                                                                                                                                                   
Libraries/STM32Cube_FW_H7_V1.5.0/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_adc.h: In function 'void LL_ADC_SetCalibrationLinearFactor(ADC_TypeDef*, uint32_t, uint32_t)':                                                                                                                                                                                                               
Libraries/STM32Cube_FW_H7_V1.5.0/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_adc.h:2517:21: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]                                                                                                                                                                                                             
 2517 |   register uint32_t timeout_cpu_cycles = ADC_LINEARITY_BIT_TOGGLE_TIMEOUT;                                                                                                                                                                                                                                                                                                          
      |                     ^~~~~~~~~~~~~~~~~~                                                                                                                                                                                                                                                                                                                                              
Libraries/STM32Cube_FW_H7_V1.5.0/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_adc.h: In function 'uint32_t LL_ADC_GetCalibrationLinearFactor(ADC_TypeDef*, uint32_t)':                                                                                                                                                                                                                     
Libraries/STM32Cube_FW_H7_V1.5.0/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_adc.h:2544:21: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]                                                                                                                                                                                                             
 2544 |   register uint32_t timeout_cpu_cycles = ADC_LINEARITY_BIT_TOGGLE_TIMEOUT;                                                                                                                                                                                                                                                                                                          
      |                     ^~~~~~~~~~~~~~~~~~                                                                                                                                                                                                                                                                                                                                              
Libraries/STM32Cube_FW_H7_V1.5.0/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_adc.h: In function 'void LL_ADC_SetOffset(ADC_TypeDef*, uint32_t, uint32_t, uint32_t)':                                                                                                                                                                                                                      
Libraries/STM32Cube_FW_H7_V1.5.0/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_adc.h:2797:27: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]                                                                                                                                                                                                             
 2797 |   register __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->OFR1, Offsety);                                                                                                                                                                                                                                                                                                         
      |                           ^~~~                                                                                                                                                                                                                                                                                                                                                      
Libraries/STM32Cube_FW_H7_V1.5.0/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_adc.h: In function 'uint32_t LL_ADC_GetOffsetChannel(ADC_TypeDef*, uint32_t)':                                                                                                                                                                                                                               
Libraries/STM32Cube_FW_H7_V1.5.0/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_adc.h:2869:33: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]                                                                                                                                                                                                             
 2869 |   register const __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->OFR1, Offsety);                                                                                                                                                                                                                                                                                                   
      |                                 ^~~~
Libraries/STM32Cube_FW_H7_V1.5.0/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_adc.h: In function 'uint32_t LL_ADC_GetOffsetLevel(ADC_TypeDef*, uint32_t)':
Libraries/STM32Cube_FW_H7_V1.5.0/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_adc.h:2895:33: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
 2895 |   register const __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->OFR1, Offsety);
      |                                 ^~~~
Libraries/STM32Cube_FW_H7_V1.5.0/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_adc.h: In function 'void LL_ADC_SetOffsetSignedSaturation(ADC_TypeDef*, uint32_t, uint32_t)':
Libraries/STM32Cube_FW_H7_V1.5.0/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_adc.h:2960:28: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
 2960 |    register __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->OFR1, Offsety);
      |                            ^~~~
Libraries/STM32Cube_FW_H7_V1.5.0/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_adc.h: In function 'uint32_t LL_ADC_GetOffsetSignedSaturation(ADC_TypeDef*, uint32_t)':
Libraries/STM32Cube_FW_H7_V1.5.0/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_adc.h:2983:33: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
 2983 |   register const __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->OFR1, Offsety);
      |                                 ^~~~
Libraries/STM32Cube_FW_H7_V1.5.0/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_adc.h: In function 'uint32_t LL_ADC_REG_GetTriggerSource(ADC_TypeDef*)':
Libraries/STM32Cube_FW_H7_V1.5.0/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_adc.h:3085:26: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
 3085 |   register __IO uint32_t TriggerSource = READ_BIT(ADCx->CFGR, ADC_CFGR_EXTSEL | ADC_CFGR_EXTEN);
      |                          ^~~~~~~~~~~~~
Libraries/STM32Cube_FW_H7_V1.5.0/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_adc.h:3089:21: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
 3089 |   register uint32_t ShiftExten = ((TriggerSource & ADC_CFGR_EXTEN) >> (ADC_REG_TRIG_EXTEN_BITOFFSET_POS - 2UL));
      |                     ^~~~~~~~~~
Libraries/STM32Cube_FW_H7_V1.5.0/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_adc.h: In function 'void LL_ADC_REG_SetSequencerRanks(ADC_TypeDef*, uint32_t, uint32_t)':
Libraries/STM32Cube_FW_H7_V1.5.0/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_adc.h:3411:27: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
 3411 |   register __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->SQR1, ((Rank & ADC_REG_SQRX_REGOFFSET_MASK) >> ADC_SQRX_REGOFFSET_POS));
      |                           ^~~~
Libraries/STM32Cube_FW_H7_V1.5.0/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_adc.h: In function 'uint32_t LL_ADC_REG_GetSequencerRanks(ADC_TypeDef*, uint32_t)':
Libraries/STM32Cube_FW_H7_V1.5.0/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_adc.h:3509:33: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
 3509 |   register const __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->SQR1, ((Rank & ADC_REG_SQRX_REGOFFSET_MASK) >> ADC_SQRX_REGOFFSET_POS));
      |                                 ^~~~
Libraries/STM32Cube_FW_H7_V1.5.0/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_adc.h: In function 'uint32_t LL_ADC_INJ_GetTriggerSource(ADC_TypeDef*)':
Libraries/STM32Cube_FW_H7_V1.5.0/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_adc.h:3733:26: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
 3733 |   register __IO uint32_t TriggerSource = READ_BIT(ADCx->JSQR, ADC_JSQR_JEXTSEL | ADC_JSQR_JEXTEN);
      |                          ^~~~~~~~~~~~~
Libraries/STM32Cube_FW_H7_V1.5.0/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_adc.h:3737:21: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
 3737 |   register uint32_t ShiftJexten = ((TriggerSource & ADC_JSQR_JEXTEN) >> (ADC_INJ_TRIG_EXTEN_BITOFFSET_POS - 2UL));
      |                     ^~~~~~~~~~~
Libraries/STM32Cube_FW_H7_V1.5.0/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_adc.h: In function 'void LL_ADC_INJ_ConfigQueueContext(ADC_TypeDef*, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t)':
Libraries/STM32Cube_FW_H7_V1.5.0/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_adc.h:4337:21: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
 4337 |   register uint32_t is_trigger_not_sw = (uint32_t)((TriggerSource != LL_ADC_INJ_TRIG_SOFTWARE) ? 1UL : 0UL);
      |                     ^~~~~~~~~~~~~~~~~
Libraries/STM32Cube_FW_H7_V1.5.0/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_adc.h: In function 'void LL_ADC_SetChannelSamplingTime(ADC_TypeDef*, uint32_t, uint32_t)':
Libraries/STM32Cube_FW_H7_V1.5.0/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_adc.h:4458:27: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
 4458 |   register __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->SMPR1, ((Channel & ADC_CHANNEL_SMPRX_REGOFFSET_MASK) >> ADC_SMPRX_REGOFFSET_POS));
      |                           ^~~~
Libraries/STM32Cube_FW_H7_V1.5.0/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_adc.h: In function 'uint32_t LL_ADC_GetChannelSamplingTime(ADC_TypeDef*, uint32_t)':
Libraries/STM32Cube_FW_H7_V1.5.0/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_adc.h:4539:33: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
 4539 |   register const __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->SMPR1, ((Channel & ADC_CHANNEL_SMPRX_REGOFFSET_MASK) >> ADC_SMPRX_REGOFFSET_POS));
      |                                 ^~~~
Libraries/STM32Cube_FW_H7_V1.5.0/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_adc.h: In function 'void LL_ADC_SetAnalogWDMonitChannels(ADC_TypeDef*, uint32_t, uint32_t)':
Libraries/STM32Cube_FW_H7_V1.5.0/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_adc.h:4801:27: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
 4801 |   register __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->CFGR, ((AWDy & ADC_AWD_CRX_REGOFFSET_MASK) >> ADC_AWD_CRX_REGOFFSET_POS)
      |                           ^~~~
Libraries/STM32Cube_FW_H7_V1.5.0/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_adc.h: In function 'uint32_t LL_ADC_GetAnalogWDMonitChannels(ADC_TypeDef*, uint32_t)':
Libraries/STM32Cube_FW_H7_V1.5.0/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_adc.h:4936:33: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
 4936 |   register const __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->CFGR, ((AWDy & ADC_AWD_CRX_REGOFFSET_MASK) >> ADC_AWD_CRX_REGOFFSET_POS)
      |                                 ^~~~
Libraries/STM32Cube_FW_H7_V1.5.0/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_adc.h:4939:21: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
 4939 |   register uint32_t AnalogWDMonitChannels = (READ_BIT(*preg, AWDy) & AWDy & ADC_AWD_CR_ALL_CHANNEL_MASK);
      |                     ^~~~~~~~~~~~~~~~~~~~~
Libraries/STM32Cube_FW_H7_V1.5.0/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_adc.h: In function 'void LL_ADC_SetAnalogWDThresholds(ADC_TypeDef*, uint32_t, uint32_t, uint32_t)':
Libraries/STM32Cube_FW_H7_V1.5.0/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_adc.h:5051:27: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
 5051 |   register __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->LTR1, (((AWDy & ADC_AWD_TRX_REGOFFSET_MASK) >> ADC_AWD_TRX_REGOFFSET_POS) * 2UL)
      |                           ^~~~
Libraries/STM32Cube_FW_H7_V1.5.0/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_adc.h: In function 'uint32_t LL_ADC_GetAnalogWDThresholds(ADC_TypeDef*, uint32_t, uint32_t)':
Libraries/STM32Cube_FW_H7_V1.5.0/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_adc.h:5083:33: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
 5083 |   register const __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->LTR1, (((AWDy & ADC_AWD_TRX_REGOFFSET_MASK) >> ADC_AWD_TRX_REGOFFSET_POS) * 2UL)
      |                                 ^~~~
Libraries/STM32Cube_FW_H7_V1.5.0/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_adc.h: In function 'uint32_t LL_ADC_INJ_ReadConversionData32(ADC_TypeDef*, uint32_t)':
Libraries/STM32Cube_FW_H7_V1.5.0/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_adc.h:6078:33: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
 6078 |   register const __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, ((Rank & ADC_INJ_JDRX_REGOFFSET_MASK) >> ADC_JDRX_REGOFFSET_POS));
      |                                 ^~~~
Libraries/STM32Cube_FW_H7_V1.5.0/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_adc.h: In function 'uint16_t LL_ADC_INJ_ReadConversionData16(ADC_TypeDef*, uint32_t)':
Libraries/STM32Cube_FW_H7_V1.5.0/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_adc.h:6105:33: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
 6105 |   register const __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, ((Rank & ADC_INJ_JDRX_REGOFFSET_MASK) >> ADC_JDRX_REGOFFSET_POS));
      |                                 ^~~~
Libraries/STM32Cube_FW_H7_V1.5.0/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_adc.h: In function 'uint16_t LL_ADC_INJ_ReadConversionData14(ADC_TypeDef*, uint32_t)':
Libraries/STM32Cube_FW_H7_V1.5.0/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_adc.h:6132:33: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
 6132 |   register const __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, ((Rank & ADC_INJ_JDRX_REGOFFSET_MASK) >> ADC_JDRX_REGOFFSET_POS));
      |                                 ^~~~
Libraries/STM32Cube_FW_H7_V1.5.0/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_adc.h: In function 'uint16_t LL_ADC_INJ_ReadConversionData12(ADC_TypeDef*, uint32_t)':
Libraries/STM32Cube_FW_H7_V1.5.0/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_adc.h:6159:33: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
 6159 |   register const __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, ((Rank & ADC_INJ_JDRX_REGOFFSET_MASK) >> ADC_JDRX_REGOFFSET_POS));
      |                                 ^~~~
Libraries/STM32Cube_FW_H7_V1.5.0/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_adc.h: In function 'uint16_t LL_ADC_INJ_ReadConversionData10(ADC_TypeDef*, uint32_t)':
Libraries/STM32Cube_FW_H7_V1.5.0/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_adc.h:6186:33: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
 6186 |   register const __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, ((Rank & ADC_INJ_JDRX_REGOFFSET_MASK) >> ADC_JDRX_REGOFFSET_POS));
      |                                 ^~~~
Libraries/STM32Cube_FW_H7_V1.5.0/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_adc.h: In function 'uint8_t LL_ADC_INJ_ReadConversionData8(ADC_TypeDef*, uint32_t)':
Libraries/STM32Cube_FW_H7_V1.5.0/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_adc.h:6213:33: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
 6213 |   register const __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, ((Rank & ADC_INJ_JDRX_REGOFFSET_MASK) >> ADC_JDRX_REGOFFSET_POS));

The same is possibly true for other header files, also in HAL code for other STM32 CPUs, for example here:

https://github.com/STMicroelectronics/STM32CubeF4/blob/master/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_adc.h#L1828

I think, the keyword should just be removed.

ExtMem_Boot: hardfault caused by unaligned memory access

Hello!

I'm playing with the STM32h7B3I-DK with the ExtMem_Boot and the LedToggling application.
I'm trying to load bootload the both DATA and CODE in the internal ram as follows:

#define DATA_AREA USE_INTERNAL_SRAM // //
#define CODE_AREA USE_INTERNAL_SRAM // USE_EXTERNAL_SDRAM //
#define BINARY_AREA USE_SPI_NOR // USE_SDMMC //

But after flashing both the boot and app binaries, the extboot application rise an hardfault caused by unaligned memory access when accesing the OSPI. While if I return in the original configuration with #define CODE_AREA USE_EXTERNAL_SDRAM, everythings goes fine.

I do not know if it is caused by and error in the bootloader app or in the linking of the LedToggling app, heres how I updated the ld file of the LedToggling:

MEMORY
{
  ITCMRAM    (xrw)    : ORIGIN = 0x00000000,   LENGTH = 64K
  RAM    (xrw)    : ORIGIN = 0x24000000,   LENGTH = 1000K
  ROM    (rx)    : ORIGIN = 0xD0000000,   LENGTH = 8192K
}

/* Sections */
SECTIONS
{
  /* The startup code into "ROM" Rom type memory */
  .isr_vector :
  {
    . = ALIGN(4);
    KEEP(*(.isr_vector)) /* Startup code */
    . = ALIGN(4);
  } >RAM /*ROM*/

  /* The program code and other data into "ROM" Rom type memory */
  .text :
  {
    . = ALIGN(4);
    *(.text)           /* .text sections (code) */
    *(.text*)          /* .text* sections (code) */
    *(.glue_7)         /* glue arm to thumb code */
    *(.glue_7t)        /* glue thumb to arm code */
    *(.eh_frame)

    KEEP (*(.init))
    KEEP (*(.fini))

    . = ALIGN(4);
    _etext = .;        /* define a global symbols at end of code */
  } >RAM /*ROM*/

  /* Constant data into "ROM" Rom type memory */
  .rodata :
  {
    . = ALIGN(4);
    *(.rodata)         /* .rodata sections (constants, strings, etc.) */
    *(.rodata*)        /* .rodata* sections (constants, strings, etc.) */
    . = ALIGN(4);
  } >RAM /*ROM*/

  .ARM.extab   : { 
    . = ALIGN(4);
    *(.ARM.extab* .gnu.linkonce.armextab.*)
    . = ALIGN(4);
  } >RAM /*ROM*/
  
  .ARM : {
    . = ALIGN(4);
    __exidx_start = .;
    *(.ARM.exidx*)
    __exidx_end = .;
    . = ALIGN(4);
  } >RAM /*ROM*/

  .preinit_array     :
  {
    . = ALIGN(4);
    PROVIDE_HIDDEN (__preinit_array_start = .);
    KEEP (*(.preinit_array*))
    PROVIDE_HIDDEN (__preinit_array_end = .);
    . = ALIGN(4);
  } >RAM /*ROM*/
  
  .init_array :
  {
    . = ALIGN(4);
    PROVIDE_HIDDEN (__init_array_start = .);
    KEEP (*(SORT(.init_array.*)))
    KEEP (*(.init_array*))
    PROVIDE_HIDDEN (__init_array_end = .);
    . = ALIGN(4);
  } >RAM /*ROM*/
  
  .fini_array :
  {
    . = ALIGN(4);
    PROVIDE_HIDDEN (__fini_array_start = .);
    KEEP (*(SORT(.fini_array.*)))
    KEEP (*(.fini_array*))
    PROVIDE_HIDDEN (__fini_array_end = .);
    . = ALIGN(4);
  } >RAM /*ROM*/

  /* Used by the startup to initialize data */
  _sidata = LOADADDR(.data);

  /* Initialized data sections into "RAM" Ram type memory */
  .data : 
  {
    . = ALIGN(4);
    _sdata = .;        /* create a global symbol at data start */
    *(.data)           /* .data sections */
    *(.data*)          /* .data* sections */

    . = ALIGN(4);
    _edata = .;        /* define a global symbol at data end */
    
  } >RAM /*AT> ROM*/

Can you help me?

Thx,
Paul

Missing include in eth.c

How to:

  • STM32CubeMX used to generate NUCLEO-H743ZI basic setup with Ethernet
  • Generate code for Makefile project using make clean all

Result:

  • Compiling the generated project will generate warnings concerning memset function

Solution:

  • Add <string.h> to the eth.c file

CubeMX: 0-pointer access in generated code if TIM6 is used for HAL tick and DAC is enabled

Hi!

I don't know where to report CubeMX bugs, so I leave it here. It might also be considered a HAL problem.

I noticed this behavior after enabling a MPU region to catch 0-pointer accesses.

If TIM6 is used as the HAL Timebase and the DAC is enabled, there may be a 0-Pointer access in HAL_DAC_IRQHandler (called by TIM6_DAC_IRQHandler), if a tick IRQ happens before MX_DAC1_Init() is called.

The same bug likely exists in all other HAL and CubeMX versions.

Simple workaround: Use another timer, that has a non-shared IRQ handler.

best regards,
Thomas

DSI/emWin crash on dual-core H7

Hello,

example affected:
/Projects/STM32H747I-DISCO/Applications/STemWin/STemWin_HelloWorld/CM7/STemWin/App/BASIC_HelloWorld.c

running on non-modified STM32H747I-DISCO board.

Without edit to this file, 'Hello world!' string is displayed on the screen, but there is very limited amount of time that the function can print to the LCD, after that i suspect a crash of the emWin or the DSI LCD driver.

So this code displays only one line:

void MainTask(void)
{
int i;

GUI_Clear();
GUI_SetFont(&GUI_Font32_1);
GUI_DispStringAt("Hello world!", (LCD_GetXSize()-100)/2, (LCD_GetYSize()-20)/2);

for(i = 0; i < 0x5FFFFF; i++)
__asm(".hword 0x46C0");

GUI_DispStringAt("Hello world!", (LCD_GetXSize()-100)/2, (LCD_GetYSize()-20)/2 + 40);

while(1)
{
}
}

decreasing the delay to 0x5FFFF allows for the second line to be printed. So anything printed before that timeout is reached will be displayed, but nothing after that. The four LEDs that get toggled by the timer will still blink.

I have similar issue with other example projects (the Menu Launcher, the STemWin Demonstration)
that use similar version of the same DSI driver.

My best guess would be:

  • some type of watchdog running by default ?
  • the M4 crashes maybe and indirectly affects the LCD print ?
  • some unknown emWin library crash (i have used it on various ST and NXP chips and never seen this issue before).

Thank you!
K.

USART fails to compile

Caution
The Issues are strictly limited for the reporting of problem encountered with the software provided in this project.
For any other problem related to the STM32 product, the performance, the hardware characteristics and boards, the tools the environment in general, please post a topic in the ST Community/STM32 MCUs forum

Describe the set-up

  • Custom board with STM32H743
  • STM32CubeIDE 1.3.0
  • STM32CubeMX 5.6.1

Describe the bug
Compiling stm32h7xx_hal_usart.c fails

How To Reproduce

  1. Indicate the global behavior of your application project
    Use USART1 as Synchronous master

  2. The modules that you suspect to be the cause of the problem (Driver, BSP, MW ...)
    USART1

  3. The use case that generates the problem
    Compiling

  4. How we can reproduce the problem
    STM32CubeMX 5.6.1

  • Start new project fot STM32H743VITx
  • From Connectivity, add USART1 as Synchronus master
  • In Project Manager, give name, select STM32CubeIDE
  • Firmware package is STM32Cube FW_H7 V1.7.0
  • Generate code
    STM32CubeIDE 1.3.0
  • Build project
    Gives:
    ../Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_usart.c: In function 'HAL_USART_IRQHandler':
    ../Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_usart.c:2153:7: warning: implicit declaration of function '__HAL_UART_CLEAR_FLAG'; did you mean '__HAL_USART_CLEAR_FLAG'? [-Wimplicit-function-declaration]
    __HAL_UART_CLEAR_FLAG(husart, UART_CLEAR_RTOF);
    ^~~~~~~~~~~~~~~~~~~~~
    __HAL_USART_CLEAR_FLAG
    ../Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_usart.c:2153:37: error: 'UART_CLEAR_RTOF' undeclared (first use in this function); did you mean 'USART_CLEAR_RTOF'?
    __HAL_UART_CLEAR_FLAG(husart, UART_CLEAR_RTOF);
    ^~~~~~~~~~~~~~~
    USART_CLEAR_RTOF

Additional context
Pull-request will follow, it seems to be just a typo.

Screenshots
None

enabling unwanted global interrupts

In file stm32h7xx_hal_lptim.c function void LPTIM_Disable(LPTIM_HandleTypeDef *hlptim) use __disable_irq() and __enable_irq() without checking PRIMASK state.

FreeRTOS cannot enable timer

Hi ST,

I try to enable freeRTOS timer by set the configUSE_TIMERS = 1 in the FreeRTOSConfig.h, but it can't work. The same method in STM32L031, it works normal.
Did I miss something?

I used project is STM32CubeH7/Projects/NUCLEO-H743ZI/Applications/FreeRTOS/FreeRTOS_SemaphoreFromISR/

Regards,
Wei

Regression in QSPI vs. v1.3.0

Hi!

Describe the set-up

We are using an STM32H743XIH6 (Rev. V) @ 480 MHz, on a custom board with a W25Q128JVEIQ flash in Quad-SPI mode. Our Toolchain is gcc-arm-none-eabi-9-2019-q4-major.

Describe the bug

We're using the HAL_QSPI_Transmit_DMA function.

When using CubeMX libraries v1.3.0, we could run QSPI with 120 MHz clock (Clock Prescaler 1).

After an upgrade to CubeMX libraries v1.5.0, we had to set the prescaler to 8, or even 16 to achieve stable operation, otherwise, HAL_QSPI_Transmit_DMA would fail.

We can send you the CubeMX file if required.

Additional context

I haven't looked into the bug in detail yet, but I could narrow it down to this single change:

v1.5.0, bad:

/* Enable the QSPI transfer error and complete Interrupts : Workaround for QSPI low kernel clock frequency */
__HAL_QSPI_ENABLE_IT(hqspi, QSPI_IT_TE |QSPI_IT_TC);

v1.3.0, good:

      __HAL_QSPI_ENABLE_IT(hqspi, QSPI_IT_TE);

After reverting the change, we can run with 120 MHz again.

What was the reason for the change in 1.5.0?
Perhaps you can already try to reproduce on an evaluation board.

Confusing configuration of ADC trigger at CubeMX (STM32H750)

At register level selecting ADC trigger event is done thru EXTSEL with many internal sources (timers) and one external (EXTI Line 11). Consistent approach is in LL API, where selecting trigger source by "LL_ADC_REG_SetTriggerSource" function or thru LL_ADC_REG_InitTypeDef TriggerSource. But in CubeMX is that configuration splited in two places with confusing labels.

menu1
menu2

If i want to select internal triggers i have to select literaly "Conversion trigger Disable" (realy confusing because by this option in reality i am enabling internal trigger source selections - or in other words i am disabling only one specific trigger source (EXTI)). In addition internal trigger sources are called "External Trigger Conversion Sources". I suppose that both these options should be merged into one configuration field to correspond with logic of reference manual...

version of CubeMX 5.6.1

FreeRTOS-MPU fails to run if its privileged RAM is in a cacheable memory region

The setup

  • Hardware: Nucleo-H743ZI2
  • IDE: IAR for Arm v8.32.1

The bug

FreeRTOS-MPU faults during initialization because of a cache coherency issue with pxCurrentTCB; allocated in the Privileged RAM region.

The SDK example only works because the Privileged RAM section is allocated in DTCM, a non-cacheable memory region.

To solve it, that memory region should be set as non-cacheable in the MPU. That way it can be allocated in cacheable memory regions.

In more technical detail:

  • FreeRTOS-MPU allocates pxCurrentTCB in the privileged RAM section.
  • During xPortStartScheduler, the privileged RAM section is allocated in the MPU as cacheable
  • As a result, if the DCache is enabled, pxCurrentTCB will be cached.
  • Cache coherency is lost during the initialization of the RTOS' scheduler, the assembly routine vPortRestoreContextOfFirstTask attempts to access a Reserved memory region, and results in a hard fault

How To Reproduce

  1. Grab the FreeRTOS-MPU sample application from the SDK
  2. Fix the FreeRTOS-MPU bug described in issue #38 so the MPU is enabled
  3. Update the linker script and main.c to allocate the Privileged Data section into AXI ram instead of DTCM
  4. If you're using different hardware than me, make sure the DCache is enabled and has access to the AXI SRAM region you set up in the previous step
  5. Try to run the application, and you should get a crash right away. Or perhaps some other serious misbehavior, depending on which incorrect values are loaded into your registers from vPortRestoreContextOfFirstTask

Additional context

For a minimum viable fix, a couple of things need to be updated in each FreeRTOS-MPU port affected by this bug:

  1. portmacro.h needs to support "normal, shareable, non-cacheable" configurations of MPU->RASR registers. That's TEX=001 S=1 B=0 C=0 according to the docs:
    #define portMPU_REGION_SHAREABLE_NON_CACHEABLE ( 0x0cUL << 16UL )
  2. Privileged RAM needs to be configured using that portMPU_REGION_SHAREABLE_NON_CACHEABLE instead of portMPU_REGION_CACHEABLE_BUFFERABLE.
    • In prvSetupMPU:
         portMPU_REGION_ATTRIBUTE_REG =  ( portMPU_REGION_PRIVILEGED_READ_WRITE ) |
    #if 0 /* Original code */
                                         ( portMPU_REGION_CACHEABLE_BUFFERABLE ) |
    #else /* fix */
                                         ( portMPU_REGION_SHAREABLE_NON_CACHEABLE ) |
    #endif
                                         prvGetMPURegionSizeSetting( ( uint32_t ) __privileged_data_end__ - ( uint32_t ) __privileged_data_start__ ) |
                                         ( portMPU_REGION_ENABLE );
    
    • In vPortStoreTaskMPUSettings:
        xMPUSettings->xRegion[ 1 ].ulRegionAttribute =
                ( portMPU_REGION_PRIVILEGED_READ_WRITE ) |
    #if 0 /* Original code */
                ( portMPU_REGION_CACHEABLE_BUFFERABLE ) |
    #else /* fix */
                ( portMPU_REGION_SHAREABLE_NON_CACHEABLE ) |
    #endif
                prvGetMPURegionSizeSetting( ( uint32_t ) __privileged_data_end__ - ( uint32_t ) __privileged_data_start__ ) |
                ( portMPU_REGION_ENABLE );
    

Alternatively, memory barriers could be used to ensure the coherency of pxCurrentTCB, but I was not successful in my attempts, and I'm not sure if other FreeRTOS variables would still be affected in more insidious ways.

More context

The fix described earlier got me past this problem, but I'm still running into other crashes shortly after. These may or may not have related causes; I'm still investigating.

If you uncover any other issues while fixing this one, a heads-up would be greatly appreciated.

Thanks,
JC

Version control management

Caution
Version had not been managed in the proper way.
Describe the set-up
Version 1.7.0 is not backward compatible with 1.5.0. So as per version control system, major number should be increased in that scenario. So while upgrading the version of Cube package, user will be able to know whether to update or not.

Additional context
Semantic version control can be introduced for release.

Screenshots
If applicable, add screenshots to help explain your problem.

CubeMX: 0-Pointer access in generated MX_ETH_Init code

Hi!

I don't know where to report CubeMX bugs, so I leave it here. It might also be considered a HAL problem.

I noticed this behavior after enabling a MPU region to catch 0-pointer accesses.

CubeMX 5.6.0 generates this code for Ethernet initialization:

static void MX_ETH_Init(void)
{
...
  heth.Instance = ETH;
  heth.Init.MACAddr[0] =   0x00;
  heth.Init.MACAddr[1] =   0x80;
  heth.Init.MACAddr[2] =   0xE1;
  heth.Init.MACAddr[3] =   0x00;
  heth.Init.MACAddr[4] =   0x00;
  heth.Init.MACAddr[5] =   0x00;
...
}

But heth.Init.MACAddr is defined as a uint8_t * here:

/**
* @brief ETH Init Structure definition
*/
typedef struct
{
uint8_t *MACAddr; /*!< MAC Address of used Hardware: must be pointer on an array of 6 bytes */
ETH_MediaInterfaceTypeDef MediaInterface; /*!< Selects the MII interface or the RMII interface. */
ETH_DMADescTypeDef *TxDesc; /*!< Provides the address of the first DMA Tx descriptor in the list */
ETH_DMADescTypeDef *RxDesc; /*!< Provides the address of the first DMA Rx descriptor in the list */
uint32_t RxBuffLen; /*!< Provides the length of Rx buffers size */
}ETH_InitTypeDef;

This causes a 0-Pointer access, when accessing MACAddr[0].

Work-Around:

Initialize heth.Init.MACAddr to point to an array.

static void MX_ETH_Init(void)
{

  /* USER CODE BEGIN ETH_Init 0 */

  // Workaround for 0-Pointer access in generated MX_ETH_Init code
  // https://github.com/STMicroelectronics/STM32CubeH7/issues/33
  //
  static uint8_t macaddr[6];
  heth.Init.MACAddr = macaddr;

  /* USER CODE END ETH_Init 0 */
...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.