1 00:00:01,160 --> 00:00:05,810 OK, I'm going to show you how to build and test the projects on Windows 10. 2 00:00:06,620 --> 00:00:08,119 So first, we open the terminal. 3 00:00:10,430 --> 00:00:16,550 in this video, Ubuntu system is used, we need to change the directory to mount 4 00:00:18,510 --> 00:00:21,030 c drive and users, 5 00:00:22,620 --> 00:00:31,200 The name of the user, work in my computer. You should change the path to your user path and desktop, 6 00:00:32,450 --> 00:00:33,080 boot file 7 00:00:34,720 --> 00:00:35,710 And press enter. 8 00:00:37,270 --> 00:00:41,020 OK, we can check the file using command ls. 9 00:00:42,580 --> 00:00:44,320 you can see the assembly file, the build script and the boot image. 10 00:00:44,470 --> 00:00:50,590 The boot image file is the blank 10 mb image we created 11 00:00:50,590 --> 00:00:56,980 in lecture working with windows 10. So make sure to copy the image to the project before we run the build script 12 00:00:56,980 --> 00:01:01,240 because we need to write the projects into this image. 13 00:01:02,140 --> 00:01:07,210 The bochs configuration file is also the one we created in lecture working with Windows 10. 14 00:01:07,630 --> 00:01:10,780 We need to copy the configuration file in the project as well. 15 00:01:11,260 --> 00:01:18,910 OK, let's build the project. We run the build script by typing ./build.sh 16 00:01:21,350 --> 00:01:22,740 and press enter. 17 00:01:24,840 --> 00:01:25,200 OK. 18 00:01:25,230 --> 00:01:27,630 It says 512 bytes copied. 19 00:01:28,590 --> 00:01:32,400 So if we check the directory, we open the boot folder. 20 00:01:34,300 --> 00:01:37,570 you can see the boot.bin file is generated. 21 00:01:39,140 --> 00:01:45,410 We can also inspect the binary file using hexdump command. 22 00:01:46,810 --> 00:01:50,290 So in the terminal, we type hexdump, 23 00:01:52,940 --> 00:01:57,950 dash C so that we can see the file with character string, 24 00:01:59,520 --> 00:02:01,950 and the name of the file boot.bin, 25 00:02:03,170 --> 00:02:03,840 press enter. 26 00:02:06,640 --> 00:02:11,050 As you see, the last two bytes are 55 and AA. 27 00:02:11,530 --> 00:02:18,490 The first column shows the address in hexadecimal. 200 is equal to 512 in decimal. 28 00:02:19,470 --> 00:02:22,770 So the boot file is 512 bytes. 29 00:02:23,310 --> 00:02:25,200 The right column shows the ascii code. 30 00:02:26,390 --> 00:02:28,340 We can see message Hello is here. 31 00:02:30,450 --> 00:02:30,810 OK. 32 00:02:31,800 --> 00:02:37,440 In order to run the program in the virtual machine, we copy the bochs configure file into the directory 33 00:02:37,920 --> 00:02:40,020 which is already copied here. 34 00:02:41,260 --> 00:02:42,730 We need to do some editing, 35 00:02:44,010 --> 00:02:48,630 so we add the bochs configuration file to visual studio code. 36 00:02:50,460 --> 00:02:53,940 Here we need to change the path to the current directory 37 00:02:54,060 --> 00:02:56,310 the boot image locates. 38 00:02:56,310 --> 00:02:57,420 Here I have set it up. 39 00:03:00,960 --> 00:03:02,400 OK, we are good to go. 40 00:03:06,300 --> 00:03:09,480 Running bochs is simple. We just double-click it. 41 00:03:12,130 --> 00:03:13,510 And bochs is running. 42 00:03:15,340 --> 00:03:18,360 Ok now you can see hello is printed on the screen. 43 00:03:19,500 --> 00:03:21,840 The other messages are printed by bochs, 44 00:03:22,170 --> 00:03:24,960 You can see we are booting from hard disk. 45 00:03:27,090 --> 00:03:28,560 OK, we just closed it out. 46 00:03:32,120 --> 00:03:38,150 If you want to write the boot file into usb flash drive and boot it on a real machine, 47 00:03:38,150 --> 00:03:44,270 we need to insert the usb drive to the computer and write the image to it using rufus in windows 48 00:03:44,450 --> 00:03:50,480 or dd command in linux and mac os. Since this is the first project we build, 49 00:03:50,990 --> 00:03:54,090 let's see how to do it. In Windows environment, 50 00:03:54,170 --> 00:03:56,300 we open rufus 51 00:04:01,570 --> 00:04:03,520 and select the boot image file 52 00:04:04,950 --> 00:04:06,210 by clicking select. 53 00:04:08,250 --> 00:04:11,970 And choose the boot image here, click open. 54 00:04:14,090 --> 00:04:18,620 If you inserted the USB thumb drive, you should see it in the device here. 55 00:04:21,130 --> 00:04:24,160 Also, you need to check that this is the correct device. 56 00:04:25,640 --> 00:04:28,850 Then we can write to the image file by clicking start. 57 00:04:31,220 --> 00:04:33,020 This is a warning message popping up. 58 00:04:33,590 --> 00:04:34,730 We just click OK. 59 00:04:37,930 --> 00:04:43,660 This process is really quick, and now we have bootable USB flash drive. 60 00:04:45,870 --> 00:04:47,990 With USB flash drive ready to use, 61 00:04:48,610 --> 00:04:52,020 we insert it into the test computer and boot the computer. 62 00:04:54,510 --> 00:04:56,640 Because we are running in legacy bios mode, 63 00:04:56,760 --> 00:05:04,380 we have to make sure the csm support is enable if the motherboard has uefi system, 64 00:05:04,380 --> 00:05:05,790 which should be enabled by default. 65 00:05:06,510 --> 00:05:09,630 As you can see, this is the BIOS interface in my computer. 66 00:05:10,440 --> 00:05:12,870 We navigated to BIOS option. 67 00:05:13,900 --> 00:05:19,870 And CSM is enabled. Also BIOS interface could be different in your machine, so you need to check 68 00:05:19,870 --> 00:05:23,680 whether the C,S,M option is at in your computer. 69 00:05:24,520 --> 00:05:27,160 OK, we exit and reboot the computer. 70 00:05:34,360 --> 00:05:40,210 Since we didn't set up boot device priority, we open boot menu. In this menu, 71 00:05:40,210 --> 00:05:45,600 we choose which device we want to boot. Since this is a test computer which has no hard disk, 72 00:05:46,190 --> 00:05:48,580 the only option is the USB flash drive 73 00:05:48,610 --> 00:05:51,520 I just inserted. Press enter. 74 00:05:55,660 --> 00:05:58,480 If everything goes as expected, we can see hello is printed. 75 00:05:59,550 --> 00:06:00,900 That's it for this lecture. 76 00:06:00,990 --> 00:06:02,460 See you in the next video.