cmd: mvebu/bubt: Add support for reading image from the SATA disk partition

This change allows to load boot image from the first SATA/SCSI device
partition and burn it to board boot location (e.g. SPI-NOR). This is
particularly when storage device is not handled by U-Boot as USB mass
storage (which is already supported by bubt) but as SATA/SCSI device.

Signed-off-by: Pali Rohár <pali@kernel.org>
This commit is contained in:
Pali Rohár 2023-01-21 23:29:36 +01:00 committed by Stefan Roese
parent c8f5009029
commit 4bf91e2203
2 changed files with 38 additions and 3 deletions

View File

@ -420,6 +420,36 @@ static int sata_burn_image(size_t image_size)
#endif
}
static size_t sata_read_file(const char *file_name)
{
loff_t act_read = 0;
struct udevice *dev;
int rc;
/* try to recognize storage devices immediately */
scsi_scan(false);
/* Try to recognize storage devices immediately */
blk_first_device(UCLASS_SCSI, &dev);
if (!dev) {
printf("Error: SATA device not found\n");
return 0;
}
/* Always load from scsi 0 */
if (fs_set_blk_dev("scsi", "0", FS_TYPE_ANY)) {
printf("Error: SATA 0 not found\n");
return 0;
}
/* Perfrom file read */
rc = fs_read(file_name, get_load_addr(), 0, 0, &act_read);
if (rc)
return 0;
return act_read;
}
static int is_sata_active(void)
{
return 1;
@ -430,6 +460,11 @@ static int sata_burn_image(size_t image_size)
return -ENODEV;
}
static size_t sata_read_file(const char *file_name)
{
return 0;
}
static int is_sata_active(void)
{
return 0;
@ -656,7 +691,7 @@ struct bubt_dev bubt_devs[BUBT_MAX_DEV] = {
{"tftp", tftp_read_file, NULL, is_tftp_active},
{"usb", usb_read_file, NULL, is_usb_active},
{"mmc", mmc_read_file, mmc_burn_image, is_mmc_active},
{"sata", NULL, sata_burn_image, is_sata_active},
{"sata", sata_read_file, sata_burn_image, is_sata_active},
{"spi", NULL, spi_burn_image, is_spi_active},
{"nand", NULL, nand_burn_image, is_nand_active},
};
@ -1206,7 +1241,7 @@ U_BOOT_CMD(
"[file-name] [destination [source]]\n"
"\t-file-name The image file name to burn. Default = " CONFIG_MVEBU_UBOOT_DFLT_NAME "\n"
"\t-destination Flash to burn to [spi, nand, mmc, sata]. Default = " DEFAULT_BUBT_DST "\n"
"\t-source The source to load image from [tftp, usb, mmc]. Default = " DEFAULT_BUBT_SRC "\n"
"\t-source The source to load image from [tftp, usb, mmc, sata]. Default = " DEFAULT_BUBT_SRC "\n"
"Examples:\n"
"\tbubt - Burn flash-image.bin from tftp to active boot device\n"
"\tbubt flash-image-new.bin nand - Burn flash-image-new.bin from tftp to NAND flash\n"

View File

@ -6,7 +6,7 @@ The bubt command gets the following parameters: ATF file name, destination devic
bubt [file-name] [destination [source]]
- file-name Image file name to burn. default = flash-image.bin
- destination Flash to burn to [spi, nand, mmc, sata]. default = active flash
- source Source to load image from [tftp, usb]. default = tftp
- source Source to load image from [tftp, usb, mmc, sata]. default = tftp
Examples:
bubt - Burn flash-image.bin from tftp to active flash