As of August 2020 the site you are on ( is deprecated, and content is now at

CW1173 ChipWhisperer-Lite/AVR Programmer

From ChipWhisperer Wiki
Jump to: navigation, search

This section was recently updated for ChipWhisperer 5. The old version can be found here:

The CW1173 and CW1200 have built-in support for programming either Atmel AVR or Atmel XMEGA device. This is designed to allow you to program our target boards (including the built-in XMEGA target).

Note this programmer is fairly simple, and does not provide all the features of a stand-alone programmer.

The AVR device programmer requires four connections to the target: RESET, MOSI, MISO, SCK. See #20-Pin_Connector for details of AVR programming pin connections.

Accessing the Programmer

First, setup the ChipWhisperer as usual:

import chipwhisperer as cw
scope = cw.scope()
target =

Next, the AVR programmer can be accessed through the cw.programmers.AVRProgrammer object:

prog = cw.programmers.AVRProgrammer

Programming the Flash

Note to use the AVR programmer you may require a valid clock source for the AVR. It is suggested to use the default ChipWhisperer setup, which will generate a 7.37MHz clock:


Note that NewAE's Notduino targets have the transmit and receive pins swapped compared to the usual targets. If you're using one of these targets, swap them using the API: = "serial_tx" = "serial_rx"

Next, try programming the device by calling cw.program_target():

cw.program_target(scope, prog, "<path to hex file")

The default SPI data rate for the programmer is too fast for devices which are running slower than 2 MHz. If programming a device with a clock source slower than 2 MHz, you will need to enable the "Slow Clock Mode". In "Slow Clock Mode" the entire SAM3U and FPGA clock is changed from 96 MHz to 12 MHz. Note the default fuse bytes for a virgin ATMega328P result in a 1 MHz clock, so you will need to use "slow clock mode" to program the correct fuse bytes, after which point you will not need to use "slow clock mode".

To enable slow clock mode, call program_target with an additional slow_clock = True parameter:

cw.program_target(scope, prog, "<path to hex file", slow_clock=True)

The 'slow clock mode' is used to provide a slower SPI clock than would otherwise be possible. When switching into 'slow clock mode' it will cause all DCM blocks in the FPGA to become unlocked. You will need to reset the DCM blocks, or simply call default_setup() again (this will reset the serial pins, so you'll have to swap them again if you're using a Notduino target).

Programming the Fuses

By default the AVR programmer allows you to modify the LOW fuse byte only, as this byte controls the clock source selection. To change the value of the fuse byte, you'll need to manually setup the programmer:

avr_programmer = prog(slow_clock=False) #call with slow_clock = True to enable the slow clock
avr_programmer.scope = scope

Once that's accomplished, the readFuse() and writeFuse() methods can be used to read and write the fuse bits, respectively:

fuse_vals = avr_programmer.readFuse(<value>)
avr_programmer.writeFuse(<value>, <lfuse>)

with <value> corresponding to one of the following: "low", "high", or "extended".

See an Online Fuse Calculator to better understand what the values mean.

If programming a virgin ATMega328P device, the default low-fuse value of 62 results in the internal 8 MHz oscillator being divided down to 1 MHz. Any external clock is ignored.

The low fuse byte must be changed to D0 to use the external clock provided by the ChipWhisperer toolchain.


If you run into issues when programming the AVR, try the following troubleshooting methods:

  • Ensure the ChipWhisperer is outputting a clock if the target requires one.
  • Ensure you have the serial pins the right way around
  • Ensure the fuse bits are set correctly.