Developing under OS-X

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Wolfos
Posts: 2
Joined: Tue May 08, 2012 1:19 pm

Developing under OS-X

Post by Wolfos »

Well, what works is assembling to binary with nasm, but I obviously don't have a floppy drive, so I would like to test under a virtual machine (Virtualbox). Now I tried making a disk image, but I'm stuck. How do you create a disk image from raw data that works under Virtualbox?
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: Developing under OS-X

Post by bluemoon »

You have to create an image file in format it understand.
http://www.virtualbox.org/manual/ch05.html#vdidetails
There is probably some tools to convert from raw image to the listed format too. Try google it.

As a side note, I'm not familiar with virtualbox but qemu support plain file as disk image, ie. each 512 byte is exactly the same sector position in the disk view from guest machine. it support i386 and x86_64 and is easily install with macport / sudo port install qemu.
Wolfos
Posts: 2
Joined: Tue May 08, 2012 1:19 pm

Re: Developing under OS-X

Post by Wolfos »

Alright, then I'll just try Qemu. Thanks!
ATXcs1372
Member
Member
Posts: 30
Joined: Wed Jun 01, 2011 7:14 pm

Re: Developing under OS-X

Post by ATXcs1372 »

bluemoon wrote:There is probably some tools to convert from raw image to the listed format too. Try google it.
VirtualBox has it's own tool for this.
Create a DMG/IMG using hdiutil or even just dd then use

Code: Select all

VBoxManage convertFromRaw --format VDI input.dmg output.vdi
Here is a link to the actual VirtualBox documentation for it
ATXcs1372
Member
Member
Posts: 30
Joined: Wed Jun 01, 2011 7:14 pm

Re: Developing under OS-X

Post by ATXcs1372 »

berkus wrote:I would still recommend bochs.app over any other tool for osdev on osx.
I've found QEMU to be faster on the new i5 and i7 based Macs.
Granted, I am emulating multiple cores (large slowdown) as well as a resolution of 1440 x 900 (some buffer copies can be intensive)
Otherwise I absolutely agree.
User avatar
Griwes
Member
Member
Posts: 374
Joined: Sat Jul 30, 2011 10:07 am
Libera.chat IRC: Griwes
Location: Wrocław/Racibórz, Poland
Contact:

Re: Developing under OS-X

Post by Griwes »

I think that the key factor here isn't speed, but ease of debugging - and I highly doubt that any other emulator will ever (or at least soon) become superior to bochs in terms of debugging.
Reaver Project :: Repository :: Ohloh project page
<klange> This is a horror story about what happens when you need a hammer and all you have is the skulls of the damned.
<drake1> as long as the lock is read and modified by atomic operations
User avatar
iansjack
Member
Member
Posts: 4711
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Developing under OS-X

Post by iansjack »

The best tool for programming OS stuff on a Mac (IMO) is Linux running in a VM. Then on the VM Linux run your OS under SimNow (for low-level debugging) or qemu (for C source level debugging). I've not tried Bochs, but SimNow is superb for assembler-level debugging.

It sounds a bit perverse running VMs within VMs, but I find it far easier than setting up the appropriate development environment on OS X.
User avatar
turdus
Member
Member
Posts: 496
Joined: Tue Feb 08, 2011 1:58 pm

Re: Developing under OS-X

Post by turdus »

iansjack wrote:The best tool for programming OS stuff on a Mac (IMO) is Linux running in a VM.
WTF?!? What's wrong with it's native stuff? You have bash, vim, perl, binutils, gcc, llvm, gnu/make, nasm, fasm, dd... everything you'll ever need for OSDEV. You can create and mount FAT natively. Only thing to do is a cross-compiler (same as with Linux), that's all (or you can use objconv).

I think using linuxvm is a very very bad advice.
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: Developing under OS-X

Post by bluemoon »

iansjack wrote:The best tool for programming OS stuff on a Mac (IMO) is Linux running in a VM.
LoL, by definition this is not programming OS stuff on a Mac, but is programming on Linux.
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: Developing under OS-X

Post by bluemoon »

turdus wrote:You have bash, vim, perl, binutils, gcc, llvm, gnu/make, nasm, fasm, dd... everything you'll ever need for OSDEV. You can create and mount FAT natively. Only thing to do is a cross-compiler (same as with Linux), that's all (or you can use objconv).
I would add building gdb to the list as well. Mac's built-in gdb won't work with elf. But then, develop on mac is totally workable, as I'm just doing that.
gerryg400
Member
Member
Posts: 1801
Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia

Re: Developing under OS-X

Post by gerryg400 »

bluemoon wrote:
turdus wrote:You have bash, vim, perl, binutils, gcc, llvm, gnu/make, nasm, fasm, dd... everything you'll ever need for OSDEV. You can create and mount FAT natively. Only thing to do is a cross-compiler (same as with Linux), that's all (or you can use objconv).
I would add building gdb to the list as well. Mac's built-in gdb won't work with elf. But then, develop on mac is totally workable, as I'm just doing that.
+1 from me too. You also have Eclipse and Xcode. I use vmware fusion and connect a cross-gdb to the vmware kernel debugger to debug my OS. I also use VMware serial ports tailed to a terminal for kernel logging. The only time I need Windows or Linux is to occasionally check that my build scripts work on those OS's.

[Edit] Okay, I also occasionally use Linux to reformat my virtual disks when my ext2 driver trashes them.
If a trainstation is where trains stop, what is a workstation ?
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: Developing under OS-X

Post by bluemoon »

gerryg400 wrote:I also occasionally use Linux to reformat my virtual disks when my ext2 driver trashes them.
I always have a copy of clean disk image, so when I messed up the testing image, I'd just "cp initial.img testing.img".
User avatar
iansjack
Member
Member
Posts: 4711
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Developing under OS-X

Post by iansjack »

bluemoon wrote:
iansjack wrote:The best tool for programming OS stuff on a Mac (IMO) is Linux running in a VM.
LoL, by definition this is not programming OS stuff on a Mac, but is programming on Linux.
I think you confuse Macs and OS X; they are not the same thing. It is programming in Linux on a Mac (it sure as hell isn't a PC!).
User avatar
iansjack
Member
Member
Posts: 4711
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Developing under OS-X

Post by iansjack »

turdus wrote:
iansjack wrote:The best tool for programming OS stuff on a Mac (IMO) is Linux running in a VM.
WTF?!? What's wrong with it's native stuff? You have bash, vim, perl, binutils, gcc, llvm, gnu/make, nasm, fasm, dd... everything you'll ever need for OSDEV. You can create and mount FAT natively. Only thing to do is a cross-compiler (same as with Linux), that's all (or you can use objconv).

I think using linuxvm is a very very bad advice.
Well, I think it's useful to keep my cross-compiling environment jailed from my native environment. I can take snapshots of the environment, play about with it and revert easily if I don't like the results.

It suits me. If it doesn't suit you, that's fine.
User avatar
iansjack
Member
Member
Posts: 4711
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Developing under OS-X

Post by iansjack »

bluemoon wrote:
gerryg400 wrote:I also occasionally use Linux to reformat my virtual disks when my ext2 driver trashes them.
I always have a copy of clean disk image, so when I messed up the testing image, I'd just "cp initial.img testing.img".
I always have a clean copy of my entire development environment. Same logic.
Post Reply