Skip to content

Commit

Permalink
Merge branch '2023-04-26-enable-bootstd-for-all-rockchip'
Browse files Browse the repository at this point in the history
- Merge Simon's series that enables bootstd and the distro bootmeth
  there for all of Rockchip.
  • Loading branch information
trini committed Apr 26, 2023
2 parents 2356053 + 4204c50 commit caf0a88
Show file tree
Hide file tree
Showing 21 changed files with 91 additions and 133 deletions.
3 changes: 1 addition & 2 deletions arch/arm/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1956,8 +1956,7 @@ config ARCH_ROCKCHIP
imply ADC
imply CMD_DM
imply DEBUG_UART_BOARD_INIT
imply DISTRO_DEFAULTS if !ROCKCHIP_RK3399
imply BOOTSTD_DEFAULTS if !DISTRO_DEFAULTS
imply BOOTSTD_DEFAULTS
imply FAT_WRITE
imply SARADC_ROCKCHIP
imply SPL_SYSRESET
Expand Down
37 changes: 28 additions & 9 deletions boot/bootdev-uclass.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,15 +174,16 @@ int bootdev_find_in_blk(struct udevice *dev, struct udevice *blk,
} else {
ret = fs_set_blk_dev_with_part(desc, bflow->part);
bflow->state = BOOTFLOWST_PART;
if (ret)
return log_msg_ret("fs", ret);

/* Use an #ifdef due to info.sys_ind */
#ifdef CONFIG_DOS_PARTITION
log_debug("%s: Found partition %x type %x fstype %d\n",
blk->name, bflow->part, info.sys_ind,
ret ? -1 : fs_get_type());
#endif
if (ret)
return log_msg_ret("fs", ret);
bflow->blk = blk;
bflow->state = BOOTFLOWST_FS;
}

Expand Down Expand Up @@ -364,7 +365,8 @@ int bootdev_unbind_dev(struct udevice *parent)
* @seqp: Returns the sequence number, or -1 if none
* @method_flagsp: If non-NULL, returns any flags implied by the label
* (enum bootflow_meth_flags_t), 0 if none
* Returns: sequence number on success, else -ve error code
* Returns: sequence number on success, -EPFNOSUPPORT is the uclass is not
* known, other -ve error code on other error
*/
static int label_to_uclass(const char *label, int *seqp, int *method_flagsp)
{
Expand Down Expand Up @@ -394,8 +396,7 @@ static int label_to_uclass(const char *label, int *seqp, int *method_flagsp)
id = UCLASS_ETH;
method_flags |= BOOTFLOW_METHF_DHCP_ONLY;
} else {
log_warning("Unknown uclass '%s' in label\n", label);
return -EINVAL;
return -EPFNOSUPPORT;
}
}
if (id == UCLASS_USB)
Expand Down Expand Up @@ -458,7 +459,6 @@ int bootdev_find_by_label(const char *label, struct udevice **devp,
}
log_debug("- no device in %s\n", media->name);
}
log_warning("Unknown seq %d for label '%s'\n", seq, label);

return -ENOENT;
}
Expand Down Expand Up @@ -577,9 +577,28 @@ int bootdev_next_label(struct bootflow_iter *iter, struct udevice **devp,

log_debug("next\n");
for (dev = NULL; !dev && iter->labels[++iter->cur_label];) {
log_debug("Scanning: %s\n", iter->labels[iter->cur_label]);
bootdev_hunt_and_find_by_label(iter->labels[iter->cur_label],
&dev, method_flagsp);
const char *label = iter->labels[iter->cur_label];
int ret;

log_debug("Scanning: %s\n", label);
ret = bootdev_hunt_and_find_by_label(label, &dev,
method_flagsp);
if (iter->flags & BOOTFLOWIF_SHOW) {
if (ret == -EPFNOSUPPORT) {
log_warning("Unknown uclass '%s' in label\n",
label);
} else if (ret == -ENOENT) {
/*
* looking for, e.g. 'scsi0' should find
* something if SCSI is present
*/
if (!trailing_strtol(label)) {
log_warning("No bootdevs for '%s'\n",
label);
}
}
}

}

if (!dev)
Expand Down
49 changes: 31 additions & 18 deletions boot/bootmeth_efi.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,14 @@ static int get_efi_pxe_vci(char *str, int max_len)
return 0;
}

