justinian / jsix

A hobby operating system for x86_64, boots with UEFI.
Other
69 stars 12 forks source link

boot.elf #1

Closed bojumoxu5musicinfo closed 6 years ago

bojumoxu5musicinfo commented 6 years ago

Hi,

While executing waf build, I get this error

IOError: [Errno 2] No such file or directory: '/home/.../popcorn/build/src/boot/boot.elf'

There's no boot.elf in that directory, from the src/boot/wscript this file seems to be an input file.

efi.set_inputs([out.make_node("boot.elf")])

Any ideas? Thanks

justinian commented 6 years ago

boot.elf is an intermediate file that should be built by a previous step, are there any previous errors or warnings in the build process? Also, were you building from the master or the reorg branch? I've been changing the waf scripts a bunch in reorg so it's very possible I broke something.

bojumoxu5musicinfo commented 6 years ago

I'm using master branch. I'm building using Cygwin, I had to install mtools manually, but apart from that there was no errors or warning.

Bob@DESKTOP-GCPUQ3T ~/popcorn $ ./waf configure Setting top to : /home/Bob/popcorn Setting out to : /home/Bob/popcorn/build Checking for program 'ld' : /usr/bin/ld Checking for program 'nasm, yasm' : /usr/bin/nasm Checking for program 'clang' : /usr/bin/clang Checking for program 'llvm-ar, ar' : /usr/bin/ar Checking for program 'ar' : /usr/bin/ar Checking for program 'clang++' : /usr/bin/clang++ Checking for program 'llvm-ar, ar' : /usr/bin/ar Checking for program 'ar' : /usr/bin/ar Checking for program 'objcopy' : /usr/bin/objcopy Checking for program 'objdump' : /usr/bin/objdump Checking for program 'mcopy' : /usr/bin/mcopy Checking for program 'dd' : /usr/bin/dd Checking for program 'clang++' : /usr/bin/clang++ Checking for program 'llvm-ar, ar' : /usr/bin/ar Checking for program 'ar' : /usr/bin/ar 'configure' finished successfully (1.687s)

Bob@DESKTOP-GCPUQ3T` ~/popcorn $ ./waf build

Waf: Entering directory `/home/Bob/popcorn/build'

