dfu: add scsi backend

This is extremely similar to the MMC backend, but there are some notable
differences.

Works with a DFU string like

    scsi 4=u-boot-bin part 11

Where "4" is the SCSI dev number (sequential LUN across all SCSI devices)
and "11" is the partition number.

Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Acked-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
This commit is contained in:
Caleb Connolly
2024-10-12 15:57:17 +02:00
parent 0ce0b77243
commit ef14c347db
6 changed files with 507 additions and 1 deletions

View File

@@ -24,6 +24,7 @@ enum dfu_device_type {
DFU_DEV_SF,
DFU_DEV_MTD,
DFU_DEV_VIRT,
DFU_DEV_SCSI,
};
enum dfu_layout {
@@ -99,6 +100,19 @@ struct virt_internal_data {
int dev_num;
};
struct scsi_internal_data {
int lun;
/* RAW programming */
unsigned int lba_start;
unsigned int lba_size;
unsigned int lba_blk_size;
/* FAT/EXT */
unsigned int dev; // Always 0???
unsigned int part;
};
#if defined(CONFIG_DFU_NAME_MAX_SIZE)
#define DFU_NAME_SIZE CONFIG_DFU_NAME_MAX_SIZE
#else
@@ -126,6 +140,7 @@ struct dfu_entity {
struct ram_internal_data ram;
struct sf_internal_data sf;
struct virt_internal_data virt;
struct scsi_internal_data scsi;
} data;
int (*get_medium_size)(struct dfu_entity *dfu, u64 *size);
@@ -516,6 +531,18 @@ static inline int dfu_fill_entity_virt(struct dfu_entity *dfu, char *devstr,
}
#endif
#if CONFIG_IS_ENABLED(DFU_SCSI)
int dfu_fill_entity_scsi(struct dfu_entity *dfu, char *devstr,
char **argv, int argc);
#else
static inline int dfu_fill_entity_scsi(struct dfu_entity *dfu, char *devstr,
char **argv, int argc)
{
puts("SCSI support not available!\n");
return -1;
}
#endif
extern bool dfu_reinit_needed;
extern bool dfu_alt_info_changed;