static int efiload_read_file(struct blk_desc *desc, struct bootflow *bflow)
static void set_efi_bootdev(struct blk_desc *desc, struct bootflow *bflow)
{
const struct udevice *media_dev;
int size = bflow->size;
const char *dev_name;
char devnum_str[9];
char dirname[200];
char *last_slash;
int ret;

ret = bootmeth_alloc_file(bflow, 0x2000000, 0x10000);
if (ret)
return log_msg_ret("read", ret);

/*
* This is a horrible hack to tell EFI about this boot device. Once we
Expand All @@ -117,7 +112,9 @@ static int efiload_read_file(struct blk_desc *desc, struct bootflow *bflow)
* this can go away.
*/
media_dev = dev_get_parent(bflow->dev);
snprintf(devnum_str, sizeof(devnum_str), "%x", dev_seq(media_dev));
snprintf(devnum_str, sizeof(devnum_str), "%x:%x",
desc ? desc->devnum : dev_seq(media_dev),
bflow->part);

strlcpy(dirname, bflow->fname, sizeof(dirname));
last_slash = strrchr(dirname, '/');
Expand All @@ -130,6 +127,15 @@ static int efiload_read_file(struct blk_desc *desc, struct bootflow *bflow)
dev_name = device_get_uclass_id(media_dev) == UCLASS_MASS_STORAGE ?
"usb" : dev_get_uclass_name(media_dev);
efi_set_bootdev(dev_name, devnum_str, bflow->fname, bflow->buf, size);
}

