Skip to contentSkip to conversation

x86: Improve bootstd support

PATCH Superseded Simon Glass 3 participants 32 messages Jul 30, 2023 – Aug 3, 2023

Subsystems (8)
SCSI USB Block layer Library code +4 more subsystems

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover x86: Improve bootstd support

This series provides some bootstd fixes so that IDE can be used reliably for booting a distro. It also includes some documentation on how to boot from coreboot in various scenarios, using QEMU.

With this it is possible to boot Ubuntu 2023.04 from coreboot64, for example.

Changes in v2:
- Use log_warning() for the warning
- Fix the function name in the header as well

Simon Glass (9):
fs: fat: Support reading from a larger block size
usb: Return -ENOENT when no devices are found
lib: Suppress E when writing error-string output
bootstd: Rename bootdev_setup_sibling_blk()
bootstd: Correct creating of bootdev sibling
bootstd: Add some more debugging in the bootdev uclass
x86: coreboot: Add IDE and SATA
x86: coreboot: Enable standard boot
x86: coreboot: Enable support for CBFS

 boot/bootdev-uclass.c           |  17 +++--
 common/usb_storage.c            |   2 +-
 configs/coreboot64_defconfig    |  16 ++---
 configs/coreboot_defconfig      |  11 ++++
 doc/board/coreboot/coreboot.rst |  74 ++++++++++++++++++++--
 doc/develop/bootstd.rst         |   4 +-
 drivers/block/ide.c             |   4 +-
 drivers/mmc/mmc-uclass.c        |   2 +-
 drivers/nvme/nvme.c             |   2 +-
 drivers/scsi/scsi.c             |   2 +-
 drivers/usb/host/usb-uclass.c   |   2 +-
 drivers/virtio/virtio-uclass.c  |   2 +-
 fs/fat/Kconfig                  |  13 ++++
 fs/fat/fat.c                    | 107 ++++++++++++++++++++++++++++----
 fs/fat/fat_write.c              |   8 ++-
 include/bootdev.h               |  10 +--
 include/usb.h                   |   9 ++-
 lib/vsprintf.c                  |   5 +-
 18 files changed, 238 insertions(+), 52 deletions(-)
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
#1 lore raw

PATCH v2 1/9 fs: fat: Support reading from a larger block size

At present it is not possible to read from some CDROM drives since the FAT sector size does not match the media's block size. Add a conversion option for this, so that reading is possible.

This does increase SPL size for read-only FAT support by 25 bytes but all but 6 are covered by the previous patch. We could reduce the overhead of this feature to 0 bytes by making the code uglier (using a static variable).

---

Changes in v2:
- Use log_warning() for the warning

 fs/fat/Kconfig     |  13 ++++++
 fs/fat/fat.c       | 107 ++++++++++++++++++++++++++++++++++++++++-----
 fs/fat/fat_write.c |   8 ++--
 3 files changed, 114 insertions(+), 14 deletions(-)
fs/fat/Kconfig +13 -0
index 9bb11eac9f7a..b0aa888c6cc4 100644
@@ -22,3 +22,16 @@ config FS_FAT_MAX_CLUSTSIZE
 	  is the smallest amount of disk space that can be used to hold a
 	  file. Unless you have an extremely tight memory memory constraints,
 	  leave the default.
+
+config FAT_BLK_XLATE
+	bool "Enable FAT filesystem on a device with a larger block size"
+	depends on FS_FAT
+	help
+	  This provides a simple translation mechanism for reading FAT
+	  filesystems which don't use the same sector size as the underlying
+	  media. For example, the FAT filesystem may use 512 bytes but the
+	  media uses 2048, e.g. on a CDROM drive.
+
+	  This only supports the case where the FAT filesystem's sector size is
+	  smaller than the media's block size. It does not support creating or
+	  writing files.
fs/fat/fat.c +96 -11

167 lines not on this page · raw message

fs/fat/fat_write.c +5 -3
index e2a9913f807a..95f7a60caa2b 100644
@@ -477,7 +477,7 @@ static int set_fatent_value(fsdata *mydata, __u32 entry, __u32 entry_value)
 
 		startblock += mydata->fat_sect;
 
