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

Changes

Jump to: navigation, search

CW1173 ChipWhisperer-Lite/AVR Programmer

994 bytes added, 19:05, 12 March 2020
no edit summary
{{Warningbox|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).
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 Programming Programmer ====
To access the AVR ProgrammerFirst, select the &quot;CW-Lite AVR Programmer&quot; from setup the pull-down Tools menuChipWhisperer as usual:<syntaxhighlight lang=python>import chipwhisperer as cwscope = cw.scope()target = cw.target(scope)</syntaxhighlight>
[[File:avrprog_menuNext, the AVR programmer can be accessed through the cw.png|image]]programmers.AVRProgrammer object:
Which should give you the AVR Programmer Window<syntaxhighlight lang=python>prog = cw.programmers.AVRProgrammer</syntaxhighlight>==== Programming the Flash ====
==== Clock Source Selection ====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 to use the AVR programmer you may require a valid clock source for the AVR<syntaxhighlight lang=python>scope. It is suggested to select one of the setup scripts default_setup(such as <code>ChipWhisperer-Lite: AES Simple-Serial on ATMega328P)</codesyntaxhighlight>) which will generate a 7.37 MHz clock.
Check if Note that NewAE's Notduino targets have the device is found by pressing transmit and receive pins swapped compared to the &quot;Check Signature&quot; buttonusual targets. The status window will show If you're using one of these targets, swap them using the detected device based on the signature.API:
[[File:avrprog_sigok<syntaxhighlight lang=python>scope.png|image]]io.tio1 = "serial_tx"scope.io.tio2 = "serial_rx"</syntaxhighlight>
If this failsNext, double-check connections, and ensure try programming the clock source to the AVR is suitabledevice by calling <code>cw. Note some errors will appear as part of the main window logprogram_target()</code>:
[[File:avrprog_fail<syntaxhighlight lang=python>cw.png|image]]program_target(scope, prog, "<path to hex file")</syntaxhighlight>
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 &quot;Slow Clock Mode&quot;. In &quot;Slow Clock Mode&quot; 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 &quot;slow clock mode&quot; to program the correct fuse bytes, after which point you will not need to use &quot;slow clock mode&quot;.
 
To enable slow clock mode, call <code>program_target</code> with an additional <code>slow_clock = True</code> parameter:
 
<syntaxhighlight lang=python>
cw.program_target(scope, prog, "<path to hex file", slow_clock=True)
</syntaxhighlight>
<blockquote>'''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 restart call <code>default_setup()</code> again (this will reset the CW-Capture software and run the setup scriptserial pins, so you'll have to swap them again if you're using a Notduino target).
</blockquote>
==== 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:
<syntaxhighlight lang=python>avr_programmer = prog(slow_clock=False) # Press call with slow_clock = True to enable the &quot;Read Fuses&quot; buttonslow clockavr_programmer.scope = scopeavr_programmer.open()avr_programmer.find()</syntaxhighlight> Once that's accomplished, and the values should readFuse() and writeFuse() methods can be populated# Specify used to read and write the new low fuse bits, respectively: <syntaxhighlight lang=python>fuse_vals = avr_programmer.readFuse(<value>)# Hit &quot;Write Fuses&quot;avr_programmer.writeFuse(<value>, <lfuse>)</syntaxhighlight> with <value> corresponding to one of the following: "low", "high", or "extended".
See [http://eleccelerator.com/fusecalc/fusecalc.php?chip=atmega328p an Online Fuse Calculator] to better understand what the values mean.
The low fuse byte must be changed to <code>D0</code> to use the external clock provided by the ChipWhisperer toolchain.
</blockquote>
==== Programming the Flash Troubleshooting ==== Programming the flash is accomplished by selecting the new .hex file in the &quot;Find&quot; menu, and pressing the &quot;Erase/Program/Verify FLASH&quot; button. The &quot;Status&quot; line will show the following information:
* File programmed into device* Time file was last modified (very useful to confirm If you are using changed file run into issues when doing development)* Status of verificationprogramming the AVR, and number of bytes programmed/verifiedtry the following troubleshooting methods:
[[File:avrprog_progok* 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.png|image]]
Approved_users, administrator
366
edits

Navigation menu