cancel
Showing results for 
Search instead for 
Did you mean: 

Can STM32CubeMX add the BSP when generating code?

john doe
Lead
Posted on January 16, 2017 at 15:19

Is there a way to get STM32CubeMX to add the BSP when it generates code?

6 REPLIES 6
Imen.D
ST Employee
Posted on January 16, 2017 at 15:33

Hello

doe.john.016

,

BSP library is

not supported in the code generation

by CubeMx, it should be added manually by the user, to the project generated under project's workspace.

I forward your request to our CubeMx team for further investigation.

Regards

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
Jeanne Joly
Senior III
Posted on January 24, 2017 at 13:45

Hello

doe.john.016

,

As Imen already said, BSP is not supported in the CubeMX code generation.

However, a study is in progress to implement BSP in CubeMX in order to generate it automatically. This is the first step of the topic, it remains lot of things to do (development, integration, validation..) so it won't be implemented soon and I can't give you any delivery date for the moment.

BR. Eric

Posted on January 26, 2017 at 05:08

 ,

 ,

It was easy enough.

I copied the BSP directory from STM32Cube/Repository/STM32Cube_FW_F7_V1.6.0/Drivers/BSP/STM32F769I-Discovery/ into the Drivers/BSP directory of my project. Added that folder to the includes search path

Then I copied the Utilties folder from STM32Cube/Repository/STM32Cube_FW_F7_V1.6.0/Utilities/ into my project, and added it to the includes search path

I used STM32CubeMX to generate code with only the default settings except for the clocks, and what I wanted turned on, which was i2c, spi, uart, and a couple of timer/counters.

Clock settings:

 , RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE|RCC_OSCILLATORTYPE_LSE,

 ,

 , RCC_OscInitStruct.HSEState = RCC_HSE_ON,

 ,

 , RCC_OscInitStruct.LSEState = RCC_LSE_ON,

 ,

 , RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON,

 ,

 , RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE,

 ,

 , RCC_OscInitStruct.PLL.PLLM = 25,

 ,

 , RCC_OscInitStruct.PLL.PLLN = 432,

 ,

 , RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2,

 ,

 , RCC_OscInitStruct.PLL.PLLQ = 4,

If you're going to use the SDRAM, the documentation says don't go faster than 200mhz so change the PLL M from 432 to 400 and you will get 200mhz sysclock

Then I added ♯ include ''stm32f769i_discovery.h'' and tried to build. I let the linker tell me which HAL driver files were needed one by one. Added them to Drivers/STM32F7xx_HAL_Driver/Inc/

stm32f7xx_hal_cortex.h

 ,

stm32f7xx_hal_dcmi_ex.h

 ,

stm32f7xx_hal_dcmi.h

 ,

stm32f7xx_hal_def.h

 ,

stm32f7xx_hal_dfsdm.h

 ,

stm32f7xx_hal_dma_ex.h

 ,

stm32f7xx_hal_dma.h

 ,

stm32f7xx_hal_dma2d.h

 ,

stm32f7xx_hal_dsi.h

 ,

stm32f7xx_hal_flash_ex.h

 ,

stm32f7xx_hal_flash.h

 ,

stm32f7xx_hal_gpio_ex.h

 ,

stm32f7xx_hal_gpio.h

 ,

stm32f7xx_hal_i2c_ex.h

 ,

stm32f7xx_hal_i2c.h

 ,

stm32f7xx_hal_i2s.h

 ,

stm32f7xx_hal_lptim.h

 ,

stm32f7xx_hal_ltdc_ex.h

 ,

stm32f7xx_hal_ltdc.h

 ,

stm32f7xx_hal_mmc.h

 ,

stm32f7xx_hal_pwr_ex.h

 ,

stm32f7xx_hal_pwr.h

 ,

stm32f7xx_hal_qspi.h

 ,

stm32f7xx_hal_rcc_ex.h

 ,

stm32f7xx_hal_rcc.h

 ,

stm32f7xx_hal_sai_ex.h

 ,

stm32f7xx_hal_sai.h

 ,

stm32f7xx_hal_sd.h

 ,

stm32f7xx_hal_sdram.h

 ,

