Adding variables to a pre-build step

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
DaGr_294516
Level 3
Level 3
10 sign-ins 10 questions asked First solution authored

Is there a way to add the device name as an argument to a pre-build step? I presume there is a list of variables accessible to pre/post build commands but I can't find it easily....

Could someone point me in the right direction please?

Cheers,

Dan

 

0 Likes
1 Solution

Dan,

Would this be helpful?:

The project file xxx.cyprj is an xml file.

If you can parse the xml and look for a string:

"selected_device v="  the string in the xml field is the PsoC device being used in the project.

You can then create a script that parses the .cyprj file places the selected device into your own local environment variable and then use it in your own pre- or post- build executables.

Len
"Engineering is an Art. The Art of Compromise."

View solution in original post

0 Likes
10 Replies
SampathS_11
Moderator
Moderator
Moderator
250 sign-ins 250 solutions authored 5 questions asked

Hello @DaGr_294516 

It would be great if we know that you are referring to PSoC Creator or PSoC Designer.

Best regards,

Sampath Selvaraj

0 Likes
DaGr_294516
Level 3
Level 3
10 sign-ins 10 questions asked First solution authored

Oh, sorry, yes I can see that would be useful. It's Creator 4.3.

I did find some macros eventually, but device name wasn't in there (architecture and cpu type were, but I want the full chip name CY8C5... etc). 

The best I've come up with so far is to write a script to parse the project file and extract it from there but that seems a little clunky....


Cheer for your help,
Dan

0 Likes

This would be a very useful feature to have in PSoC Creator. We use the pre-build step to generate header files which get compiled into the firmware. Sometimes it can be very useful for the bootloader to know the exact part number, so it can verify that the firmware being uploaded is the correct type.

I would like to request this as a feature for a future version of PSoC Creator. (plus any other variables that may be available)

Many thanks

Hugo

 

0 Likes

Hello @HuEl_264296 ,

Thank you for the feedback. I will pass this request for evaluation by the software team. Currently, we have only the list of macros mentioned by @Len_CONSULTRON in the earlier post. 

For the specific device being used, parsing the .cyprj file for the <selected_device> label is the best way to go. 

On a side note, if the bootloader and the bootloadable target different devices, Creator is going to throw an error indicating the mismatch during the build. But this happens after build, I agree something to determine this in the pre-build might be useful. 

DheerajK_81_0-1622173066957.png

Hope this helps 🙂

Regards,
Dheeraj

0 Likes

Thanks, parsing the project file is where I ended up.  Much as I am loath to admit it, python saved the day 😉 

We actually need the info pre and post build. Our system is arcane with multiple types of PSoC and a funky custom comms stack so we need both embedded and host devices to know exactly what chip each bit of firmware is meant for...  Anyway, got there in the end 🙂

0 Likes

Dan,

I have found this in the PSoC Creator Help file.

Build Settings Macros:

The Build Settings dialog contains macros that can be used to substitute names for directories and files. You can use these macros in any Build Settings field where you can type.

Macro

Description

Example Values

${Config}

Build Configuration.

"Debug" or "Release"

${ProcessorType}

Name of the processor type.

"CortexM0", "CortexM3", ...

${Platform}

Name of Toolchain.

"ARM_GCC_541", "ARM_GCC_Generic", …

${ProjectShortName}

Name of the project without Extension.

"Design01", Design02",  …

${ProjectDir}

Directory of the project file relative to current directory.

".\Design01.cyprj", ".\Design02.cyprj", …

${ProjectFile}

Path of the project file relative to current directory.

"."

${WorkspaceDir}

Directory of the workspace file relative to current directory.

"..", ".", …

${WorkspaceFile}

Path of the workspace file relative to current directory.

"..\Workspace01.cywrk", "..\Workspace02.cywrk", …

${OutputDir}

Path of the output directory as specified by in the toolchain's "General" page.

"${ProjectDir}\${ProcessorType}\${Platform}\${Config}"

Note There is also a $(CompileFile) macro that corresponds to the file being compiled when running compile/assemble commands. It is ignored everywhere else, and it should not to used.

The PSoC Device name is used internally but may not be available as a Local environment variable.   Only Infineon can say otherwise.

Len
"Engineering is an Art. The Art of Compromise."
0 Likes

Hi Len,

Thanks. I've seen this, but there is no variable listed which gives the device name.

Hugo

 

0 Likes

Dan,

Would this be helpful?:

The project file xxx.cyprj is an xml file.

If you can parse the xml and look for a string:

"selected_device v="  the string in the xml field is the PsoC device being used in the project.

You can then create a script that parses the .cyprj file places the selected device into your own local environment variable and then use it in your own pre- or post- build executables.

Len
"Engineering is an Art. The Art of Compromise."
0 Likes
HuEl_264296
Level 5
Level 5
First like given 25 sign-ins First solution authored

Hi Len,

Thanks, that's what we're actually doing at the moment. It would just be more convenient for other people not to have to do that.

Hugo

 

0 Likes

Hugo,

Good to hear. 

Make a suggestion for Infineon to add it to their "to-do" list.

There is a chance that the selected device is a local variable already.  I've looked through the psoc_creator.exe code but could not identify further local variable names.

Len
"Engineering is an Art. The Art of Compromise."
0 Likes