]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
qemu-x86: Use config_distro_bootcmd
authorJoshua Watt <jpewhacker@gmail.com>
Wed, 3 Jul 2019 17:45:32 +0000 (12:45 -0500)
committerBin Meng <bmeng.cn@gmail.com>
Fri, 9 Aug 2019 14:24:02 +0000 (22:24 +0800)
Converts qemu x86 machines to boot using distro_config. The intent is to
allow u-boot in qemu to be maximally compatible with many boot methods
without having to change the config. Previously, u-boot would only boot
in a very limited set of circumstances where there was a /boot/vmlinuz
on scsi 0:3 with no ramdisk.

Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
[bmeng: convert doc updates to reST]
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
configs/qemu-x86_64_defconfig
configs/qemu-x86_defconfig
doc/board/emulation/qemu-x86.rst
include/configs/qemu-x86.h

index 532611f4a9182b40b972631cd47f679c2f782ea0..53d9c8cf8239e400299195601eee23a14566cea7 100644 (file)
@@ -12,6 +12,7 @@ CONFIG_SMP=y
 CONFIG_GENERATE_PIRQ_TABLE=y
 CONFIG_GENERATE_MP_TABLE=y
 CONFIG_GENERATE_ACPI_TABLE=y
+CONFIG_DISTRO_DEFAULTS=y
 CONFIG_BUILD_ROM=y
 CONFIG_FIT=y
 CONFIG_SPL_LOAD_FIT=y
index ef85c5259279cc9b1dfe663978a35d525857eed4..ad5613540103d7b8140f88a3453860c898fa2a53 100644 (file)
@@ -6,6 +6,7 @@ CONFIG_SMP=y
 CONFIG_GENERATE_PIRQ_TABLE=y
 CONFIG_GENERATE_MP_TABLE=y
 CONFIG_GENERATE_ACPI_TABLE=y
+CONFIG_DISTRO_DEFAULTS=y
 CONFIG_BUILD_ROM=y
 CONFIG_FIT=y
 CONFIG_BOOTSTAGE=y
index c2e704afb2bce56db0672d399fbd8fc9ff878f5e..db842f2ece6e86ae515bc63cda7cbaf278093a96 100644 (file)
@@ -54,6 +54,23 @@ If you want to check both consoles, use '-serial stdio'.
 Multicore is also supported by QEMU via '-smp n' where n is the number of cores
 to instantiate. Note, the maximum supported CPU number in QEMU is 255.
 
+U-Boot uses 'distro_bootcmd' by default when booting on x86 QEMU. This tries to
+load a boot script, kernel, and ramdisk from several different interfaces. For
+the default boot order, see 'qemu-x86.h'. For more information, see
+'README.distro'. Most Linux distros can be booted by writing a uboot script.
+For example, Debian (stretch) can be booted by creating a script file named
+'boot.txt' with the contents::
+
+   setenv bootargs root=/dev/sda1 ro
+   load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr_r} /vmlinuz
+   load ${devtype} ${devnum}:${distro_bootpart} ${ramdisk_addr_r} /initrd.img
+   zboot ${kernel_addr_r} - ${ramdisk_addr_r} ${filesize}
+
+Then compile and install it with::
+
+   $ apt install u-boot-tools && \
+     mkimage -T script -C none -n "Boot script" -d boot.txt /boot/boot.scr
+
 The fw_cfg interface in QEMU also provides information about kernel data,
 initrd, command-line arguments and more. U-Boot supports directly accessing
 these informtion from fw_cfg interface, which saves the time of loading them
index 64e7a60b8a0ec7599d48909b4ba491a783e7f605..097ed414f88e3919a36b338f7e34e98ffef6ce14 100644 (file)
 #ifndef __CONFIG_H
 #define __CONFIG_H
 
+#include <linux/sizes.h>
+
+#define BOOT_TARGET_DEVICES(func) \
+       func(USB, usb, 0) \
+       func(SCSI, scsi, 0) \
+       func(VIRTIO, virtio, 0) \
+       func(IDE, ide, 0) \
+       func(DHCP, dhcp, na)
+
+#include <config_distro_bootcmd.h>
 #include <configs/x86-common.h>
 
+#undef CONFIG_ENV_SIZE
+#define CONFIG_ENV_SIZE                        SZ_256K
+
+#define CONFIG_PREBOOT "pci enum"
+
+#undef CONFIG_EXTRA_ENV_SETTINGS
+#define CONFIG_EXTRA_ENV_SETTINGS \
+       CONFIG_STD_DEVICES_SETTINGS \
+       "scriptaddr=0x7000000\0" \
+       "kernel_addr_r=0x1000000\0" \
+       "ramdisk_addr_r=0x4000000\0" \
+       "consoledev=ttyS0\0" \
+       CONFIG_OTHBOOTARGS \
+       BOOTENV
+
 #define CONFIG_SYS_MONITOR_LEN         (1 << 20)
 
 #define CONFIG_STD_DEVICES_SETTINGS    "stdin=serial,i8042-kbd\0" \