summaryrefslogtreecommitdiff
path: root/doc/board/emulation
diff options
context:
space:
mode:
Diffstat (limited to 'doc/board/emulation')
-rw-r--r--doc/board/emulation/index.rst12
-rw-r--r--doc/board/emulation/qemu-arm.rst82
-rw-r--r--doc/board/emulation/qemu-mips.rst234
-rw-r--r--doc/board/emulation/qemu-riscv.rst49
-rw-r--r--doc/board/emulation/qemu-x86.rst101
5 files changed, 478 insertions, 0 deletions
diff --git a/doc/board/emulation/index.rst b/doc/board/emulation/index.rst
new file mode 100644
index 0000000000..1adefee155
--- /dev/null
+++ b/doc/board/emulation/index.rst
@@ -0,0 +1,12 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+Emulation
+=========
+
+.. toctree::
+ :maxdepth: 2
+
+ qemu-arm
+ qemu-mips
+ qemu-riscv
+ qemu-x86
diff --git a/doc/board/emulation/qemu-arm.rst b/doc/board/emulation/qemu-arm.rst
new file mode 100644
index 0000000000..ca751d4af4
--- /dev/null
+++ b/doc/board/emulation/qemu-arm.rst
@@ -0,0 +1,82 @@
+.. SPDX-License-Identifier: GPL-2.0+
+.. Copyright (C) 2017, Tuomas Tynkkynen <tuomas.tynkkynen@iki.fi>
+
+QEMU ARM
+========
+
+QEMU for ARM supports a special 'virt' machine designed for emulation and
+virtualization purposes. This document describes how to run U-Boot under it.
+Both 32-bit ARM and AArch64 are supported.
+
+The 'virt' platform provides the following as the basic functionality:
+
+ - A freely configurable amount of CPU cores
+ - U-Boot loaded and executing in the emulated flash at address 0x0
+ - A generated device tree blob placed at the start of RAM
+ - A freely configurable amount of RAM, described by the DTB
+ - A PL011 serial port, discoverable via the DTB
+ - An ARMv7/ARMv8 architected timer
+ - PSCI for rebooting the system
+ - A generic ECAM-based PCI host controller, discoverable via the DTB
+
+Additionally, a number of optional peripherals can be added to the PCI bus.
+
+Building U-Boot
+---------------
+Set the CROSS_COMPILE environment variable as usual, and run:
+
+- For ARM::
+
+ make qemu_arm_defconfig
+ make
+
+- For AArch64::
+
+ make qemu_arm64_defconfig
+ make
+
+Running U-Boot
+--------------
+The minimal QEMU command line to get U-Boot up and running is:
+
+- For ARM::
+
+ qemu-system-arm -machine virt -bios u-boot.bin
+
+- For AArch64::
+
+ qemu-system-aarch64 -machine virt -cpu cortex-a57 -bios u-boot.bin
+
+Note that for some odd reason qemu-system-aarch64 needs to be explicitly
+told to use a 64-bit CPU or it will boot in 32-bit mode.
+
+Additional persistent U-boot environment support can be added as follows:
+
+- Create envstore.img using qemu-img::
+
+ qemu-img create -f raw envstore.img 64M
+
+- Add a pflash drive parameter to the command line::
+
+ -drive if=pflash,format=raw,index=1,file=envstore.img
+
+Additional peripherals that have been tested to work in both U-Boot and Linux
+can be enabled with the following command line parameters:
+
+- To add a Serial ATA disk via an Intel ICH9 AHCI controller, pass e.g.::
+
+ -drive if=none,file=disk.img,id=mydisk -device ich9-ahci,id=ahci -device ide-drive,drive=mydisk,bus=ahci.0
+
+- To add an Intel E1000 network adapter, pass e.g.::
+
+ -netdev user,id=net0 -device e1000,netdev=net0
+
+- To add an EHCI-compliant USB host controller, pass e.g.::
+
+ -device usb-ehci,id=ehci
+
+- To add a NVMe disk, pass e.g.::
+
+ -drive if=none,file=disk.img,id=mydisk -device nvme,drive=mydisk,serial=foo
+
+These have been tested in QEMU 2.9.0 but should work in at least 2.5.0 as well.
diff --git a/doc/board/emulation/qemu-mips.rst b/doc/board/emulation/qemu-mips.rst
new file mode 100644
index 0000000000..529a908b55
--- /dev/null
+++ b/doc/board/emulation/qemu-mips.rst
@@ -0,0 +1,234 @@
+.. SPDX-License-Identifier: GPL-2.0+
+.. sectionauthor:: Vlad Lungu <vlad.lungu@windriver.com>
+
+QEMU MIPS
+=========
+
+Qemu is a full system emulator. See http://www.nongnu.org/qemu/
+
+Limitations & comments
+----------------------
+Supports the "-M mips" configuration of qemu: serial,NE2000,IDE.
+Supports little and big endian as well as 32 bit and 64 bit.
+Derived from au1x00 with a lot of things cut out.
+
+Supports emulated flash (patch Jean-Christophe PLAGNIOL-VILLARD) with
+recent qemu versions. When using emulated flash, launch with
+-pflash <filename> and erase mips_bios.bin.
+
+
+Notes for the Qemu MIPS port
+----------------------------
+
+Example usage
+^^^^^^^^^^^^^
+
+Using u-boot.bin as ROM (replaces Qemu monitor):
+
+32 bit, big endian::
+
+ # make qemu_mips
+ # qemu-system-mips -M mips -bios u-boot.bin -nographic
+
+32 bit, little endian::
+
+ # make qemu_mipsel
+ # qemu-system-mipsel -M mips -bios u-boot.bin -nographic
+
+64 bit, big endian::
+
+ # make qemu_mips64
+ # qemu-system-mips64 -cpu MIPS64R2-generic -M mips -bios u-boot.bin -nographic
+
+64 bit, little endian::
+
+ # make qemu_mips64el
+ # qemu-system-mips64el -cpu MIPS64R2-generic -M mips -bios u-boot.bin -nographic
+
+or using u-boot.bin from emulated flash:
+
+if you use a qemu version after commit 4224
+
+.. code-block:: none
+
+ create image:
+ # dd of=flash bs=1k count=4k if=/dev/zero
+ # dd of=flash bs=1k conv=notrunc if=u-boot.bin
+ start it (see above):
+ # qemu-system-mips[64][el] [-cpu MIPS64R2-generic] -M mips -pflash flash -nographic
+
+Download kernel + initrd
+^^^^^^^^^^^^^^^^^^^^^^^^
+
+On ftp://ftp.denx.de/pub/contrib/Jean-Christophe_Plagniol-Villard/qemu_mips/
+you can downland::
+
+ #config to build the kernel
+ qemu_mips_defconfig
+ #patch to fix mips interrupt init on 2.6.24.y kernel
+ qemu_mips_kernel.patch
+ initrd.gz
+ vmlinux
+ vmlinux.bin
+ System.map
+
+Generate uImage
+^^^^^^^^^^^^^^^
+
+.. code-block:: none
+
+ # tools/mkimage -A mips -O linux -T kernel -C gzip -a 0x80010000 -e 0x80245650 -n "Linux 2.6.24.y" -d vmlinux.bin.gz uImage
+
+Copy uImage to Flash
+^^^^^^^^^^^^^^^^^^^^
+
+.. code-block:: none
+
+ # dd if=uImage bs=1k conv=notrunc seek=224 of=flash
+
+Generate Ide Disk
+^^^^^^^^^^^^^^^^^
+
+.. code-block:: none
+
+ # dd of=ide bs=1k cout=100k if=/dev/zero
+
+ # sfdisk -C 261 -d ide
+ # partition table of ide
+ unit: sectors
+
+ ide1 : start= 63, size= 32067, Id=83
+ ide2 : start= 32130, size= 32130, Id=83
+ ide3 : start= 64260, size= 4128705, Id=83
+ ide4 : start= 0, size= 0, Id= 0
+
+Copy to ide
+^^^^^^^^^^^
+
+.. code-block:: none
+
+ # dd if=uImage bs=512 conv=notrunc seek=63 of=ide
+
+Generate ext2 on part 2 on Copy uImage and initrd.gz
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+.. code-block:: none
+
+ # Attached as loop device ide offset = 32130 * 512
+ # losetup -o 16450560 -f ide
+ # Format as ext2 ( arg2 : nb blocks)
+ # mke2fs /dev/loop0 16065
+ # losetup -d /dev/loop0
+ # Mount and copy uImage and initrd.gz to it
+ # mount -o loop,offset=16450560 -t ext2 ide /mnt
+ # mkdir /mnt/boot
+ # cp {initrd.gz,uImage} /mnt/boot/
+ # Umount it
+ # umount /mnt
+
+Set Environment
+^^^^^^^^^^^^^^^
+
+.. code-block:: none
+
+ setenv rd_start 0x80800000
+ setenv rd_size 2663940
+ setenv kernel BFC38000
+ setenv oad_addr 80500000
+ setenv load_addr2 80F00000
+ setenv kernel_flash BFC38000
+ setenv load_addr_hello 80200000
+ setenv bootargs 'root=/dev/ram0 init=/bin/sh'
+ setenv load_rd_ext2 'ide res; ext2load ide 0:2 ${rd_start} /boot/initrd.gz'
+ setenv load_rd_tftp 'tftp ${rd_start} /initrd.gz'
+ setenv load_kernel_hda 'ide res; diskboot ${load_addr} 0:2'
+ setenv load_kernel_ext2 'ide res; ext2load ide 0:2 ${load_addr} /boot/uImage'
+ setenv load_kernel_tftp 'tftp ${load_addr} /qemu_mips/uImage'
+ setenv boot_ext2_ext2 'run load_rd_ext2; run load_kernel_ext2; run addmisc; bootm ${load_addr}'
+ setenv boot_ext2_flash 'run load_rd_ext2; run addmisc; bootm ${kernel_flash}'
+ setenv boot_ext2_hda 'run load_rd_ext2; run load_kernel_hda; run addmisc; bootm ${load_addr}'
+ setenv boot_ext2_tftp 'run load_rd_ext2; run load_kernel_tftp; run addmisc; bootm ${load_addr}'
+ setenv boot_tftp_hda 'run load_rd_tftp; run load_kernel_hda; run addmisc; bootm ${load_addr}'
+ setenv boot_tftp_ext2 'run load_rd_tftp; run load_kernel_ext2; run addmisc; bootm ${load_addr}'
+ setenv boot_tftp_flash 'run load_rd_tftp; run addmisc; bootm ${kernel_flash}'
+ setenv boot_tftp_tftp 'run load_rd_tftp; run load_kernel_tftp; run addmisc; bootm ${load_addr}'
+ setenv load_hello_tftp 'tftp ${load_addr_hello} /examples/hello_world.bin'
+ setenv go_tftp 'run load_hello_tftp; go ${load_addr_hello}'
+ setenv addmisc 'setenv bootargs ${bootargs} console=ttyS0,${baudrate} rd_start=${rd_start} rd_size=${rd_size} ethaddr=${ethaddr}'
+ setenv bootcmd 'run boot_tftp_flash'
+
+Now you can boot from flash, ide, ide+ext2 and tfp::
+
+ # qemu-system-mips -M mips -pflash flash -monitor null -nographic -net nic -net user -tftp `pwd` -hda ide
+
+
+How to debug U-Boot
+-------------------
+
+In order to debug U-Boot you need to start qemu with gdb server support (-s)
+and waiting the connection to start the CPU (-S)
+
+.. code-block:: none
+
+ # qemu-system-mips -S -s -M mips -pflash flash -monitor null -nographic -net nic -net user -tftp `pwd` -hda ide
+
+in an other console you start gdb
+
+Debugging of U-Boot Before Relocation
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Before relocation, the addresses in the ELF file can be used without any problems
+by connecting to the gdb server localhost:1234
+
+.. code-block:: none
+
+ # mipsel-unknown-linux-gnu-gdb u-boot
+ GNU gdb 6.6
+ Copyright (C) 2006 Free Software Foundation, Inc.
+ GDB is free software, covered by the GNU General Public License, and you are
+ welcome to change it and/or distribute copies of it under certain conditions.
+ Type "show copying" to see the conditions.
+ There is absolutely no warranty for GDB. Type "show warranty" for details.
+ This GDB was configured as "--host=i486-linux-gnu --target=mipsel-unknown-linux-gnu"...
+ (gdb) target remote localhost:1234
+ Remote debugging using localhost:1234
+ _start () at start.S:64
+ 64 RVECENT(reset,0) /* U-Boot entry point */
+ Current language: auto; currently asm
+ (gdb) b board.c:289
+ Breakpoint 1 at 0xbfc00cc8: file board.c, line 289.
+ (gdb) c
+ Continuing.
+
+ Breakpoint 1, board_init_f (bootflag=<value optimized out>) at board.c:290
+ 290 relocate_code (addr_sp, id, addr);
+ Current language: auto; currently c
+ (gdb) p/x addr
+ $1 = 0x87fa0000
+
+Debugging of U-Boot After Relocation
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+For debugging U-Boot after relocation we need to know the address to which
+U-Boot relocates itself to 0x87fa0000 by default.
+And replace the symbol table to this offset.
+
+.. code-block:: none
+
+ (gdb) symbol-file
+ Discard symbol table from `/private/u-boot-arm/u-boot'? (y or n) y
+ Error in re-setting breakpoint 1:
+ No symbol table is loaded. Use the "file" command.
+ No symbol file now.
+ (gdb) add-symbol-file u-boot 0x87fa0000
+ add symbol table from file "u-boot" at
+ .text_addr = 0x87fa0000
+ (y or n) y
+ Reading symbols from /private/u-boot-arm/u-boot...done.
+ Breakpoint 1 at 0x87fa0cc8: file board.c, line 289.
+ (gdb) c
+ Continuing.
+
+ Program received signal SIGINT, Interrupt.
+ 0xffffffff87fa0de4 in udelay (usec=<value optimized out>) at time.c:78
+ 78 while ((tmo - read_c0_count()) < 0x7fffffff)
diff --git a/doc/board/emulation/qemu-riscv.rst b/doc/board/emulation/qemu-riscv.rst
new file mode 100644
index 0000000000..214833496b
--- /dev/null
+++ b/doc/board/emulation/qemu-riscv.rst
@@ -0,0 +1,49 @@
+.. SPDX-License-Identifier: GPL-2.0+
+.. Copyright (C) 2018, Bin Meng <bmeng.cn@gmail.com>
+
+QEMU RISC-V
+===========
+
+QEMU for RISC-V supports a special 'virt' machine designed for emulation and
+virtualization purposes. This document describes how to run U-Boot under it.
+Both 32-bit 64-bit targets are supported.
+
+The QEMU virt machine models a generic RISC-V virtual machine with support for
+the VirtIO standard networking and block storage devices. It has CLINT, PLIC,
+16550A UART devices in addition to VirtIO and it also uses device-tree to pass
+configuration information to guest software. It implements RISC-V privileged
+architecture spec v1.10.
+
+Building U-Boot
+---------------
+Set the CROSS_COMPILE environment variable as usual, and run:
+
+- For 32-bit RISC-V::
+
+ make qemu-riscv32_defconfig
+ make
+
+- For 64-bit RISC-V::
+
+ make qemu-riscv64_defconfig
+ make
+
+Running U-Boot
+--------------
+The minimal QEMU command line to get U-Boot up and running is:
+
+- For 32-bit RISC-V::
+
+ qemu-system-riscv32 -nographic -machine virt -kernel u-boot
+
+- For 64-bit RISC-V::
+
+ qemu-system-riscv64 -nographic -machine virt -kernel u-boot
+
+The commands above create targets with 128MiB memory by default.
+A freely configurable amount of RAM can be created via the '-m'
+parameter. For example, '-m 2G' creates 2GiB memory for the target,
+and the memory node in the embedded DTB created by QEMU reflects
+the new setting.
+
+These have been tested in QEMU 3.0.0.
diff --git a/doc/board/emulation/qemu-x86.rst b/doc/board/emulation/qemu-x86.rst
new file mode 100644
index 0000000000..c2e704afb2
--- /dev/null
+++ b/doc/board/emulation/qemu-x86.rst
@@ -0,0 +1,101 @@
+.. SPDX-License-Identifier: GPL-2.0+
+.. sectionauthor:: Bin Meng <bmeng.cn@gmail.com>
+
+QEMU x86
+========
+
+Build instructions for bare mode
+--------------------------------
+
+To build u-boot.rom for QEMU x86 targets, just simply run::
+
+ $ make qemu-x86_defconfig (for 32-bit)
+ $ make qemu-x86_64_defconfig (for 64-bit)
+ $ make all
+
+Note this default configuration will build a U-Boot for the QEMU x86 i440FX
+board. To build a U-Boot against QEMU x86 Q35 board, you can change the build
+configuration during the 'make menuconfig' process like below::
+
+ Device Tree Control --->
+ ...
+ (qemu-x86_q35) Default Device Tree for DT control
+
+Test with QEMU for bare mode
+----------------------------
+
+QEMU is a fancy emulator that can enable us to test U-Boot without access to
+a real x86 board. Please make sure your QEMU version is 2.3.0 or above test
+U-Boot. To launch QEMU with u-boot.rom, call QEMU as follows::
+
+ $ qemu-system-i386 -nographic -bios path/to/u-boot.rom
+
+This will instantiate an emulated x86 board with i440FX and PIIX chipset. QEMU
+also supports emulating an x86 board with Q35 and ICH9 based chipset, which is
+also supported by U-Boot. To instantiate such a machine, call QEMU with::
+
+ $ qemu-system-i386 -nographic -bios path/to/u-boot.rom -M q35
+
+Note by default QEMU instantiated boards only have 128 MiB system memory. But
+it is enough to have U-Boot boot and function correctly. You can increase the
+system memory by pass '-m' parameter to QEMU if you want more memory::
+
+ $ qemu-system-i386 -nographic -bios path/to/u-boot.rom -m 1024
+
+This creates a board with 1 GiB system memory. Currently U-Boot for QEMU only
+supports 3 GiB maximum system memory and reserves the last 1 GiB address space
+for PCI device memory-mapped I/O and other stuff, so the maximum value of '-m'
+would be 3072.
+
+QEMU emulates a graphic card which U-Boot supports. Removing '-nographic' will
+show QEMU's VGA console window. Note this will disable QEMU's serial output.
+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.
+
+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
+from hard disk or network again, through emulated devices. To use it , simply
+providing them in QEMU command line::
+
+ $ qemu-system-i386 -nographic -bios path/to/u-boot.rom -m 1024 \
+ -kernel /path/to/bzImage -append 'root=/dev/ram console=ttyS0' \
+ -initrd /path/to/initrd -smp 8
+
+Note: -initrd and -smp are both optional
+
+Then start QEMU, in U-Boot command line use the following U-Boot command to
+setup kernel::
+
+ => qfw
+ qfw - QEMU firmware interface
+
+ Usage:
+ qfw <command>
+ - list : print firmware(s) currently loaded
+ - cpus : print online cpu number
+ - load <kernel addr> <initrd addr> : load kernel and initrd (if any) and setup for zboot
+
+ => qfw load
+ loading kernel to address 01000000 size 5d9d30 initrd 04000000 size 1b1ab50
+
+Here the kernel (bzImage) is loaded to 01000000 and initrd is to 04000000. Then,
+'zboot' can be used to boot the kernel::
+
+ => zboot 01000000 - 04000000 1b1ab50
+
+To run 64-bit U-Boot, qemu-system-x86_64 should be used instead, e.g.::
+
+ $ qemu-system-x86_64 -nographic -bios path/to/u-boot.rom
+
+A specific CPU can be specified via the '-cpu' parameter but please make
+sure the specified CPU supports 64-bit like '-cpu core2duo'. Conversely
+'-cpu pentium' won't work for obvious reasons that the processor only
+supports 32-bit.
+
+Note 64-bit support is very preliminary at this point. Lots of features
+are missing in the 64-bit world. One notable feature is the VGA console
+support which is currently missing, so that you must specify '-nographic'
+to get 64-bit U-Boot up and running.