stm32f7xx_hal_spi.h

 ,

stm32f7xx_hal_sram.h

 ,

stm32f7xx_hal_tim_ex.h

 ,

stm32f7xx_hal_tim.h

 ,

stm32f7xx_hal_uart_ex.h

 ,

stm32f7xx_hal_uart.h

 ,

stm32f7xx_hal.h

 ,

stm32f7xx_ll_adc.h

 ,

stm32f7xx_ll_bus.h

 ,

stm32f7xx_ll_cortex.h

 ,

stm32f7xx_ll_crc.h

 ,

stm32f7xx_ll_dac.h

 ,

stm32f7xx_ll_dma.h

 ,

stm32f7xx_ll_dma2d.h

 ,

stm32f7xx_ll_exti.h

 ,

stm32f7xx_ll_fmc.h

 ,

stm32f7xx_ll_gpio.h

 ,

stm32f7xx_ll_i2c.h

 ,

stm32f7xx_ll_iwdg.h

 ,

stm32f7xx_ll_lptim.h

 ,

stm32f7xx_ll_pwr.h

 ,

stm32f7xx_ll_rcc.h

 ,

stm32f7xx_ll_rng.h

 ,

stm32f7xx_ll_rtc.h

 ,

stm32f7xx_ll_sdmmc.h

 ,

stm32f7xx_ll_spi.h

 ,

stm32f7xx_ll_system.h

 ,

stm32f7xx_ll_tim.h

 ,

stm32f7xx_ll_usart.h

 ,

stm32f7xx_ll_usb.h

 ,

stm32f7xx_ll_utils.h

 ,

stm32f7xx_ll_wwdg.h

I'm sure some got added that didn't need to be because I just did some basic pattern matching and was being lazy. don't forget to add the corresponding .c file to the Src folder. Don't just copy *.c because some template files will get copied raw and your build will probably fail.

The whole board support package, with being able to print to the screen, has these includes:

♯ include ''stm32f769i_discovery.h''

 ,

♯ include ''stm32f769i_discovery_sdram.h''

 ,

♯ include ''stm32f769i_discovery_lcd.h''

 ,

♯ include ''stm32f769i_discovery_qspi.h''

 ,

♯ include ''stm32f769i_discovery_ts.h''

 ,

♯ include ''stm32f769i_discovery_audio.h''

 ,

♯ include ''stm32f769i_discovery_sd.h''

 ,

♯ include ''stm32f769i_discovery_eeprom.h''

 ,

♯ include ''lcd_log.h''

Ok now that the includes and source files are in place, we have to turn the modules on. Keep a copy of this file because there's no place for USER CODE in it and the STM32CubeMX will clobber it if you generate new code.

from stm32f7xx_hal_conf.h:

/* ♯ ♯ ♯ ♯ ♯ ♯ ♯ ♯ ♯ ♯ ♯ ♯ ♯ ♯ ♯ ♯ ♯ ♯ ♯ ♯ ♯ ♯ ♯ ♯ ♯ ♯ Module Selection ♯ ♯ ♯ ♯ ♯ ♯ ♯ ♯ ♯ ♯ ♯ ♯ ♯ ♯ ♯ ♯ ♯ ♯ ♯ ♯ ♯ ♯ ♯ ♯ ♯ ♯ ♯ ♯ ♯ ♯ */

 ,

/**

 ,

 , * @brief This is the list of modules to be used in the HAL driver

 ,

 , */

 ,

