1
\$\begingroup\$

I have been using the Ardunio IDE to edit code for an Arduino sketch.

I was having trouble uploading to the board, so I bought a pocket progammer in response to this question: What possible ways can I upload sketches to arduino mega chips?

Now, using this programmer I can upload .hex files via the command line.

Now I want to create a .HEX file from my existing .PDE files.

The problem is:

  • The graphical IDE has a "Upload Sketch" button (which compiles and attempts to upload in one go), but there doesn't seem to be a "Create Sketch" button.
  • avr-gcc can create a sketch (I believe) but doesn't recognise .PDE files.

How can I go about creating this Sketch?

\$\endgroup\$
2
\$\begingroup\$

When the Arduino IDE compiles your sketch it creates a .HEX file in a temp directory, which is then uses to upload to your board.

The .HEX file will have the same name as your sketch (without the .pde extension), followed by .cpp.hex

I just tried a build and the .HEX file was created in a directory called build2849146248544311107.tmp inside my Temp directory (C:\Users\USERNAME\AppData\Local\Temp\ on Windows 7). Presumably the numbers in the build2849146248544311107.tmp directory name will chanage.

\$\endgroup\$
  • \$\begingroup\$ AHA, found it. I suppose if I need a repeatable build process I'll have to generate MakeFiles, but getting it from the temp directory will suffice for one-offs. \$\endgroup\$ – Andrew Shepherd Jul 5 '11 at 1:04
2
\$\begingroup\$

At a project i'm working on we use the basic Makefile delivered by arduino and made some tweaks in it. You would need https://github.com/zarya/OpenCTRL/blob/master/src/c/Arduino.mk and https://github.com/zarya/OpenCTRL/blob/master/src/c/Makefile.sample rename the Makefile.sample to Makefile and you want to change the settings there. You might also want to remove the # at line 272 and place a one at the start of line 273 of Arduino.mk we use this make file on Debian and Ubuntu, hope it's also compatible with other distributions / windows?

The only downside, currently we can only include one external library in our projects. I'll probably fix this problem in the feature although we actually don't need more then one library at the moment :)

\$\endgroup\$
  • \$\begingroup\$ For windows you'll need GNU Make, along with any binaries the Makefile calls. You may well need to edit the Makefile to change lots of paths to said binaries as they probably aren't in Windows' $PATH environment variable. \$\endgroup\$ – Majenko Jul 4 '11 at 8:41
2
\$\begingroup\$

Press Shift and press Upload button in the IDE simultaneously.

By pressing Shift key when clicking on upload button when compiling, a hex file is made in temp folder somewhere in C: drive by name xx.hex where xx is file name.

\$\endgroup\$
  • \$\begingroup\$ Welcome to Electrical Engineering! Please take a moment to copy-edit your answer using the 'edit' link beneath the text. I copied your later answer into this post (this isn't a forum, try to form one answer per question), but additionally it appears that you've failed to capitalize sentences, abbreviated 'and' to 'n', and your second sentence runs together. While your content is great, the presentation is lacking - please try to be a bit more professional! Thanks. \$\endgroup\$ – Kevin Vermeer Jun 14 '12 at 14:39
0
\$\begingroup\$

I'd first would start to make namings clear: the Arduino software names .pde files as "sketches". Uploading those to the hardware would be useless, because the processor can't handle these text files. Hence, the compiler first needs to compile such source code (.pde files are indeed .cpp files - except of a few lines of code which the Arduino software automatically adds during the compilation process) to the binary format. The .hex files still are text files, but they now describe the binary content which the upload programs understand and upload to the microcontroller in your Arduino board.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.