Programming GRBL into an Arduino

If you find yourself with a dead Arduino Grbl controller, or you are building a system from scratch, it is useful to know how to program the GRBL firmware into the device.  This consists of a few simple steps.  Note that these steps refer to a Windows 7 based computer, Windows 8 and 10 are similar but may have small differences in procedure.

You can load the GRBL firmware into an Arduino using the Arduino Programming IDE, which you can download from Arduino’s website.  However, this method is more for use by experienced programmers, and is kind of hard to figure out for the layman.  The method presented here is much simpler.

 

GRBL Firmware

First, you need to download the latest GRBL firmware.  At this writing, the current version is 1.1H.  It is available from Github here:

https://github.com/gnea/grbl/releases

The latest version will always be at the top of the list, but scroll down to find the download files. You should see something like grbl_v1.1h.20190825.HEX. Download this to a directory on your computer and remember where you put it.  Make sure you download the .HEX file only, you don’t need the source code. I usually put stuff on the desktop so I can find it, and move it to safe storage later.  You will need to enter the full directory location in the next step.

 

Install the Device Driver for your Arduino

If this is the first time you have connected an Arduino to your computer, you may have to install a device driver for the USB/Serial converter.   Usually this is an automatic process, with your computer running, simply plug in the Arduino USB cable to the computer.  It should automatically detect the converter and search Windows Update for the correct driver.  Note that you must be connected to the internet for this to work.  Once Windows has installed the driver, it will come up with a “Your Device is ready to use” message.  You should be good to go, and use the next section to determine which COM port was assigned to the Arduino.

 

Determine your COM Port

When you plug a USB/Serial device into a computer, Windows will automatically assign it a COM port.  Note that Windows may reassign this to a different COM port if you move the device to a different USB socket.  It may also do this if you replace your Arduino with a new one, because it has a different identifier code.  Sometimes Windows will change the port number on a reboot as well.    If Windows reassigns the COM port, you will have to change the setting in your G-Code Sender program as well in order to talk to your machine.

To determine your Arduino’s COM port:

  1. Windows 7: Click “Start” -> Right click “Computer” -> Select “Manage” -> Select “Device Manager” from left pane.  You can also get to Device Manager through Control Panel and by several other routes.
  2. In the tree, expand “Ports (COM & LPT)
  3. Your Arduino will be the “USB-Serial (Chip#)(COMX)”, where the “X” represents the COM number, for example COM6.
  4. If there are multiple USB/Serial ports, the (Chip#) for the Arduino will be “FTDI” if it is a true Arduino board, or “CH340” if it is a clone board.
 

Download XLoader

XLoader is a small program used specifically to load firmware into ATMEGA microcontrollers like the one on the Arduino.

To flash a GRBL hex to an Arduino:

    1. Download and extract XLoader .  It is a zip file.  Suggest you put it on your desktop.
    2. Make sure the Arduino is plugged into a USB port.  Find the COM port from above.
    3. Open XLoader and select your Arduino’s COM port from the drop down menu on the lower left.
    4. Select the appropriate device from the dropdown list titled “Device“.Normally this will be Duemilanove/Nano(ATMega 328) for the Nano, or Uno(ATMega 328). Note that they have different Baud rates, if you select the wrong one it won’t upload.
    5. Check that XLoader set the correct baud rate for the device: 57600 for Duemilanove/Nano(ATmega 328) or 115200 for Uno(ATmega 328).
    6. Now use the browse button on the top right of the form to browse to your grbl hex file.
    7. Once your Grbl hex file is selected, click “Upload
    8. It should take about 30-40 seconds to upload.  Once “XXXXX bytes Uploaded” appears in the lower left corner, it’s done.
    9. If you get “Upload Failed”, you may have the wrong Baud rate (chip type) or COM Port selected

That’s pretty much it.  The Arduino should now contain the GRBL firmware and respond correctly when connected to a compatible GRBL G-code Sender such as GRBL Panel.