Waf: Leaving directory `/home/Bob/popcorn/build' Build failed Traceback (most recent call last): File "/home/Bob/popcorn/.waf-2.0.7-63e8685c267915c8f1b03d9a344b09f7/waflib/Runner.py", line 221, in task_status return tsk.runnable_status() File "/home/Bob/popcorn/.waf-2.0.7-63e8685c267915c8f1b03d9a344b09f7/waflib/Task.py", line 348, in runnable_status new_sig=self.signature() File "/home/Bob/popcorn/.waf-2.0.7-63e8685c267915c8f1b03d9a344b09f7/waflib/Task.py", line 329, in signature self.sig_explicit_deps() File "/home/Bob/popcorn/.waf-2.0.7-63e8685c267915c8f1b03d9a344b09f7/waflib/Task.py", line 390, in sig_explicit_deps upd(x.get_bld_sig()) File "/home/Bob/popcorn/.waf-2.0.7-63e8685c267915c8f1b03d9a344b09f7/waflib/Node.py", line 468, in get_bld_sig ret=cache[self]=self.h_file() File "/home/Bob/popcorn/.waf-2.0.7-63e8685c267915c8f1b03d9a344b09f7/waflib/Node.py", line 457, in h_file return Utils.h_file(self.abspath()) File "/home/Bob/popcorn/.waf-2.0.7-63e8685c267915c8f1b03d9a344b09f7/waflib/Utils.py", line 159, in h_file with open(fname,'rb')as f: IOError: [Errno 2] No such file or directory: '/home/Bob/popcorn/build/src/boot/boot.elf'

Thanks for your help

justinian commented 6 years ago

Hmm. I haven't tried building under cygwin (only under Linux, or WSL on windows). But there should be a lot more output from waf between the "Entering directory" and "Leaving directory" lines. Could you try running waf build -vvv and see if waf is properly picking up the build tasks?

Also, if it is actually building, it might be appending .exe to the output - is there a boot.elf.exe or similarly-named file in thr build/src/boot directory? If so it'll likely take a little bit of work to make the waf scripts work under cygwin.

bojumoxu5musicinfo commented 6 years ago

Here's the output for 'waf build -vvv' waf build -vvv.txt

From the output everything look fine until the end. There's that line

'04:57:47 task_gen posted boot.elf'

I suppose that means the file has been created, however there no such file or boot.elf.exe in the expected directory

Bob@DESKTOP-GCPUQ3T ~/popcorn/src/boot $ ls -la total 69 drwxr-xr-x+ 1 Bob None 0 Jun 12 21:32 . drwxrwxr-x+ 1 Bob None 0 Jun 10 21:12 .. -rwxr-xr-x+ 1 Bob None 6971 Jun 10 21:12 console.c -rwxr-xr-x+ 1 Bob None 480 Jun 10 21:12 console.h -rwxr-xr-x+ 1 Bob None 2530 Jun 10 21:12 crt0.s -rwxr-xr-x+ 1 Bob None 1356 Jun 10 21:12 elf.h -rwxr-xr-x+ 1 Bob None 365 Jun 10 21:12 guids.c -rwxr-xr-x+ 1 Bob None 192 Jun 10 21:12 guids.h -rwxr-xr-x+ 1 Bob None 452 Jun 10 21:12 guids.inc -rwxr-xr-x+ 1 Bob None 7146 Jun 10 21:12 loader.c -rwxr-xr-x+ 1 Bob None 964 Jun 10 21:12 loader.h -rwxr-xr-x+ 1 Bob None 5085 Jun 10 21:12 main.c -rwxr-xr-x+ 1 Bob None 5554 Jun 10 21:12 memory.c -rwxr-xr-x+ 1 Bob None 579 Jun 10 21:12 memory.h -rwxr-xr-x+ 1 Bob None 2889 Jun 10 21:12 reloc.c -rwxr-xr-x+ 1 Bob None 2366 Jun 10 21:12 utility.c -rwxr-xr-x+ 1 Bob None 830 Jun 10 21:12 utility.h -rwxr-xr-x+ 1 Bob None 1741 Jun 12 21:32 wscript

I'll try to install WSL+Ubuntu, And keep you up to date.

Thanks

justinian commented 6 years ago

Oh, one more thing to check: waf does out-of-tree builds, so boot.elf should be under ~/popcorn/build/src/boot, not ~/popcorn/src/boot. Is there anything there? Or maybe are any of those directories missing? (The IOError might be from a failure of making directories instead of the file itself, which would explain the early error before anything else was building.)

bojumoxu5musicinfo commented 6 years ago

I've ended up formatting my computer because I've previously completely removed Windows Store and I wasn't able to install WSL+Ubuntu, so I don't have Cygwin or the original repository, So I now have WSL+Ubuntu, I was able to "waf configure" logs.txt without any issues, however when I build I get this error

[37/46] Compiling src/kernel/scheduler.cpp ../src/kernel/log.cpp:25:1: error: must use 'class' tag to refer to type 'log' in this scope log log::s_log; ^ class /usr/include/x86_64-linux-gnu/bits/mathcalls.h:109:17: note: class 'log' is hidden by a non-type declaration of 'log' here __MATHCALL_VEC (log,, (Mdouble __x)); ^ 1 error generated.

Waf: Leaving directory `/home/bob/popcorn/build' Broken revdeps detected on set([ {task 140260353110096: mcopy disk.fat,boot.efi,popcorn.elf,screenfont.psf -> popcorn.fat}, {task 140260352899744: objdump popcorn.elf -> kernel.dump}, {task 140260353110576: addpart disk.img,popcorn.fat -> popcorn.img}, {task 140260344011184: cxxprogram driver.cpp.1.o,hba.cpp.1.o,port.cpp.1.o,allocator.cpp.1.o,apic.cpp.1.o,assert.cpp.1.o,console.cpp.1.o,cpprt.cpp.1.o,cpu.cpp.1.o,device_manager.cpp.1.o,font.cpp.1.o,gpt.cpp.1.o,gdt.cpp.1.o,interrupts.cpp.1.o,io.cpp.1.o,log.cpp.1.o,main.cpp.1.o,memory_bootstrap.cpp.1.o,page_manager.cpp.1.o,pci.cpp.1.o,scheduler.cpp.1.o,screen.cpp.1.o,serial.cpp.1.o,boot.s.1.o,debug.s.1.o,interrupts.s.1.o -> popcorn.elf}])

