USB PIC Bootloader. User Manual


7.4.2. BOOT_READ_FLASH response

Bootloader sends this response after BOOT_READ_FLASH command processing. The response contains block of data, read from microcontroller flash memory.

If XTEA encryption algorithm is used (see the section called “XTEA - The encryption key”), the response contains the encrypted data. This data can be decrypted with encoder application, which is part of Bootloader setup package. During decryption you have to use the password, identical to the password in Bootloader.

To ease data processing boot_rsp_read_flash structure can be used:

typedef struct
{
   unsigned char cmd;  /* command code, see BOOT_xxx constants */
   unsigned char echo;  /* echo is used to link between command and response */
   unsigned char addr_lo;  /* address must be divisible by 2 */
   unsigned char addr_hi;
   unsigned char reserved[1];
   unsigned char size8;  /* size must be divisible by 8*/
   unsigned char data[BOOT_RSP_SIZE - 6];
} boot_rsp_read_flash;

Fields assignment:

cmd

Data field is used to make the size of all packages equal to BOOT_RSP_SIZE bytes.

echo

Header field is used to access common for all packages parameters - cmd and echo. These parameters are also available from the structures that define specific responses.

addr_lo

LSB byte of the address, flash memory reading starts from.

addr_hi

MSB byte of the address, flash memory reading starts from.

reserved

Not used

size8

The size of the data in bytes.

data

Data read from microcontroller flash memory.