gostlink

package module
v0.0.0-...-460ac18 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2021 License: GPL-3.0 Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

About

Go library that provides support for interacting with ST-Link (> V2) to read out ram or SWO messages. It also includes a simple SeggerRTT interface which provides support for real time transfer.

The usb interface is based on the OpenOCD project https://sourceforge.net/p/openocd/code

The rtt implemenation ist based on phryniszak reversed engineered strtt library https://github.com/phryniszak/strtt

Usage

For usage see in stRttLogger/

Installation under Windows

Gostlink uses the gousb package. For installation see:

https://github.com/google/gousb

Documentation

Index

Constants

View Source
const (
	StLinkModeUnknown   StLinkMode = 0
	StLinkModeDfu                  = 1
	StLinkModeMass                 = 2
	StLinkModeDebugJtag            = 3
	StLinkModeDebugSwd             = 4
	StLinkModeDebugSwim            = 5
)
View Source
const (
	Memory8BitBlock  MemoryBlockSize = 1
	Memory16BitBlock                 = 2
	Memory32BitBlock                 = 4
)
View Source
const (
	SeggerRttModeNoBlockSkip     seggerRttMode = 0
	SeggerRttModeNoBlockTrim                   = 1
	SeggerRttModeBlockIfFifoFull               = 2
)
View Source
const (
	TraceConfigTypeDisabled TraceConfigType = 0 // tracing is disabled
	TraceConfigTypeExternal                 = 1 // trace output is captured externally
	TraceConfigTypeInternal                 = 2 // trace output is handled by OpenOCD adapter driver
)
View Source
const (
	TpuiPinProtocolSync           TpuiPinProtocolType = 0 // synchronous trace output
	TpuiPinProtocolAsynManchester                     = 1 // asynchronous output with Manchester coding
	TpuiPinProtocolAsyncUart                          = 2 // asynchronous output with NRZ coding
)
View Source
const AllSupportedPIds = 0xFFFF
View Source
const AllSupportedVIds = 0xFFFF
View Source
const (
	DefaultRamStart = 0x20000000
)

Variables

This section is empty.

Functions

func CloseUSB

func CloseUSB()

func InitUsb

func InitUsb() error

func SetLogger

func SetLogger(loggerInstance *logrus.Logger)

Types

type Buffer

type Buffer struct {
	bytes.Buffer
}

func NewBuffer

func NewBuffer(initSize int) *Buffer

func (*Buffer) ReadUint16BE

func (buf *Buffer) ReadUint16BE() uint16

Read next 2 bytes as unsigned integer Big Endian !!! This differe from original source which buffer pointer is not advenced (ie. doest not Read from Buffer)

func (*Buffer) ReadUint16LE

func (buf *Buffer) ReadUint16LE() uint16

Read next 2 bytes as unsigned integer Little Endian !!! This differe from original source which buffer pointer is not advenced (ie. doest not Read from Buffer)

func (*Buffer) ReadUint32BE

func (buf *Buffer) ReadUint32BE() uint32

Read next 4 bytes as unsigned integer Big Endian !!! This differe from original source which buffer pointer is not advenced (ie. doest not Read from Buffer)

func (*Buffer) ReadUint32LE

func (buf *Buffer) ReadUint32LE() uint32

Read next 4 bytes as unsigned integer Little Endian !!! This differe from original source which buffer pointer is not advenced (ie. doest not Read from Buffer)

func (*Buffer) WriteUint16LE

func (buf *Buffer) WriteUint16LE(value uint16)

func (*Buffer) WriteUint32LE

func (buf *Buffer) WriteUint32LE(value uint32)

type Endian

type Endian uint8

type MemoryBlockSize

type MemoryBlockSize int // block size for read and write operations

type RttDataCb

type RttDataCb func(int, []byte) error
type StLink struct {
	// contains filtered or unexported fields
}

*

func NewStLink(config *StLinkInterfaceConfig) (*StLink, error)

func (*StLink) Close

func (h *StLink) Close()

func (*StLink) ConfigTrace

func (h *StLink) ConfigTrace(enabled bool, tpiuProtocol TpuiPinProtocolType, portSize uint32,
	traceFreq *uint32, traceClkInFreq uint32, preScaler *uint16) error

