1.17.3 Write Flash Command

This command will program the flash with the data in the payload section. The address and size of the payload will be inspected by the bootloader to prevent accidental over-write of protected spaces. Attempts to write into the memory where the bootloader or configuration bits resides will be prevented and an error will be returned. The flash architecture also places limitations on the address alignment and size of the requests. The start address must always be on an Min Write Size aligned address and its length must also be modulus the Min Write Size in bytes. If either address or length is not aligned the device will not write the data and a status of 0xFE (Invalid Address) will be returned. The user is responsible for erasing flash before writing. Failure to do so will have unexpected results. The correct unlock sequence must be sent to the part for each command as it is not stored on the device

 

Field Size

Description

Data Type

Comments

1

Cmd

uint8_t

Command (0x02) - Write Program Memory

2

Length

uint16_t

Number of bytes to program. Must be evenly divisible by the Minimum Write Size parameter in the Get Version response. Command will return error if it's not evenly divisible

4

Unlock Seqeunce

uint32_t

Unlock sequence for flash. Key for currently supported parts is 0x00AA0055

4

Address

uint32_t

Address of the first memory location to program. Must be aligned to the Minimum Write Size parameter in the Get Version response. Command will return error if it's not aligned

Variable

Data To Write

uint8_t

Seqeunce of bytes. Data to write

 

Write Command Response Format

Field Size

Description

Data Type

Comments

1

Cmd

uint8_t

Command (0x02) - Write Program Memory

2

Length

uint16_t

Number of bytes to write.

4

Unlock Seqeunce

uint32_t

Unlock sequence for flash. Key for currently supported parts is 0x00AA0055

4

Address

uint32_t

Address of the first memory location to write. Must be aligned to and modulus of the Minimum Write Size.

1

Status

uint8_t

Status of Command
  • 0x01 Success

  • 0xFF Unsupported command

  • 0xFE Invalid Address

 

Write_Example Command

Write 8 bytes of data (0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08) starting at address 0x00001878. All values in Hex

Example command to the device

Field Size

Description

Data Type

Value

1

Cmd

uint8_t

0x02

2

Length

uint16_t

0x0008

4

Unlock Seqeunce

uint32_t

0x00AA0055

4

Address

uint32_t

0x00001878

8(for this example)

Data to write

uint8_t

0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08

Example as viewed on bus: 0x02, 0x08, 0x00, 0x55, 0x00, 0xAA, 0x00, 0x78, 0x18, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08

Example Response Sequence:

Example reponse from the device

Field Size

Description

Data Type

Value

1

Cmd

uint8_t

0x02

2

Length

uint16_t

0x0008

4

Unlock Seqeunce

uint32_t

0x00AA0055

4

Address

uint32_t

0x00001878

1

Status

uint32_t

0x01

Example as viewed on bus: 0x02, 0x08, 0x00, 0x55, 0x00, 0xAA, 0x00, 0x78, 0x18, 0x00, 0x00, 0x01