gocw

package module
v0.0.0-...-c04bd44 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 1, 2019 License: Apache-2.0 Imports: 19 Imported by: 0

README

GO - ChipWhisperer

About

ChipWhisperer is an open platform for embedded hardware security research. CW was developed by Colin O'flynn.

CWLite

gocw is a re-implementation of CW software stack, written in go.

gocw main features:

  • Clean interface to CW capture device.
  • Self contained flash programmers for XMEGA and STM32F targets.
  • Web based UI to view captured power traces.
  • Efficient implementation of several power-analysis algorithms (DPA/CPA/Templates) using gonum.

Setup

  1. Get external git repositories:
$ git submodule init
$ git submodule update
  1. Get package dependencies:
$ go get -d ./...
  1. Generate enum strings, mocks, static file resources:
$ go get -u golang.org/x/tools/cmd/stringer
$ go get -u github.com/omeid/go-resources/cmd/resources
$ go get -u github.com/golang/mock/gomock
$ go install github.com/golang/mock/mockgen
$ go generate ./hardware ./...
$ go test github.com/google/gocw
  1. Build firmware files. See CW wiki for information on how to install the required toolchains.
$ mkdir build
$ cd build

# For STM32 targets run the following:
build$ PLATFORM=CWLITEARM cmake ..

# For XMEGA targets run the following:
build$ PLATFORM=CWLITEXMEGA cmake ..

build$ make

Smoke Tests

The tests under tests/ are e2e integration tests that verify gocw stack is working properly. Each test programs the target, sends requests over the serial based communication protocol, and verifies the firmware returns the expected output.

To run the tests, plugin CW device, and run:

$ go test ./tests/simple_serial_smoke_test.go -count 1 -v
$ go test ./tests/aes_smoke_test.go -count 1 -v
$ go test ./tests/ecdh_smoke_test.go -count 1 -v

Power Analysis Process

The following demonstrates how to use gocw to mount a correlation power analysis (CPA) on the first round of AES-128 running on the target device.

  1. Program the target device.
$ go run cmd/program.go -logtostderr -firmware build/firmware/tiny_aes.hex
  1. Capture 50 traces, 5000 samples per trace, starting from offset 0 from the trigger:
$ go run cmd/capture.go -logtostderr \
  -traces 50 -samples 5000 -offset 0 -output captures/aes_t50_s5000.json.gz
  1. Launch Web UI to view the captures:
$ go run viewer/server.go -port 8080 -dir captures

Browse to http://localhost:8080, and examine the power trace:

Main viewer window

Load new traces by clicking on the rows in the traces window:

Multiple traces

Zoom in by selecting a samples time region:

Trace selection

Zoomed in

The web UI monitors the captures directory for changes. We can run the server in the background go run viewer/server.go&, and new capture files will automatically be displayed on the captures window.

Captures window

  1. Run correlation power analysis to recover the key:
$ go run cmd/attack_sbox_cpa.go -logtostderr -input captures/aes_t50_s5000.json.gz
...attack_sbox_cpa.go:113] Loaded capture with 50 traces / 5000 samples per trace
...attack_sbox_cpa.go:165] Fully recovered key: 2b7e151628aed2a6abf7158809cf4f3c

Implemented Attacks

  • Correlation Power Analysis attacks the SBOX lookup of the first round of AES-128. Attack fully recovers the key from ~50 traces.

  • Differential Power Analysis attacks the SBOX lookup of the first round of AES-128. Attack fully recovers the key from ~500 traces.

  • ECDH Template Attack builds a power trace classifier that identifies when a EC multiplication operation resulted with a zero-coordinate point. Classifier successfully identifies traces in the validation set from training from ~150 traces.

Supported Hardware

gocw was only tested on ChipWhisperer-lite with XMEGA and STM32F targets. Contributions for additional hardware support are welcome.

Disclaimer

This is not an official Google product (experimental or otherwise), it is just code that happens to be owned by Google.

Documentation

Overview

Analog-Digital-Converter (OpenADC). Implements AdcInterface.

