Uploading Grbl .hex to the Arduino Uno

If your Uno came without GRBL, or you want to start fresh or upgrade to a newer version, here are some upload steps.
Preparation:
    1. You will need AVRDude on your Mac/PC, easiest way to do this and to ensure all things are in the right place is to simply install the Arduino IDE from the Arduino Site.  Note you are installing this, not simply downloading it to your desktop and running it!
    2. Plug the UNO in via usb and ensure that its found correctly, if you find issues with the arduino being detected be sure not to be using multiple usb extension leads!! The Uno can be detected incorrectly as a USB hub or other device, or not at all if you have a string of usb extension leads between it and the computer
    3. Verify the Serial/COM port.   Open the Arduino software, goto tools => serial port and identify the device in this list. Mine shows up here on the mac as /dev/tty.usbmodem142121 

        and here in windows as COM5

      If you have multiples and don’t know which is which, try pulling the Arduino out and watch which one disappears!  If you dont see your device it may not have been detected correctly, re insert, restart your computer, then if still nothing – you’ve got more work to do searching for why its not showing – this problem solving is not covered further in this post.

    4. Download the version of grbl (in hex format) that you would like to upload – the list is here:https://github.com/grbl/grbl, look under the master brach and archive headings for the hex files.   Take NOTE: Don’t follow these links and copy all the code into a text file, this is fraught with problems!  Simply right click on the link and ‘save link as’, this will download the file for you!   Save it to your desktop for now.
Using AVR Dude to upload
This is where the windows/mac procedures have different requirments.
For Mac OSX – you can simply upload via AVRdude by editing then running the following command via terminal.

/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avrdude -v -v -v -v -patmega328p -carduino -P/dev/tty.usbmodem142141 -b115200 -D -Uflash:w:/Users/BenHarper/Desktop/grbl_v0_9g_atmega328p_16mhz_115200_for_SO2.hex:i

    • Note  “tty.usbmodem142141″ must be upated to your device name we identified earlier!
    • Note “BenHarper” must be updated to your username – you can see your username right there in the terminal when you open it, type ‘$HOME’ and hit enter to see the folder path. You can also issue the command ‘whoami’ to get your username.
    • Note “grbl_v0_9g_atmega328p_16mhz_115200_for_SO2.hex” must be replaced with the exact name of the file you downloaded or the name you saved it as!
Once you have correctly modified this command you can run it by hitting enter, if all went well thousands of lines of code will run up the screen for around 15 seconds and then you will see ‘avrdude done.  Thank you.’  If the upload process is considerably shorter it or it errors out then it didnt work,  recheck all of the above and make sure you got everything right!

For WINDOWS – you upload via AVRdude by editing then running the following command via terminal.

Goto C:\Program Files (x86)\Arduino\hardware\tools\avr\
Do a search for a file called Avrdude.conf, 
We want to copy this file to C:\Program Files (x86)\Arduino\hardware\tools\avr\bin\
 
Then we go to a dos prompt, copy the whole line below including “” and paste it in using right click and paste, you cant use ctrl V
But first change -PCOM5 to -PCOM#  with # being the number of the com port your arduino is sitting on.
And also change 
 
“C:\Program Files (x86)\Arduino\hardware\tools\avr\bin\avrdude.exe” -v -v -v -v -patmega328p -carduino -PCOM5 -b115200 -D -Uflash:w:/grbl_v0_9g_atmega328p_16mhz_115200_for_SO2.hex