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
|
2021-01-07 18:24:15 +03:00
|
|
|
# Files must be in this order:
|
|
|
|
# out : mbrtool fatshell os_image loader floppyboot everything_else
|
2020-06-21 05:15:00 +03:00
|
|
|
rule BuildSDImage image : files
|
2018-10-18 18:07:12 +03:00
|
|
|
{
|
2021-01-07 18:24:15 +03:00
|
|
|
local mbrtool = <build>mbrtool ;
|
|
|
|
local fatshell = <build>fat_shell ;
|
|
|
|
|
2020-06-21 05:15:00 +03:00
|
|
|
Depends $(image) : $(files) $(TARGET_DEVICE_TREES) ;
|
2021-01-07 18:24:15 +03:00
|
|
|
Depends $(image) : $(HAIKU_IMAGE_NAME) ;
|
|
|
|
Depends $(image) : $(mbrtool) ;
|
|
|
|
Depends $(image) : $(fatshell) ;
|
|
|
|
|
|
|
|
SDIMAGE_OS_SIZE on $(image) = $(HAIKU_IMAGE_SIZE) ;
|
2020-06-21 05:15:00 +03:00
|
|
|
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!" ;
|
|
|
|
}
|
2021-01-07 18:24:15 +03:00
|
|
|
BuildEfiSDImage1 $(image) : $(mbrtool) $(fatshell) $(files) ;
|
2021-06-07 15:28:18 +03:00
|
|
|
} else if $(TARGET_BOOT_PLATFORM) = u-boot {
|
2021-01-07 18:24:15 +03:00
|
|
|
BuildUBootSDImage1 $(image) : $(mbrtool) $(fatshell) $(files) ;
|
2021-06-07 15:28:18 +03:00
|
|
|
} else {
|
|
|
|
# TODO: For now we do nothing. Maybe we want a "AddSDImage" to
|
|
|
|
# append additional loaders like the raw riscv one?
|
|
|
|
echo "Asked for $(TARGET_BOOT_PLATFORM) target boot platform" ;
|
|
|
|
echo "Unknown path to handle adding to image" ;
|
2020-06-21 05:15:00 +03:00
|
|
|
}
|
2018-10-18 18:07:12 +03:00
|
|
|
}
|
|
|
|
|
2021-01-07 18:24:15 +03:00
|
|
|
# Usage:
|
|
|
|
# out : mbrtool fatshell os_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)
|
2021-01-07 18:24:15 +03:00
|
|
|
|
2021-01-08 01:05:46 +03:00
|
|
|
export $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR)
|
|
|
|
|
2021-01-07 18:24:15 +03:00
|
|
|
# in KiB
|
|
|
|
EFI_SIZE=32768
|
|
|
|
BOOT_SIZE=`expr ${EFI_SIZE} + $(SDIMAGE_BEGIN)`
|
|
|
|
MMC_SIZE=`expr $(SDIMAGE_OS_SIZE) \* 1024 + ${BOOT_SIZE}`
|
|
|
|
|
|
|
|
# Build "boot" disk
|
|
|
|
dd if=/dev/zero of=$(1) bs=1K count=${BOOT_SIZE}
|
2020-06-21 05:15:00 +03:00
|
|
|
|
|
|
|
# generate u-boot environment variables
|
|
|
|
echo 'os=haiku' > uEnv.txt
|
|
|
|
echo 'platform=u-boot' >> uEnv.txt
|
2021-01-07 18:24:15 +03:00
|
|
|
echo "loader=haiku_loader.ub" >> uEnv.txt
|
|
|
|
|
|
|
|
# Lay down partition map
|
|
|
|
OS_LENGTH=`expr ${MMC_SIZE} - ${BOOT_SIZE}`
|
|
|
|
|
|
|
|
# EFI System Partition
|
|
|
|
$(2[1]) $(1) 0 0xef $(SDIMAGE_BEGIN) ${EFI_SIZE}
|
|
|
|
# OS Partition
|
|
|
|
$(2[1]) $(1) 1 0xeb ${BOOT_SIZE} ${OS_LENGTH}
|
|
|
|
|
|
|
|
FATFS="$(2[2]) --start-offset `expr $(SDIMAGE_BEGIN) \* 1024`"
|
|
|
|
|
|
|
|
# format the image
|
|
|
|
${FATFS} --end-offset `expr ${BOOT_SIZE} \* 1024` \
|
|
|
|
--initialize "$(1)" 'Haiku Boot'
|
2020-06-21 05:15:00 +03:00
|
|
|
|
|
|
|
# populate
|
2021-01-07 18:24:15 +03:00
|
|
|
for i in $(2[4-]) ; do
|
|
|
|
echo "cp :${i} myfs/" | ${FATFS} $(1)
|
|
|
|
done
|
|
|
|
|
|
|
|
echo "cp :uEnv.txt myfs/" | ${FATFS} $(1)
|
|
|
|
|
|
|
|
# lay down FDT's
|
|
|
|
echo "mkdir myfs/fdt" | ${FATFS} $(1)
|
|
|
|
for i in $(TARGET_DEVICE_TREES[1-]) ; do
|
|
|
|
echo "cp :${i} myfs/fdt/" | ${FATFS} $(1)
|
|
|
|
done
|
|
|
|
|
2020-06-21 05:15:00 +03:00
|
|
|
# list content
|
2021-01-07 18:24:15 +03:00
|
|
|
echo "ls myfs" | ${FATFS} $(1)
|
|
|
|
|
2020-06-21 05:15:00 +03:00
|
|
|
# cleanup
|
|
|
|
$(RM) uEnv.txt
|
|
|
|
$(RM) boot.scr
|
2021-01-07 18:24:15 +03:00
|
|
|
|
|
|
|
# Add haiku partition to MMC image
|
|
|
|
cat $(2[3-3]) >> $(1)
|
2020-06-21 05:15:00 +03:00
|
|
|
}
|
|
|
|
|
2021-01-07 18:24:15 +03:00
|
|
|
|
|
|
|
# Usage:
|
|
|
|
# out : mbrtool fatshell os_image loader floppyboot everything_else
|
2020-06-21 05:15:00 +03:00
|
|
|
actions BuildEfiSDImage1
|
|
|
|
{
|
|
|
|
$(RM) $(1)
|
2021-01-07 18:24:15 +03:00
|
|
|
|
2021-01-08 01:05:46 +03:00
|
|
|
export $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR)
|
|
|
|
|
2021-01-07 18:24:15 +03:00
|
|
|
# in KiB
|
|
|
|
EFI_SIZE=32768
|
|
|
|
BOOT_SIZE=`expr ${EFI_SIZE} + $(SDIMAGE_BEGIN)`
|
|
|
|
MMC_SIZE=`expr $(SDIMAGE_OS_SIZE) \* 1024 + ${BOOT_SIZE}`
|
|
|
|
|
|
|
|
# Build "boot" disk
|
|
|
|
dd if=/dev/zero of=$(1) bs=1K count=${BOOT_SIZE}
|
2020-06-21 05:15:00 +03:00
|
|
|
|
|
|
|
# generate u-boot environment variables
|
|
|
|
echo 'os=haiku' > uEnv.txt
|
|
|
|
echo 'platform=efi' >> uEnv.txt
|
|
|
|
echo "loader=EFI/BOOT/$(EFINAME)" >> uEnv.txt
|
|
|
|
|
2021-01-07 18:24:15 +03:00
|
|
|
# Lay down partition map
|
|
|
|
OS_LENGTH=`expr ${MMC_SIZE} - ${BOOT_SIZE}`
|
|
|
|
|
|
|
|
# EFI System Partition
|
|
|
|
$(2[1]) $(1) 0 0xef $(SDIMAGE_BEGIN) ${EFI_SIZE}
|
|
|
|
# OS Partition
|
|
|
|
$(2[1]) $(1) 1 0xeb ${BOOT_SIZE} ${OS_LENGTH}
|
|
|
|
|
|
|
|
FATFS="$(2[2]) --start-offset `expr $(SDIMAGE_BEGIN) \* 1024`"
|
|
|
|
|
|
|
|
# format the image
|
|
|
|
${FATFS} --end-offset `expr ${BOOT_SIZE} \* 1024` \
|
|
|
|
--initialize "$(1)" 'Haiku Boot'
|
|
|
|
|
2020-06-21 05:15:00 +03:00
|
|
|
# populate
|
2021-01-07 18:24:15 +03:00
|
|
|
echo "mkdir -p myfs/EFI/BOOT" | ${FATFS} $(1)
|
|
|
|
echo "cp :$(2[4-4]) myfs/EFI/BOOT/$(EFINAME)" | ${FATFS} $(1)
|
|
|
|
|
|
|
|
# copy misc files
|
|
|
|
for i in $(2[5-]) ; do
|
|
|
|
echo "cp :${i} myfs/" | ${FATFS} $(1)
|
|
|
|
done
|
|
|
|
echo "cp :uEnv.txt myfs/" | ${FATFS} $(1)
|
|
|
|
|
|
|
|
# lay down FDT's
|
|
|
|
echo "mkdir myfs/fdt" | ${FATFS} $(1)
|
|
|
|
for i in $(TARGET_DEVICE_TREES[1-]) ; do
|
|
|
|
echo "cp :${i} myfs/fdt/" | ${FATFS} $(1)
|
|
|
|
done
|
|
|
|
|
2020-06-21 05:15:00 +03:00
|
|
|
# list content
|
2021-01-07 18:24:15 +03:00
|
|
|
echo "ls myfs" | ${FATFS} $(1)
|
|
|
|
|
2020-06-21 05:15:00 +03:00
|
|
|
# cleanup
|
|
|
|
$(RM) uEnv.txt
|
|
|
|
$(RM) boot.scr
|
2021-01-07 18:24:15 +03:00
|
|
|
|
|
|
|
# Add haiku partition to MMC image
|
|
|
|
cat $(2[3-3]) >> $(1)
|
2020-06-21 05:15:00 +03:00
|
|
|
}
|
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 {
|
2021-08-28 18:42:31 +03:00
|
|
|
if $(TARGET_ARCH) = arm || $(TARGET_ARCH) = riscv64 {
|
2020-08-22 02:07:33 +03:00
|
|
|
# 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) ;
|
|
|
|
}
|
2021-06-07 15:28:18 +03:00
|
|
|
} else if $(TARGET_BOOT_PLATFORM) = u-boot {
|
2020-06-21 05:15:00 +03:00
|
|
|
BuildSDImage $(HAIKU_MMC_NAME) :
|
|
|
|
$(HAIKU_IMAGE) haiku_loader.$(TARGET_BOOT_PLATFORM) haiku-floppyboot.tgz.$(TARGET_BOOT_PLATFORM) boot.scr ;
|
2021-06-07 15:28:18 +03:00
|
|
|
} else {
|
|
|
|
BuildSDImage $(HAIKU_MMC_NAME) :
|
|
|
|
$(HAIKU_IMAGE) haiku_loader.$(TARGET_BOOT_PLATFORM) boot.scr ;
|
2020-06-21 05:15:00 +03:00
|
|
|
}
|
|
|
|
}
|
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) ;
|