[SOLVED] Problems executing post-build script

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • [SOLVED] Problems executing post-build script

    Hello all-

    For a project we are currently using :
    SEGGER Embedded Studio for ARM
    Release 7.12a Build 2023031402.52776
    Windows x64

    Our goal is to allow a Python script to execute when the build process completes. As I understand it, I cannot tell SES to directly execute the PY file. Instead, I have to run a batch file which in turn can execute the Python script. Going to the common project settings I selected our batch file as the Post-Build Command option. The batch file consists of this code :

    Source Code

    1. @echo off
    2. "C:\Program Files\Python310\python.exe" "post_build_script.py"
    3. pause
    The problem is that SES freezes up when doing this post-build step. No terminal window pops up for either the BAT file or the PY file and I can't find any evidence that either file actually executed. Nothing can be done with SES since it won't move past the post-build step, including even allowing you to exit the application itself, I have to use Task Manager to abort it. The only feedback I can get from the output window is :

    Post-Building ‘edgecon_stm32l062’

    C:/Segger_Projects/EdgeCon_0/STM32L062/post_build_script.bat


    It is unclear how to further troubleshoot this issue since most posts I can find in the forums merely discuss how to launch a command by choosing it as the post-build step.
  • Hello,

    Thank you for your inquiry.

    Eqqman wrote:

    As I understand it, I cannot tell SES to directly execute the PY file.
    That is not correct. You can call the same Python CL call that you do in your bat file directly in post build steps.


    Eqqman wrote:

    The problem is that SES freezes up when doing this post-build step. No terminal window pops up for either the BAT file or the PY file and I can't find any evidence that either file actually executed.
    Looking at your batch script source that is expected and not really a freeze. Embedded Studio is simply waiting for your batch script to finish which it never does. You use "@echo off" which disables terminal output which is why you are not seeing any print output from your script and you are calling "pause" which pauses the script in that line so the command line call never returns so Embedded Studio keeps waiting.

    Remove that two lines from your batch script and it should behave as expected. Or call the Python script directly.

    Best regards,
    Nino
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Thank you for the reply.

    Segger - Nino wrote:



    Remove that two lines from your batch script and it should behave as expected. Or call the Python script directly.
    It does not matter what variations I put in that would or would not leave a terminal window open if I ran the command directly from the command line. I never see a terminal window spawn nor do I see any output. I have tried to use BAT files that write log outputs so that I could verify the batch file even started but none are ever written. Under Windows, even if you run a terminal window that wouldn't stay open on its own you still see the window launch and then immediately disappear when the commands are completed. If I follow the advice and change the Properties -> User Build Step -> Post Build Command to "C:\Program Files\Python310\python.exe" "post_build_script.py" where the Python script is this :

    Source Code

    1. print("Executing post_build_script.py to rename output HEX file...")
    2. with open("test_file.txt", "a") as file :
    3. file.write("testing...\n")
    4. #
    5. #
    The SES Output window never moves past "Post-Building" and test_file.txt is never created. SES continues to be blocked until I use Task Manager to stop it.
  • Hello,

    Not reproducible for me.

    Attached you can find an example project that runs your script as post build steps.
    Right now I am calling "python" "Test.py" but I also tested that with the absolute path to the python exe as well as without quotation marks.
    All variants work for me without any issues and as expected.

    Could you give the example project a try. Does this work for you?

    Please note that we generally recommend to use the latest Embedded Studio version if possible.
    But I also tested this with the V7.12a you are using and same result, all works as expected.

    Best regards,
    Nino
    Files
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.