web analytics
September 22, 2015

Flashing with ArduinoISP

Disclaimer

Warning: SPI programmers can cause accidental writing to the fuse and lock bits of the microprocessor when the wired connections are not solid. Do not touch the wire connections nor the device while it is being programmed, as you may cause mechanical noise that can brick the device. Fixing this requires replacing the entire microprocessor.

We strongly advise against using ArduinoISP as a programmer. There have been reported cases of microprocessors getting bricked even when following all guidelines. Repairing requires the chip to be replaced, for which you need specialized tools. If you accidentally brick your Phoenard this way, you can send the board to us for repair, but that will be at your own expenses. If you are looking into updating the firmware, please use the toolkit.

Alright, moving on…

Updating using Arduino ISP Programmer

Upload the ‘Arduino as ISP’ example sketch to your Arduino. In this tutorial, we use the Arduino UNO.

  1. Plug the Arduino to be used as programmer into the computer
  2. Make sure to select the right port (tools -> port) for the UNO.
  3. Open the ‘Arduino as ISP’ sketch (file -> examples -> ArduinoISP)
  4. Select the tools -> board ->Arduino UNO
  5. Upload this sketch to the Arduino
  6. Close the Arduino IDE again when upload succeeds

Programmer Connections

bootflash_a bootflash_a

To start out, connect the following pins:

Arduino Side Phoenard Side
Pin 10 Pin RST (Reset)
Pin 11 Pin MOSI
Pin 12 Pin MISO
Pin 13 Pin SCK
GND GND

Flashing the Firmware

The next step is to upload the phoenboot.hex file. Depending on your operating system, different options exist. For Windows, you can use AVRDudess.

After installing AVRDUDESS and launching it, set up the options as follows:

avrdudess_options

  • Programmer: Atmel STK500 Version 1.x firmware
  • Port: Select the port to your Arduino you use as programmer
  • Baud rate: 19200
  • Flash: Locate the downloaded phoenboot.hex file
  • Press ‘Detect’ under the MCU tab to verify our connections
  • Press ‘Program!’ if the MCU was detected. If not detected, check the connections.

Alternatively, execute the following command in your console (cmd.exe) or bash:

avrdude -c stk500v1 -p m2560 -P [port] -b 19200 -e -U flash:w:”path/to/phoenboot.hex”:a

 

Fuses

If you are programming a virgin Microcontroller and the fuses are incorrect, you also have to flash the fuses to the right values. Be aware that AVRDude reports the fuses in reverse order (bug); do not swap the fuses thinking it is meant to be that way. Do not read the fuses in AVRDudess and change them, they are invalid! Wrong fuses can brick your device, so take special care not to use the wrong values. Triple-check them.

  • Low fuse: 0xFF
  • High fuse: 0xD8
  • Extended fuse: 0xFD

You can use AVRDudess, or execute the following command in a console window:

avrdude -c stk500v1 -p m2560 -P [port] -b 19200 -U lfuse:w:0xff:m -U hfuse:w:0xd8:m -U efuse:w:0xfd:m