Auto-versioning with "-D" Make flag in SmartSnippets

⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at//www.xmece.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
4 posts / 0 new
Last post
Merigh
Offline
Last seen:6 months 2 weeks ago
加入:2020-08-25 20:51
Auto-versioning with "-D" Make flag in SmartSnippets

Hello,

I am trying to implement some auto-versioning so that I don't have to manually check I am staying up to date with my software versions. To do this, I figured I would dynamically set a preprocessor macro with the current date and time.

In SmartSnippets, I can go to settings, C/C++ Build->Cross ARM C Compiler-> Preprocessor settings, then Defined symbols (-D) to add what I want. My exact syntax here is: BLACKORCA_SW_VERSION="\"C$(date +"%Y.%m.%d.%H.%M")\"" with the intention that "date" calls the shell command to get the current date and is subsequently formatted how I want. I also want the "C" prefix.

I have tested this syntax with gcc locally, and it works great. When I try to skirt around SmartSnippets and call "make" manually from a terminal (invoking the proper cross compiler instead of gcc) and from the project build folder, I can see the output of this correctly resolves to the current date and time. But, when I go through SmartSnippets and my Build Configuration, the macro is properly recognized to be defined (no compiler errors), but when I flash my board (I have a dev board and a custom board), the macro ends up being resolved to "C" only, and the rest of the string does not show up.

I know this is a super specific request, but if the macro resolves correctly for me when locally using gcc, and when using arm-none-eabi-gcc while manually calling make from a terminal, then there might be something SmartSnippets/Eclipse related that I need help with.

Any advice? If there is an easier way to implement this auto-versioning, please do let me know. Thanks.

仅仅是

Device:
PM_Dialog
Offline
Last seen:7 hours 46 min ago
工作人员
加入:2018-02-08 11:03
Hi Merigh,

Hi Merigh,

Thanks for your question online. Let me check it and I’ll get back to you.

Thanks, PM_Dialog

Merigh
Offline
Last seen:6 months 2 weeks ago
加入:2020-08-25 20:51
Hi again,

Hi again,

Another option may be to use the Pre-build steps in the Smart Snippets Project Settings. Currently this field is populated with the "Generate linker scripts" command(s). Is there an easy way to simply add a pre-build step? Or do I simply append text in the little box? Then, I can modify my sw_version.h file no problem from there. I think.

Thanks for any help,

M

Merigh
Offline
Last seen:6 months 2 weeks ago
加入:2020-08-25 20:51
Another update,

Another update,

Adding raw text in the Pre-Build steps works great. Now I have another related question:

Does Dialog's SUOTA 1.1 specification require that the version string be 16 characters long? Or can I make it 18, for example? That is because I want CYYYY.MM.DD.HH.mm format.

Thanks, M