Product Comparison: USB I2C | USB SPI | USB GPIO

USB PIC Bootloader. User Manual


7.3.2. BOOT_READ_FLASH command

BOOT_READ_FLASH command is used to read data block from microcontrollers flash memory.

Before you send this command you have to fill in boot_cmd_read_flash structure:

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 */
} boot_cmd_read_flash;

Commands description:

cmd

Command code; the given field must be initialized by BOOT_READ_FLASH constant value.

echo

Package ID. Its value is selected arbitrarily before the command is sent. In the simplest case it is a counter value, increased by one while sending every new command. Bootloader does not analyze this field value. It simply copies it into response. Therefore, when response received, PC program can connect this response to previously sent command.

addr_lo

LSB byte of the address, from which flash memory read starts. As flash memory is organized to store data as words, addr_lo parameter value must be odd – aligned with 16-bit word boundary.

addr_hi

MSB byte of the address, from which flash memory read starts.

reserved

Not used.

size8

Flash memory size to read. The size specifies the number of bytes to read and must be divisible by 8.

After this command is processed, Bootloader sends response with code BOOT_READ_FLASH.