Analog-Digital-Converter (OpenADC) interface.

Collects power trace measurements.

FPGA interface.

External memory interface.

simple-serial protocol.

Serial USART interface.

Provides low-level interface for ChipWhisperer USB device. Based on chipwhisperer/software/chipwhisperer/hardware/naeusb/naeusb.py. Implementation is hard-coded for ChipWhisperer-Lite hardware.

Index

Constants

This section is empty.

Variables

View Source
var AdcSrcClkGenX1ViaDcm = AdcSrcTuple{
	AdcSrcDcm, 1, DcmInputClkGen,
}
View Source
var AdcSrcClkGenX4ViaDcm = AdcSrcTuple{
	AdcSrcDcm, 4, DcmInputClkGen,
}
View Source
var AdcSrcExtClkDirect = AdcSrcTuple{
	AdcSrcExtClk, 4, DcmInputClkGen,
}

Predefined ADC clock values

View Source
var AdcSrcExtClkX1ViaDcm = AdcSrcTuple{
	AdcSrcDcm, 1, DcmInputExtClk,
}
View Source
var AdcSrcExtClkX4ViaDcm = AdcSrcTuple{
	AdcSrcDcm, 4, DcmInputExtClk,
}

Functions

This section is empty.

Types

type Adc

type Adc struct {
	// contains filtered or unexported fields
}

func NewAdc

func NewAdc(fpga *Fpga) (*Adc, error)

func (*Adc) ActiveCount

func (c *Adc) ActiveCount() uint32

func (*Adc) AdcClockSource

func (c *Adc) AdcClockSource() AdcSrcTuple

Clock settings.

func (*Adc) AdcFreq

func (c *Adc) AdcFreq() uint32

func (*Adc) AdcSampleRate

func (c *Adc) AdcSampleRate() uint32

ADC Sample Rate. Takes account of decimation factor (if set).

func (*Adc) ClkGenDcmLocked

func (c *Adc) ClkGenDcmLocked() bool

func (*Adc) ClkGenInputSource

func (c *Adc) ClkGenInputSource() ClkGenInputSrc

func (*Adc) ClkGenOutputFreq

func (c *Adc) ClkGenOutputFreq() uint32

func (*Adc) Close

func (c *Adc) Close() error

func (*Adc) DcmLocked

func (c *Adc) DcmLocked() bool

func (*Adc) DownsampleFactor

func (c *Adc) DownsampleFactor() uint16

func (*Adc) Error

func (c *Adc) Error() error

func (*Adc) ExtClockFreq

func (c *Adc) ExtClockFreq() uint32

func (*Adc) FreqCounter

func (c *Adc) FreqCounter() uint32

func (*Adc) FreqCounterSource

func (c *Adc) FreqCounterSource() FreqCounterSrc

func (*Adc) Gain

func (c *Adc) Gain() uint8

func (*Adc) GainMode

func (c *Adc) GainMode() GainMode

Gain settings.

func (*Adc) Hs2

func (c *Adc) Hs2() Hs2Mode

func (*Adc) MaxSamples

func (c *Adc) MaxSamples() uint32

func (*Adc) NRST

func (c *Adc) NRST() GpioMode

func (*Adc) PDIC

func (c *Adc) PDIC() GpioMode

func (*Adc) PDID

func (c *Adc) PDID() GpioMode

func (*Adc) PreTriggerSamples

func (c *Adc) PreTriggerSamples() uint32

func (*Adc) ProcessTraceData

func (c *Adc) ProcessTraceData(data []byte) []float64

Converts encoded data samples to float measurements. Exported for testing.

func (*Adc) SetAdcClockSource

func (c *Adc) SetAdcClockSource(src AdcSrcTuple)

func (*Adc) SetArmOff

func (c *Adc) SetArmOff()

func (*Adc) SetArmOn

func (c *Adc) SetArmOn()

Capture settings.

func (*Adc) SetClkGenInputSource

func (c *Adc) SetClkGenInputSource(src ClkGenInputSrc)

