cancel
Showing results for 
Search instead for 
Did you mean: 

Add files to designer code + LL drivers

Deividas
Associate II

Hello,

I am trying to add serial communication to the designer generated gui code. I used the blank template from TouchGFX designer for STM32F469I-disco board. Gui works fine, but I cannot manage to add my own code to it. I guess I need to edit the target/gcc/Makefile and add the files to specific locations, but I cannot find any information to where/how.

Files:

serial.c/serial.h // serial implementation that uses LL drivers and FreeRTOS
 
/* Snippet from serial.h */
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
#include "semphr.h"
 
#include "stm32f4xx.h"
#include "stm32f4xx_ll_rcc.h"
#include "stm32f4xx_ll_bus.h"
#include "stm32f4xx_ll_cortex.h"
#include "stm32f4xx_ll_dma.h"
#include "stm32f4xx_ll_gpio.h"
#include "stm32f4xx_ll_usart.h"
 
#include <string.h>

FreeRTOS files are already included in the generated code by TouchGFX designer. I need to add LL drivers and serial.c/.h to the project.

  1. I already tried just copying files to target/ and including the serial.h to main.cpp but I got bunch of compile errors. It seems that every ll*.c file needs a make rule.
  2. I also tried to copy the used ll_*_.h&.c files to the STM32F4xx_HAL_Driver include and source directories. Then editted the Makefile under board_c_files to add the ll*.c files like others. It seems that defines for all registers from stm32f4xx.h and stm32f469.h do not get included, because i got bunch of error: undeclared that point to registers.
  3. I tried adding all files to target/serial and editting Makefile. Added target/serial to include_paths and source_paths but still with lots of compile errors.

Whole day i kept trying different things but to no success. I hope someone can help!

1 ACCEPTED SOLUTION

Accepted Solutions
Martin KJELDSEN
Chief III

Hi @Deividas​,

You're right in assuming that you need to modify target/gcc/Makefile. You'll find the following lines.

include_paths := $(library_includes) $(foreach comp, $(all_components), $(comp)/include) $(framework_includes)
source_paths = $(foreach comp, $(all_components), $(comp)/src)

Add your own paths here, relative to the root of the application. E.g using the 469-DISCO template you'd have something like the following structure (incomplete) with mydrivers having both your .c and .h files.

+- assets
+- gui
+- generated
+- target
+- mydrivers

You'd then make the following modifications:

include_paths := $(library_includes) $(foreach comp, $(all_components), $(comp)/include) $(framework_includes) mydrivers
source_paths = $(foreach comp, $(all_components), $(comp)/src) mydrivers

Try it out!

/Martin

View solution in original post

8 REPLIES 8
Martin KJELDSEN
Chief III

Hi @Deividas​,

You're right in assuming that you need to modify target/gcc/Makefile. You'll find the following lines.

include_paths := $(library_includes) $(foreach comp, $(all_components), $(comp)/include) $(framework_includes)
source_paths = $(foreach comp, $(all_components), $(comp)/src)

Add your own paths here, relative to the root of the application. E.g using the 469-DISCO template you'd have something like the following structure (incomplete) with mydrivers having both your .c and .h files.

+- assets
+- gui
+- generated
+- target
+- mydrivers

You'd then make the following modifications:

include_paths := $(library_includes) $(foreach comp, $(all_components), $(comp)/include) $(framework_includes) mydrivers
source_paths = $(foreach comp, $(all_components), $(comp)/src) mydrivers

Try it out!

/Martin

Deividas
Associate II

Hi @Martin KJELDSEN​ 

I did as you mentioned but still i cannot compile it. I still get pages and pages of these errors:

minUnit/stm32f4xx_ll_rcc.h: In function 'LL_RCC_PLL_ConfigDomain_48M':
minUnit/stm32f4xx_ll_rcc.h:4416:38: error: 'RCC_PLLCFGR_PLLN_Pos' undeclared (first use in this function)
              Source | PLLM | PLLN << RCC_PLLCFGR_PLLN_Pos | PLLQ);
 
 
minUnit/minUnitSerial.c: At top level:
minUnit/minUnitSerial.c:7:1: error: unknown type name 'SemaphoreHandle_t'
 SemaphoreHandle_t semTxBufferAvailable;

It seems that it cannot find FreeRTOS source/headers too. Defines for LL drivers are in stm32f469xx.h, which I even added to the minUnit folder together with systen_stm32f4xx.c/h files, stm32f4xx.h and startup_stm32f469xx.s. But none of them seems to get used by the *_ll_*.h/.c drivers. Another thing that I noticed is that STM32Cube version for the designer template is 1.15.0, but on the STM site only 1.23 and 1.24 are available. Maybe they are incompatible with each other. Even the FreeRTOS 7.6 for the template is used, so maybe my v1.24 LL drivers and FreeRTOS 9.0 somehow does not fit..

Martin KJELDSEN
Chief III

Was it compiling freertos files before your change? It should, since this is an application templat.

Deividas
Associate II

Yes it was. I could use the touchgfx environment, cd to the project and use make -f target/gcc/Makefile (on freshly generated code from designer). I could compile and flash it and everything worked fine.

Martin KJELDSEN
Chief III

Okay. Well, if you're simply referring to the fact that it cannot find SemaphoreHandle_t then it may be because the way the freertos headerfiles are included from minUnitSerial does not work with this Makefile. Can you show me the include statements from minUnit/minUnitSerial?

/Martin

Deividas
Associate II

They are in the initial post. Saved in minUnitSerial.h

#ifndef __MINUNITSERIAL_H
#define __MINUNITSERIAL_H
 
 
/* Includes */
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
#include "semphr.h"
 
#include "stm32f4xx.h"
#include "stm32f4xx_ll_rcc.h"
#include "stm32f4xx_ll_bus.h"
#include "stm32f4xx_ll_cortex.h"
#include "stm32f4xx_ll_dma.h"
#include "stm32f4xx_ll_gpio.h"
#include "stm32f4xx_ll_usart.h"
 
#include <string.h>

Thanks for taking the time to help!

Deividas
Associate II

I could not compile new files because the TouchGFX designer generated code uses FreeRTOS 7.6.0. It has only *generic* functions and outdated APIs as in FreeRTOS 9.0. Moreover, designer code has STM32CubeF4 v1.15, which is not compatible with the version 1.23 and 1.24 available in ST website( I might be wrong, if so update me pls). I'll try to do a Application Template with new FreeRTOS and CubeF4 versions.

Hi @Deividas​,

We do not update the application templates because new versions of CubeFW come out. You should be able to upgrade yourself if you want - Even FreeRTOS. Let me know and i'll help you out.

/Martin