"mcopy" command says "Disk full" when copying kernel.elf

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
LyricalRain
Posts: 16
Joined: Thu Jul 01, 2021 3:24 pm

"mcopy" command says "Disk full" when copying kernel.elf

Post by LyricalRain »

Hello! I've encountered a problem that stumps me. When creating a disk image for x86-64 UEFI, the "mcopy" command keeps saying "Disk full" whenever I try to copy the kernel.elf to its root directory. This only happened a few hours ago and it was working fine for the last few days. It started happening after I used -mcmodel=kernel, but I don't know if that is what is causing it. The ELF file is only 2 MB, and the disk is 48MB, so there shouldn't be a problem of lack of space.
Below are the commands I'm running to make the disk:

Code: Select all

dd if=/dev/zero of=$(BUILDDIR)/$(OSNAME).img bs=512 count=93750
	mformat -i $(BUILDDIR)/$(OSNAME).img -f 1440 ::
	mmd -i $(BUILDDIR)/$(OSNAME).img ::/EFI
	mmd -i $(BUILDDIR)/$(OSNAME).img ::/EFI/BOOT
	mcopy -i $(BUILDDIR)/$(OSNAME).img $(BOOTEFI) ::/EFI/BOOT
	mcopy -i $(BUILDDIR)/$(OSNAME).img startup.nsh ::
	mcopy -i $(BUILDDIR)/$(OSNAME).img $(BUILDDIR)/kernel.elf ::
I reiterate, this only started happening after I cross compiled my gcc and ld for x86_64 and used -mcmodel=kernel. Any ideas on how to fix this?
User avatar
bzt
Member
Member
Posts: 1584
Joined: Thu Oct 13, 2016 4:55 pm
Contact:

Re: "mcopy" command says "Disk full" when copying kernel.elf

Post by bzt »

What does

Code: Select all

du -hs *.elf *.img
say?

Have you tried mounting the image through a loopback device and copying kernel.elf as usual? Does that work?

Cheers,
bzt
LyricalRain
Posts: 16
Joined: Thu Jul 01, 2021 3:24 pm

Re: "mcopy" command says "Disk full" when copying kernel.elf

Post by LyricalRain »

bzt wrote:What does

Code: Select all

du -hs *.elf *.img
say?
It says 8 KB for the kernel and 48 MB for the disk.
bzt wrote:Have you tried mounting the image through a loopback device and copying kernel.elf as usual? Does that work?
Yeah I did that just now, but the kernel wouldn't boot.

So the disk gets made properly with the elf generated from my native gcc, but not from my cross compiled one. So there lies the problem.
Thanks for your help!
LyricalRain
Posts: 16
Joined: Thu Jul 01, 2021 3:24 pm

Re: "mcopy" command says "Disk full" when copying kernel.elf

Post by LyricalRain »

Okay I figured out the problem, I was not using the -no-red-zone flag with ld smh.
davmac314
Member
Member
Posts: 121
Joined: Mon Jul 05, 2021 6:57 pm

Re: "mcopy" command says "Disk full" when copying kernel.elf

Post by davmac314 »

Code: Select all

  mformat -i $(BUILDDIR)/$(OSNAME).img -f 1440 ::
You are trying to copy a 2Mb kernel to a filesystem formatted as 1.44Mb :wink:
Post Reply