-		if (disk_read(startblock, getsize, bufptr) < 0) {
+		if (disk_read(NULL, startblock, getsize, bufptr) < 0) {
 			debug("Error reading FAT blocks\n");
 			return -1;
 		}
@@ -712,7 +712,8 @@ get_set_cluster(fsdata *mydata, __u32 clustnum, loff_t pos, __u8 *buffer,
 	/* partial write at beginning */
 	if (pos) {
 		wsize = min(bytesperclust - pos, size);
-		ret = disk_read(startsect, mydata->clust_size, tmpbuf_cluster);
+		ret = disk_read(NULL, startsect, mydata->clust_size,
+				tmpbuf_cluster);
 		if (ret != mydata->clust_size) {
 			debug("Error reading data (got %d)\n", ret);
 			return -1;
@@ -778,7 +779,8 @@ get_set_cluster(fsdata *mydata, __u32 clustnum, loff_t pos, __u8 *buffer,
 	/* partial write at end */
 	if (size) {
 		wsize = size;
-		ret = disk_read(startsect, mydata->clust_size, tmpbuf_cluster);
+		ret = disk_read(NULL, startsect, mydata->clust_size,
+				tmpbuf_cluster);
 		if (ret != mydata->clust_size) {
 			debug("Error reading data (got %d)\n", ret);
 			return -1;
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
#2 lore raw

Re: [PATCH v2 1/9] fs: fat: Support reading from a larger block size

Quoted 13 lines · Simon Glass

At present it is not possible to read from some CDROM drives since the FAT sector size does not match the media's block size. Add a conversion option for this, so that reading is possible.

This does increase SPL size for read-only FAT support by 25 bytes but all but 6 are covered by the previous patch. We could reduce the overhead of this feature to 0 bytes by making the code uglier (using a static variable).

---

Quoted 8 lines

Changes in v2:
- Use log_warning() for the warning

 fs/fat/Kconfig     |  13 ++++++
 fs/fat/fat.c       | 107 ++++++++++++++++++++++++++++++++++++++++-----
 fs/fat/fat_write.c |   8 ++--
 3 files changed, 114 insertions(+), 14 deletions(-)

As discussed in another thread [1], this patch will not be accepted due to invalid use case of using -cdrom on isohybrid images.

[1] https://patchwork.ozlabs.org/project/uboot/patch/20230619125956.v4.32.Ia13846500fab3d5a1d5573db11a040d233994fa6@changeid/

Regards,
Bin

#3 lore raw

PATCH v2 2/9 usb: Return -ENOENT when no devices are found

In reply to Simon Glass

When USB finds no devices it currently returns -EPERM which bootstd does not understand. This causes other bootdevs of the same priority to be skipped.

Fix this by returning the correct error code.

---

(no changes since v1)

 drivers/usb/host/usb-uclass.c | 2 +-
 include/usb.h                 | 9 ++++++++-
 2 files changed, 9 insertions(+), 2 deletions(-)
drivers/usb/host/usb-uclass.c +1 -1
index 02c0138a2065..7a03435ba773 100644
@@ -346,7 +346,7 @@ int usb_init(void)
 	if (controllers_initialized == 0)
 		printf("No working controllers found\n");
 
-	return usb_started ? 0 : -1;
+	return usb_started ? 0 : -ENOENT;
 }
 
 int usb_setup_ehci_gadget(struct ehci_ctrl **ctlrp)
include/usb.h +8 -1
index 42b001c3dd5e..09e3f0cb309c 100644
@@ -257,7 +257,14 @@ int usb_kbd_deregister(int force);
 
 #endif
 /* routines */
-int usb_init(void); /* initialize the USB Controller */
+
+/*
+ * usb_init() - initialize the USB Controllers
+ *
+ * Returns: 0 if OK, -ENOENT if there are no USB devices
+ */
+int usb_init(void);
+
 int usb_stop(void); /* stop the USB Controller */
 int usb_detect_change(void); /* detect if a USB device has been (un)plugged */
 
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
Reviewed-by on v2 2/9
#4 lore raw

Re: [PATCH v2 2/9] usb: Return -ENOENT when no devices are found

Quoted 2 lines · Simon Glass

When USB finds no devices it currently returns -EPERM which bootstd does

The code returns -1, not -EPERM

Quoted 38 lines

not understand. This causes other bootdevs of the same priority to be skipped.

Fix this by returning the correct error code.

---

(no changes since v1)

 drivers/usb/host/usb-uclass.c | 2 +-
 include/usb.h                 | 9 ++++++++-
 2 files changed, 9 insertions(+), 2 deletions(-)
drivers/usb/host/usb-uclass.c +1 -1
index 02c0138a2065..7a03435ba773 100644
@@ -346,7 +346,7 @@ int usb_init(void)
        if (controllers_initialized == 0)
                printf("No working controllers found\n");
 
-       return usb_started ? 0 : -1;
+       return usb_started ? 0 : -ENOENT;
 }
 
 int usb_setup_ehci_gadget(struct ehci_ctrl **ctlrp)
include/usb.h +2 -1
index 42b001c3dd5e..09e3f0cb309c 100644
@@ -257,7 +257,14 @@ int usb_kbd_deregister(int force);
 
 #endif
 /* routines */
-int usb_init(void); /* initialize the USB Controller */
+
+/*

include/usb.h int usb_kbd_deregister(int force);

Quoted 10 lines
include/usb.h +6 -1
+ * usb_init() - initialize the USB Controllers
+ *
+ * Returns: 0 if OK, -ENOENT if there are no USB devices
+ */
+int usb_init(void);
+
 int usb_stop(void); /* stop the USB Controller */
 int usb_detect_change(void); /* detect if a USB device has been (un)plugged */
 
--

Otherwise,

#5 lore raw

Re: [PATCH v2 2/9] usb: Return -ENOENT when no devices are found

Hi Bin,

Quoted 6 lines · Bin Meng
Quoted 2 lines · Simon Glass

When USB finds no devices it currently returns -EPERM which bootstd does

The code returns -1, not -EPERM

Yes, I mean that -1 is -EPERM.

Regards,
Simon

Quoted 52 lines
Quoted 39 lines

not understand. This causes other bootdevs of the same priority to be skipped.

Fix this by returning the correct error code.

---

(no changes since v1)

 drivers/usb/host/usb-uclass.c | 2 +-
 include/usb.h                 | 9 ++++++++-
 2 files changed, 9 insertions(+), 2 deletions(-)
drivers/usb/host/usb-uclass.c +1 -1
index 02c0138a2065..7a03435ba773 100644
@@ -346,7 +346,7 @@ int usb_init(void)
        if (controllers_initialized == 0)
                printf("No working controllers found\n");
 
-       return usb_started ? 0 : -1;
+       return usb_started ? 0 : -ENOENT;
 }
 
 int usb_setup_ehci_gadget(struct ehci_ctrl **ctlrp)
include/usb.h +2 -1
index 42b001c3dd5e..09e3f0cb309c 100644
@@ -257,7 +257,14 @@ int usb_kbd_deregister(int force);
 
 #endif
 /* routines */
-int usb_init(void); /* initialize the USB Controller */
+
+/*

include/usb.h int usb_kbd_deregister(int force);

Quoted 10 lines
include/usb.h +6 -1
+ * usb_init() - initialize the USB Controllers
+ *
+ * Returns: 0 if OK, -ENOENT if there are no USB devices
+ */
+int usb_init(void);
+
 int usb_stop(void); /* stop the USB Controller */
 int usb_detect_change(void); /* detect if a USB device has been (un)plugged */
 
--

Otherwise,

#6 lore raw

Re: [PATCH v2 2/9] usb: Return -ENOENT when no devices are found

In reply to Bin Meng
Quoted 54 lines · Bin Meng
Quoted 2 lines · Simon Glass

When USB finds no devices it currently returns -EPERM which bootstd does

The code returns -1, not -EPERM

Quoted 47 lines

not understand. This causes other bootdevs of the same priority to be skipped.

Fix this by returning the correct error code.

---

(no changes since v1)

 drivers/usb/host/usb-uclass.c | 2 +-
 include/usb.h                 | 9 ++++++++-
 2 files changed, 9 insertions(+), 2 deletions(-)
drivers/usb/host/usb-uclass.c +1 -1
index 02c0138a2065..7a03435ba773 100644
@@ -346,7 +346,7 @@ int usb_init(void)
        if (controllers_initialized == 0)
                printf("No working controllers found\n");
 
-       return usb_started ? 0 : -1;
+       return usb_started ? 0 : -ENOENT;
 }
 
 int usb_setup_ehci_gadget(struct ehci_ctrl **ctlrp)
include/usb.h +8 -1
index 42b001c3dd5e..09e3f0cb309c 100644
@@ -257,7 +257,14 @@ int usb_kbd_deregister(int force);
 
 #endif
 /* routines */
-int usb_init(void); /* initialize the USB Controller */
+
+/*
+ * usb_init() - initialize the USB Controllers
+ *
+ * Returns: 0 if OK, -ENOENT if there are no USB devices
+ */
+int usb_init(void);
+
 int usb_stop(void); /* stop the USB Controller */
 int usb_detect_change(void); /* detect if a USB device has been (un)plugged */
 
Quoted 4 lines
Quoted 1 line

--

Otherwise,

applied to u-boot-x86, thanks!

#7 lore raw

PATCH v2 3/9 lib: Suppress E when writing error-string output

In reply to Simon Glass

When CONFIG_ERRNO_STR is not enabled this shows a spurious 'E' from the format string. Fix this.

Fixes 7f331941321 ("lib: Support printing an error string")

---

(no changes since v1)

 lib/vsprintf.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
lib/vsprintf.c +3 -2
index e87503e41ada..e14c6ca9f966 100644
@@ -680,8 +680,10 @@ repeat:
 			break;
 
 		case 'd':
-			if (fmt[1] == 'E')
+			if (fmt[1] == 'E') {
 				flags |= ERRSTR;
+				fmt++;
+			}
 		/* fallthrough */
 		case 'i':
 			flags |= SIGN;
@@ -725,7 +727,6 @@ repeat:
 			ADDCH(str, ' ');
 			for (p = errno_str(num); *p; p++)
 				ADDCH(str, *p);
-			fmt++;
 		}
 	}
 
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
Reviewed-by on v2 3/9
#8 lore raw

Re: [PATCH v2 3/9] lib: Suppress E when writing error-string output

Quoted 4 lines · Simon Glass

When CONFIG_ERRNO_STR is not enabled this shows a spurious 'E' from the format string. Fix this.

Quoted 9 lines
Fixes 7f331941321 ("lib: Support printing an error string")

---

(no changes since v1)

 lib/vsprintf.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
#9 lore raw

Re: [PATCH v2 3/9] lib: Suppress E when writing error-string output

Quoted 10 lines · Bin Meng
Quoted 8 lines · Simon Glass

When CONFIG_ERRNO_STR is not enabled this shows a spurious 'E' from the format string. Fix this.

Fixes 7f331941321 ("lib: Support printing an error string")

---

Quoted 7 lines
Quoted 5 lines

(no changes since v1)

 lib/vsprintf.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

applied to u-boot-x86, thanks!

#10 lore raw

PATCH v2 4/9 bootstd: Rename bootdev_setup_sibling_blk()

In reply to Simon Glass

This name is a little confusing since it suggests that it sets up the sibling block device. In fact it sets up a bootdev for it. Rename the function to make this clearer.

---

Changes in v2:
- Fix the function name in the header as well

 boot/bootdev-uclass.c          |  8 +++++---
 common/usb_storage.c           |  2 +-
 doc/develop/bootstd.rst        |  4 ++--
 drivers/mmc/mmc-uclass.c       |  2 +-
 drivers/nvme/nvme.c            |  2 +-
 drivers/scsi/scsi.c            |  2 +-
 drivers/virtio/virtio-uclass.c |  2 +-
 include/bootdev.h              | 10 +++++-----
 8 files changed, 17 insertions(+), 15 deletions(-)
boot/bootdev-uclass.c +5 -3
index 9660ff75676d..114853ffb72a 100644
@@ -262,7 +262,7 @@ static int bootdev_get_suffix_start(struct udevice *dev, const char *suffix)
 	return len;
 }
 
