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
Reset via Programming Interface: Rewrite to use aux module
TODO - see reset via programming interface for now
== Reset via Programming Interface Auxiliary Module ==
The following example targets Auxiliary modules are small pieces of code that can perform some extra functions during the ChipWhisperer-Lite XMEGA targetcapture process. You can modify it for ChipWhisperer-Lite AVR target by replacing <code>XMEGA</code> with <code>AVR</code> in The functions inside these Python modules are run before a capture, before the function callspower measurement is armed, before the measurement is triggered, after a single trace is completed, and after an entire capture is finished. We'll first learn how will use an existing auxiliary module to recreate reset the process of pressing target chip before arming the ''Check Signature'' button via the API. This isnmeasurement so that we don't normally exposed, but we can explore that using have to manually reset the Python Consoledevice.
<ol style="list-style-type: decimal;">
<li><p>Type <code>self<We're going to use the ''Reset AVR/code> into the Python console, the output will look like XMEGA via CW-Lite'' auxiliary module. Let's get an idea of how thismodule works:</p><pre>&gt;&gt;&gt; self&lt;__main__.ChipWhispererCapture object at 0x072F25F8&gt;</pre><p>This tells us that * Navigate to the class type of this opject is auxiliary modules folder (<code>ChipWhispererCapturechipwhisperer\software\chipwhisperer\capture\auxiliary\</code>. We can ) and open the source code for that class, and determine where the &quot;scope&quot; is stored. This takes some effort the first time through, but eventually you would discover there is a <code>selfResetCW1183Read.scopepy</code>in your choice of text editor.</p><p>Type * Find the function definition for <code>self.scoperesetDevice()</code> into the Python console. It contains a line that looks like:</p><pre>&gt;&gt;&gt; self.scope&lt;chipwhispererCWCoreAPI.capturegetInstance().scopesgetScope().OpenADCscopetype.OpenADCInterface object at 0x0D4986C0&gt;cwliteXMEGA.readSignature()</pre><p>Opening * Look for the file <code>chipwhisperer\capture\scopes\OpenADClines where this function gets called.py</code> would tell us You'll find that the function <code>.scopetypetraceArm()</code> is used to store the next level of the interface. We want to reach very far down to get to the AVR/XMEGA programmer interface, so will continue down the rabbit holeuses it like:</p> <pre>&gt;&gt;&gt; resettiming = self.scopefindParam('resettiming').scopetype value()&lt;chipwhispererif resettiming == 'Pre-Arm': self.capture.scopes.OpenADC.OpenADCInterface_NAEUSBChip object at 0x0D5BC4B8&gt;resetDevice()</pre><p>FinallyEffectively, checking this code will read the source for target's signature before we arm the <code>OpenADCInterface_NAEUSBChip</code> class in power measurement. This means that same file gives us this source code:the target will automatically be reset before capturing a power trace.</pli><pre>...code...self.cwliteXMEGA = XMEGAProgrammerDialog(global_mod.main_window)
self<li> Go back to the ChipWhisperer Capture software.xmegaProgramAct = QAction(In the ''Generic Settings'' tab, switch the Auxiliary Module to ''Reset AVR/XMEGA via CW-Lite XMEGA Programmer''.</li><li> Now, selfin the ''Aux Settings'' tab,we can configure our automatic reset. Make sure the settings are: statusTip='Open XMEGA Programmer * Pre-arm delay: roughly 1200 ms* Post-arm delay: the default (ChipWhisperer0 ms) is fine* Reset timing: Pre-Lite Onlyarm (reset the device before we arm the scope)</li><li> Press ''Capture 1''. The target will automatically reset, triggered=selfwith the Safe-o-matic 3000 boot sequence appearing in the console.cwliteXMEGAThen, 1 second later, the program will send the password to the target and record a power trace.show)</li>
self.cwliteAVR = AVRProgrammerDialog(global_mod.main_window)...code...</pre><p>We can finally try reaching out and touching the XMEGA or AVR programmer:</p><pre>&gt;&gt;&gt; self.scope.scopetype.cwliteXMEGA&lt;chipwhisperer.capture.utils.XMEGAProgrammer.XMEGAProgrammerDialog object at 0x0D5BC670&gt;</pre><p>This allows us to touch the XMEGA programmer dialog directly. At this point Now, confirm that you can refer to the file <code>chipwhisperer\capture\utils\XMEGAProgrammer.py</code> to confirm the class interface. Part of this will be the <code>readSignature()</code> function, which we can try running:</p><pre>&gt;&gt;&gt; self.scope.scopetype.cwliteXMEGA.readSignaturedifferent passwords ()</pre><p>Success! You should see the terminal emulator print the startup message, indicating the target was rebooted.</p></li><li><p>Now we need to understand how to force this to be called. This can be done via the ''Auxiliary Modules'', which we used in the previous part to toggle an IO line. Instead we will define one through the command prompt, before finally using it in a custom script.</p><p>At the console, type the following to import some require modules (ignore the &gt;&gt;&gt; which just indicate the console prompt):</p><pre>&gt;&gt;&gt; from time import sleep&gt;&gt;&gt; from chipwhisperer.capture.auxiliary.AuxiliaryTemplate import AuxiliaryTemplate</pre></li><li><p>We will now define a simple <code>reset_device()</code> function. You will do this interactively at the console, the objective being to enter the following chunk of code:</p><pre>def reset_device(): self.scope.scopetype.cwliteXMEGA.readSignature() sleep(0.8)</pre><p>Remember Python is ''whitespace sensitiveTarget Settings'', so you'll have to be careful with indents in use. To being with, simply type <code>def reset_device():</code> at the console and press enter. You'll notice see how the <code>&gt;&gt;&gt;</code> power trace changes to <code>...</code> at the console prompt:</p><blockquote><p>[[File:Consoledotdot.png|image]]</p></blockquote><p>Now you will enter the next two lines. Remember you must insert at least one space before each line, and it must be consistent between the two lines entered. Once you enter the last line, press enter and the <code>...</code> should change back to <code>&gt;&gt;&gt;</code></p><blockquote><p>[[File:Consolespace.png|image]]</p></blockquote></li><li>Check you can run <code>reset_device()</code> at the console and the device resets. If there is an error check you've run the import statements previously and for other typos. Re-run the <code>def reset_device():</code> step if required.</li><li><p>Now we need to define the class which links the function to a step in the capture. To do so, we want to define the following:</p><pre>class resetClass(AuxiliaryTemplate): def traceDone(self): reset_device()</pre><p>Pay very careful attention to the indentation -- when entering via the command line, we need to ensure <code>def traceDone(self):</code> your password has one level of indents0, and <code>reset_device()</code> has additional indent. You can use a single space if you want for one-level1, and two spaces for two-levels for example:</p><pre>&gt;&gt;&gt; class resetClass(AuxiliaryTemplate):2... def traceDone(self):... reset_device()</pre></li><li><p>Finally, generate an object using that class, and confirm it again resets the device:</p><pre>&gt;&gt;&gt; rc = resetClass()&gt;&gt;&gt; rc.traceDone()</pre></li><li><p>Now all that is left is to link this class into the Auxiliary interface. This is done simply with the following call:</p><pre>&gt;&gt;&gt; self.auxChanged(rc)</pre><p><code>auxChanged()</code> is called with the new Auxiliary module to be loaded (or list of modules). The <code>traceDone()</code> method will be called once a single trace is done.</p></li><li>Confirm you can press ''Capture 1'' in the GUI without needing to manually reset the XMEGA target device. Play around with the password to again see the effect of changing password length. In particular, start to consider where you might look for an indicator about how far in the loop you can go? Play around with 0 correct digits, 1 correct digits, etccharacters.</li></ol>
= Scripting Communications =
Approved_users
510
edits

Navigation menu