static int efiload_read_file(struct blk_desc *desc, struct bootflow *bflow)
{
int ret;

ret = bootmeth_alloc_file(bflow, 0x2000000, 0x10000);
if (ret)
return log_msg_ret("read", ret);

return 0;
}
Expand Down Expand Up @@ -235,21 +241,21 @@ static int distro_efi_read_bootflow_file(struct udevice *dev,

/* try the various available names */
ret = -ENOENT;
for (seq = 0; ret; seq++) {
*fname = '\0';
for (seq = 0; ret == -ENOENT; seq++) {
ret = distro_efi_get_fdt_name(fname, sizeof(fname), seq);
if (ret == -EALREADY) {
if (ret == -EALREADY)
bflow->flags = BOOTFLOWF_USE_PRIOR_FDT;
break;
}
if (ret)
return log_msg_ret("nam", ret);
ret = bootmeth_common_read_file(dev, bflow, fname, fdt_addr,
&size);
if (!ret)
ret = bootmeth_common_read_file(dev, bflow, fname,
fdt_addr, &size);
}

bflow->fdt_fname = strdup(fname);
if (!bflow->fdt_fname)
return log_msg_ret("fil", -ENOMEM);
if (*fname) {
bflow->fdt_fname = strdup(fname);
if (!bflow->fdt_fname)
return log_msg_ret("fil", -ENOMEM);
}

if (!ret) {
bflow->fdt_size = size;
Expand Down Expand Up @@ -373,6 +379,13 @@ int distro_efi_boot(struct udevice *dev, struct bootflow *bflow)

/* A non-zero buffer indicates the kernel is there */
if (bflow->buf) {
/* Set the EFI bootdev again, since reading an FDT loses it! */
if (bflow->blk) {
struct blk_desc *desc = dev_get_uclass_plat(bflow->blk);

set_efi_bootdev(desc, bflow);
}

kernel = (ulong)map_to_sysmem(bflow->buf);

/*
Expand Down
3 changes: 3 additions & 0 deletions cmd/bootflow.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ static int do_bootflow_scan(struct cmd_tbl *cmdtp, int flag, int argc,
if (list)
show_footer(i, num_valid);

if (IS_ENABLED(CONFIG_CMD_BOOTFLOW_FULL) && !num_valid && !list)
printf("No bootflows found; try again with -l\n");

return 0;
}

Expand Down
6 changes: 6 additions & 0 deletions drivers/virtio/virtio-uclass.c
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,12 @@ static int virtio_bootdev_hunt(struct bootdev_hunter *info, bool show)
{
int ret;

if (IS_ENABLED(CONFIG_PCI)) {
ret = uclass_probe_all(UCLASS_PCI);
if (ret && ret != -ENOENT)
return log_msg_ret("pci", ret);
}

ret = uclass_probe_all(UCLASS_VIRTIO);
if (ret && ret != -ENOENT)
return log_msg_ret("vir", ret);
Expand Down
2 changes: 1 addition & 1 deletion include/bootdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ int bootdev_find_by_label(const char *label, struct udevice **devp,
* @devp: returns the device found, on success
* @method_flagsp: If non-NULL, returns any flags implied by the label
* (enum bootflow_meth_flags_t), 0 if none. Unset if function fails
* Return: 0 if OK, -EINVAL if the uclass is not supported by this board,
* Return: 0 if OK, -EPFNOSUPPORT if the uclass is not supported by this board,
* -ENOENT if there is no device with that number
*/
int bootdev_find_by_any(const char *name, struct udevice **devp,
Expand Down
3 changes: 1 addition & 2 deletions include/configs/px30_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@
"kernel_addr_c=0x03e80000\0" \
"ramdisk_addr_r=0x0a200000\0"

#include <config_distro_bootcmd.h>
#define CFG_EXTRA_ENV_SETTINGS \
ENV_MEM_LAYOUT_SETTINGS \
"fdtfile=" CONFIG_DEFAULT_FDT_FILE "\0" \
"partitions=" PARTS_DEFAULT \
ROCKCHIP_DEVICE_SETTINGS \
BOOTENV
"boot_targets=" BOOT_TARGETS "\0"

#endif
4 changes: 1 addition & 3 deletions include/configs/rk3036_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,13 @@
"kernel_addr_r=0x62000000\0" \
"ramdisk_addr_r=0x64000000\0"

#include <config_distro_bootcmd.h>

/* Linux fails to load the fdt if it's loaded above 512M on a evb-rk3036 board,
* so limit the fdt reallocation to that */
#define CFG_EXTRA_ENV_SETTINGS \
"fdt_file=" CONFIG_DEFAULT_FDT_FILE "\0" \
"fdt_high=0x7fffffff\0" \
"partitions=" PARTS_DEFAULT \
ENV_MEM_LAYOUT_SETTINGS \
BOOTENV
"boot_targets=" BOOT_TARGETS "\0"

#endif
4 changes: 1 addition & 3 deletions include/configs/rk3066_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@
"kernel_addr_r=0x62000000\0" \
"ramdisk_addr_r=0x64000000\0"

#include <config_distro_bootcmd.h>

#define CFG_EXTRA_ENV_SETTINGS \
"fdt_high=0x6fffffff\0" \
"initrd_high=0x6fffffff\0" \
"partitions=" PARTS_DEFAULT \
ENV_MEM_LAYOUT_SETTINGS \
ROCKCHIP_DEVICE_SETTINGS \
BOOTENV
"boot_targets=" BOOT_TARGETS "\0"

#endif
3 changes: 1 addition & 2 deletions include/configs/rk3128_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@
"kernel_addr_r=0x62000000\0" \
"ramdisk_addr_r=0x64000000\0"

#include <config_distro_bootcmd.h>
#define CFG_EXTRA_ENV_SETTINGS \
ENV_MEM_LAYOUT_SETTINGS \
"fdt_file=" CONFIG_DEFAULT_FDT_FILE "\0" \
"partitions=" PARTS_DEFAULT \
BOOTENV
"boot_targets=" BOOT_TARGETS "\0"

#endif
4 changes: 1 addition & 3 deletions include/configs/rk3188_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
"kernel_addr_r=0x62000000\0" \
"ramdisk_addr_r=0x64000000\0"

#include <config_distro_bootcmd.h>

/* Linux fails to load the fdt if it's loaded above 256M on a Rock board,
* so limit the fdt reallocation to that */
#define CFG_EXTRA_ENV_SETTINGS \
Expand All @@ -32,6 +30,6 @@
"partitions=" PARTS_DEFAULT \
ENV_MEM_LAYOUT_SETTINGS \
ROCKCHIP_DEVICE_SETTINGS \
BOOTENV
"boot_targets=" BOOT_TARGETS "\0"

#endif
4 changes: 1 addition & 3 deletions include/configs/rk322x_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,13 @@
"kernel_addr_r=0x62000000\0" \
"ramdisk_addr_r=0x64000000\0"

#include <config_distro_bootcmd.h>

/* Linux fails to load the fdt if it's loaded above 512M on a evb-rk3036 board,
* so limit the fdt reallocation to that */
#define CFG_EXTRA_ENV_SETTINGS \
"fdtfile=" CONFIG_DEFAULT_FDT_FILE "\0" \
"fdt_high=0x7fffffff\0" \
"partitions=" PARTS_DEFAULT \
ENV_MEM_LAYOUT_SETTINGS \
BOOTENV
"boot_targets=" BOOT_TARGETS "\0"

#endif
4 changes: 1 addition & 3 deletions include/configs/rk3288_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
"kernel_addr_r=0x02000000\0" \
"ramdisk_addr_r=0x04000000\0"

#include <config_distro_bootcmd.h>

/* Linux fails to load the fdt if it's loaded above 256M on a Rock 2 board, so
* limit the fdt reallocation to that */
#define CFG_EXTRA_ENV_SETTINGS \
Expand All @@ -34,6 +32,6 @@
"partitions=" PARTS_DEFAULT \
ENV_MEM_LAYOUT_SETTINGS \
ROCKCHIP_DEVICE_SETTINGS \
BOOTENV
"boot_targets=" BOOT_TARGETS "\0"

#endif
3 changes: 1 addition & 2 deletions include/configs/rk3308_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@
"kernel_addr_r=0x00680000\0" \
"ramdisk_addr_r=0x04000000\0"

#include <config_distro_bootcmd.h>
#define CFG_EXTRA_ENV_SETTINGS \
ENV_MEM_LAYOUT_SETTINGS \
"partitions=" PARTS_DEFAULT \
ROCKCHIP_DEVICE_SETTINGS \
BOOTENV
"boot_targets=" BOOT_TARGETS "\0"

#endif
3 changes: 1 addition & 2 deletions include/configs/rk3328_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@
"kernel_comp_addr_r=0x08000000\0" \
"kernel_comp_size=0x2000000\0"

#include <config_distro_bootcmd.h>
#define CFG_EXTRA_ENV_SETTINGS \
ENV_MEM_LAYOUT_SETTINGS \
"fdtfile=" CONFIG_DEFAULT_FDT_FILE "\0" \
"partitions=" PARTS_DEFAULT \
BOOTENV
"boot_targets=" BOOT_TARGETS "\0"

#endif
6 changes: 2 additions & 4 deletions include/configs/rk3368_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@
"kernel_addr_r=0x280000\0" \
"ramdisk_addr_r=0x5bf0000\0"

#include <config_distro_bootcmd.h>

#define CFG_EXTRA_ENV_SETTINGS \
"fdtfile=" CONFIG_DEFAULT_DEVICE_TREE ".dtb\0" \
ENV_MEM_LAYOUT_SETTINGS \
BOOTENV
ENV_MEM_LAYOUT_SETTINGS \
"boot_targets=" BOOT_TARGETS "\0"

#endif
5 changes: 2 additions & 3 deletions include/configs/rk3568_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@
"kernel_comp_addr_r=0x08000000\0" \
"kernel_comp_size=0x2000000\0"

#include <config_distro_bootcmd.h>
#define CFG_EXTRA_ENV_SETTINGS \
ENV_MEM_LAYOUT_SETTINGS \
"fdtfile=" CONFIG_DEFAULT_FDT_FILE "\0" \
"partitions=" PARTS_DEFAULT \
ROCKCHIP_DEVICE_SETTINGS \
BOOTENV
ROCKCHIP_DEVICE_SETTINGS \
"boot_targets=" BOOT_TARGETS "\0"

#endif
5 changes: 2 additions & 3 deletions include/configs/rk3588_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@
"kernel_comp_addr_r=0x08000000\0" \
"kernel_comp_size=0x2000000\0"

#include <config_distro_bootcmd.h>
#define CFG_EXTRA_ENV_SETTINGS \
"fdtfile=" CONFIG_DEFAULT_FDT_FILE "\0" \
"partitions=" PARTS_DEFAULT \
ENV_MEM_LAYOUT_SETTINGS \
ROCKCHIP_DEVICE_SETTINGS \
BOOTENV
ROCKCHIP_DEVICE_SETTINGS \
"boot_targets=" BOOT_TARGETS "\0"

#endif /* __CONFIG_RK3588_COMMON_H */
Loading

0 comments on commit caf0a88

Please sign in to comment.