ccboot

package module
v0.0.0-...-9c50df9 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2018 License: MIT Imports: 7 Imported by: 0

README

Godoc

Description

This is a low level interface library to the TI CC2538/CC26xx Serial Bootloader.

Documentation

Overview

Package ccboot provides the low level interface to the CC2650 bootloader. This may be similar enough to other CC chips.

Used the bootloader interface described in section 8.2 of the following datasheet: http://www.ti.com/lit/ug/swcu117g/swcu117g.pdf

Index

Constants

View Source
const (
	CC_ACK  byte = 0xCC
	CC_NACK byte = 0x33
)
View Source
const (
	COMMAND_PING         = CommandType(0x20)
	COMMAND_DOWNLOAD     = CommandType(0x21)
	COMMAND_GET_STATUS   = CommandType(0x23)
	COMMAND_SEND_DATA    = CommandType(0x24)
	COMMAND_RESET        = CommandType(0x25)
	COMMAND_SECTOR_ERASE = CommandType(0x26)
	COMMAND_CRC32        = CommandType(0x27)
	COMMAND_GET_CHIP_ID  = CommandType(0x28)
	COMMAND_MEMORY_READ  = CommandType(0x2A)
	COMMAND_MEMORY_WRITE = CommandType(0x2B)
	COMMAND_BANK_ERASE   = CommandType(0x2C)
	COMMAND_SET_CCFG     = CommandType(0x2D)
)

CommandType constants

View Source
const (
	COMMAND_RET_SUCCESS     = Status(0x40)
	COMMAND_RET_UNKNOW_CMD  = Status(0x41)
	COMMAND_RET_INVALID_CMD = Status(0x42)
	COMMAND_RET_INVALID_ADR = Status(0x43)
	COMMAND_RET_FLASH_FAIL  = Status(0x44)
)

These constants are returned from COMMAND_GET_STATUS

View Source
const (
	ReadWriteType8Bit  = ReadWriteType(0)
	ReadWriteType32Bit = ReadWriteType(1)
)
View Source
const (
	ReadMaxCount8Bit  = uint8(253)
	ReadMaxCount32Bit = uint8(63)
)
View Source
const (
	WriteMaxCount8Bit  = uint8(247)
	WriteMaxCount32Bit = uint8(244) // 32 bit aligned writes - divisible by 4
)
View Source
const (
	ID_SECTOR_PROT       = CCFG_FieldID(0)
	ID_IMAGE_VALID       = CCFG_FieldID(1)
	ID_TEST_TAP_LCK      = CCFG_FieldID(2)
	ID_PRCM_TAP_LCK      = CCFG_FieldID(3)
	ID_CPU_DAP_LCK       = CCFG_FieldID(4)
	ID_WUC_TAP_LCK       = CCFG_FieldID(5)
	ID_PBIST1_TAP_LCK    = CCFG_FieldID(6)
	ID_PBIST2_TAP_LCK    = CCFG_FieldID(7)
	ID_BANK_ERASE_DIS    = CCFG_FieldID(8)
	ID_CHIP_ERASE_DIS    = CCFG_FieldID(9)
	ID_TI_FA_ENABLE      = CCFG_FieldID(10)
	ID_BL_BACKDOOR_EN    = CCFG_FieldID(11)
	ID_BL_BACKDOOR_PIN   = CCFG_FieldID(12)
	ID_BL_BACKDOOR_LEVEL = CCFG_FieldID(13)
	ID_BL_ENABLE         = CCFG_FieldID(14)
)
View Source
const (
	SendDataMaxSize = 255 - 3
)

Variables

View Source
var CC_SYNC = []byte{0x55, 0x55}

CC_SYNC contains the bootloader sync words var CC_SYNC = []byte{0x00, 0x03, 0x00, 0x00, 0x55, 0x55}

View Source
var ErrBadArguments = errors.New("The arguments supplied are invalid")
View Source
var ErrBadPacket = errors.New("The received packet was malformed")
View Source
var ErrDevice = errors.New("Unexpected error from device")
View Source
var ErrDeviceTimeout = errors.New("Timed out waiting for device")
View Source
var ErrNotImplemented = errors.New("This method is not implemented yet")
View Source
var ErrParse = errors.New("Unable to parse given string")
View Source
var ErrSerial = errors.New("Error interacting with reader or writer")

Functions

This section is empty.

Types

type CCFG_FieldID

type CCFG_FieldID uint32

func ParseCCFGFieldID

func ParseCCFGFieldID(fieldname string) (CCFG_FieldID, error)

ParseCCFGFieldID parses a string that names a CCFG Field ID and returns the proper CCFG_FieldID value

func (CCFG_FieldID) String

func (c CCFG_FieldID) String() string

type Command

type Command struct {
	Type       CommandType
	Parameters []byte
}

Command represents the command type and paramerters

func (*Command) Marshal

func (c *Command) Marshal() []byte

func (Command) String

func (c Command) String() string

func (*Command) Unmarshal

func (c *Command) Unmarshal(data []byte) error

type CommandType

type CommandType byte

func (CommandType) String

func (c CommandType) String() string

type Device

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

func NewDevice

func NewDevice(port io.ReadWriteCloser) *Device

NewDevice sets up a new CC bootloader device.

We assume that port.Read has some timeout set

func (*Device) BankErase

func (d *Device) BankErase() error

func (*Device) CRC32

func (d *Device) CRC32(address, size, rcount uint32) (uint32, error)

func (*Device) Download

func (d *Device) Download(address, size uint32) error

Download indicates to the bootloader where to store data in flash and how many bytes will be sent by the following SendData command.

This command must be followed by a GetStatus command to ensure that the program address and program size are valid for the device.

func (*Device) GetChipID

func (d *Device) GetChipID() (uint32, error)

func (*Device) GetStatus

func (d *Device) GetStatus() (Status, error)

func (*Device) MemoryRead

func (d *Device) MemoryRead(address uint32, typ ReadWriteType, count uint8) ([]byte, error)

func (*Device) MemoryWrite

func (d *Device) MemoryWrite(address uint32, typ ReadWriteType, data []byte) error

func (*Device) Ping

func (d *Device) Ping() error

func (*Device) RecvPacket

func (d *Device) RecvPacket() ([]byte, error)

func (*Device) Reset

func (d *Device) Reset() error

func (*Device) SectorErase

func (d *Device) SectorErase(address uint32) error

func (*Device) SendData

func (d *Device) SendData(data []byte) error

SendData must only follow a Download command or another SendData command, if more data is needed. Consecutive SendData commands automatically increment the address and continue programming from the previous location.

The command terminates programming when the number of bytes indicated by the Download command is received. Each time this function is called, send a GetStatus command to ensure that the data was successfully programmed into the flash. 252 is max data size

func (*Device) SendPacket

func (d *Device) SendPacket(pkt []byte) error

func (*Device) SetCCFG

func (d *Device) SetCCFG(id CCFG_FieldID, value uint32) error

func (*Device) Sync

func (d *Device) Sync() error

Sync sends the sync command and waits for the device to respond

type ReadWriteType

type ReadWriteType byte

func (ReadWriteType) String

func (rt ReadWriteType) String() string

type Status

type Status byte

Status represents the status received by the GetStatus command

func (Status) String

func (s Status) String() string

Jump to

Keyboard shortcuts

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