summaryrefslogtreecommitdiffstats
path: root/scripts/qemucommand.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/qemucommand.py')
-rw-r--r--scripts/qemucommand.py34
1 files changed, 29 insertions, 5 deletions
diff --git a/scripts/qemucommand.py b/scripts/qemucommand.py
index 8d3ee0e..86b5b9f 100644
--- a/scripts/qemucommand.py
+++ b/scripts/qemucommand.py
@@ -40,9 +40,25 @@ def random_mac():
40 40
41class QemuCommand(object): 41class QemuCommand(object):
42 def __init__(self, args): 42 def __init__(self, args):
43 print(args)
44 self.enable_u_boot = True
43 self.dry_run = args.dry_run 45 self.dry_run = args.dry_run
44 self.overlay = args.overlay 46 self.overlay = args.overlay
45 self.host_fwd = None 47 self.host_fwd = None
48 self.kernel = None
49 self.drive_interface = "ide"
50
51 if hasattr(args, 'uboot_enable'):
52 self.enable_u_boot = args.uboot_enable.lower() in ("yes", "true", "1")
53
54 # Rise an exception if U-Boot is disabled and overlay option is used
55 if not self.enable_u_boot and self.overlay:
56 raise EnvironmentError("An overlay option is currently supported only with U-Boot loader!")
57
58 # If booting with u-boot is disabled we use "ext4" root fs instead of custom one "ota-ext4"
59 if not self.enable_u_boot:
60 self.drive_interface = "virtio"
61 EXTENSIONS['qemux86-64'] = 'ext4'
46 62
47 if args.machine: 63 if args.machine:
48 self.machine = args.machine 64 self.machine = args.machine
@@ -59,9 +75,7 @@ class QemuCommand(object):
59 # overlay so that we can keep it around just in case. 75 # overlay so that we can keep it around just in case.
60 if args.efi: 76 if args.efi:
61 self.bios = 'OVMF.fd' 77 self.bios = 'OVMF.fd'
62 else: 78 elif self.enable_u_boot:
63 if args.bootloader:
64 uboot_path = args.bootloader
65 uboot_path = abspath(join(args.dir, self.machine, 'u-boot-qemux86-64.rom')) 79 uboot_path = abspath(join(args.dir, self.machine, 'u-boot-qemux86-64.rom'))
66 if self.overlay: 80 if self.overlay:
67 new_uboot_path = self.overlay + '.u-boot.rom' 81 new_uboot_path = self.overlay + '.u-boot.rom'
@@ -77,6 +91,8 @@ class QemuCommand(object):
77 if not exists(uboot_path) and not (self.dry_run and not exists(self.overlay)): 91 if not exists(uboot_path) and not (self.dry_run and not exists(self.overlay)):
78 raise ValueError("U-Boot image %s does not exist" % uboot_path) 92 raise ValueError("U-Boot image %s does not exist" % uboot_path)
79 self.bios = uboot_path 93 self.bios = uboot_path
94 else:
95 self.kernel = abspath(join(args.dir, self.machine, 'bzImage-qemux86-64.bin'))
80 96
81 # If using an overlay, we need to keep the "backing" image around, as 97 # If using an overlay, we need to keep the "backing" image around, as
82 # bitbake will often clean it up, and the overlay silently depends on 98 # bitbake will often clean it up, and the overlay silently depends on
@@ -140,10 +156,14 @@ class QemuCommand(object):
140 156
141 cmdline = [ 157 cmdline = [
142 "qemu-system-x86_64", 158 "qemu-system-x86_64",
143 "-bios", self.bios
144 ] 159 ]
160 if self.enable_u_boot:
161 cmdline += ["-bios", self.bios]
162 else:
163 cmdline += ["-kernel", self.kernel]
164
145 if not self.overlay: 165 if not self.overlay:
146 cmdline += ["-drive", "file=%s,if=ide,format=raw,snapshot=on" % self.image] 166 cmdline += ["-drive", "file=%s,if=%s,format=raw,snapshot=on" % (self.image, self.drive_interface)]
147 cmdline += [ 167 cmdline += [
148 "-serial", "tcp:127.0.0.1:%d,server,nowait" % self.serial_port, 168 "-serial", "tcp:127.0.0.1:%d,server,nowait" % self.serial_port,
149 "-m", self.mem, 169 "-m", self.mem,
@@ -177,6 +197,10 @@ class QemuCommand(object):
177 cmdline += ['-cpu', 'Haswell'] 197 cmdline += ['-cpu', 'Haswell']
178 if self.overlay: 198 if self.overlay:
179 cmdline.append(self.overlay) 199 cmdline.append(self.overlay)
200
201 # If booting with u-boot is disabled, add kernel command line arguments through qemu -append option
202 if not self.enable_u_boot:
203 cmdline += ["-append", "root=/dev/vda rw highres=off console=ttyS0 ip=dhcp"]
180 return cmdline 204 return cmdline
181 205
182 def img_command_line(self): 206 def img_command_line(self):