func (*StLink) ForceDebug

func (h *StLink) ForceDebug() error

Force the target go to debug mode

func (*StLink) GetIdCode

func (h *StLink) GetIdCode() (uint32, error)

func (*StLink) GetRegister

func (h *StLink) GetRegister(register uint8) (uint32, error)

Get one register content

func (*StLink) GetRegisters

func (h *StLink) GetRegisters() (*TargetRegisters, error)

Get all registers content

func (*StLink) GetTargetVoltage

func (h *StLink) GetTargetVoltage() (float32, error)

func (*StLink) InitializeRtt

func (h *StLink) InitializeRtt(rttSearchRanges [][2]uint64) error

func (*StLink) PollTrace

func (h *StLink) PollTrace(buffer []byte, size *uint32) error

func (*StLink) ReadMem

func (h *StLink) ReadMem(addr uint32, bitLength MemoryBlockSize, count uint32, buffer *bytes.Buffer) error

func (*StLink) ReadRttChannels

func (h *StLink) ReadRttChannels(callback RttDataCb) error

func (*StLink) Reset

func (h *StLink) Reset()

func (*StLink) SetSpeed

func (h *StLink) SetSpeed(khz uint32, query bool) (uint32, error)

func (*StLink) UpdateRttChannels

func (h *StLink) UpdateRttChannels(readChannelNames bool) error

func (*StLink) UsbCurrentMode

func (h *StLink) UsbCurrentMode() (byte, error)

func (*StLink) UsbInitMode

func (h *StLink) UsbInitMode(connectUnderReset bool, initialInterfaceSpeed uint32) error

func (*StLink) UsbLeaveMode

func (h *StLink) UsbLeaveMode(mode StLinkMode) error

func (*StLink) UsbModeEnter

func (h *StLink) UsbModeEnter(stMode StLinkMode) error

*

func (*StLink) UsbReadMem

func (h *StLink) UsbReadMem(addr uint32, len uint16, buffer *bytes.Buffer) error

Read len bytes from Target's memory, NO aligment needed for add and len

func (*StLink) UsbReadMem8

func (h *StLink) UsbReadMem8(addr uint32, len uint16, buffer *bytes.Buffer) error

Read (len * 1) bytes from Target's memory

func (*StLink) UsbReadMem16

func (h *StLink) UsbReadMem16(addr uint32, len uint16, buffer *bytes.Buffer) error

Read ((len/2) * 2) bytes from Target's memory, addr must be 16bit aligned

func (*StLink) UsbReadMem32

func (h *StLink) UsbReadMem32(addr uint32, len uint16, buffer *bytes.Buffer) error

Read ((len/4) * 4) bytes from Target's memory, addr must be 32bit aligned

func (*StLink) UsbWriteMem8

func (h *StLink) UsbWriteMem8(addr uint32, len uint16, buffer []byte) error

func (*StLink) UsbWriteMem16

func (h *StLink) UsbWriteMem16(addr uint32, len uint16, buffer []byte) error

func (*StLink) UsbWriteMem32

func (h *StLink) UsbWriteMem32(addr uint32, len uint16, buffer []byte) error

func (*StLink) WriteMem

func (h *StLink) WriteMem(address uint32, bitLength MemoryBlockSize, count uint32, buffer []byte) error

type StLinkInterfaceConfig

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

func NewStLinkConfig

func NewStLinkConfig(vid gousb.ID, pid gousb.ID, mode StLinkMode,
	serial string, initialSpeed uint32, connectUnderReset bool) *StLinkInterfaceConfig

type StLinkMode

type StLinkMode uint8 // stlink debug modes

type StmCpuInfo

type StmCpuInfo struct {
	RamStart uint64
	RamSize  uint64
}

func GetCpuInformation

func GetCpuInformation(cpuId string) *StmCpuInfo

type TargetRegisters

type TargetRegisters struct {
	Status    uint32
	R         [16]uint32
	XPSR      uint32
	MainSP    uint32
	ProcessSP uint32
	RW        uint32
	RW2       uint32
}

type TpuiPinProtocolType

type TpuiPinProtocolType int

type TraceConfigType

type TraceConfigType int

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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