0

I am trying to run a post-build script in Segger Embedded Studio (v6.20a).

I want to have access to variables that are Macro-defined in SES. Example variable is NRFUTIL, which should expand to a filepath.

Based on this forum post from Segger, Macros that are defined at the global or project level should be accessible by pre or post build scripts.

I have confirmed that I have NRFUTIL defined globally: enter image description here

But, I am unable to access it from a post build script:

enter image description here

Why can't my script find my global macro?

Chris Fernandez
  • 1,316
  • 14
  • 32

2 Answers2

0

I think you should be using curly braces instead of parentheses around your variable names: ${NRFUTIL} instead of $(NRFUTIL).

Elliot Alderson
  • 31,192
  • 5
  • 29
  • 67
0

The solution I found that worked for me was to explicitly pass the necessary macros to my script as parameters when the script is called.

My post build command:

../Post_build/post_build.sh $(NRFUTIL) $(ProjectDir) $(ProjectName) $(Configuration) $(SigningKey)

Then, in my post build script, I pass those parameters to local variables within my script:

#!/bin/bash
NRFUTIL=$1
ProjectDir=$2
ProjectName=$3
Configuration=$4
SigningKey=$5

Application_file_path=$ProjectDir/Output/$Configuration/Exe/$ProjectName.hex
DFU_zip_file_path=$ProjectDir/../Post_build/Outputs/$Configuration/DFU_package

echo "Generating DFU package."
nrfutil pkg generate --application-version 1 --application $Application_file_path --hw-version 52 --sd-req 0x0103 --sd-id 0x0103 --key-file $SigningKey $DFU_zip_file_path/$ProjectName.zip
Chris Fernandez
  • 1,316
  • 14
  • 32