As of August 2020 the site you are on (wiki.newae.com) is deprecated, and content is now at rtfm.newae.com.

Test

From ChipWhisperer Wiki
Revision as of 16:16, 21 March 2017 by Dsevastian (Talk | contribs)

Jump to: navigation, search

AVR Programmer

this si a cool section about AVR Programmer

Right-black-arrow.png

This section was recently updated for ChipWhisperer 5. The old version can be found here: https://wiki.newae.com/V4:CW1173_ChipWhisperer-Lite/AVR_Programmer.

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 = cw.target(scope)

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:

scope.default_setup()

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:

scope.io.tio1 = "serial_tx"
scope.io.tio2 = "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)
note

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
avr_programmer.open()
avr_programmer.find()

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.

tip
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.

Troubleshooting

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.

AVR Programmer

this si a cool section about AVR Programmer

This section was recently updated for ChipWhisperer 5. The old version can be found here: https://wiki.newae.com/V4:CW1173_ChipWhisperer-Lite/AVR_Programmer.

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 = cw.target(scope)

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:

scope.default_setup()

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:

scope.io.tio1 = "serial_tx"
scope.io.tio2 = "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)
note

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
avr_programmer.open()
avr_programmer.find()

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.

tip
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.

Troubleshooting

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.


AVR Programmer

this si a cool section about AVR Programmer

Right-black-arrow.png

This section was recently updated for ChipWhisperer 5. The old version can be found here: https://wiki.newae.com/V4:CW1173_ChipWhisperer-Lite/AVR_Programmer.

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 = cw.target(scope)

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:

scope.default_setup()

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:

scope.io.tio1 = "serial_tx"
scope.io.tio2 = "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)
note

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
avr_programmer.open()
avr_programmer.find()

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.

tip
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.

Troubleshooting

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.

AVR Programmer

this si a cool section about AVR Programmer

This section was recently updated for ChipWhisperer 5. The old version can be found here: https://wiki.newae.com/V4:CW1173_ChipWhisperer-Lite/AVR_Programmer.

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 = cw.target(scope)

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:

scope.default_setup()

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:

scope.io.tio1 = "serial_tx"
scope.io.tio2 = "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)
note

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
avr_programmer.open()
avr_programmer.find()

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.

tip
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.

Troubleshooting

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.


XMEGA Programmer

this si a cool section about XMEGA

Right-black-arrow.png

This section has been recently updated for ChipWhisperer 5. The previous version can be found here: https://wiki.newae.com/V4:CW1173_ChipWhisperer-Lite/XMEGA_Programmer

The XMEGA device programmer requires only two connections to the target: clock (PDIC) and data (PDID). The PDIC line is usually shared with the RESET pin, and the PDID pin is a specific pin on the XMEGA device. See #20-Pin_Connector for details of XMEGA programming pin connections. Once you have the scope setup, the programmer can be accessed through cw.programmers.XMEGAProgrammer:

prog = cw.programmers.XMEGAProgrammer
cw.program_target(scope, prog, "<path to fw hex file>")

XMEGA Programmer

this si a cool section about XMEGA

This section has been recently updated for ChipWhisperer 5. The previous version can be found here: https://wiki.newae.com/V4:CW1173_ChipWhisperer-Lite/XMEGA_Programmer

The XMEGA device programmer requires only two connections to the target: clock (PDIC) and data (PDID). The PDIC line is usually shared with the RESET pin, and the PDID pin is a specific pin on the XMEGA device. See #20-Pin_Connector for details of XMEGA programming pin connections. Once you have the scope setup, the programmer can be accessed through cw.programmers.XMEGAProgrammer:

prog = cw.programmers.XMEGAProgrammer
cw.program_target(scope, prog, "<path to fw hex file>")