Preparation
Table of Contents
WSL Good
Lab Environment
WSL 1 (Ubuntu 18.04 LTS) on Windows 1909 Education.
➜ nemo neofetch
.-/+oossssoo+/-. nemo@marshmallow-laptop
`:+ssssssssssssssssss+:` -----------------------
-+ssssssssssssssssssyyssss+- OS: Ubuntu 18.04.4 LTS on Windows 10 x86_64
.ossssssssssssssssssdMMMNysssso. Kernel: 4.4.0-18362-Microsoft
/ssssssssssshdmmNNmmyNMMMMhssssss/ Uptime: 2 days, 9 hours, 14 mins
+ssssssssshmydMMMMMMMNddddyssssssss+ Packages: 1019
/sssssssshNMMMyhhyyyyhmNMMMNhssssssss/ Shell: zsh 5.4.2
.ssssssssdMMMNhsssssssssshNMMMdssssssss. Terminal: /dev/tty6
+sssshhhyNMMNyssssssssssssyNMMMysssssss+ CPU: Intel i5-8300H (8) @ 2.304GHz
ossyNMMMNyMMhsssssssssssssshmmmhssssssso Memory: 10956MiB / 16239MiB
ossyNMMMNyMMhsssssssssssssshmmmhssssssso
+sssshhhyNMMNyssssssssssssyNMMMysssssss+
.ssssssssdMMMNhsssssssssshNMMMdssssssss.
/sssssssshNMMMyhhyyyyhdNMMMNhssssssss/
+sssssssssdmydMMMMMMMMddddyssssssss+
/ssssssssssshdmNNNNmyNMMMMhssssss/
.ossssssssssssssssssdMMMNysssso.
-+sssssssssssssssssyyyssss+-
`:+ssssssssssssssssss+:`
.-/+oossssoo+/-.
Dependencies
sudo apt update && sudo apt install git build-essential binutils g++-multilib libgtk2.0-dev libtool-bin libsdl-dev -y
MIT QEMU
Warning: Don’t do this under Windows paths, like /mnt/c
By default, binary is at /usr/local/qemu/bin/qemu-system-i386
. If you want to change install path, change --prefix
when you do ./configure
bellow.
Get the source, then ./configure
, make
and make install
:
git clone https://github.com/mit-pdos/6.828-qemu.git qemu && cd qemu
./configure --disable-kvm --disable-werror --target-list="i386-softmmu x86_64-softmmu" --prefix=/usr/local/qemu
sudo make && sudo make install
Result
➜ nemo /usr/local/qemu/bin/qemu-system-i386
(qemu-system-i386:9398): Gtk-WARNING **: 19:03:08.047: cannot open display:
It’s normal that you can’t open display on WSL 1. If you did opened, something mysterious might had happened to you.
JOS
Fetch the source:
git clone https://pdos.csail.mit.edu/6.828/2018/jos.git os-lab && cd os-lab
Remember to edit ./conf/env.mk
.
# env.mk - configuration variables for the JOS lab
<!-- omit some lines till you get to the last line -->
QEMU=/usr/local/qemu/bin/qemu-system-i386 # *Change to your path_to_qemu_binary here*
Start JOS:
make qemu-nox
You would see:
➜ os-lab git:(lab1) make qemu-nox
***
*** Use Ctrl-a x to exit qemu
***
/usr/local/qemu/bin/qemu-system-i386 -nographic -drive file=obj/kern/kernel.img,index=0,media=disk,format=raw -serial mon:stdio -gdb tcp::26000 -D qemu.log
6828 decimal is XXX octal!
entering test_backtrace 5
entering test_backtrace 4
entering test_backtrace 3
entering test_backtrace 2
entering test_backtrace 1
entering test_backtrace 0
leaving test_backtrace 0
leaving test_backtrace 1
leaving test_backtrace 2
leaving test_backtrace 3
leaving test_backtrace 4
leaving test_backtrace 5
Welcome to the JOS kernel monitor!
Type 'help' for a list of commands.
K>
If you want to use gdb
:
Terminal #1
➜ os-lab git:(lab1) make qemu-nox-gdb
***
*** Now run 'make gdb'.
***
/usr/local/qemu/bin/qemu-system-i386 -nographic -drive file=obj/kern/kernel.img,index=0,media=disk,format=raw -serial mon:stdio -gdb tcp::26000 -D qemu.log -S
Terminal #2
➜ os-lab git:(lab1) make gdb
gdb -n -x .gdbinit
GNU gdb (Ubuntu 8.1-0ubuntu3.2) 8.1.0.20180409-git
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
+ target remote localhost:26000
warning: No executable has been specified and target does not support
determining executable automatically. Try using the "file" command.
warning: A handler for the OS ABI "GNU/Linux" is not built into this configuration
of GDB. Attempting to continue with the default i8086 settings.
The target architecture is assumed to be i8086
[f000:fff0] 0xffff0: ljmp $0xf000,$0xe05b
0x0000fff0 in ?? ()
+ symbol-file obj/kern/kernel
(gdb)
If gdb
prompts you something like it couldn’t start the debugging session, just do as it prompted you to do.
Extra
Use VNC Viewer
.
➜ os-lab git:(lab1) make qemu-nox-gdb-vnc
***
*** VNC Server at port 5900
***
***
*** Now run 'make gdb'.
***
/usr/local/qemu/bin/qemu-system-i386 -nographic -drive file=obj/kern/kernel.img,index=0,media=disk,format=raw -serial mon:stdio -gdb tcp::26000 -D qemu.log -S -vga std -nographic -vnc :0