cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeMX Processing Before and After Code Generation

AGill.4
Associate II

STM32CubeMX release 6.9.0 contained support for processing before and after code generation. The documentation does not appear to be updated to describe how this works.

What kind of file and scripting is expected for this feature?

5 REPLIES 5
cvanbeek
Associate III

Any luck with this?  I also couldn't find any documentation from STM about this feature, despite them advertising it on the home page of STM32CubeMx.

I tried making both a powershell script and a shell script that would just echo a string into a file.  When I set the After Code Generation path to either of these scripts, it caused CubeMX to freeze up and I had to kill it from the task manager.

oskar
Associate

I also really need this functionality but I find the current implementation pretty useless:

  • There seems to be no way to specify a relative path to this script (relative to the sourcecode directory). Of course I this script inside my sourcede tree and check it into my version control system together with the sourcecode.
  • Also the working directory of the script seems to be the installation directory of STM32CubeMX. And there is no environment variable or any other way to find the sourcecode directory(!) What good is this script supposed to do if it can't find or access the generated sourcecode?

 

cvanbeek
Associate III

@oskar what language is your script in?

oskar
Associate

I wrote it in bash. It's on a linux laptop. 

jose luu
Associate III

 

If the script is within the project, begin the script with the lines below, these will set the current directory to where the script is:

Windows

 

 

 

set SCRIPT_DIR=%~dp0%
cd %SCRIPT_DIR%

 

 

 

 

Linux

 

 

 

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd ${SCRIPT_DIR}

 

 

 

 

The *BAD* news is that the script path must be absolute on Windows (eg C:\Users...) even though is is within the project directory.

Using the Windows utility procmon.exe, I can see that when using relative path, the script is noticed but it is not executed