♯ define HAL_MODULE_ENABLED  ,

 ,/* ♯ define HAL_ADC_MODULE_ENABLED , , */

 ,

 ,/* ♯ define HAL_CAN_MODULE_ENABLED , , */

 ,

 ,/* ♯ define HAL_CEC_MODULE_ENABLED , , */

 ,

 ,/* ♯ define HAL_CRC_MODULE_ENABLED , , */

 ,

 ,/* ♯ define HAL_CRYP_MODULE_ENABLED , , */

 ,

 ,/* ♯ define HAL_DAC_MODULE_ENABLED , , */

 ,

 , ♯ define HAL_DCMI_MODULE_ENABLED

 ,

 , ♯ define HAL_DMA2D_MODULE_ENABLED

 ,

 ,/* ♯ define HAL_ETH_MODULE_ENABLED , , */

 ,

 ,/* ♯ define HAL_NAND_MODULE_ENABLED , , */

 ,

 ,/* ♯ define HAL_NOR_MODULE_ENABLED , , */

 ,

 , ♯ define HAL_SRAM_MODULE_ENABLED

 ,

 , ♯ define HAL_SDRAM_MODULE_ENABLED

 ,

 ,/* ♯ define HAL_HASH_MODULE_ENABLED , , */

 ,

 , ♯ define HAL_I2S_MODULE_ENABLED

 ,

 ,/* ♯ define HAL_IWDG_MODULE_ENABLED , , */

 ,

 , ♯ define HAL_LPTIM_MODULE_ENABLED

 ,

 , ♯ define HAL_LTDC_MODULE_ENABLED

 ,

 , ♯ define HAL_QSPI_MODULE_ENABLED

 ,

 ,/* ♯ define HAL_RNG_MODULE_ENABLED , , */

 ,

 ,/* ♯ define HAL_RTC_MODULE_ENABLED , , */

 ,

 , ♯ define HAL_SAI_MODULE_ENABLED

 ,

 , ♯ define HAL_SD_MODULE_ENABLED

 ,

 , ♯ define HAL_MMC_MODULE_ENABLED

 ,

 ,/* ♯ define HAL_SPDIFRX_MODULE_ENABLED , , */

 ,

 , ♯ define HAL_SPI_MODULE_ENABLED

 ,

 , ♯ define HAL_TIM_MODULE_ENABLED

 ,

 , ♯ define HAL_UART_MODULE_ENABLED

 ,

 ,/* ♯ define HAL_USART_MODULE_ENABLED , , */

 ,

 ,/* ♯ define HAL_IRDA_MODULE_ENABLED , , */

 ,

 ,/* ♯ define HAL_SMARTCARD_MODULE_ENABLED , , */

 ,

 ,/* ♯ define HAL_WWDG_MODULE_ENABLED , , */

 ,

 ,/* ♯ define HAL_PCD_MODULE_ENABLED , , */

 ,

 ,/* ♯ define HAL_HCD_MODULE_ENABLED , , */

 ,

 , ♯ define HAL_DFSDM_MODULE_ENABLED

 ,

 , ♯ define HAL_DSI_MODULE_ENABLED

 ,

 ,/* ♯ define HAL_JPEG_MODULE_ENABLED , , */

 ,

 ,/* ♯ define HAL_MDIOS_MODULE_ENABLED , , */

 ,

 ,/* ♯ define HAL_SMBUS_MODULE_ENABLED , , */

 ,

 , ♯ define HAL_MMC_MODULE_ENABLED

 ,

 , ♯ define HAL_GPIO_MODULE_ENABLED

 ,

 , ♯ define HAL_DMA_MODULE_ENABLED

 ,

 , ♯ define HAL_RCC_MODULE_ENABLED

 ,

 , ♯ define HAL_FLASH_MODULE_ENABLED

 ,

 , ♯ define HAL_PWR_MODULE_ENABLED

 ,

 , ♯ define HAL_I2C_MODULE_ENABLED

 ,

 , ♯ define HAL_CORTEX_MODULE_ENABLED

and that's how i got the BSP working on my STM32F769I-Discovery using SW4STM32.

0690X00000603ZmQAI.jpg
Posted on January 26, 2017 at 12:53

I think adding BSP means copying BSP directory to Drivers and updating include path in project (I'm using System Workbench, that's done in project's 'Properties'). The BSP directory should only contain relevant board, e.g. 'STM32746G-Discovery' directory.

Utilities is not needed, that's for sure not BSP, it contains e.g. audio files. Drivers/STM32F7xx_HAL_Driver/Inc/ should already contain relevant files, that directory is generated by CubeMX.

Posted on January 26, 2017 at 12:59

Utilities contains Log and Fonts

The CubeMX only populates the include and source directories by what is chosen. it does not install the entire hal library.

Posted on July 17, 2017 at 08:05

Found this really helpful! Appreciate it!