2018-10-18 18:07:12 +03:00
|
|
|
# Set anyboot file name and directory defaults.
|
|
|
|
HAIKU_MMC_NAME ?= $(HAIKU_DEFAULT_MMC_NAME) ;
|
|
|
|
HAIKU_MMC_DIR ?= $(HAIKU_DEFAULT_MMC_DIR) ;
|
|
|
|
HAIKU_MMC = $(HAIKU_MMC_NAME) ;
|
|
|
|
HAIKU_MMC_LABEL ?= $(HAIKU_DEFAULT_MMC_LABEL) ;
|
|
|
|
|
|
|
|
# SD/mmc image rule
|
|
|
|
# requires mtools package on linux
|
2019-06-19 23:55:43 +03:00
|
|
|
# Files must be in this order: loader floppyboot everything_else
|
2020-06-21 05:15:00 +03:00
|
|
|
rule BuildSDImage image : files
|
2018-10-18 18:07:12 +03:00
|
|
|
{
|
2020-06-21 05:15:00 +03:00
|
|
|
Depends $(image) : $(files) $(TARGET_DEVICE_TREES) ;
|
|
|
|
SDIMAGE_BLOCK_SIZE on $(image) = 1048576 ; # 1MiB
|
|
|
|
SDIMAGE_MTOOLS_H on $(image) = 255 ;
|
|
|
|
SDIMAGE_MTOOLS_S on $(image) = 63 ;
|
|
|
|
SDIMAGE_MTOOLS_C on $(image) = 8 ;
|
|
|
|
SDIMAGE_SIZE on $(image) = $(HAIKU_BOOT_SDIMAGE_SIZE) ;
|
|
|
|
SDIMAGE_BEGIN on $(image) = $(HAIKU_BOOT_SDIMAGE_BEGIN:E=63) ;
|
|
|
|
|
|
|
|
if $(TARGET_BOOT_PLATFORM) = efi {
|
|
|
|
switch $(TARGET_ARCH) {
|
|
|
|
case x86_64 :
|
|
|
|
EFINAME on $(image) = "BOOTX64.EFI" ;
|
|
|
|
case arm :
|
|
|
|
EFINAME on $(image) = "BOOTARM.EFI" ;
|
|
|
|
case arm64 :
|
|
|
|
EFINAME on $(image) = "BOOTAA64.EFI" ;
|
|
|
|
case riscv32 :
|
|
|
|
EFINAME on $(image) = "BOOTRISCV32.EFI" ;
|
|
|
|
case riscv64 :
|
|
|
|
EFINAME on $(image) = "BOOTRISCV64.EFI" ;
|
|
|
|
case * :
|
|
|
|
Exit "Error: Unknown EFI architecture!" ;
|
|
|
|
}
|
|
|
|
BuildEfiSDImage1 $(image) : $(files) ;
|
|
|
|
} else {
|
|
|
|
BuildUBootSDImage1 $(image) : $(files) ;
|
|
|
|
}
|
2018-10-18 18:07:12 +03:00
|
|
|
}
|
|
|
|
|
2020-08-22 02:07:33 +03:00
|
|
|
# Usage: image : loader floppyboot everything_else
|
2018-10-18 18:07:12 +03:00
|
|
|
actions BuildUBootSDImage1
|
|
|
|
{
|
2020-06-21 05:15:00 +03:00
|
|
|
$(RM) $(1)
|
|
|
|
$(RM) $(1).mtools
|
|
|
|
|
|
|
|
# make an empty image
|
|
|
|
dd of=$(1) \
|
|
|
|
if=/dev/zero \
|
|
|
|
bs=$(SDIMAGE_BLOCK_SIZE) \
|
|
|
|
count=$(SDIMAGE_SIZE)
|
|
|
|
# generate mtools config
|
|
|
|
echo 'drive i: file="$(1)" partition=1 cylinders=$(SDIMAGE_MTOOLS_C)
|
|
|
|
heads=$(SDIMAGE_MTOOLS_H) sectors=$(SDIMAGE_MTOOLS_S)
|
|
|
|
mformat_only' > $(1).mtools
|
|
|
|
# partition it
|
|
|
|
MTOOLSRC=$(1).mtools mpartition -b$(SDIMAGE_BEGIN) -cI -T 0xc i:
|
|
|
|
# format the image
|
|
|
|
MTOOLSRC=$(1).mtools mformat -L 32 -v "HAIKU" i:
|
|
|
|
|
|
|
|
# generate u-boot environment variables
|
|
|
|
echo 'os=haiku' > uEnv.txt
|
|
|
|
echo 'platform=u-boot' >> uEnv.txt
|
|
|
|
echo 'loader=haiku_loader.ub' >> uEnv.txt
|
|
|
|
|
|
|
|
# populate
|
|
|
|
MTOOLSRC=$(1).mtools mcopy $(2[2-2]) i:/haiku_loader.ub
|
|
|
|
MTOOLSRC=$(1).mtools mcopy $(2[3-3]) i:/haiku_floppyboot.ub
|
|
|
|
MTOOLSRC=$(1).mtools mcopy $(2[4-]) i:
|
|
|
|
MTOOLSRC=$(1).mtools mcopy uEnv.txt i:
|
|
|
|
# populate fdts
|
|
|
|
MTOOLSRC=$(1).mtools mmd i:/fdt
|
|
|
|
MTOOLSRC=$(1).mtools mcopy $(TARGET_DEVICE_TREES[1-]) i:/fdt/
|
|
|
|
# list content
|
|
|
|
MTOOLSRC=$(1).mtools mdir i:
|
|
|
|
MTOOLSRC=$(1).mtools mdir i:/fdt
|
|
|
|
# cleanup
|
|
|
|
$(RM) $(1).mtools
|
|
|
|
$(RM) uEnv.txt
|
|
|
|
$(RM) boot.scr
|
|
|
|
# Add haiku bootstrap partition to MMC image
|
|
|
|
cat $(2[0]) >> $(1)
|
|
|
|
}
|
|
|
|
|
2020-08-22 02:07:33 +03:00
|
|
|
# Usage: image : loader everything_else
|
2020-06-21 05:15:00 +03:00
|
|
|
actions BuildEfiSDImage1
|
|
|
|
{
|
|
|
|
$(RM) $(1)
|
|
|
|
$(RM) $(1).mtools
|
|
|
|
|
|
|
|
# make an empty image
|
|
|
|
dd of=$(1) \
|
|
|
|
if=/dev/zero \
|
|
|
|
bs=$(SDIMAGE_BLOCK_SIZE) \
|
|
|
|
count=$(SDIMAGE_SIZE)
|
|
|
|
# generate mtools config
|
|
|
|
echo 'drive i: file="$(1)" partition=1 cylinders=$(SDIMAGE_MTOOLS_C)
|
|
|
|
heads=$(SDIMAGE_MTOOLS_H) sectors=$(SDIMAGE_MTOOLS_S)
|
|
|
|
mformat_only' > $(1).mtools
|
|
|
|
# partition it
|
|
|
|
MTOOLSRC=$(1).mtools mpartition -b$(SDIMAGE_BEGIN) -cI -T 0xc i:
|
|
|
|
# format the image
|
|
|
|
MTOOLSRC=$(1).mtools mformat -L 32 -v "HAIKU" i:
|
|
|
|
|
|
|
|
# generate u-boot environment variables
|
|
|
|
echo 'os=haiku' > uEnv.txt
|
|
|
|
echo 'platform=efi' >> uEnv.txt
|
|
|
|
echo "loader=EFI/BOOT/$(EFINAME)" >> uEnv.txt
|
|
|
|
|
|
|
|
# populate
|
|
|
|
MTOOLSRC=$(1).mtools mmd i:/EFI
|
|
|
|
MTOOLSRC=$(1).mtools mmd i:/EFI/BOOT
|
|
|
|
MTOOLSRC=$(1).mtools mcopy $(2[2-2]) i:/EFI/BOOT/$(EFINAME)
|
2020-08-22 02:07:33 +03:00
|
|
|
MTOOLSRC=$(1).mtools mcopy $(2[3-]) i:
|
2020-06-21 05:15:00 +03:00
|
|
|
MTOOLSRC=$(1).mtools mcopy uEnv.txt i:
|
|
|
|
# populate fdts
|
|
|
|
MTOOLSRC=$(1).mtools mmd i:/fdt
|
|
|
|
MTOOLSRC=$(1).mtools mcopy $(TARGET_DEVICE_TREES[1-]) i:/fdt/
|
|
|
|
# list content
|
|
|
|
MTOOLSRC=$(1).mtools mdir i:
|
|
|
|
MTOOLSRC=$(1).mtools mdir i:/fdt
|
|
|
|
MTOOLSRC=$(1).mtools mdir i:/EFI/BOOT
|
|
|
|
# cleanup
|
|
|
|
$(RM) $(1).mtools
|
|
|
|
$(RM) uEnv.txt
|
|
|
|
$(RM) boot.scr
|
|
|
|
# Add haiku bootstrap partition to MMC image
|
|
|
|
cat $(2[0]) >> $(1)
|
|
|
|
}
|
2018-10-18 18:07:12 +03:00
|
|
|
|
2020-06-21 05:15:00 +03:00
|
|
|
for platform in [ MultiBootSubDirSetup ] {
|
|
|
|
on $(platform) {
|
|
|
|
# SD/mmc image targets
|
|
|
|
if $(TARGET_BOOT_PLATFORM) = efi {
|
2020-08-22 02:07:33 +03:00
|
|
|
if $(TARGET_ARCH) = arm || $(TARGET_ARCH) = arm64 {
|
|
|
|
# These EFI platforms need u-boot to get them going
|
|
|
|
BuildSDImage $(HAIKU_MMC_NAME) : $(HAIKU_IMAGE)
|
|
|
|
haiku_loader.$(TARGET_BOOT_PLATFORM)
|
|
|
|
boot.scr ;
|
|
|
|
} else {
|
|
|
|
BuildSDImage $(HAIKU_MMC_NAME) : $(HAIKU_IMAGE)
|
|
|
|
haiku_loader.$(TARGET_BOOT_PLATFORM) ;
|
|
|
|
}
|
2020-06-21 05:15:00 +03:00
|
|
|
} else {
|
|
|
|
BuildSDImage $(HAIKU_MMC_NAME) :
|
|
|
|
$(HAIKU_IMAGE) haiku_loader.$(TARGET_BOOT_PLATFORM) haiku-floppyboot.tgz.$(TARGET_BOOT_PLATFORM) boot.scr ;
|
|
|
|
}
|
|
|
|
}
|
2018-10-18 18:07:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#BlessSDImage haiku-$(TARGET_KERNEL_ARCH).mmc ;
|
|
|
|
NotFile haiku-mmc-image ;
|
|
|
|
Depends haiku-mmc-image : $(HAIKU_MMC_NAME) ;
|