Any idea?

I've attached the full log if that helps

Thanks

justinian commented 6 years ago

Hmm, interesting.. there must be a difference in the include files that we're using, looks like something is including math headers. Seems like a legit collision, maybe the log class should be renamed logger or something. (Not that kernel code should ever be using the log function to do logarithms...) You could try making the change the compiler is recommending (changing that line to class log log::s_log;) though it might have the same collision everywhere else.

I see two options for the true fix: renaming the class (which should just be a big find/replace) or finding what is including that math header and changing it from the C-style #include <foo.h> to the C++ style #include <cfoo>. The latter seems better to me, but sounds like more work digging around in headers.

If you just want to get the code up and running, I've been using WSL+Debian as my WSL environment (you should be able to install both side by side if you want to try it), which may give you better luck. I'll try installing WSL+Ubuntu tonight if I can, and see if I can repro the error you're seeing.

bojumoxu5musicinfo commented 6 years ago

Hurray, So I've installed debian and was able to configure and build without any issue, however 'waf test' throw this error

image

I see the implementation in src/kernel/allocator.cpp, but somehow the tests doesn't see the implementation!

And for 'waf qemu' I suppose that's what I should see image

Thanks

justinian commented 6 years ago

Yep, that's what the output should be under QEMU - task A and task B should just loop forever doing syscalls and the scheduler should be swapping between them.

Looks like the tests are broken for me on master too. I'll probably merge the reorg branch (where the tests do work) to master soon, so I'll just let that be the eventual fix for the tests.

Sorry you had to reinstall windows and then install two different WSL environments to get it working!

bojumoxu5musicinfo commented 6 years ago

Np, Thanks for all your help and all your work, can't wait to study this project. Side question, do you have a way to debug the code at run-time (breakpoint, watches, ...)?

Thanks

justinian commented 6 years ago

I sometimes use the virtualbox debugger, but mainly I use the qemu gdb mode (the -s option). Unfortunately, gdb doesn't like it when the UEFI firmware switches to 64 bit though, so I add a while loop with a boolean flag as an initial breakpoint, then attach the debugger, set any actual breakpoints I want, and flip the flag.

On Thu, Jun 14, 2018, 1:55 PM bojumoxu5musicinfo notifications@github.com wrote:

Np, Thanks for all your help and all your work, can't wait to study this project. Side question, do you have a way to debug the code at run-time (breakpoint, watches, ...)?

Thanks

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/justinian/popcorn/issues/1#issuecomment-397435118, or mute the thread https://github.com/notifications/unsubscribe-auth/AAE784qlJFTr0YWE09bewplr_EAkbxCzks5t8s2tgaJpZM4UicFh .

bojumoxu5musicinfo commented 6 years ago

Hi, I close the ticket as the issue has been resolved, But continuing on my quest to study with that os, I've encounter a more general issue and not too sure who could help me I'm now trying to debug the solution, I was able to setup gdb and gdbgui. I've compile with a while loop in /popcorn/src/boot/main.c at line 40 started qemu with -s option in gdbgui >target remote localhost:1234 >symbol-file /home/bob/popcorn/build/src/boot/boot.elf open /popcorn/src/boot/main.c added a breakpoint >continue but the breakpoint never get hit the cpu is spinning, and qemu is a blank screen any idea what I might be doing wrong?

Thanks

justinian commented 6 years ago

You'll have to manually pause the kernel's execution. I don't know gdbgui, but in plain gdb you can just hit ctrl-C. You should then be in the loop, and be able to set the value of your boolean flag to exit the loop, then continue execution. Then it should go on and hit any breakpoints you've set later in the code.