func (*Adc) SetClkGenOutputFreq

func (c *Adc) SetClkGenOutputFreq(freq uint32)

func (*Adc) SetDownsampleFactor

func (c *Adc) SetDownsampleFactor(factor uint16)

func (*Adc) SetExtClockFreq

func (c *Adc) SetExtClockFreq(freq uint32)

func (*Adc) SetFreqCounterSource

func (c *Adc) SetFreqCounterSource(src FreqCounterSrc)

func (*Adc) SetGain

func (c *Adc) SetGain(gain uint8)

func (*Adc) SetGainMode

func (c *Adc) SetGainMode(mode GainMode)

func (*Adc) SetHs2

func (c *Adc) SetHs2(mode Hs2Mode)

func (*Adc) SetNRST

func (c *Adc) SetNRST(mode GpioMode)

func (*Adc) SetPDIC

func (c *Adc) SetPDIC(mode GpioMode)

func (*Adc) SetPDID

func (c *Adc) SetPDID(mode GpioMode)

func (*Adc) SetPreTriggerSamples

func (c *Adc) SetPreTriggerSamples(samples uint32)

func (*Adc) SetTargetIo1

func (c *Adc) SetTargetIo1(mode TargetIoMode)

func (*Adc) SetTargetIo2

func (c *Adc) SetTargetIo2(mode TargetIoMode)

func (*Adc) SetTotalSamples

func (c *Adc) SetTotalSamples(samples uint32)

func (*Adc) SetTriggerMode

func (c *Adc) SetTriggerMode(mode TriggerMode)

func (*Adc) SetTriggerOffset

func (c *Adc) SetTriggerOffset(offset uint32)

func (*Adc) SetTriggerTargetIoPin

func (c *Adc) SetTriggerTargetIoPin(pin TriggerTargetIoPin)

func (*Adc) SysFreq

func (c *Adc) SysFreq() uint32

func (*Adc) TargetIo1

func (c *Adc) TargetIo1() TargetIoMode

GPIO settings.

func (*Adc) TargetIo2

func (c *Adc) TargetIo2() TargetIoMode

func (*Adc) TotalSamples

func (c *Adc) TotalSamples() uint32

func (*Adc) TraceData

func (c *Adc) TraceData() []float64

func (*Adc) TriggerMode

func (c *Adc) TriggerMode() TriggerMode

func (*Adc) TriggerOffset

func (c *Adc) TriggerOffset() uint32

func (*Adc) TriggerPinState

func (c *Adc) TriggerPinState() bool

Base trigger settings.

func (*Adc) TriggerTargetIoPins

func (c *Adc) TriggerTargetIoPins() []TriggerTargetIoPin

TODO(cfir): add boolean operations support.

func (*Adc) Version

func (c *Adc) Version() HwVersion

Hardware information.

func (*Adc) WaitForTigger

func (c *Adc) WaitForTigger() bool

type AdcInterface

