How to Upload Hex File in Arduino

Here's how to employ the CMD prompt to upload a .hex file (compiled hex file) to Arduino without using the Arduino IDE. Also, how to use the command prompt to upload a .bin file to an ESP8266 or ESP32.

If you're not sure what .hex and .bin files are, read on. The code written in the Arduino IDE is written in C and/or C++, a loftier-level programming linguistic communication that is easy for united states to read and write. Microcontrollers are incapable of understanding high-level programming languages.

Even so, when you click upload, the Arduino IDE converts your code into hex or/and bin files, which are and then uploaded to microcontrollers. In general these files deed as your device'due south firmware.

Many times, a developer would make .hex or .bin file accessible to a client considering the programmer put in a lot of effort to write that code and doesn't desire to evidence you how he did it, and so the developer tin merely provide you with a compiled .hex or .bin file instead of programming lawmaking, and you lot would need to learn these steps to upload .hex and .bin file using command prompt (CMD prompt) without using Arduino IDE.

HOW TO CREATE A .hex OR .bin FILE

Select your 'development board' under "Tools," then click on 'Export compiled binary' under "Sketch."

    • Tools → Board: → Arduino Genuino/Uno (let)
      Select Board Arduino Genuino Uno
      Select Board Arduino Genuino/Uno
    • Sketch → Consign compiled Binary
      Export Compiled Binary Arduino
      Export Compiled Binary Arduino

This will generate two hex files if you're using an Arduino board, or bin files if you're using an ESP8266 or ESP32 lath, in the same folder (same location) where the ino file is saved.

HOW TO UPLOAD .hex FILE IN ARDUINO UNO/NANO/MEGA USING COMMAND PROMPT

Earlier you begin, proceed in mind that you volition need three things

    • avrdude location
    • avrdude.conf location
    • .hex file location
STEP i

To brainstorm open the Arduino IDE and get to File > Preferences, check the box upload under Testify verbose output during:

Show verbose output during compilation and upload Arduino IDE
Bear witness verbose output during compilation and upload – Arduino IDE
Step 2

Select a board from the tools card, in my case Arduino Genuino/Uno, and a COM port from the tools menu. Mine is COM14, merely it'south possible that yours is dissimilar.

Select COM port (Communication Port)
Select COM port
STEP 3

If everything is in guild, you can upload any code or sketch (either bare or any)

STEP four

Before the red color text began from, something like "avrdude: Version 6.3-20171130" as seen in the screenshot, afterward the upload was successful.

Find hex file upload command
Detect hex file upload command

Yous'll come across avr dude control similar this, but your path may be slightly different. Have a look at these points and run into if they contain -CC, -Uflash:w:\path_of_hex_file:i

          C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CC:\Plan Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -five -patmega328p -carduino -PCOM14 -b115200 -D -Uflash:              w:D:\MyCode\String_Seprator\String_Seprator.ino.standard.hex:i                              

Copy this line and paste into some text editor like notepad++, side by side 2 steps are important.

Stride 5

Replace the path betwixt 'w' and 'i' in the terminal ruby line with the path to the hex file you intend to upload.

STEP 6

Since the CMD prompt doesn't recognize spaces betwixt paths see here in Program Files (x86), employ double-class "" for the path This is what the command above would expect similar. (come across below).

                      "C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude"            "-CC:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"            -v -patmega328p -carduino -PCOM14 -b115200 -D -Uflash:w:              "              D:\PIJA Instruction\String_Seprator\String_Seprator.ino.standard.hex:i              "                              

If you don't employ double-course, you'll go an error similar this:

C Program not recognized as an internal or external command
'C:\Programme' is not recognized every bit an internal or external command

'C:\Program' is non recognized every bit an internal or external command, operable plan or batch file.

Footstep 7

At present open up a control prompt (Windows+r), type cmd in the run sorcerer, and click OK.

Run window - cmd
Run window – cmd
STEP 8

The path from step six should be copied, right-clicked, and pasted; the shortcut key ctrl + v would not piece of work hither in cmd prompt.

Footstep ix

If all of the steps in a higher place are completed correctly, you can see that the upload was successful. with a message at stop "avrdude done.  Thanks."

Upload hex file in Arduino using Command (cmd) prompt
Upload hex file in Arduino using cmd prompt

HOW TO UPLOAD .bin FILE IN ESP8266 USING COMMAND PROMPT

To upload .bin file to ESP8266, follow the same instructions from 1 to 3 every bit nosotros did for Arduino, except board and port selection, these will be different unlike this time. For example board may exist  NodeMCU 0.ix (ESP-12 Module) and Port is COM11.

Pace i

Once you upload code successfully, Before the red color text began from, something like "esptool.py v2.eight" equally seen in the screenshot

Find NodeMCU/ESP8266 bin file upload command
Find NodeMCU/ESP8266 bin file upload command

You'll come acrossupload command like this, but your path may be slightly dissimilar.

          C:\Users\abc\AppData\Local\Arduino15\packages\esp8266\tools\python3\three.7.2-post1/python3 C:\Users\abc\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.four/tools/upload.py --chip esp8266 --port COM11 --baud 115200 --before default_reset --subsequently hard_reset write_flash 0x0            C:\Users\abc\AppData\Local\Temp\arduino_build_9655/test.ino.bin                  

Re-create this line and paste into some text editor like notepad++, next 2 steps are important.

Footstep 2

Replace the path in the last ruby line with the path to thebin file you intend to upload.

Footstep 3

Since the CMD prompt doesn't recognize spaces between paths see hither in Program Files (x86), applydouble-class"" for the path, if space present in path. This is what the control above would look similar. (see below).

          C:\Users\abc\AppData\Local\Arduino15\packages\esp8266\tools\python3\three.vii.ii-post1/python3 C:\Users\abc\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4/tools/upload.py --bit esp8266 --port COM11 --baud 115200 --earlier default_reset --subsequently hard_reset write_flash 0x0            "            D:\PIJA Education\examination/test.ino.nodemcu.bin            "                  
Step 4

Now open up a command prompt (Windows+r), typecmd in the run wizard, and click OK.

Run window - cmd
Run window – cmd
STEP 5

The path from pace 3 should be copied,right-clicked, and pasted; the shortcut central ctrl + v would not piece of work here in cmd prompt.

Stride 6

If all of the steps above are completed correctly, then click enter and you can run into that the upload was successful with a bulletin at end "Difficult resetting  via RTS pivot…"

HOW TO UPLOAD .bin FILE IN ESP8266 USING COMMAND PROMPT
Upload bin file in ESP8266 using Control (cmd) prompt

warddefe2001.blogspot.com

Source: https://pijaeducation.com/upload-hex-file-in-arduino-using-cmd-prompt/

0 Response to "How to Upload Hex File in Arduino"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel