I am compiling a script for a mega 2560 with an ESP8266 add-on module. I need to compile the script and export a .bin file to use with Blynk. Currently the process creates a .hex file. I found some instuctions for adding a recipe for creating the .bin by adding some code to a platform.local.txt file and putting it in the same directory as my platform.txt file. The problem I have 230 copies of platform.txt in various subfolders in the ...\arduino\libraries folder. I'm not sure which one to use. Any suggestions?
Hi @garlydog. You can find the location by examining the output from compiling a sketch for that board when you have verbose output enabled.
- Select File > Preferences from the Arduino IDE menus.
- Check the box next to "Show verbose output during: ☐ compilation".
- Click the OK button.
- Select the board you want to find the
platform.txtof from the Tools > Board menu. - Select Sketch > Verify/Compile from the Arduino IDE menus.
- Wait for the compilation to finish.
- Scroll the black "Output" panel at the bottom of the Arduino IDE window all the way to the top.
Near the top of the output, you will see a line that looks something like this:
Using board 'mega' from platform in folder: C:\Users\per\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6
The platform.txt file associated with the board you compiled for is located at that path.
Note that the path is often located under a folder that is hidden by default by your file browser or operating system (e.g., C:\Users\per\AppData is hidden by Windows File Explorer), so if you can't find the folder check to make sure your system is configured to show hidden files.
If you are interested in more information about platform.txt, platform.local.txt, and the Arduino boards platform system in general, check the documentation here:
https://arduino.github.io/arduino-cli/latest/platform-specification/
Thank you for the reply. I found the location.
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr
I cannot copy my platform.local.txt to that folder. I tried all the usual techniques to grant myself permission to the folder, but keep getting blocked.
This is due to the very strict security restrictions placed on the installation of Microsoft Store Apps. It is possible to do it, but extremely difficult and not worth the effort.
I can provide you with a workaround, but I'll need a little bit of information from you first because I don't happen to have an installation of the Microsoft Store version of the Arduino IDE convenient:
Please do this and then report your findings here:
Please try this:
- Select Tools > Board > Boards Manager from the Arduino IDE menus.
- Wait for the updates to finish.
- Scroll down through the list of boards platforms until you see the entry for "Arduino AVR Boards".
On the second line of the entry, under the "Arduino AVR Boards", it will show which version of that platform is installed (e.g., "by Arduino version 1.8.6 INSTALLED"). Please tell me which version it shows you have installed there.
1.8.6
OK, that is a bit unfortunate. I was hoping the Microsoft Store version was still using 1.8.5, which would allow us to easily create an installation of the platform at an accessible location by simply updating it via Boards Manager.
I think the best way to proceed is to do a manual installation of Arduino AVR Boards. Even though the installation is slightly more complex, you might actually find this more convenient in the long run because the manual installation is more accessible for modifications.
I'll provide instructions for manually installing the "Arduino AVR Boards" platform.
-
Create the following folders under your sketchbook folder:
<Sketchbook location>\hardware\arduino-dev\avr\<Sketchbook location>/ ├── hardware/ │ └── arduino-dev/ │ └── avr/ └── ...ⓘ If you don't know the location of your sketchbook folder, open the "Preferences" dialog in Arduino IDE (File > Preferences) and check the path shown in the "Sketchbook location" field.
-
Download "Arduino AVR Boards' from this link:
https://github.com/arduino/ArduinoCore-avr/archive/refs/tags/1.8.6.zip -
Unzip the downloaded file.
-
Copy the contents of the unzipped
ArduinoCore-avr-1.8.6folder to the<Sketchbook location>\hardware\arduino-dev\avr\folder.
The installation must have the following structure; withplatform.txtdirectly under theavrfolder:<Sketchbook location>/ ├── hardware/ │ └── arduino-dev/ │ └── avr/ │ ├── boards.txt │ ├── platform.txt │ └── ... └── .... -
Add your
platform.local.txtfile to the<Sketchbook location>\hardware\arduino-dev\avr\folder. -
Restart Arduino IDE if it is running.
Manual installations and modifications to platforms are only recognized after restarting the IDE. -
Open the Tools > Board menu in the Arduino IDE.
-
You will now see that there are now two "Arduino AVR Boards" entries in the menu:
- Arduino AVR Boards
- Arduino AVR Boards (in sketchbook)
Select the board from the "(in sketchbook)" submenu when you want to use the modified platform. You can use the other submenu if you want to use the unmodified platform.
I really appreciate your help. Everything worked, except my original problem remains. I created a file called platform.local.txt in the folder. Restarted the IDE. Ran export compiled binary. The .bin file is not created, only a .hex file. Here is the only code I put in my platform.local.txt
Create output (bin file)
recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2hex.cmd}" -O binary {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin"
I even added the code to the platform.txt file and still no luck creating the .bin file.
How did you manage that? Just curious, I do not know how the Windows Store version works. For my feeling, Arduino\libraries is not the place to have platform.txt files but I might be wrong.
A way to solve your headaches might be to use portable installs for each of the different processor architectures; in your case one for AVR and one for ESP8266.
recipe.objcopy.bin.pattern only defines the pattern used to generate the command for producing a binary file. If you check the sketch build folder you will see that adding this did indeed cause an additional .bin file to appear in that folder after compiling (or doing an "Export compiled Binary" operation, no difference).
But another "recipe" determines which of the files from the build folder Arduino IDE 1.x exports to the sketch folder when you run an "Export compiled Binary" operation:
https://arduino.github.io/arduino-cli/dev/platform-specification/#recipes-to-export-compiled-binary
Two recipes affect how Export compiled Binary works:
- recipe.output.tmp_file: Defines the binary's filename in the build folder.
- recipe.output.save_file: Defines the filename to use when copying the binary file to the sketch folder.
So you would need to add the following lines to your platform.local.txt file:
recipe.output.tmp_file={build.project_name}.bin
recipe.output.save_file={build.project_name}.{build.variant}.bin
Note that these will override the recipes from platform.txt that caused the .hex files to be exported, so you will only get .bin files after making this change. I don't think there is any way to specify multiple filenames via the recipe.output.* recipes to export multiple files (though it could be accomplished via build hooks.
All this is much more simple when using Arduino IDE 2.x because it ignores the recipe.output.* recipes and simply exports all the binary files produced by the build to the build subfolder of the sketch when you run "Export compiled Binary" operation. So just the recipe.objcopy.bin.pattern line alone that you added would have been sufficient if you were using Arduino IDE 2.x instead of 1.x.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.