How to add files to an MX generated project
Hi folks,
I’m afraid my lack of experience with Eclipse and the framework has me stymied. This question actualy has two sides.
First I wanted to add a BSP file to support the LCD (on an STM32F429I-DISCO.) It was not obvious where it should go in what seems to be a pretty elaborate directory structure. When working in Java, my recollection is that new files just appeared and were compiled and linked into the executable. That didn’t seem to work here until I added it to:
Blink02MX/SW4STM32/Blink02MX Configuration/user
It’s not obvious to me that this is the “right” place to add a library file, but it gets compiled and linked.
The second issue is HAL library files. This BSP driver uses the DMA2D library. I can see the file in
Blink02MX/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma2d.c
but it is not included in
barta@yggdrasil ~/Documents/ecl-ws/Blink02MX $ cat './SW4STM32/Blink02MX Configuration/Debug/objects.list' ./user/stm32f429i_discovery_lcd.o ./user/syscalls.o ./Drivers/STM32F4xx_HAL_Driver/stm32f4xx_hal.o ./Drivers/STM32F4xx_HAL_Driver/stm32f4xx_hal_cortex.o ./Drivers/STM32F4xx_HAL_Driver/stm32f4xx_hal_dma.o ./Drivers/STM32F4xx_HAL_Driver/stm32f4xx_hal_dma_ex.o ./Drivers/STM32F4xx_HAL_Driver/stm32f4xx_hal_flash.o ./Drivers/STM32F4xx_HAL_Driver/stm32f4xx_hal_flash_ex.o ./Drivers/STM32F4xx_HAL_Driver/stm32f4xx_hal_flash_ramfunc.o ./Drivers/STM32F4xx_HAL_Driver/stm32f4xx_hal_gpio.o ./Drivers/STM32F4xx_HAL_Driver/stm32f4xx_hal_i2c.o ./Drivers/STM32F4xx_HAL_Driver/stm32f4xx_hal_i2c_ex.o ./Drivers/STM32F4xx_HAL_Driver/stm32f4xx_hal_ltdc.o ./Drivers/STM32F4xx_HAL_Driver/stm32f4xx_hal_pwr.o ./Drivers/STM32F4xx_HAL_Driver/stm32f4xx_hal_pwr_ex.o ./Drivers/STM32F4xx_HAL_Driver/stm32f4xx_hal_rcc.o ./Drivers/STM32F4xx_HAL_Driver/stm32f4xx_hal_rcc_ex.o ./Drivers/STM32F4xx_HAL_Driver/stm32f4xx_hal_sdram.o ./Drivers/STM32F4xx_HAL_Driver/stm32f4xx_hal_spi.o ./Drivers/STM32F4xx_HAL_Driver/stm32f4xx_ll_fmc.o ./Drivers/CMSIS/system_stm32f4xx.o ./Application/User/main.o ./Application/User/stm32f4xx_hal_msp.o ./Application/User/stm32f4xx_it.o ./Application/SW4STM32/startup_stm32f429xx.o hbarta@yggdrasil ~/Documents/ecl-ws/Blink02MX $
I suppose I could move the HAL files to the same location where I put the BSP file but I think there must be some place where it gets added to the list of other HAL library files that are compiled and linked. Where is that?
Thanks!
Edit: I keep digging. I found the .project file that seems to include all of the source files. I added stm32f4xx_hal_dma2d.c to the list. Now it compiles - there is a .o file. It is included in objects.list file so it should be included in the executable. The related unresolved references remain unresolved.
Maybe I should be asking how to resolve:
Invoking: MCU GCC Linker arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -mfloat-abi=soft -T"../STM32F429ZITx_FLASH.ld" -Wl,-Map=output.map -Wl,--gc-sections -o "Blink02MX Configuration.elf" @"objects.list" ./user/stm32f429i_discovery_lcd.o: In function `BSP_LCD_Init': /home/hbarta/Documents/ecl-ws/Blink02MX/SW4STM32/Blink02MX Configuration/Debug/../user/stm32f429i_discovery_lcd.c:229: undefined reference to `BSP_SDRAM_Init' /home/hbarta/Documents/ecl-ws/Blink02MX/SW4STM32/Blink02MX Configuration/Debug/../user/stm32f429i_discovery_lcd.c:235: undefined reference to `ili9341_drv' ./user/stm32f429i_discovery_lcd.o: In function `FillBuffer': /home/hbarta/Documents/ecl-ws/Blink02MX/SW4STM32/Blink02MX Configuration/Debug/../user/stm32f429i_discovery_lcd.c:1340: undefined reference to `HAL_DMA2D_Init' /home/hbarta/Documents/ecl-ws/Blink02MX/SW4STM32/Blink02MX Configuration/Debug/../user/stm32f429i_discovery_lcd.c:1342: undefined reference to `HAL_DMA2D_ConfigLayer' /home/hbarta/Documents/ecl-ws/Blink02MX/SW4STM32/Blink02MX Configuration/Debug/../user/stm32f429i_discovery_lcd.c:1344: undefined reference to `HAL_DMA2D_Start' /home/hbarta/Documents/ecl-ws/Blink02MX/SW4STM32/Blink02MX Configuration/Debug/../user/stm32f429i_discovery_lcd.c:1347: undefined reference to `HAL_DMA2D_PollForTransfer' collect2: error: ld returned 1 exit status make: *** [Blink02MX Configuration.elf] Error 1
They’re in the HAL dma2d file:
hbarta@yggdrasil ~/Documents/ecl-ws/Blink02MX $ egrep "HAL_DMA2D_Init|HAL_DMA2D_ConfigLayer|HAL_DMA2D_Start|HAL_DMA2D_PollForTransfer" Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma2d.c HAL_DMA2D_Init() function. and the input offset using HAL_DMA2D_ConfigLayer() function for foreground the transfer using HAL_DMA2D_Start() (+) Wait for end of transfer using HAL_DMA2D_PollForTransfer(), at this stage the transfer using HAL_DMA2D_Start_IT() HAL_StatusTypeDef HAL_DMA2D_Init(DMA2D_HandleTypeDef *hdma2d) HAL_StatusTypeDef HAL_DMA2D_Start(DMA2D_HandleTypeDef *hdma2d, uint32_t pdata, uint32_t DstAddress, uint32_t Width, uint32_t Height) HAL_StatusTypeDef HAL_DMA2D_Start_IT(DMA2D_HandleTypeDef *hdma2d, uint32_t pdata, uint32_t DstAddress, uint32_t Width, uint32_t Height) HAL_StatusTypeDef HAL_DMA2D_PollForTransfer(DMA2D_HandleTypeDef *hdma2d, uint32_t Timeout) HAL_StatusTypeDef HAL_DMA2D_ConfigLayer(DMA2D_HandleTypeDef *hdma2d, uint32_t LayerIdx)
It’s called out in the linker file
hbarta@yggdrasil ~/Documents/ecl-ws/Blink02MX $ grep dma2d 'SW4STM32/Blink02MX Configuration/Debug/objects.list' ./Drivers/STM32F4xx_HAL_Driver/stm32f4xx_hal_dma2d.o hbarta@yggdrasil ~/Documents/ecl-ws/Blink02MX $
I remain baffled.