cancel
Showing results for 
Search instead for 
Did you mean: 

Project generation from command line, headless

andrew_parlane
Associate II

I'm trying to generate a project from a .ioc file automatically on a headless system. This sees to be a very common source of problems. Is there a definitive solution for this? Otherwise I'm just here adding my vote for ST to add support for this.

OS: OpenSUSE.

I can't find a way of doing this with the STM32cubeIDE install. But if I install STM32cubeMX separately then the docs say you can do this via a script using ./STM32CubeMX -s yourscript. That nor the -i (for interactive) arguments work. The solution as provided in threads from 2019 is to do: "java -jar /path/to/STM32CubeMx -q yourscript". Why are the docs still wrong / why is this workaround still required when this has been a reported issue for 4 years?

The next issue is that even this workaround isn't true CLI, as it still requires a display, if you try to run this headless you get: No X11 DISPLAY variable was set,

And when running it on the local machine I see a small gui progress bar, and then a dialogue box pops up asking if I'm sure I want to generate the project. This issue I've seen reported in forum post from 2022. I could setup a virtual display to handle the progress bar, but having to press OK on the dialogue box is a problem, maybe I can find a way to fake keyboard input or something to get through this, but it really shouldn't be needed.

The best workaround ATM seems to be check in the auto-generated code. As with many other people I'd really rather avoid this, so are there any real solutions here?

Thanks

Andrew Parlane

8 REPLIES 8

>> This sees to be a very common source of problems

You'd think there'd be more motivation among the user base to come up with a solution, document it, or fund work..

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
BarryWhit
Lead II

> I can't find a way of doing this with the STM32cubeIDE install. 

You can run the CubeMX plugin installed with CubeIDE in standalone mode by invoking java and using the jar file:

 

 

 

java -jar <CUBEIDE_HOME>\STM32CubeIDE\plugins\com.st.stm32cube.common.mx_6.10.0.202311202037\STM32CubeMX.jar

 

 

 

all the command line arguments seem to work (I tested this on windows, but it should work on linux too)

 

That nor the -i (for interactive) arguments work.

 

Typos?

 

the docs say you can do this via a script using ./STM32CubeMX -s yourscript. 

 

Clicking the "Help" menu in CubeMX launches UM1718, which tells me that to run in command-line mode using a script​, without UI, you should use

 

 

 

./STM32CubeMX -q yourscript

 

 

 

(with -q not -s). I tested it on linux, and it works.

 

If you create the following script

 

 

 

help
exit

 

 

 

...and run it, you'll get a list of scripting commands. They are also documented in the UM1718 help document, but that may get stale over time.

 

> The solution as provided in threads from 2019 is to do: "java -jar /path/to/STM32CubeMx -q yourscript". Why are the > docs still wrong / why is this workaround still required when this has been a reported issue for 4 years?

 

As stated above, docs seem to be up-to-date.

 

> The next issue is that even this workaround isn't true CLI, as it still requires a display, if you try to run this headless you > get: No X11 DISPLAY variable was set,

 

This is a known issue that has long plagued people setting up CI jobs. There is a well-known solution,

you can use Xvfb to get around this. I tested this in a virtual console and it worked without issue on the first try.

 

> when running it on the local machine I see a small gui progress bar, and then a dialogue box pops up asking if I'm sure > I want to generate the project. 

 

Inside X, I also get a progress bar, but no dialog or prompt requiring interaction (maybe it depends on your script or project state?). But with Xvfb there's of course nothing and it still works. I was able to generate a project from a ioc with a script (in the virtual console, using xvfb). I also tested that user modifications are preserved.

 

It's as slow as a paraplegic snail and feels wonky as hell, but it works.

 

> You'd think there'd be more motivation among the user base to come up with a solution, document it, or fund work..

 

Done. Funding offers are most welcome.

 

- If someone's post helped resolve your issue, please thank them by clicking "Accept as Solution".
- Please post an update with details once you've solved your issue. Your experience may help others.

Hi BarryWhit,

Thanks for the reply.


@BarryWhit wrote:

You can run the CubeMX plugin installed with CubeIDE in standalone mode by invoking java and using the jar file:

 

