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
- Variables
- type CCFG_FieldID
- type Command
- type CommandType
- type Device
- func (d *Device) BankErase() error
- func (d *Device) CRC32(address, size, rcount uint32) (uint32, error)
- func (d *Device) Download(address, size uint32) error
- func (d *Device) GetChipID() (uint32, error)
- func (d *Device) GetStatus() (Status, error)
- func (d *Device) MemoryRead(address uint32, typ ReadWriteType, count uint8) ([]byte, error)
- func (d *Device) MemoryWrite(address uint32, typ ReadWriteType, data []byte) error
- func (d *Device) Ping() error
- func (d *Device) RecvPacket() ([]byte, error)
- func (d *Device) Reset() error
- func (d *Device) SectorErase(address uint32) error
- func (d *Device) SendData(data []byte) error
- func (d *Device) SendPacket(pkt []byte) error
- func (d *Device) SetCCFG(id CCFG_FieldID, value uint32) error
- func (d *Device) Sync() error
- type ReadWriteType
- type Status
Constants ¶
const ( CC_ACK byte = 0xCC CC_NACK byte = 0x33 )
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
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
const ( ReadWriteType8Bit = ReadWriteType(0) ReadWriteType32Bit = ReadWriteType(1) )
const ( ReadMaxCount8Bit = uint8(253) ReadMaxCount32Bit = uint8(63) )
const ( WriteMaxCount8Bit = uint8(247) WriteMaxCount32Bit = uint8(244) // 32 bit aligned writes - divisible by 4 )
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) )
const (
SendDataMaxSize = 255 - 3
)
Variables ¶
var CC_SYNC = []byte{0x55, 0x55}
CC_SYNC contains the bootloader sync words var CC_SYNC = []byte{0x00, 0x03, 0x00, 0x00, 0x55, 0x55}
var ErrBadArguments = errors.New("The arguments supplied are invalid")
var ErrBadPacket = errors.New("The received packet was malformed")
var ErrDevice = errors.New("Unexpected error from device")
var ErrDeviceTimeout = errors.New("Timed out waiting for device")
var ErrNotImplemented = errors.New("This method is not implemented yet")
var ErrParse = errors.New("Unable to parse given string")
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
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) Download ¶
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) MemoryRead ¶
func (*Device) MemoryWrite ¶
func (d *Device) MemoryWrite(address uint32, typ ReadWriteType, data []byte) error
func (*Device) RecvPacket ¶
func (*Device) SectorErase ¶
func (*Device) SendData ¶
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 ¶
type ReadWriteType ¶
type ReadWriteType byte
func (ReadWriteType) String ¶
func (rt ReadWriteType) String() string