-int bootdev_setup_sibling_blk(struct udevice *blk, const char *drv_name)
+int bootdev_setup_for_sibling_blk(struct udevice *blk, const char *drv_name)
 {
 	struct udevice *parent, *dev;
 	char dev_name[50];
@@ -305,7 +305,9 @@ int bootdev_get_sibling_blk(struct udevice *dev, struct udevice **blkp)
 	if (device_get_uclass_id(dev) != UCLASS_BOOTDEV)
 		return -EINVAL;
 
-	/* This should always work if bootdev_setup_sibling_blk() was used */
+	/*
+	 * This should always work if bootdev_setup_for_sibling_blk() was used
+	 */
 	len = bootdev_get_suffix_start(dev, ".bootdev");
 	ret = device_find_child_by_namelen(parent, dev->name, len, &blk);
 	if (ret) {
@@ -335,7 +337,7 @@ static int bootdev_get_from_blk(struct udevice *blk, struct udevice **bootdevp)
 	if (device_get_uclass_id(blk) != UCLASS_BLK)
 		return -EINVAL;
 
-	/* This should always work if bootdev_setup_sibling_blk() was used */
+	/* This should always work if bootdev_setup_for_sibling_blk() was used */
 	len = bootdev_get_suffix_start(blk, ".blk");
 	snprintf(dev_name, sizeof(dev_name), "%.*s.%s", len, blk->name,
 		 "bootdev");
common/usb_storage.c +1 -1
index ac6427577379..85774220ef2a 100644
@@ -246,7 +246,7 @@ static int usb_stor_probe_device(struct usb_device *udev)
 		if (ret)
 			return ret;
 
-		ret = bootdev_setup_sibling_blk(dev, "usb_bootdev");
+		ret = bootdev_setup_for_sibling_blk(dev, "usb_bootdev");
 		if (ret) {
 			int ret2;
 
doc/develop/bootstd.rst +2 -2
index 7a2a69fdfcec..ec3136535783 100644
@@ -306,7 +306,7 @@ media device::
 
 The bootdev device is typically created automatically in the media uclass'
 `post_bind()` method by calling `bootdev_setup_for_dev()` or
-`bootdev_setup_sibling_blk()`. The code typically something like this::
+`bootdev_setup_for_sibling_blk()`. The code typically something like this::
 
     /* dev is the Ethernet device */
     ret = bootdev_setup_for_dev(dev, "eth_bootdev");
@@ -316,7 +316,7 @@ The bootdev device is typically created automatically in the media uclass'
 or::
 
     /* blk is the block device (child of MMC device)
-    ret = bootdev_setup_sibling_blk(blk, "mmc_bootdev");
+    ret = bootdev_setup_for_sibling_blk(blk, "mmc_bootdev");
     if (ret)
         return log_msg_ret("bootdev", ret);
 
drivers/mmc/mmc-uclass.c +1 -1
index 01d9b0201f2c..0e157672eae0 100644
@@ -421,7 +421,7 @@ int mmc_bind(struct udevice *dev, struct mmc *mmc, const struct mmc_config *cfg)
 	mmc->cfg = cfg;
 	mmc->priv = dev;
 
-	ret = bootdev_setup_sibling_blk(bdev, "mmc_bootdev");
+	ret = bootdev_setup_for_sibling_blk(bdev, "mmc_bootdev");
 	if (ret)
 		return log_msg_ret("bootdev", ret);
 
drivers/nvme/nvme.c +1 -1
index a7add66ab4d1..20dc910d8a33 100644
@@ -910,7 +910,7 @@ int nvme_init(struct udevice *udev)
 		if (ret)
 			goto free_id;
 
-		ret = bootdev_setup_sibling_blk(ns_udev, "nvme_bootdev");
+		ret = bootdev_setup_for_sibling_blk(ns_udev, "nvme_bootdev");
 		if (ret)
 			return log_msg_ret("bootdev", ret);
 
drivers/scsi/scsi.c +1 -1
index 6caeb3fcdd0d..0a3420b7fbc2 100644
@@ -607,7 +607,7 @@ static int do_scsi_scan_one(struct udevice *dev, int id, int lun, bool verbose)
 		/* TODO: undo create */
 		return log_msg_ret("pro", ret);
 
-	ret = bootdev_setup_sibling_blk(bdev, "scsi_bootdev");
+	ret = bootdev_setup_for_sibling_blk(bdev, "scsi_bootdev");
 	if (ret)
 		return log_msg_ret("bd", ret);
 
drivers/virtio/virtio-uclass.c +1 -1
index 31bb21c534e5..87323ab6d193 100644
@@ -248,7 +248,7 @@ static int virtio_uclass_post_probe(struct udevice *udev)
 	device_set_name_alloced(vdev);
 
 	if (uc_priv->device == VIRTIO_ID_BLOCK && !IS_ENABLED(CONFIG_SANDBOX)) {
-		ret = bootdev_setup_sibling_blk(vdev, "virtio_bootdev");
+		ret = bootdev_setup_for_sibling_blk(vdev, "virtio_bootdev");
 		if (ret)
 			return log_msg_ret("bootdev", ret);
 	}
include/bootdev.h +5 -5
index 1533adfe5065..848233187f87 100644
@@ -371,7 +371,7 @@ int bootdev_next_prio(struct bootflow_iter *iter, struct udevice **devp);
 /**
  * bootdev_setup_for_dev() - Bind a new bootdev device (deprecated)
  *
- * Please use bootdev_setup_sibling_blk() instead since it supports multiple
+ * Please use bootdev_setup_for_sibling_blk() instead since it supports multiple
  * (child) block devices for each media device.
  *
  * Creates a bootdev device as a child of @parent. This should be called from
@@ -386,7 +386,7 @@ int bootdev_next_prio(struct bootflow_iter *iter, struct udevice **devp);
 int bootdev_setup_for_dev(struct udevice *parent, const char *drv_name);
 
 /**
- * bootdev_setup_for_blk() - Bind a new bootdev device for a blk device
+ * bootdev_setup_for_sibling_blk() - Bind a new bootdev device for a blk device
  *
  * Creates a bootdev device as a sibling of @blk. This should be called from
  * the driver's bind() method or its uclass' post_bind() method, at the same
@@ -398,7 +398,7 @@ int bootdev_setup_for_dev(struct udevice *parent, const char *drv_name);
  * @drv_name: Name of bootdev driver to bind
  * Return: 0 if OK, -ve on error
  */
-int bootdev_setup_sibling_blk(struct udevice *blk, const char *drv_name);
+int bootdev_setup_for_sibling_blk(struct udevice *blk, const char *drv_name);
 
 /**
  * bootdev_get_sibling_blk() - Locate the block device for a bootdev
@@ -428,8 +428,8 @@ static inline int bootdev_setup_for_dev(struct udevice *parent,
 	return 0;
 }
 
-static inline int bootdev_setup_sibling_blk(struct udevice *blk,
-					    const char *drv_name)
+static inline int bootdev_setup_for_sibling_blk(struct udevice *blk,
+						const char *drv_name)
 {
 	return 0;
 }
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
Reviewed-by on v2 4/9
#11 lore raw

Re: [PATCH v2 4/9] bootstd: Rename bootdev_setup_sibling_blk()

Quoted 11 lines · Simon Glass

This name is a little confusing since it suggests that it sets up the sibling block device. In fact it sets up a bootdev for it. Rename the function to make this clearer.

---

Changes in v2:
- Fix the function name in the header as well

Quoted 10 lines
 boot/bootdev-uclass.c          |  8 +++++---
 common/usb_storage.c           |  2 +-
 doc/develop/bootstd.rst        |  4 ++--
 drivers/mmc/mmc-uclass.c       |  2 +-
 drivers/nvme/nvme.c            |  2 +-
 drivers/scsi/scsi.c            |  2 +-
 drivers/virtio/virtio-uclass.c |  2 +-
 include/bootdev.h              | 10 +++++-----
 8 files changed, 17 insertions(+), 15 deletions(-)
Reviewed-by on v2 4/9
#12 lore raw

Re: [PATCH v2 4/9] bootstd: Rename bootdev_setup_sibling_blk()

In reply to Simon Glass
Quoted 5 lines · Simon Glass

This name is a little confusing since it suggests that it sets up the sibling block device. In fact it sets up a bootdev for it. Rename the function to make this clearer.

Quoted 179 lines

---

Changes in v2:
- Fix the function name in the header as well

 boot/bootdev-uclass.c          |  8 +++++---
 common/usb_storage.c           |  2 +-
 doc/develop/bootstd.rst        |  4 ++--
 drivers/mmc/mmc-uclass.c       |  2 +-
 drivers/nvme/nvme.c            |  2 +-
 drivers/scsi/scsi.c            |  2 +-
 drivers/virtio/virtio-uclass.c |  2 +-
 include/bootdev.h              | 10 +++++-----
 8 files changed, 17 insertions(+), 15 deletions(-)
boot/bootdev-uclass.c +5 -3
index 9660ff75676d..114853ffb72a 100644
@@ -262,7 +262,7 @@ static int bootdev_get_suffix_start(struct udevice *dev, const char *suffix)
 	return len;
 }
 
-int bootdev_setup_sibling_blk(struct udevice *blk, const char *drv_name)
+int bootdev_setup_for_sibling_blk(struct udevice *blk, const char *drv_name)
 {
 	struct udevice *parent, *dev;
 	char dev_name[50];
@@ -305,7 +305,9 @@ int bootdev_get_sibling_blk(struct udevice *dev, struct udevice **blkp)
 	if (device_get_uclass_id(dev) != UCLASS_BOOTDEV)
 		return -EINVAL;
 
-	/* This should always work if bootdev_setup_sibling_blk() was used */
+	/*
+	 * This should always work if bootdev_setup_for_sibling_blk() was used
+	 */
 	len = bootdev_get_suffix_start(dev, ".bootdev");
 	ret = device_find_child_by_namelen(parent, dev->name, len, &blk);
 	if (ret) {
@@ -335,7 +337,7 @@ static int bootdev_get_from_blk(struct udevice *blk, struct udevice **bootdevp)
 	if (device_get_uclass_id(blk) != UCLASS_BLK)
 		return -EINVAL;
 
-	/* This should always work if bootdev_setup_sibling_blk() was used */
+	/* This should always work if bootdev_setup_for_sibling_blk() was used */
 	len = bootdev_get_suffix_start(blk, ".blk");
 	snprintf(dev_name, sizeof(dev_name), "%.*s.%s", len, blk->name,
 		 "bootdev");
common/usb_storage.c +1 -1
index ac6427577379..85774220ef2a 100644
@@ -246,7 +246,7 @@ static int usb_stor_probe_device(struct usb_device *udev)
 		if (ret)
 			return ret;
 
-		ret = bootdev_setup_sibling_blk(dev, "usb_bootdev");
+		ret = bootdev_setup_for_sibling_blk(dev, "usb_bootdev");
 		if (ret) {
 			int ret2;
 
doc/develop/bootstd.rst +2 -2
index 7a2a69fdfcec..ec3136535783 100644
@@ -306,7 +306,7 @@ media device::
 
 The bootdev device is typically created automatically in the media uclass'
 `post_bind()` method by calling `bootdev_setup_for_dev()` or
-`bootdev_setup_sibling_blk()`. The code typically something like this::
+`bootdev_setup_for_sibling_blk()`. The code typically something like this::
 
     /* dev is the Ethernet device */
     ret = bootdev_setup_for_dev(dev, "eth_bootdev");
@@ -316,7 +316,7 @@ The bootdev device is typically created automatically in the media uclass'
 or::
 
     /* blk is the block device (child of MMC device)
-    ret = bootdev_setup_sibling_blk(blk, "mmc_bootdev");
+    ret = bootdev_setup_for_sibling_blk(blk, "mmc_bootdev");
     if (ret)
         return log_msg_ret("bootdev", ret);
 
drivers/mmc/mmc-uclass.c +1 -1
index 01d9b0201f2c..0e157672eae0 100644
@@ -421,7 +421,7 @@ int mmc_bind(struct udevice *dev, struct mmc *mmc, const struct mmc_config *cfg)
 	mmc->cfg = cfg;
 	mmc->priv = dev;
 
-	ret = bootdev_setup_sibling_blk(bdev, "mmc_bootdev");
+	ret = bootdev_setup_for_sibling_blk(bdev, "mmc_bootdev");
 	if (ret)
 		return log_msg_ret("bootdev", ret);
 
drivers/nvme/nvme.c +1 -1
index a7add66ab4d1..20dc910d8a33 100644
@@ -910,7 +910,7 @@ int nvme_init(struct udevice *udev)
 		if (ret)
 			goto free_id;
 
-		ret = bootdev_setup_sibling_blk(ns_udev, "nvme_bootdev");
+		ret = bootdev_setup_for_sibling_blk(ns_udev, "nvme_bootdev");
 		if (ret)
 			return log_msg_ret("bootdev", ret);
 
drivers/scsi/scsi.c +1 -1
index 6caeb3fcdd0d..0a3420b7fbc2 100644
@@ -607,7 +607,7 @@ static int do_scsi_scan_one(struct udevice *dev, int id, int lun, bool verbose)
 		/* TODO: undo create */
 		return log_msg_ret("pro", ret);
 
-	ret = bootdev_setup_sibling_blk(bdev, "scsi_bootdev");
+	ret = bootdev_setup_for_sibling_blk(bdev, "scsi_bootdev");
 	if (ret)
 		return log_msg_ret("bd", ret);
 
drivers/virtio/virtio-uclass.c +1 -1
index 31bb21c534e5..87323ab6d193 100644
@@ -248,7 +248,7 @@ static int virtio_uclass_post_probe(struct udevice *udev)
 	device_set_name_alloced(vdev);
 
 	if (uc_priv->device == VIRTIO_ID_BLOCK && !IS_ENABLED(CONFIG_SANDBOX)) {
-		ret = bootdev_setup_sibling_blk(vdev, "virtio_bootdev");
+		ret = bootdev_setup_for_sibling_blk(vdev, "virtio_bootdev");
 		if (ret)
 			return log_msg_ret("bootdev", ret);
 	}
include/bootdev.h +5 -5
index 1533adfe5065..848233187f87 100644
@@ -371,7 +371,7 @@ int bootdev_next_prio(struct bootflow_iter *iter, struct udevice **devp);
 /**
  * bootdev_setup_for_dev() - Bind a new bootdev device (deprecated)
  *
- * Please use bootdev_setup_sibling_blk() instead since it supports multiple
+ * Please use bootdev_setup_for_sibling_blk() instead since it supports multiple
  * (child) block devices for each media device.
  *
  * Creates a bootdev device as a child of @parent. This should be called from
@@ -386,7 +386,7 @@ int bootdev_next_prio(struct bootflow_iter *iter, struct udevice **devp);
 int bootdev_setup_for_dev(struct udevice *parent, const char *drv_name);
 
 /**
- * bootdev_setup_for_blk() - Bind a new bootdev device for a blk device
+ * bootdev_setup_for_sibling_blk() - Bind a new bootdev device for a blk device
  *
  * Creates a bootdev device as a sibling of @blk. This should be called from
  * the driver's bind() method or its uclass' post_bind() method, at the same
@@ -398,7 +398,7 @@ int bootdev_setup_for_dev(struct udevice *parent, const char *drv_name);
  * @drv_name: Name of bootdev driver to bind
  * Return: 0 if OK, -ve on error
  */
-int bootdev_setup_sibling_blk(struct udevice *blk, const char *drv_name);
+int bootdev_setup_for_sibling_blk(struct udevice *blk, const char *drv_name);
 
 /**
  * bootdev_get_sibling_blk() - Locate the block device for a bootdev
@@ -428,8 +428,8 @@ static inline int bootdev_setup_for_dev(struct udevice *parent,
 	return 0;
 }
 
-static inline int bootdev_setup_sibling_blk(struct udevice *blk,
-					    const char *drv_name)
+static inline int bootdev_setup_for_sibling_blk(struct udevice *blk,
+						const char *drv_name)
 {
 	return 0;
 }
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
#13 lore raw

Re: [PATCH v2 4/9] bootstd: Rename bootdev_setup_sibling_blk()

Quoted 16 lines · Mattijs Korpershoek
Quoted 5 lines · Simon Glass

This name is a little confusing since it suggests that it sets up the sibling block device. In fact it sets up a bootdev for it. Rename the function to make this clearer.

Quoted 5 lines

---

Changes in v2:
- Fix the function name in the header as well

applied to u-boot-x86, thanks!

#14 lore raw

PATCH v2 5/9 bootstd: Correct creating of bootdev sibling

In reply to Simon Glass

Use the correct function here, since there may be multiple IDE devices available.

---

(no changes since v1)

 drivers/block/ide.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/block/ide.c +2 -2
index 89201dd4d229..c698f9cbd558 100644
@@ -1059,9 +1059,9 @@ static int ide_probe(struct udevice *udev)
 		desc->lba48 = pdesc.lba48;
 		desc->type = pdesc.type;
 
-		ret = bootdev_setup_for_dev(udev, "ide_bootdev");
+		ret = bootdev_setup_for_sibling_blk(blk, "ide_bootdev");
 		if (ret)
-			return log_msg_ret("bootdev", ret);
+			return log_msg_ret("bd", ret);
 	}
 
 	return 0;
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
#15 lore raw

Re: [PATCH v2 5/9] bootstd: Correct creating of bootdev sibling

Hi Simon,

Quoted 18 lines · Simon Glass

Use the correct function here, since there may be multiple IDE devices available.

---

(no changes since v1)

 drivers/block/ide.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/block/ide.c +0 -0
index 89201dd4d229..c698f9cbd558 100644

drivers/block/ide.c static int ide_probe(struct udevice *udev) · line 1064

Quoted 8 lines
drivers/block/ide.c +2 -2
@@ -1059,9 +1059,9 @@ static int ide_probe(struct udevice *udev)
                desc->lba48 = pdesc.lba48;
                desc->type = pdesc.type;
 
-               ret = bootdev_setup_for_dev(udev, "ide_bootdev");
+               ret = bootdev_setup_for_sibling_blk(blk, "ide_bootdev");
                if (ret)
-                       return log_msg_ret("bootdev", ret);
+                       return log_msg_ret("bd", ret);

Why changes from bootdev to bd here? To me, bd is unclear, and sounds like "boardinfo" in U-Boot.

drivers/block/ide.c static int ide_probe(struct udevice *udev)

Quoted 4 lines
drivers/block/ide.c +0 -1
        }
 
        return 0;
--

Regards,
Bin

#16 lore raw

Re: [PATCH v2 5/9] bootstd: Correct creating of bootdev sibling

Hi Bin,

Quoted 34 lines · Bin Meng

Hi Simon,

Quoted 7 lines · Simon Glass


        }

        return 0;

--

Regards,
Bin

Quoted 20 lines

Use the correct function here, since there may be multiple IDE devices available.

---

(no changes since v1)

 drivers/block/ide.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/block/ide.c +0 -0
index 89201dd4d229..c698f9cbd558 100644
@@ -1059,9 +1059,9 @@ static int ide_probe(struct udevice *udev)
                desc->lba48 = pdesc.lba48;
                desc->type = pdesc.type;
 
Quoted 8 lines

drivers/block/ide.c static int ide_probe(struct udevice *udev) · line 1064

Quoted 5 lines
drivers/block/ide.c +2 -2
-               ret = bootdev_setup_for_dev(udev, "ide_bootdev");
+               ret = bootdev_setup_for_sibling_blk(blk, "ide_bootdev");
                if (ret)
-                       return log_msg_ret("bootdev", ret);
+                       return log_msg_ret("bd", ret);

Why changes from bootdev to bd here? To me, bd is unclear, and sounds like "boardinfo" in U-Boot.

I don't need to...the goal is to have the strings be 4 bytes or less, so they don't use up too much space in the image...but also have them unique enough that you can look at the function and see which call site failed.

For this one, I don't mind either way.

Regards,
Simon

#17 lore raw

Re: [PATCH v2 5/9] bootstd: Correct creating of bootdev sibling

Hi Simon,

Quoted 47 lines · Simon Glass

Hi Bin,

Quoted 34 lines · Bin Meng

Hi Simon,

Quoted 7 lines · Simon Glass


        }

        return 0;

--

Regards,
Bin

Quoted 20 lines

Use the correct function here, since there may be multiple IDE devices available.

---

(no changes since v1)

 drivers/block/ide.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/block/ide.c +0 -0
index 89201dd4d229..c698f9cbd558 100644
@@ -1059,9 +1059,9 @@ static int ide_probe(struct udevice *udev)
                desc->lba48 = pdesc.lba48;
                desc->type = pdesc.type;
 
Quoted 8 lines

drivers/block/ide.c static int ide_probe(struct udevice *udev) · line 1064

Quoted 5 lines
drivers/block/ide.c +2 -2
-               ret = bootdev_setup_for_dev(udev, "ide_bootdev");
+               ret = bootdev_setup_for_sibling_blk(blk, "ide_bootdev");
                if (ret)
-                       return log_msg_ret("bootdev", ret);
+                       return log_msg_ret("bd", ret);

Why changes from bootdev to bd here? To me, bd is unclear, and sounds like "boardinfo" in U-Boot.

Quoted 4 lines

I don't need to...the goal is to have the strings be 4 bytes or less, so they don't use up too much space in the image...but also have them unique enough that you can look at the function and see which call site failed.

I see the needs of saving size in TPL, or maybe SPL, but not everywhere, right?

Quoted 2 lines

For this one, I don't mind either way.

Regards,
Bin

#18 lore raw

Re: [PATCH v2 5/9] bootstd: Correct creating of bootdev sibling

Hi Bin,

Quoted 51 lines · Bin Meng

Hi Simon,

Quoted 47 lines · Simon Glass

Hi Bin,

Quoted 42 lines · Bin Meng

Hi Simon,

Quoted 7 lines · Simon Glass


        }

        return 0;

--

Regards,
Bin

Quoted 17 lines

Use the correct function here, since there may be multiple IDE devices available.

---

(no changes since v1)

 drivers/block/ide.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/block/ide.c +0 -0
index 89201dd4d229..c698f9cbd558 100644

drivers/block/ide.c static int ide_probe(struct udevice *udev) · line 1064

Quoted 8 lines
drivers/block/ide.c +2 -2
@@ -1059,9 +1059,9 @@ static int ide_probe(struct udevice *udev)
                desc->lba48 = pdesc.lba48;
                desc->type = pdesc.type;
 
-               ret = bootdev_setup_for_dev(udev, "ide_bootdev");
+               ret = bootdev_setup_for_sibling_blk(blk, "ide_bootdev");
                if (ret)
-                       return log_msg_ret("bootdev", ret);
+                       return log_msg_ret("bd", ret);

Why changes from bootdev to bd here? To me, bd is unclear, and sounds like "boardinfo" in U-Boot.

Quoted 6 lines
Quoted 4 lines

I don't need to...the goal is to have the strings be 4 bytes or less, so they don't use up too much space in the image...but also have them unique enough that you can look at the function and see which call site failed.

I see the needs of saving size in TPL, or maybe SPL, but not everywhere, right?

The thing is, we only have one knob to control this - CONFIG_LOG_ERROR_RETURN

When you enable it, all of the log_msg_ret() calls in U-Boot produce a string. So there is quite a big impact.

For example, on coral, the text size increases by about 35KB. So it is about a 6% increase. If it gets to much then it might not fit, or it might cause other prolbems. For example, we have fixed-size regions in binman for U-Boot.

Regards,
Simon

Quoted 3 lines
Quoted 3 lines

For this one, I don't mind either way.

Regards,
Simon

#20 lore raw

PATCH v2 6/9 bootstd: Add some more debugging in the bootdev uclass

In reply to Simon Glass

Add some more output to make it easier to see what is going wrong when a bootdev hunter fails.

---

(no changes since v1)

 boot/bootdev-uclass.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
boot/bootdev-uclass.c +8 -1
index 114853ffb72a..a3661b18e28d 100644
@@ -537,6 +537,8 @@ static int default_get_bootflow(struct udevice *dev, struct bootflow_iter *iter,
 	int ret;
 
 	ret = bootdev_get_sibling_blk(dev, &blk);
+	log_debug("sibling_blk ret=%d, blk=%s\n", ret,
+		  ret ? "(none)" : blk->name);
 	/*
 	 * If there is no media, indicate that no more partitions should be
 	 * checked
@@ -662,7 +664,8 @@ int bootdev_next_prio(struct bootflow_iter *iter, struct udevice **devp)
 				ret = bootdev_hunt_prio(iter->cur_prio,
 							iter->flags &
 							BOOTFLOWIF_SHOW);
-				log_debug("- hunt ret %d\n", ret);
+				log_debug("- bootdev_hunt_prio() ret %d\n",
+					  ret);
 				if (ret)
 					return log_msg_ret("hun", ret);
 			}
@@ -698,6 +701,7 @@ int bootdev_setup_iter(struct bootflow_iter *iter, const char *label,
 	/* hunt for any pre-scan devices */
 	if (iter->flags & BOOTFLOWIF_HUNT) {
 		ret = bootdev_hunt_prio(BOOTDEVP_1_PRE_SCAN, show);
+		log_debug("- bootdev_hunt_prio() ret %d\n", ret);
 		if (ret)
 			return log_msg_ret("pre", ret);
 	}
@@ -768,6 +772,7 @@ static int bootdev_hunt_drv(struct bootdev_hunter *info, uint seq, bool show)
 		log_debug("Hunting with: %s\n", name);
 		if (info->hunt) {
 			ret = info->hunt(info, show);
+			log_debug("  - hunt result %d\n", ret);
 			if (ret)
 				return ret;
 		}
@@ -833,9 +838,11 @@ int bootdev_hunt_prio(enum bootdev_prio_t prio, bool show)
 		if (prio != info->prio)
 			continue;
 		ret = bootdev_hunt_drv(info, i, show);
+		log_debug("bootdev_hunt_drv() return %d\n", ret);
 		if (ret && ret != -ENOENT)
 			result = ret;
 	}
+	log_debug("exit %d\n", result);
 
 	return result;
 }
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
Reviewed-by on v2 6/9
#21 lore raw

Re: [PATCH v2 6/9] bootstd: Add some more debugging in the bootdev uclass

Quoted 4 lines · Simon Glass

Add some more output to make it easier to see what is going wrong when a bootdev hunter fails.

Quoted 8 lines

---

(no changes since v1)

 boot/bootdev-uclass.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
#22 lore raw

Re: [PATCH v2 6/9] bootstd: Add some more debugging in the bootdev uclass

Quoted 9 lines · Bin Meng
Quoted 7 lines · Simon Glass

Add some more output to make it easier to see what is going wrong when a bootdev hunter fails.

---

Quoted 7 lines
Quoted 5 lines

(no changes since v1)

 boot/bootdev-uclass.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

applied to u-boot-x86, thanks!

#23 lore raw

PATCH v2 7/9 x86: coreboot: Add IDE and SATA

In reply to Simon Glass

Add these options to permit access to more disk types.

Add some documentation as well.

---

(no changes since v1)

 configs/coreboot64_defconfig    |  1 +
 configs/coreboot_defconfig      |  9 +++++++++
 doc/board/coreboot/coreboot.rst | 20 ++++++++++++++++++++
 3 files changed, 30 insertions(+)
configs/coreboot64_defconfig +1 -0
index 8aadaa68c279..ded0e6f2422d 100644
@@ -26,6 +26,7 @@ CONFIG_SYS_PBSIZE=532
 CONFIG_CMD_IDE=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_PART=y
+CONFIG_CMD_SATA=y
 CONFIG_CMD_USB=y
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_CMD_DHCP=y
configs/coreboot_defconfig +9 -0
index 8e11de663819..56cc542df6c6 100644
@@ -22,8 +22,10 @@ CONFIG_LOGF_FUNC=y
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_LAST_STAGE_INIT=y
 CONFIG_PCI_INIT_R=y
+CONFIG_CMD_IDE=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_PART=y
+CONFIG_CMD_SATA=y
 CONFIG_CMD_USB=y
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_CMD_DHCP=y
@@ -48,6 +50,13 @@ CONFIG_USE_ROOTPATH=y
 CONFIG_REGMAP=y
 CONFIG_SYSCON=y
 # CONFIG_ACPIGEN is not set
+CONFIG_SYS_IDE_MAXDEVICE=4
+CONFIG_SYS_ATA_DATA_OFFSET=0
+CONFIG_SYS_ATA_REG_OFFSET=0
+CONFIG_SYS_ATA_ALT_OFFSET=0
+CONFIG_ATAPI=y
+CONFIG_LBA48=y
+CONFIG_SYS_64BIT_LBA=y
 CONFIG_NVME_PCI=y
 # CONFIG_PCI_PNP is not set
 CONFIG_SOUND=y
doc/board/coreboot/coreboot.rst +20 -0
index 0fe95af56d2d..8e638a3c74cf 100644
@@ -41,6 +41,26 @@ At present it seems that for Minnowboard Max, coreboot does not pass through
 the video information correctly (it always says the resolution is 0x0). This
 works correctly for link though.
 
+You can run via QEMU using::
+
+  qemu-system-x86_64 -bios build/coreboot.rom -serial mon:stdio
+
+The `-serial mon:stdio` part shows both output in the display and on the
+console. It is optional. You can add `nographic` as well to *only* get console
+output.
+
+To run with a SATA drive called `$DISK`::
+
+  qemu-system-x86_64 -bios build/coreboot.rom -serial mon:stdio \
+	-drive id=disk,file=$DISK,if=none \
+	-device ahci,id=ahci \
+	-device ide-hd,drive=disk,bus=ahci.0
+
+Then you can scan it with `scsi scan` and access it normally.
+
+To use 4GB of memory, typically necessary for booting Linux distros, add
+`-m 4GB`.
+
 64-bit U-Boot
 -------------
 
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
#24 lore raw

Re: [PATCH v2 7/9] x86: coreboot: Add IDE and SATA

Hi Simon,

Quoted 63 lines · Simon Glass

Add these options to permit access to more disk types.

Add some documentation as well.

---

(no changes since v1)

 configs/coreboot64_defconfig    |  1 +
 configs/coreboot_defconfig      |  9 +++++++++
 doc/board/coreboot/coreboot.rst | 20 ++++++++++++++++++++
 3 files changed, 30 insertions(+)
configs/coreboot64_defconfig +1 -0
index 8aadaa68c279..ded0e6f2422d 100644
@@ -26,6 +26,7 @@ CONFIG_SYS_PBSIZE=532
 CONFIG_CMD_IDE=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_PART=y
+CONFIG_CMD_SATA=y
 CONFIG_CMD_USB=y
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_CMD_DHCP=y
configs/coreboot_defconfig +9 -0
index 8e11de663819..56cc542df6c6 100644
@@ -22,8 +22,10 @@ CONFIG_LOGF_FUNC=y
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_LAST_STAGE_INIT=y
 CONFIG_PCI_INIT_R=y
+CONFIG_CMD_IDE=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_PART=y
+CONFIG_CMD_SATA=y
 CONFIG_CMD_USB=y
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_CMD_DHCP=y
@@ -48,6 +50,13 @@ CONFIG_USE_ROOTPATH=y
 CONFIG_REGMAP=y
 CONFIG_SYSCON=y
 # CONFIG_ACPIGEN is not set
+CONFIG_SYS_IDE_MAXDEVICE=4
+CONFIG_SYS_ATA_DATA_OFFSET=0
+CONFIG_SYS_ATA_REG_OFFSET=0
+CONFIG_SYS_ATA_ALT_OFFSET=0
+CONFIG_ATAPI=y
+CONFIG_LBA48=y
+CONFIG_SYS_64BIT_LBA=y
 CONFIG_NVME_PCI=y
 # CONFIG_PCI_PNP is not set
 CONFIG_SOUND=y
doc/board/coreboot/coreboot.rst +0 -0
index 0fe95af56d2d..8e638a3c74cf 100644
@@ -41,6 +41,26 @@ At present it seems that for Minnowboard Max, coreboot does not pass through
 the video information correctly (it always says the resolution is 0x0). This
 works correctly for link though.

doc/board/coreboot/coreboot.rst At present it seems that for Minnowboard Max, coreboot does not pass through · line 52

Quoted 10 lines
doc/board/coreboot/coreboot.rst +9 -0
 
+You can run via QEMU using::
+
+  qemu-system-x86_64 -bios build/coreboot.rom -serial mon:stdio
+
+The `-serial mon:stdio` part shows both output in the display and on the
+console. It is optional. You can add `nographic` as well to *only* get console
+output.
+
+To run with a SATA drive called `$DISK`::

It is unclear what this is. It should clearly say this is the disk image file?

doc/board/coreboot/coreboot.rst At present it seems that for Minnowboard Max, coreboot does not pass through · line 57

Quoted 5 lines
doc/board/coreboot/coreboot.rst +5 -0
+
+  qemu-system-x86_64 -bios build/coreboot.rom -serial mon:stdio \
+       -drive id=disk,file=$DISK,if=none \
+       -device ahci,id=ahci \
+       -device ide-hd,drive=disk,bus=ahci.0

Can we use AHCI directly, instead of the legacy IDE driver?

doc/board/coreboot/coreboot.rst At present it seems that for Minnowboard Max, coreboot does not pass through

Quoted 10 lines
doc/board/coreboot/coreboot.rst +6 -1
+
+Then you can scan it with `scsi scan` and access it normally.
+
+To use 4GB of memory, typically necessary for booting Linux distros, add
+`-m 4GB`.
+
 64-bit U-Boot
 -------------
 
--

Regards,
Bin

#25 lore raw

Re: [PATCH v2 7/9] x86: coreboot: Add IDE and SATA

Hi Bin,

Quoted 80 lines · Bin Meng

Hi Simon,

Quoted 63 lines · Simon Glass

Add these options to permit access to more disk types.

Add some documentation as well.

---

(no changes since v1)

 configs/coreboot64_defconfig    |  1 +
 configs/coreboot_defconfig      |  9 +++++++++
 doc/board/coreboot/coreboot.rst | 20 ++++++++++++++++++++
 3 files changed, 30 insertions(+)
configs/coreboot64_defconfig +1 -0
index 8aadaa68c279..ded0e6f2422d 100644
@@ -26,6 +26,7 @@ CONFIG_SYS_PBSIZE=532
 CONFIG_CMD_IDE=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_PART=y
+CONFIG_CMD_SATA=y
 CONFIG_CMD_USB=y
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_CMD_DHCP=y
configs/coreboot_defconfig +9 -0
index 8e11de663819..56cc542df6c6 100644
@@ -22,8 +22,10 @@ CONFIG_LOGF_FUNC=y
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_LAST_STAGE_INIT=y
 CONFIG_PCI_INIT_R=y
+CONFIG_CMD_IDE=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_PART=y
+CONFIG_CMD_SATA=y
 CONFIG_CMD_USB=y
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_CMD_DHCP=y
@@ -48,6 +50,13 @@ CONFIG_USE_ROOTPATH=y
 CONFIG_REGMAP=y
 CONFIG_SYSCON=y
 # CONFIG_ACPIGEN is not set
+CONFIG_SYS_IDE_MAXDEVICE=4
+CONFIG_SYS_ATA_DATA_OFFSET=0
+CONFIG_SYS_ATA_REG_OFFSET=0
+CONFIG_SYS_ATA_ALT_OFFSET=0
+CONFIG_ATAPI=y
+CONFIG_LBA48=y
+CONFIG_SYS_64BIT_LBA=y
 CONFIG_NVME_PCI=y
 # CONFIG_PCI_PNP is not set
 CONFIG_SOUND=y
doc/board/coreboot/coreboot.rst +0 -0
index 0fe95af56d2d..8e638a3c74cf 100644
@@ -41,6 +41,26 @@ At present it seems that for Minnowboard Max, coreboot does not pass through
 the video information correctly (it always says the resolution is 0x0). This
 works correctly for link though.

doc/board/coreboot/coreboot.rst At present it seems that for Minnowboard Max, coreboot does not pass through · line 52

Quoted 10 lines
doc/board/coreboot/coreboot.rst +9 -0
 
+You can run via QEMU using::
+
+  qemu-system-x86_64 -bios build/coreboot.rom -serial mon:stdio
+
+The `-serial mon:stdio` part shows both output in the display and on the
+console. It is optional. You can add `nographic` as well to *only* get console
+output.
+
+To run with a SATA drive called `$DISK`::

It is unclear what this is. It should clearly say this is the disk image file?

Quoted 8 lines

doc/board/coreboot/coreboot.rst At present it seems that for Minnowboard Max, coreboot does not pass through · line 57

Quoted 5 lines
doc/board/coreboot/coreboot.rst +5 -0
+
+  qemu-system-x86_64 -bios build/coreboot.rom -serial mon:stdio \
+       -drive id=disk,file=$DISK,if=none \
+       -device ahci,id=ahci \
+       -device ide-hd,drive=disk,bus=ahci.0

Can we use AHCI directly, instead of the legacy IDE driver?

Probably...do you know the QEMU incantation for that?

Quoted 11 lines

doc/board/coreboot/coreboot.rst At present it seems that for Minnowboard Max, coreboot does not pass through

Quoted 10 lines
doc/board/coreboot/coreboot.rst +6 -1
+
+Then you can scan it with `scsi scan` and access it normally.
+
+To use 4GB of memory, typically necessary for booting Linux distros, add
+`-m 4GB`.
+
 64-bit U-Boot
 -------------
 
--

Regards,
Simon

#26 lore raw

Re: [PATCH v2 7/9] x86: coreboot: Add IDE and SATA

Hi Simon,

Quoted 90 lines · Simon Glass

Hi Bin,

Quoted 86 lines · Bin Meng

Hi Simon,

Quoted 63 lines · Simon Glass

Add these options to permit access to more disk types.

Add some documentation as well.

---

(no changes since v1)

 configs/coreboot64_defconfig    |  1 +
 configs/coreboot_defconfig      |  9 +++++++++
 doc/board/coreboot/coreboot.rst | 20 ++++++++++++++++++++
 3 files changed, 30 insertions(+)
configs/coreboot64_defconfig +1 -0
index 8aadaa68c279..ded0e6f2422d 100644
@@ -26,6 +26,7 @@ CONFIG_SYS_PBSIZE=532
 CONFIG_CMD_IDE=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_PART=y
+CONFIG_CMD_SATA=y
 CONFIG_CMD_USB=y
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_CMD_DHCP=y
configs/coreboot_defconfig +9 -0
index 8e11de663819..56cc542df6c6 100644
@@ -22,8 +22,10 @@ CONFIG_LOGF_FUNC=y
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_LAST_STAGE_INIT=y
 CONFIG_PCI_INIT_R=y
+CONFIG_CMD_IDE=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_PART=y
+CONFIG_CMD_SATA=y
 CONFIG_CMD_USB=y
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_CMD_DHCP=y
@@ -48,6 +50,13 @@ CONFIG_USE_ROOTPATH=y
 CONFIG_REGMAP=y
 CONFIG_SYSCON=y
 # CONFIG_ACPIGEN is not set
+CONFIG_SYS_IDE_MAXDEVICE=4
+CONFIG_SYS_ATA_DATA_OFFSET=0
+CONFIG_SYS_ATA_REG_OFFSET=0
+CONFIG_SYS_ATA_ALT_OFFSET=0
+CONFIG_ATAPI=y
+CONFIG_LBA48=y
+CONFIG_SYS_64BIT_LBA=y
 CONFIG_NVME_PCI=y
 # CONFIG_PCI_PNP is not set
 CONFIG_SOUND=y
doc/board/coreboot/coreboot.rst +0 -0
index 0fe95af56d2d..8e638a3c74cf 100644
@@ -41,6 +41,26 @@ At present it seems that for Minnowboard Max, coreboot does not pass through
 the video information correctly (it always says the resolution is 0x0). This
 works correctly for link though.

doc/board/coreboot/coreboot.rst At present it seems that for Minnowboard Max, coreboot does not pass through · line 52

Quoted 10 lines
doc/board/coreboot/coreboot.rst +9 -0
 
+You can run via QEMU using::
+
+  qemu-system-x86_64 -bios build/coreboot.rom -serial mon:stdio
+
+The `-serial mon:stdio` part shows both output in the display and on the
+console. It is optional. You can add `nographic` as well to *only* get console
+output.
+
+To run with a SATA drive called `$DISK`::

It is unclear what this is. It should clearly say this is the disk image file?

Quoted 5 lines
doc/board/coreboot/coreboot.rst +5 -0
+
+  qemu-system-x86_64 -bios build/coreboot.rom -serial mon:stdio \
+       -drive id=disk,file=$DISK,if=none \
+       -device ahci,id=ahci \
+       -device ide-hd,drive=disk,bus=ahci.0
Quoted 5 lines
Quoted 2 lines

Can we use AHCI directly, instead of the legacy IDE driver?

Probably...do you know the QEMU incantation for that?

If you are using "-M q35", an AHCI controller is automatically instantiated.

If you omit "-M q35", then you can add "-device ich9-ahci".

Regards,
Bin

#27 lore raw

PATCH v2 8/9 x86: coreboot: Enable standard boot

In reply to Simon Glass

Enable bootstd options and provide instructions on how to boot a linux distro using coreboot.

---

(no changes since v1)

 configs/coreboot64_defconfig    | 14 ++------------
 configs/coreboot_defconfig      |  1 +
 doc/board/coreboot/coreboot.rst | 16 ++++++++++++++--
 3 files changed, 17 insertions(+), 14 deletions(-)
configs/coreboot64_defconfig +2 -12
index ded0e6f2422d..602465175d20 100644
@@ -10,40 +10,30 @@ CONFIG_VENDOR_COREBOOT=y
 CONFIG_TARGET_COREBOOT=y
 CONFIG_FIT=y
 CONFIG_FIT_SIGNATURE=y
+CONFIG_BOOTSTD_FULL=y
+CONFIG_BOOTSTD_DEFAULTS=y
 CONFIG_SYS_MONITOR_BASE=0x01120000
 CONFIG_SHOW_BOOT_PROGRESS=y
 CONFIG_USE_BOOTARGS=y
 CONFIG_BOOTARGS="root=/dev/sdb3 init=/sbin/init rootwait ro"
-CONFIG_USE_BOOTCOMMAND=y
-CONFIG_BOOTCOMMAND="ext2load scsi 0:3 01000000 /boot/vmlinuz; zboot 01000000"
 CONFIG_PRE_CONSOLE_BUFFER=y
 CONFIG_SYS_CONSOLE_INFO_QUIET=y
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_LAST_STAGE_INIT=y
 CONFIG_SPL_NO_BSS_LIMIT=y
-CONFIG_HUSH_PARSER=y
 CONFIG_SYS_PBSIZE=532
 CONFIG_CMD_IDE=y
 CONFIG_CMD_MMC=y
-CONFIG_CMD_PART=y
 CONFIG_CMD_SATA=y
 CONFIG_CMD_USB=y
 # CONFIG_CMD_SETEXPR is not set
-CONFIG_CMD_DHCP=y
 CONFIG_BOOTP_BOOTFILESIZE=y
-CONFIG_CMD_PING=y
 CONFIG_CMD_TIME=y
 CONFIG_CMD_SOUND=y
-CONFIG_CMD_EXT2=y
-CONFIG_CMD_EXT4=y
 CONFIG_CMD_EXT4_WRITE=y
-CONFIG_CMD_FAT=y
-CONFIG_CMD_FS_GENERIC=y
 CONFIG_MAC_PARTITION=y
 # CONFIG_SPL_MAC_PARTITION is not set
 # CONFIG_SPL_DOS_PARTITION is not set
-CONFIG_ISO_PARTITION=y
-CONFIG_EFI_PARTITION=y
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_ENV_OVERWRITE=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
configs/coreboot_defconfig +1 -0
index 56cc542df6c6..735cd6eb4c22 100644
@@ -10,6 +10,7 @@ CONFIG_TARGET_COREBOOT=y
 CONFIG_FIT=y
 CONFIG_FIT_SIGNATURE=y
 CONFIG_BOOTSTD_FULL=y
+CONFIG_BOOTSTD_DEFAULTS=y
 CONFIG_SYS_MONITOR_BASE=0x01110000
 CONFIG_SHOW_BOOT_PROGRESS=y
 CONFIG_USE_BOOTARGS=y
doc/board/coreboot/coreboot.rst +14 -2
index 8e638a3c74cf..d09dfc553c87 100644
@@ -67,9 +67,21 @@ To use 4GB of memory, typically necessary for booting Linux distros, add
 In addition to the 32-bit 'coreboot' build there is a 'coreboot64' build. This
 produces an image which can be booted from coreboot (32-bit). Internally it
 works by using a 32-bit SPL binary to switch to 64-bit for running U-Boot. It
-can be useful for running UEFI applications, for example.
+can be useful for running UEFI applications, for example with the coreboot
+build in `$CBDIR`::
+
+   DISK=ubuntu-23.04-desktop-amd64.iso
+   CBDIR=~/coreboot/build
+
+   cp $CBDIR/coreboot.rom.in coreboot.rom
+   cbfstool coreboot.rom add-flat-binary -f u-boot-x86-with-spl.bin \
+      -n fallback/payload -c LZMA -l 0x1110000 -e 0x1110000
+
+   qemu-system-x86_64 -m 2G -smp 4 -bios coreboot.rom \
+      -drive id=disk,file=$DISK,if=none \
+      -device ahci,id=ahci \
+      -device ide-hd,drive=disk,bus=ahci.0 \
 
-This has only been lightly tested.
 
 
 Memory map
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
#28 lore raw

PATCH v2 9/9 x86: coreboot: Enable support for CBFS

In reply to Simon Glass

This is normally used with coreboot, so enable support for it in the coreboot builds.

Add an example to show how it is used.

---

(no changes since v1)

 configs/coreboot64_defconfig    |  1 +
 configs/coreboot_defconfig      |  1 +
 doc/board/coreboot/coreboot.rst | 34 +++++++++++++++++++++++++++++++++
 3 files changed, 36 insertions(+)
configs/coreboot64_defconfig +1 -0
index 602465175d20..55064d1ce66f 100644
@@ -56,3 +56,4 @@ CONFIG_SOUND=y
 CONFIG_SOUND_I8254=y
 CONFIG_CONSOLE_SCROLL_LINES=5
 # CONFIG_GZIP is not set
+CONFIG_CMD_CBFS=y
configs/coreboot_defconfig +1 -0
index 735cd6eb4c22..77214f1b4c06 100644
@@ -66,3 +66,4 @@ CONFIG_CONSOLE_SCROLL_LINES=5
 CONFIG_CMD_DHRYSTONE=y
 # CONFIG_GZIP is not set
 CONFIG_SMBIOS_PARSER=y
+CONFIG_CMD_CBFS=y
doc/board/coreboot/coreboot.rst +34 -0
index d09dfc553c87..11e461a2ae0b 100644
@@ -83,6 +83,40 @@ build in `$CBDIR`::
       -device ide-hd,drive=disk,bus=ahci.0 \
 
 
+CBFS access
+-----------
+
+You can use the 'cbfs' commands to access the Coreboot filesystem::
+
+   => cbfsinit
+   => cbfsinfo
+
+   CBFS version: 0x31313132
+   ROM size: 0x100000
+   Boot block size: 0x4
+   CBFS size: 0xffdfc
+   Alignment: 64
+   Offset: 0x200
+
+   => cbfsls
+        size              type  name
+   ------------------------------------------
+          32       cbfs header  cbfs master header
+       16720                17  fallback/romstage
+       53052                17  fallback/ramstage
+         398               raw  config
+         715               raw  revision
+         117               raw  build_info
+        4044               raw  fallback/dsdt.aml
+         640       cmos layout  cmos_layout.bin
+       17804                17  fallback/postcar
+      335797           payload  fallback/payload
+      607000              null  (empty)
+       10752         bootblock  bootblock
+
+   12 file(s)
+
+   =>
 
 Memory map
 ----------
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
Reviewed-by on v2 9/9
#29 lore raw

Re: [PATCH v2 9/9] x86: coreboot: Enable support for CBFS

Quoted 7 lines · Simon Glass

This is normally used with coreboot, so enable support for it in the coreboot builds.

Add an example to show how it is used.

Quoted 9 lines

---

(no changes since v1)

 configs/coreboot64_defconfig    |  1 +
 configs/coreboot_defconfig      |  1 +
 doc/board/coreboot/coreboot.rst | 34 +++++++++++++++++++++++++++++++++
 3 files changed, 36 insertions(+)
#30 lore raw

Re: [PATCH v2 9/9] x86: coreboot: Enable support for CBFS

Quoted 13 lines · Bin Meng
Quoted 11 lines · Simon Glass

This is normally used with coreboot, so enable support for it in the coreboot builds.

Add an example to show how it is used.

---

(no changes since v1)

Quoted 7 lines
Quoted 5 lines
 configs/coreboot64_defconfig    |  1 +
 configs/coreboot_defconfig      |  1 +
 doc/board/coreboot/coreboot.rst | 34 +++++++++++++++++++++++++++++++++
 3 files changed, 36 insertions(+)

applied to u-boot-x86, thanks!

#31 lore raw

Re: [PATCH v2 9/9] x86: coreboot: Enable support for CBFS

Hi Simon,

Quoted 10 lines · Bin Meng
Quoted 8 lines · Bin Meng
Quoted 6 lines · Simon Glass

This is normally used with coreboot, so enable support for it in the coreboot builds.

Add an example to show how it is used.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

---

(no changes since v1)

 configs/coreboot64_defconfig    |  1 +
 configs/coreboot_defconfig      |  1 +

It turns out there is no need to explicitly add CMD_CBFS in the defconfigs, as it is already implied by SYS_COREBOOT.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
 doc/board/coreboot/coreboot.rst | 34 +++++++++++++++++++++++++++++++++
 3 files changed, 36 insertions(+)

applied to u-boot-x86, thanks!

Commit edited in u-boot-x86.

Regards,
Bin