Firmware and configuration

Installation – Flashing the Firmware

Your Duet will have been supplied with a copy of the RepRap Firmware installed. But upgrades and enhancements will be made available regularly, and you will want to upload or flash these to your Duet.

Check your firmware version

Connect to your Duet board via the Arduino IDE Serial Monitor, or Pronterface, and send the ‘M115’ gcode. The response should be something like:

FIRMWARE_NAME:RepRapFirmware FIRMWARE_VERSION:0.78 ELECTRONICS:Duet (+ Extension) DATE:2014-06-11

Compare the firmware version information from the M115 command above, with the file name of the file in this link, which is on our github page. But DO NOT DOWNLOAD THIS FILE DIRECTLY! This file is the latest binary image of the RepRap Firmware for the Duet. The name of the firmware reflects the version number, eg RepRapFirmware-XXX.bin, where XXX is the version, and may also include the date of the firmware.

If your firmware version is the same as the github version, there is no need to update. If not, read on…

Download the latest firmware

See here for links to firmware binaries.

Required Software

You will need a copy of the Arduino IDE software (you may have already installed this if you followed the ‘commissioning’ instructions). Download and install the latest version, appropriate for you PC, from https://www.arduino.cc/en/Main/Software (currently v1.6.6, as of 1st Dec 2015). You MUST also install support for the ‘Arduino SAM-based boards’ (like the Due and Duet) by going to Tools > Board > Boards Manager.

To upload the firmware to the Duet, an application supplied with the Arduino IDE software called bossac is used. However, this is not installed as standard, but is downloaded and installed when you install support for the ‘Arduino SAM-based boards’ (see above). So make sure you have installed support for the ‘Arduino SAM-based boards’.

Once installed, bossac‘s location will depend on your operating system:

Windows – C:Users[username]AppDataRoamingArduino15packagesarduinotoolsbossac1.6.1-arduinobossac.exe
‘AppData’ is a hidden folder, so to see this you will need to ‘show hidden files, folders and drives’ in the Windows Explorer > Tools > Folder options > Views > Advanced settings.

Ubuntu/Linux – /home/[username]/.arduino15/packages/arduino/tools/bossac/1.6.1-arduino/bossac
‘.arduino15’ is an invisible folder, created in your user ‘home’ folder. Ctrl-h usually shows hidden files in Linux.

Mac – /Users/{username}/Library/Arduino15/packages/arduino/tools/bossac/1.6.1-arduino/bossac
The easiest way to get to it, as the Library folder in Users is usually hidden, is to click on the Finder ‘Go > Go to folder…’ menu option, then type ‘~/Library/’, then follow the above path.

For all operating systems, for updating the firmware, it will be easier if you copy the bossac application, and the firmware .bin file, into an easily accessible folder.

Updating the firmware

Leave the 12V power to your RepRap off, and connect the Duet to your computer with a USB cable. Make sure that the Arduino IDE Serial Monitor or Pronterface are NOT connected to the Duet board. Press the ERASE button on the Duet. Then press the RESET button. Wait a couple of seconds for the Duet board to start up. SANYO DIGITAL CAMERA

Windows

Check that the Duet has been recognised by Windows, by looking in the Device Manager (how to). The Duet should be listed in the ‘Ports (COM & LPT)’ list, as ‘bossac programming device’ if the firmware has been erased. If it’s listed as an ‘Arduino Due’, the firmware has NOT been erased; see the above step. It should also have a COM port assigned. Duet-device-manager-02
 It will be easier if you copy the bossac application (see the ‘Required software’ section above for bossac’s location), and the firmware .bin file, into an easily accessible folder. This example copies them both to a simple C:Temp folder. Duet-temp-folder-03
 Open a Command prompt (How to), then type (without quotes) ‘cd C:Temp’ and press return to change directory (or change directory to wherever you put bossac and the firmware file). Type ‘dir’ and press return to get a directory listing; you should see bossac.exe and the firmware file. Type the following (change XXX to match the firmware name you want to upload):

  bossac.exe -e -w -v -b RepRapFirmware-XXX.bin

And press return to send the command. Bossac will auto-sense the port the Duet is connected to, report the upload/flash progress then tell you that it has verified the process.

 

Mac OS X...