java -jar <CUBEIDE_HOME>\STM32CubeIDE\plugins\com.st.stm32cube.common.mx_6.10.0.202311202037\STM32CubeMX.jar

 

all the command line arguments seem to work (I tested this on windows, but it should work on linux too)


OK, that's good to know, thanks.



@BarryWhit wrote:

That nor the -i (for interactive) arguments work.

Typos?

...

Clicking the "Help" menu in CubeMX launches UM1718, which tells me that to run in command-line mode using a script​, without UI, you should use

./STM32CubeMX -q yourscript

No typos on my end.

UM1718 (March 2024) section 3.3.2 "Running STM32CubeMX in command-line mode" states:

To run STM32CubeMX in interactive command-line mode, use the following command lines:

On Linux:
cd <STM32CubeMX installation path>
./STM32CubeMX –i

To run STM32CubeMX in command-line mode, getting commands from a script, use the following command lines:

On Linux and macOS:
./STM32CubeMX –s <script filename>

I do now see the instructions saying to use -q for getting commands from a script without UI, so I guess the docs are at least partially correct.

 


@BarryWhit wrote:

This is a known issue that has long plagued people setting up CI jobs. There is a well-known solution,

you can use Xvfb to get around this. I tested this in a virtual console and it worked without issue on the first try.


Yeah, that's the solution I found, it's a bit tedious but better than nothing, except it doesn't help with the dialogue box popping up.

 


@BarryWhit wrote:

Inside X, I also get a progress bar, but no dialog or prompt requiring interaction (maybe it depends on your script or project state?). But with Xvfb there's of course nothing and it still works. I was able to generate a project from a ioc with a script (in the virtual console, using xvfb). I also tested that user modifications are preserved.


The dialogue box I get is a warning about incomplete peripheral configuration:

andrew_parlane_0-1718744900354.png

Which admittedly is something that might go away once I've finished setting up my project, although I've spent some time looking for these issues and haven't solved them yet. So maybe it's a non-issue, but it doesn't fill me with confidence that my script could just block waiting for confirmation if something changes.

 


@BarryWhit wrote:

It's as slow as a paraplegic snail and feels wonky as hell, but it works.


Yeah, I guess it's better than nothing.

Thanks again for the reply, I seem to be pretty much on the right track, which is a little depressing, oh well.

Andrew

From UM171 Nov 2023 Rev 43 Page 36/451:

headless_rev43.jpg

 

Which admittedly is something that might go away once I've finished setting up my project,

 

exactly. If you get these errors while generating from the GUI, you can't expect them to disappear simply because you're  generating in headless mode.

 

but it doesn't fill me with confidence that my script could just block waiting for confirmation if something changes.

 

$ timeout 2 sleep 1 || echo error

[Nothing]

$ timeout 2 sleep 3 || echo error

error

- If someone's post helped resolve your issue, please thank them by clicking "Accept as Solution".
- Please post an update with details once you've solved your issue. Your experience may help others.

@BarryWhit wrote:

exactly. If you get these errors while generating from the GUI, you can't expect them to disappear simply because you're  generating in headless mode.


I can't expect the warnings to go away, I definitely could expect them to get printed out over the console, as warnings and not block the generation process.

 


@BarryWhit wrote:

$ timeout 2 sleep 1 || echo error

[Nothing]

$ timeout 2 sleep 3 || echo error

error


Yeah, that works, it still just feels like a giant hack, I was hoping ST would have fixed some of these issues in the last few years, but oh well.

Thanks,

Andrew

BarryWhit
Lead II

 I definitely could expect them to get printed out over the console

St could also definitely say "we don't support command-line code generation, because there's insufficient demand from customers to justify the development and maintenance costs" , and that would be that.

- If someone's post helped resolve your issue, please thank them by clicking "Accept as Solution".
- Please post an update with details once you've solved your issue. Your experience may help others.
BarryWhit
Lead II

@andrew_parlane,  you should communicate your displeasure over at the

Running stm32cubemx without gui  thread

there's an open internal ticket about this, let them know you care.

 

- If someone's post helped resolve your issue, please thank them by clicking "Accept as Solution".
- Please post an update with details once you've solved your issue. Your experience may help others.

will do, thanks.