type AdcInterface interface {
	io.Closer
	Error() error
	//
	// Hardware information.
	//
	Version() HwVersion
	SysFreq() uint32
	MaxSamples() uint32
	//
	// Gain settings.
	//
	GainMode() GainMode
	// Sets the AD8331 Low Noise Amplifier into to "High" or \"Low\" gain mode.
	// Low mode ranges from -4.5dB to +43.5dB, and High mode ranges from +7.5dB to +55.5dB.
	// Better performance is found using the "High" gain mode typically.
	SetGainMode(mode GainMode)
	Gain() uint8
	// Sets the AD8331 gain value.
	// This is a unitless number which ranges from 0 (minimum) to 78 (maximum).
	// The resulting gain in dB is given in the "calculated" output.
	SetGain(gain uint8)
	// Gives the status of the digital signal being used as the trigger signal,
	// either high or low.
	TriggerPinState() bool
	// When using a digital system, sets the trigger mode:
	//  =============== ==============================
	//  Mode            Description
	//  =============== ==============================
	//  Rising Edge     Trigger on rising edge only.
	//  Falling Edge    Trigger on falling edge only.
	//  Low             Trigger when line is "low".
	//  High            Trigger when line is "high".
	//  =============== ==============================
	// Note the "Trigger Mode" should be set to "Rising Edge" if using either
	// the "SAD Trigger" or "IO Trigger" modes.
	// If using STREAM mode (CW-Pro only), the trigger should use a rising or
	// falling edge. Using a constant level is possible, but normally requires
	// additional delay added via "offset" (see stream mode help for details).
	TriggerMode() TriggerMode
	SetTriggerMode(mode TriggerMode)
	// Delays this many samples after the trigger event before recording samples.
	// Based on the ADC clock cycles. If using a 4x mode for example, an offset of "1000"
	// would mean we skip 250 cycles of the target device.
	TriggerOffset() uint32
	SetTriggerOffset(offset uint32)
	// Record a certain number of samples before the main samples are captured.
	// If "offset" is set to 0, this means recording samples BEFORE the trigger event.
	PreTriggerSamples() uint32
	SetPreTriggerSamples(samples uint32)
	// Total number of samples to record. Note the capture system has an upper
	// limit. Older FPGA bitstreams had a lower limit of about 256 samples.
	// For the CW-Lite/Pro, the current lower limit is 128 samples due to interactions with
	// the SAD trigger module.
	TotalSamples() uint32
	SetTotalSamples(samples uint32)
	// Downsamples incomming ADC data by throwing away the specified number of
	// samples between captures. Synchronous to the trigger so presample
	// mode is DISABLED when this value is greater than 1.
	DownsampleFactor() uint16
	SetDownsampleFactor(factor uint16)
	// Measures number of ADC clock cycles during which the trigger was active.
	// If trigger toggles more than once this may not be valid.`,
	ActiveCount() uint32
	// The ADC sample clock is generated from this source.
	// Options are either an external input (which input set elsewhere) or an internal
	// clock generator. Details of each option:
	// =================== ====================== =================== ===============
	//  Name                Description            Input Freq Range   Fine Phase Adj.
	// =================== ====================== =================== ===============
	//  EXCLK Direct       Connects sample clock     1-105 MHz            NO
	//                     external pin directly.
	//  EXTCLK xN via DCM  Takes external pin,       5-105 MHz (x1)       YES
	//                     multiplies frequency      5-26.25 MHz (x4)
	//                     xN and feeds to ADC.
	//  CLKGEN xN via DCM  Multiples CLKGEN by       5-105 MHz (x1)       YES
	//                     xN and feeds to ADC.      5-26.25 MHz (x4)
	// =================== ====================== =================== ===============
	AdcClockSource() AdcSrcTuple
	SetAdcClockSource(src AdcSrcTuple)
	AdcFreq() uint32
	// ADC Sample Rate. Takes account of decimation factor (if set).
	AdcSampleRate() uint32
	DcmLocked() bool
	// Freq Counter: Frequency of clock measured on EXTCLOCK pin in Hz.
	FreqCounter() uint32
	FreqCounterSource() FreqCounterSrc
	SetFreqCounterSource(src FreqCounterSrc)
	ClkGenInputSource() ClkGenInputSrc
	SetClkGenInputSource(src ClkGenInputSrc)
	// The input frequency from the EXTCLK source in Hz.
	//
	// This value is used to help calculate the correct CLKGEN settings to
	// obtain a desired output frequency when using EXTCLK as CLKGEN input.
	// It is not a frequency counter - it is only helpful if the EXTCLK
	// frequency is already known.
	//
	// Getter: Return the last set EXTCLK frequency in MHz (int)
	//
	// Setter: Update the EXTCLK frequency
	ExtClockFreq() uint32
	SetExtClockFreq(freq uint32)
	// CLKGEN output frequency in Hz.
	// The CLKGEN module takes the input source and multiplies/divides it
	// to get a faster or slower clock as desired.
	//
	// Getter:
	//   Return the current calculated CLKGEN output frequency in Hz
	//   (float). Note that this is the theoretical frequency - use the
	//   freq counter to determine the actual output.
	//
	// Setter:
	//   Attempt to set a new CLKGEN frequency in Hz. When this value is
	//   set, all possible DCM multiply/divide settings are tested to find
	//   which is closest to the desired output speed. If EXTCLK is the
	//   CLKGEN source, the EXTCLK frequency must be properly set for this
	//   to work. Also, both DCMs are reset.
	ClkGenOutputFreq() uint32
	SetClkGenOutputFreq(freq uint32)
	ClkGenDcmLocked() bool
	// The logical input into the trigger module.
	//
	// The trigger module uses some combination of the scope's I/O pins to
	// produce a single value, which it uses for edge/level detection or UART
	// triggers. This trigger output can combine 5 pins using one of 3
	// different boolean operations.
	//
	TriggerTargetIoPins() []TriggerTargetIoPin
	SetTriggerTargetIoPin(pin TriggerTargetIoPin)
	//
	// GPIO settings.
	//
	// Thr function of the Target IO1 pin.
	TargetIo1() TargetIoMode
	SetTargetIo1(mode TargetIoMode)
	// Thr function of the Target IO2 pin.
	TargetIo2() TargetIoMode
	SetTargetIo2(mode TargetIoMode)
	// Special GPIO: NRST
	NRST() GpioMode
	SetNRST(mode GpioMode)
	// Special GPIO: PDIC
	PDIC() GpioMode
	SetPDIC(mode GpioMode)
	// Special GPIO: PDID
	PDID() GpioMode
	SetPDID(mode GpioMode)
	// The clock signal routed to the HS2 high speed output pin.
	Hs2() Hs2Mode
	SetHs2(mode Hs2Mode)
	//
	// Capture settings.
	//
	SetArmOn()
	SetArmOff()
	WaitForTigger() bool
	TraceData() []float64
}