Check that your Duet has been recognised by your Mac. Open the Arduino IDE, and see that it is in the list of ports; it will be something like cu.usbmodemfa131. You can also get this information by sending ‘ls /dev/cu.*’ in a Terminal window for a list of ports.
It will be easier if you copy the bossac application (see the ‘Required software’ section above for bossac’s location), and the firmware .bin file, into an easily accessible folder, eg create a folder on your desktop called ‘flash’, and copy bossac and the firmware .bin file to this.
Open a Terminal window (how to), cd (change directory) to the folder where you put bossac and the RepRapFirmware-XXX.bin file. Then type the following (change XXX to match the firmware name you want to upload):

  ./bossac -e -w -v -b RepRapFirmware-XXX.bin

Send the command. You should see bossac report the upload/flash progress then tell you that it has verified the process.

 

Linux

Check that your Duet has been recognised by Linux. Open the Arduino IDE, and see that it is in the list of ports; it will be something like /dev/ttyACM0. You can also get this information by sending ‘lsusb’ in a Terminal window for a list of ports; if the firmware has been erased, the Duet should report as ‘Atmel Corp. at91sam SAMBA bootloader’. Duet-firmware-upload-02
 It will be easier if you copy the bossac application (see the ‘Required software’ section above for bossac’s location), and the firmware .bin file, (from  into an easily accessible folder, eg create a folder on your desktop called ‘flash’, and copy the bossac and the firmware .bin file to this.
 Open a terminal windows (xterm, gnome-terminal etc.) and cd (change directory) to the folder where you put bossacand theRepRapFirmware-XXX.bin file. Then type the following (change XXX to match the firmware name you want to upload):

  ./bossac -e -w -v -b RepRapFirmware-XXX.bin

Send the command. You should see bossac report the upload/flash progress then tell you that it has verified the process.

If it doesn’t work, check the error message. It may be you are running it from the wrong directory (eg ‘command not found’ or ‘no such file or directory’), or the firmware file name is wrong (‘no such file or directory’), or the command has been input incorrectly (‘bossac: invalid option’) or you haven’t waited quite long enough for the Duet to stabilise after pressing ‘erase’ and ‘reset’ (‘Auto scan for device failed’). Also, press ‘erase’ and ‘reset’ on the Duet again, and wait a little longer.

IMPORTANT: Update the SD Card files!

Finally, you need to keep the files on the SD card ON THE SAME VERSION as the firmware you just updated to. Copy the contents of the SD-Image folder from firmware folder (the .zip file you downloaded) to the root of your SD Card. Rename the sys-[printer-version] folder to ‘sys’, where [printer-version] is your printer and version (eg Ormerod 1 or Ormerod 2), as you did in the Commissioning instructions. If you have created a custom config.g file on your SD Card, copy them off the card first. Then copy the standard new config.g file to keep a backup, and edit it to reflect your custom settings for things such as network settings, bed probe points and any other custom settings.

SD Files

The Duet needs to store RepRap Firmware configuration files on an micro SD card. It needs those files to be present all the time that the firmware is running, so don’t unplug the SD card while power is applied, either from the RepRap’s main power supply, or just from the USB.

Your Duet should have been supplied with a micro SD card. You will need to copy the configuration files to this. You will also need to set your network addresses in the configuration files, if you plan to access the printer via the ethernet port.

Take the SD card, put it in a computer adapter, and plug it into your computer.

Download the RepRap Firmware files as described here. Use the Download Zip button (with the little cloud and arrow) on that page to download all the files.

There is a folder in the Github repository you downloaded called SD-Image-[printer-version]. It has three sub-folders:

Folders

You can put any GCode files you want to print in the gcodes folder. For the moment file names are restricted to 8.3 format. This restriction will be removed in a future upgrade.

Remove any old versions of these folders from the SD card, then copy the gcodes, sys, and www folders onto it.

In the sys folder on the SD card there is a file called config.g. This special G Code file is run whenever the RepRap Firmware is restarted. It is described in detail below. For the moment you just need to set appropriate values in it for your network. Open a text editor (such as gedit or Notepad) and read in the file config.g. Near the top are four lines like this:

M540 P0xBE:0xEF:0xDE:0xAD:0xFE:0xED ; Set the MAC address
M552 P192.168.1.14; Set the IP address
M553 P255.255.255.0; Set netmask
M554 P192.168.1.1; Set the gateway

Unless you run multiple Duets on one network you should not need to change the MAC address. On the following lines change the numbers after the capital letter “P” to the values for your network. If you don’t know these, your network administrator will be able to tell you. Save the edited file.

Unmount or eject the SD card and its adapter from your computer. If it asks you if you want to erase any deleted files, say yes.

Put the SD card in your Duet’s SD card slot. It has a bistable click action – push it in and it will click in. To get it out, push it again and it will spring out. A short length of RepRap 1.75mm diameter filament makes a good tool to push with.

The configuration file

As has already been mentioned, RepRap Firmware can run a configuration file when it starts to set it and your RepRap up in the way you want. This is the file config.g in the sys folder on the SD card. This is an ordinary file of G Codes, but it is saved in a separate folder so that it can’t be deleted by accident.

The contents of config.g will look something like this:

; Configuration file for RepRap Ormerod 2
; RepRapPro Ltd
;
M111 S0                             ; Debug off
M550 PMy RepRapPro Ormerod 2        ; Machine name (can be anything you like)
M551 Preprap                        ; Machine password (currently not used)
M540 P0xBE:0xEF:0xDE:0xAD:0xFE:0xED ; MAC Address
M552 P192.168.1.14                  ; IP address
M553 P255.255.255.0                 ; Netmask
M554 P192.168.1.1                   ; Gateway
M555 P2                             ; Set output to look like Marlin
G21                                 ; Work in millimetres
G90                                 ; Send absolute coordinates...
M83                                 ; ...but relative extruder moves
M906 X800 Y1000 Z800 E800           ; Set motor currents (mA)
M563 P1 D0 H1                       ; Define tool 1
G10 P1 S0 R0                        ; Set tool 1 operating and standby temperatures
M92 E420                            ; Set extruder steps per mm
M558 P2                             ; Use a modulated Z probe
G31 Z2.5 P370                       ; Set the probe height and threshold
M557 P0 X60 Y0                      ; Four...
M557 P1 X60 Y165                    ; ...probe points...
M557 P2 X222 Y165                   ; ...for bed...
M557 P3 X222 Y0                     ; ...levelling
M556 S78 X0 Y0 Z0                   ; Put your axis compensation here
M201 X800 Y800 Z15 E1000            ; Accelerations (mm/s^2)
M203 X15000 Y15000 Z100 E3600       ; Maximum speeds (mm/min)
M566 X600 Y600 Z30 E20              ; Minimum speeds mm/minute

Anything including and after a “;” is a comment and will be ignored. As you can see you can give your machine any name you like, and any password. There is a complete list of all the RepRap G, M and T codes on the RepRap website here. RepRap Firmware does not (nor does it need to) implement them all, but if you send it one that is not implemented it will output a short error message on its USB connection, which you can see in the Pronterface monitor window.

You can edit config.g with an ordinary text editor (gedit, Notepad etc.), then upload it using Pronterface as described below.

Generally speaking, it is a bad idea to put anything in config.g that will cause the RepRap machine to move, or its heaters to heat up. This is because it will do this every time it is switched on or rebooted.. Moving and heating G Codes are much better put at the head of individual G Code files for printing things, as described here.

Other sys files

RepRapFirmware allows subprograms or macros to be programmed and placed in the sys folder. There are standard ones in there for doing things like homing the axes, but you can write your own too. Simply place a GCode file in the sys folder called, say, mymacro.g. You can then run it from Pronterface or the web interface or from within a GCode file by giving the command:

M98 Pmymacro.g

Here is the macro that homes the X axis as an example, with comments:

G91 ; set movements relative
G1 Z5 F200 ; move upwards 5mm at 200 mm/min to make sure we don't hit anything
G90 ; set movements absolute
G1 X-240 F2000 S1 ; Move X a long way negative while checking the endstop
G92 X0 ; The endstop will have been hit.  Set the X coordinate to 0
G1 X3 F200 ; Move a little away from the endstop more slowly
G1 X-30 S1 ; Approach the endstop more slowly to get a more accurate 0
G92 X0 ; Set the X coordiante to 0
G91 ; set movements relative
G1 Z-5 F200 ; Go down 5mm to reset the upward movement at the beginning