Welcome, Guest. Please Login or Register
Arduino IDE for Visual Studio
 
 
When Logging a Support Issue in the Forum, please ensure you have also:-
  • Enabled vMicro > Compiler > Show Build Properties and Verbose
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
Support requests without the output above may be impossible to answer, so please help us to help you
 
  HomeSearch Tutorials & Wiki visualmicro.com LoginHelpRegister  
 
Page Index Toggle Pages: 1
Send Topic Print
Versioning the bin file and copying it to the required directory (Read 526 times)
Acuario
Member
***
Offline



Posts: 109
Versioning the bin file and copying it to the required directory
Jan 27th, 2019 at 12:29pm
 
I needed to put a version number on my compiled bin file and then copy it to a specific directory (for ftp upload to a server for subsequent download). Using a combination of the versioning code I previously wrote here: Automatic build version in built code combined with the following batch file and addition to the local Board.txt I achieved my objective.

Create a new batch file, copyme.bat in your project and mark it as exclude from project:
Code:
@echo off
setlocal EnableDelayedExpansion
set file=%1

for /F "tokens=1-3 delims=N " %%a in (%file%) do (
   for %%A in (%%a %%b %%c) do set "i=%%A"
)

set from=%2
set dest=%3

copy %from% %dest%%i%.ino.bin
 



Then add the following line in Board.txt
Code:
recipe.objcopy.hex.pattern.1.pattern=cmd.exe /c "{build.project_path}\copyme.bat {build.project_path}\version.h {vm.runtime.build.intermediate_output_path}{build.project_name}.bin {build.project_path}\php\bin\" 



Replace the {build.project_path}\php\bin\ for the directory where you want to copy the bin file.

The batch file will get run after the .bin file has been created, and will rename it to [current version].ino.bin

Hope this is of use to someone.
Back to top
« Last Edit: Jan 27th, 2019 at 6:54pm by Acuario »  
 
IP Logged
 
Acuario
Member
***
Offline



Posts: 109
Re: Versioning the bin file and copying it to the required directory
Reply #1 - Jan 27th, 2019 at 6:04pm
 
If you want to do the same for the SPIFFS file then the following works:

Add the following to the copyme.bat file
Code:
set mkspiffs=%4
set spiffsdir=%5
%mkspiffs%\0.1.2\mkspiffs -c %spiffsdir% -s 1004000 -p 256 -b 8192 %dest%%i%.spiffs.bin
 


Note: You may need to modify the path for your mkspiffs.exe file (the \0.1.2\mkspiffs bit)

Change the line in Board.txt for the following line:
Code:
recipe.objcopy.hex.pattern.1.pattern=cmd.exe /c "{build.project_path}\copyme.bat {build.project_path}\version.h {vm.runtime.build.intermediate_output_path}{build.project_name}.bin {build.project_path}\php\bin\ {tools.mkspiffs.path} {build.project_path}\data"
 



The result will be 2 files, [version].ino.bin and [version].spiffs.bin
Back to top
 
 
IP Logged
 
Acuario
Member
***
Offline



Posts: 109
Re: Versioning the bin file and copying it to the required directory
Reply #2 - Jun 10th, 2019 at 8:52am
 
The latest VM build breaks the auto copy. The fix is the same as for the auto version increment (as described in another post).

Removing the quotes from the command string (after the cmd.exe /c ".....") fixes the problem.
Back to top
 
 
IP Logged
 
Page Index Toggle Pages: 1
Send Topic Print