type AdcSrc

type AdcSrc int
const (
	AdcSrcDcm    AdcSrc = iota
	AdcSrcExtClk AdcSrc = iota
)

type AdcSrcTuple

type AdcSrcTuple struct {
	AdcSrc   AdcSrc
	DcmOut   int
	DcmInput DcmInput
}

type Address

type Address uint32

type AddressBlock

type AddressBlock struct {
	Dlen uint32
	Addr uint32
}

type AdvClkSettings

type AdvClkSettings struct {
	SrcAndStatus uint8
	Mul          uint8
	Div          uint8
	ClkGenFlags  uint8
}

type BaudRate

type BaudRate uint32
const (
	BaudRateLow  BaudRate = 38400
	BaudRateHigh BaudRate = 115200
)

type Capture

type Capture []Trace

func LoadCapture

func LoadCapture(filename string) (Capture, error)

Loads capture from file.

func LoadCaptureIo

func LoadCaptureIo(src io.Reader) (Capture, error)

Exported for testing.

func NewCapture

func NewCapture(key []byte, ptGen PtGen, numSamples, numTraces, offset int) (Capture, error)

Captures a set traces. Retries on transient errors.

func (Capture) SamplesMatrix

func (c Capture) SamplesMatrix() mat.Matrix

Collects all samples in a single m (#traces) by n (#samples) matrix.

_         _

| -- T1 -- | | -- T2 -- | | -- .. -- | | -- TM -- | |_ _|

func (Capture) Save

func (c Capture) Save(filename string) error

func (Capture) SaveIo

func (c Capture) SaveIo(dst io.Writer) error

Exported for testing.

type ClkGenInputSrc

type ClkGenInputSrc int
const (
	ClkGenInputSystem ClkGenInputSrc = iota
	ClkGenInputExtClk ClkGenInputSrc = iota
)

type DataBits

type DataBits uint8
const (
	DataBitsOneByte DataBits = 8
)

type DcmInput

type DcmInput int
const (
	DcmInputClkGen DcmInput = iota
	DcmInputExtClk DcmInput = iota
)

type Fpga

type Fpga struct {
	Mem *Memory
	// contains filtered or unexported fields
}

func NewFpga

func NewFpga(dev UsbDeviceInterface) (*Fpga, error)

func (*Fpga) IsProgrammed

func (f *Fpga) IsProgrammed() (bool, error)

func (*Fpga) Program

func (f *Fpga) Program(bitstream io.Reader) error

func (*Fpga) ProgramCwlite

func (f *Fpga) ProgramCwlite() error

type FreqCounterSrc

type FreqCounterSrc int
const (
	FreqCounterExtClkInput  FreqCounterSrc = iota
	FreqCounterClkGenOutput FreqCounterSrc = iota
)

type FwVersion

type FwVersion struct {
	Major uint8
	Minor uint8
	Debug uint8
}

type GainMode

type GainMode int
const (
	GainModeHigh GainMode = iota
	GainModeLow  GainMode = iota
)

type GpioMode

type GpioMode int
const (
	GpioLow      GpioMode = iota
	GpioHigh     GpioMode = iota
	GpioDisabled GpioMode = iota
)

type Hs2Mode

type Hs2Mode int
const (
	Hs2ModeDisabled Hs2Mode = iota
	Hs2ModeClkGen   Hs2Mode = iota
	Hs2ModeGlitch   Hs2Mode = iota
)

type HwType

type HwType int
const (
	HwUnknown               HwType = iota
	HwLx9MicroBoard         HwType = iota
	HwSaseboW               HwType = iota
	HwChipWhispererRev2Lx25 HwType = iota
	HwReserved              HwType = iota
	HwZedBoard              HwType = iota
	HwPapilioPro            HwType = iota
	HwSakuraG               HwType = iota
	HwChipWhispererLite     HwType = iota
	HwChipWhispererCw1200   HwType = iota
)

type HwVersion

type HwVersion struct {
	RegVersion uint8
	HwType     HwType
	HwVersion  uint8
}

type Memory

type Memory struct {
	// contains filtered or unexported fields
}

func NewMemory

func NewMemory(dev UsbDeviceInterface) *Memory

func (*Memory) Read

func (m *Memory) Read(addr Address, data interface{}) error

func (*Memory) Write

func (m *Memory) Write(addr Address, data interface{}, validate bool, mask interface{}) error

type Parity

type Parity uint8
const (
	ParityNone  Parity = 0
	ParityOdd   Parity = 1
	ParityEven  Parity = 2
	ParityMark  Parity = 3
	ParitySpace Parity = 4
)

type PtGen

type PtGen func() ([]byte, error)

func RandGen

func RandGen(numBytes int) PtGen

Generates random plaintext for each trace.

type Request

type Request uint8
const (
	ReqMemReadBulk  Request = 0x10
	ReqMemWriteBulk Request = 0x11
	ReqMemReadCtrl  Request = 0x12
	ReqMemWriteCtrl Request = 0x13
	ReqFpgaStatus   Request = 0x15
	ReqFpgaProgram  Request = 0x16
	ReqFwVersion    Request = 0x17
	ReqUsart0Data   Request = 0x1a
	ReqUsart0Config Request = 0x1b
	ReqXmegaProgram Request = 0x20
)

type SimpleSerial

type SimpleSerial struct {
	// contains filtered or unexported fields
}

func NewSimpleSerial

func NewSimpleSerial(usart UsartInterface) (*SimpleSerial, error)

func (*SimpleSerial) Response

func (s *SimpleSerial) Response() ([]byte, error)

Reads response.

func (*SimpleSerial) ResponseLine

func (s *SimpleSerial) ResponseLine() (string, error)

Reads response line.

func (*SimpleSerial) WriteKey

func (s *SimpleSerial) WriteKey(k []byte) error

func (*SimpleSerial) WritePlaintext

func (s *SimpleSerial) WritePlaintext(p []byte) error

type StopBits

type StopBits uint8
const (
	StopBitsOne        StopBits = 0
	StopBitsOneAndHalf StopBits = 1
	StopBitsTwo        StopBits = 2
)

type TargetIoMode

type TargetIoMode int
const (
	TargetIoModeSerialRx     TargetIoMode = iota
	TargetIoModeSerialTx     TargetIoMode = iota
	TargetIoModeHighZ        TargetIoMode = iota
	TargetIoModeGpioLow      TargetIoMode = iota
	TargetIoModeGpioHigh     TargetIoMode = iota
	TargetIoModeGpioDisabled TargetIoMode = iota
)

type Trace

type Trace struct {
	Key               []byte    `json:"k"`
	Pt                []byte    `json:"pt"`
	Ct                []byte    `json:"ct"`
	PowerMeasurements []float64 `json:"pm"`
}

type TriggerMode

type TriggerMode int
const (
	TriggerModeRisingEdge  TriggerMode = iota
	TriggerModeFallingEdge TriggerMode = iota
	TriggerModeLow         TriggerMode = iota
	TriggerModeHigh        TriggerMode = iota
)

type TriggerTargetIoPin

type TriggerTargetIoPin int
const (
	TriggerTargetIoPin1 TriggerTargetIoPin = iota
	TriggerTargetIoPin2 TriggerTargetIoPin = iota
	TriggerTargetIoPin3 TriggerTargetIoPin = iota
	TriggerTargetIoPin4 TriggerTargetIoPin = iota
)

type Usart

type Usart struct {
	// contains filtered or unexported fields
}

func NewUsart

func NewUsart(dev UsbDeviceInterface, conf *UsartConfig) (*Usart, error)

func (*Usart) Flush

func (u *Usart) Flush() (err error)

func (*Usart) Read

func (u *Usart) Read(p []byte) (n int, err error)

func (*Usart) SetTimeout

func (u *Usart) SetTimeout(timeout time.Duration)

func (*Usart) Timeout

func (u *Usart) Timeout() time.Duration

func (*Usart) Write

func (u *Usart) Write(p []byte) (n int, err error)

type UsartConfig

type UsartConfig struct {
	BaudRate BaudRate
	StopBits StopBits
	Parity   Parity
	DataBits DataBits
}

Struct layout matches what cmdInit expects, so don't change this.

type UsartInterface

type UsartInterface interface {
	io.Reader
	io.Writer
	// Clears any pending data from the read buffer.
	Flush() (err error)
	// Gets/Sets Read timeout.
	Timeout() time.Duration
	SetTimeout(timeout time.Duration)
}

type UsbDevice

type UsbDevice struct {
	// contains filtered or unexported fields
}

Encapsulates CW USB resources.

func OpenCwLiteUsbDevice

func OpenCwLiteUsbDevice() (*UsbDevice, error)

func (*UsbDevice) Close

func (d *UsbDevice) Close() error

func (*UsbDevice) ControlIn

func (d *UsbDevice) ControlIn(request Request, val uint16, data interface{}) error

func (*UsbDevice) ControlOut

func (d *UsbDevice) ControlOut(request Request, val uint16, data interface{}) error

func (*UsbDevice) Read

func (d *UsbDevice) Read(p []byte) (n int, err error)

func (*UsbDevice) ReadFwVersion

func (d *UsbDevice) ReadFwVersion(ver *FwVersion) error

Reads CW capture firmware version.

func (*UsbDevice) Write

func (d *UsbDevice) Write(buf []byte) (n int, err error)

type UsbDeviceInterface

type UsbDeviceInterface interface {
	// Reads/Writes to bulk data endpoint.
	io.Reader
	io.Writer
	io.Closer
	// Sends a request over the control endpoint.
	ControlIn(request Request, val uint16, data interface{}) error
	ControlOut(request Request, val uint16, data interface{}) error
}

Directories

Path Synopsis
Captures target power traces to file.
Captures target power traces to file.
stm32f
Programs a STM32 device using the NAEUSB firmware.
Programs a STM32 device using the NAEUSB firmware.
xmega
Programs an XMEGA device using the NAEUSB firmware.
Programs an XMEGA device using the NAEUSB firmware.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL