1
0
Fork 0
mirror of https://gitlab.com/bztsrc/bootboot.git synced 2023-02-13 20:54:32 -05:00
bztsrc--bootboot/images/Makefile

91 lines
2.9 KiB
Makefile
Raw Normal View History

2020-01-11 20:45:18 +01:00
# overall disk image size in megabytes (128M)
DISKSIZE=128
# boot partition size in kilobytes (16M)
2020-06-15 04:21:38 +02:00
BOOTSIZE=16
2020-03-16 11:39:41 +01:00
# boot partition FAT type (16 or 32). Note that smallest possible FAT32 is 33M
BOOTTYPE=16
2020-01-11 20:45:18 +01:00
# platform, either x86 or rpi
2020-01-13 22:08:44 +01:00
PLATFORM=x86
#PLATFORM=rpi
2020-01-11 20:45:18 +01:00
# the path to OVMF.fd (for testing with EFI)
OVMF=/usr/share/qemu/bios-TianoCoreEFI.bin
all: mkimg initrd.bin bootpart.bin disk
# compile the image creator
mkimg: mkimg.c
gcc -ansi -pedantic -Wall -Wextra -g mkimg.c -o mkimg
# create an initial ram disk image with the kernel inside
initrd.bin:
@mkdir initrd initrd/sys 2>/dev/null | true
ifeq ($(PLATFORM),x86)
2020-06-16 03:40:52 +02:00
cp ../mykernel/mykernel.x86_64.elf initrd/sys/core
2020-01-11 20:45:18 +01:00
else
2020-06-16 03:40:52 +02:00
cp ../mykernel/mykernel.aarch64.elf initrd/sys/core
2020-01-11 20:45:18 +01:00
endif
@cd initrd && (find . | cpio -H hpodc -o | gzip > ../initrd.bin) && cd ..
2020-01-12 14:59:05 +01:00
@rm -r initrd 2>/dev/null || true
2020-01-11 20:45:18 +01:00
# assemble the boot partition
bootpart.bin: initrd.bin
2020-06-15 04:21:38 +02:00
@mkdir boot boot/BOOTBOOT 2>/dev/null || true
2020-01-11 20:45:18 +01:00
ifeq ($(PLATFORM),x86)
@cp ../bootboot.bin boot/BOOTBOOT/LOADER || true
@mkdir boot/EFI boot/EFI/BOOT
@cp ../bootboot.efi boot/EFI/BOOT/BOOTX64.EFI || true
else
@cp ../aarch64-rpi/LIC* ../aarch64-rpi/*.bin ../aarch64-rpi/*.elf ../aarch64-rpi/*.dat boot/ || true
2020-01-11 20:57:16 +01:00
@cp ../bootboot.img boot/kernel8.img || true
2020-01-11 20:45:18 +01:00
endif
2020-06-15 04:21:38 +02:00
@printf "screen=800x600\nkernel=sys/core\n" >boot/BOOTBOOT/CONFIG || true
2020-01-11 20:45:18 +01:00
@cp initrd.bin boot/BOOTBOOT/INITRD || true
2020-06-15 04:21:38 +02:00
./mkimg fat$(BOOTTYPE) $(BOOTSIZE) boot
@rm -rf boot
2020-01-11 20:45:18 +01:00
# create hybrid disk / cdrom image or ROM image
disk: mkimg bootpart.bin
2020-06-15 04:21:38 +02:00
./mkimg disk $(DISKSIZE) disk-$(PLATFORM).img
2020-01-11 20:45:18 +01:00
2020-01-12 14:59:05 +01:00
initrd.rom: mkimg initrd.bin
2020-01-13 22:22:13 +01:00
./mkimg rom
2020-01-11 20:45:18 +01:00
2020-01-12 14:59:05 +01:00
# create a GRUB cdrom
grub.iso: initrd.bin
@mkdir iso iso/bootboot iso/boot iso/boot/grub 2>/dev/null || true
@cp ../bootboot.bin iso/bootboot/loader || true
2020-06-15 04:21:38 +02:00
@printf "screen=800x600\nkernel=sys/core\n" >iso/bootboot/config || true
2020-01-12 14:59:05 +01:00
@cp initrd.bin iso/bootboot/initrd || true
2020-06-15 04:21:38 +02:00
@printf "menuentry \"BOOTBOOT test\" {\n multiboot /bootboot/loader\n module /bootboot/initrd\n module /bootboot/config\n boot\n}" >iso/boot/grub/grub.cfg || true
2020-01-12 14:59:05 +01:00
grub-mkrescue -o grub.iso iso
@rm -r iso 2>/dev/null || true
2020-01-11 20:45:18 +01:00
# test the disk image
rom: initrd.rom
qemu-system-x86_64 -option-rom ../bootboot.bin -option-rom initrd.rom -serial stdio
bios:
qemu-system-x86_64 -drive file=disk-x86.img,format=raw -serial stdio
cdrom:
qemu-system-x86_64 -cdrom disk-x86.img -serial stdio
2020-01-12 14:59:05 +01:00
grubcdrom: grub.iso
qemu-system-x86_64 -cdrom grub.iso -serial stdio
2020-01-11 20:45:18 +01:00
efi:
qemu-system-x86_64 -bios $(OVMF) -m 64 -drive file=disk-x86.img,format=raw -serial stdio
eficdrom:
qemu-system-x86_64 -bios $(OVMF) -m 64 -cdrom disk-x86.img -serial stdio
linux:
qemu-system-x86_64 -kernel ../bootboot.bin -drive file=disk-x86.img,format=raw -serial stdio
2020-01-11 20:45:18 +01:00
sdcard:
qemu-system-aarch64 -M raspi3 -kernel ../bootboot.img -drive file=disk-rpi.img,if=sd,format=raw -serial stdio
# clean up
clean:
rm mkimg *.bin *.img *.rom 2>/dev/null || true