Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Versioning the bin file and copying it to the required directory (Read 2585 times)
Acuario
Full Member
***
Offline


Posts: 233
Location: Spain
Joined: Aug 28th, 2015
Versioning the bin file and copying it to the required directory
Jan 27th, 2019 at 12:29pm
Print Post  
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
Select All
@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
Select All
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.
« Last Edit: Jan 27th, 2019 at 6:54pm by Acuario »  
Back to top
 
IP Logged
 
Acuario
Full Member
***
Offline


Posts: 233
Location: Spain
Joined: Aug 28th, 2015
Re: Versioning the bin file and copying it to the required directory
Reply #1 - Jan 27th, 2019 at 6:04pm
Print Post  
If you want to do the same for the SPIFFS file then the following works:

Add the following to the copyme.bat file
Code
Select All
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
Select All
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
Full Member
***
Offline


Posts: 233
Location: Spain
Joined: Aug 28th, 2015
Re: Versioning the bin file and copying it to the required directory
Reply #2 - Jun 10th, 2019 at 7:52am
Print Post  
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 TopicPrint