From Alex von Gluck IV <kallisti5@xxxxxxxxxxx>:
Alex von Gluck IV has uploaded this change for review. (
https://review.haiku-os.org/c/haiku/+/2938 )
Change subject: arm: Generate proper mmc image
......................................................................
arm: Generate proper mmc image
* Stub out makebootable like on u-boot
* Place haiku_loader.efi at EFI/BOOT/BOOTXXX.EFI
* Generate boot.scr for u-boot + EFI
* haiku-mmc.image now attempts to auto-boot in qemu-system-arm
* Same code paths should roughly apply for arm64,riscv,etc
Change-Id: I563ebd77422d9e5dfcfeeedadcbc60471e8a57f4
---
M build/jam/images/MMCImage
A src/bin/makebootable/platform/efi/Jamfile
A src/bin/makebootable/platform/efi/makebootable.cpp
M src/system/boot/Jamfile
A src/tools/makebootable/platform/efi/Jamfile
5 files changed, 154 insertions(+), 50 deletions(-)
git pull ssh://git.haiku-os.org:22/haiku refs/changes/38/2938/1
diff --git a/build/jam/images/MMCImage b/build/jam/images/MMCImage
index df85b6c..93795ed 100644
--- a/build/jam/images/MMCImage
+++ b/build/jam/images/MMCImage
@@ -7,65 +7,144 @@
# SD/mmc image rule
# requires mtools package on linux
# Files must be in this order: loader floppyboot everything_else
-rule BuildUBootSDImage image : files
+rule BuildSDImage image : files
{
- 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) ;
- BuildUBootSDImage1 $(image) : $(files) ;
+ 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) ;
+ }
}
actions BuildUBootSDImage1
{
- $(RM) $(1)
- $(RM) $(1).mtools
+ $(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:
+ # 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
- # populate
- $(CP) $(2[2-2]) haiku_loader.ub
- MTOOLSRC=$(1).mtools mcopy haiku_loader.ub i:
- $(RM) haiku_loader.ub
- $(CP) $(2[3-3]) haiku_floppyboot.ub
- MTOOLSRC=$(1).mtools mcopy haiku_floppyboot.ub i:
- $(RM) 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)
+ # generate u-boot environment variables
+ echo 'os=haiku' > uEnv.txt
+ echo 'loader=uboot' >> uEnv.txt
+ # populate
+ $(CP) $(2[2-2]) haiku_loader.ub
+ MTOOLSRC=$(1).mtools mcopy haiku_loader.ub i:
+ $(RM) haiku_loader.ub
+ $(CP) $(2[3-3]) haiku_floppyboot.ub
+ MTOOLSRC=$(1).mtools mcopy haiku_floppyboot.ub i:
+ $(RM) 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)
}
-# SD/mmc image targets
-BuildUBootSDImage $(HAIKU_MMC_NAME) :
- $(HAIKU_IMAGE) haiku_loader.u-boot haiku-floppyboot.tgz.u-boot boot.scr ;
+
+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 'loader=efi' >> uEnv.txt
+ # populate
+ MTOOLSRC=$(1).mtools mmd i:/EFI
+ MTOOLSRC=$(1).mtools mmd i:/EFI/BOOT
+ $(CP) $(2[2-2]) $(EFINAME)
+ MTOOLSRC=$(1).mtools mcopy $(EFINAME) i:/EFI/BOOT/
+ $(RM) $(EFINAME)
+ #$(CP) $(2[3-3]) haiku_floppyboot.ub
+ #MTOOLSRC=$(1).mtools mcopy haiku_floppyboot.ub i:
+ #$(RM) 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
+ 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)
+}
+
+for platform in [ MultiBootSubDirSetup ] {
+ on $(platform) {
+ # SD/mmc image targets
+ if $(TARGET_BOOT_PLATFORM) = efi {
+ 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)
haiku-floppyboot.tgz.$(TARGET_BOOT_PLATFORM) boot.scr ;
+ }
+ }
+}
+
#BlessSDImage haiku-$(TARGET_KERNEL_ARCH).mmc ;
NotFile haiku-mmc-image ;
Depends haiku-mmc-image : $(HAIKU_MMC_NAME) ;
diff --git a/src/bin/makebootable/platform/efi/Jamfile
b/src/bin/makebootable/platform/efi/Jamfile
new file mode 100644
index 0000000..d5d62e6
--- /dev/null
+++ b/src/bin/makebootable/platform/efi/Jamfile
@@ -0,0 +1,3 @@
+SubDir HAIKU_TOP src bin makebootable platform efi ;
+
+BinCommand makebootable : makebootable.cpp ;
diff --git a/src/bin/makebootable/platform/efi/makebootable.cpp
b/src/bin/makebootable/platform/efi/makebootable.cpp
new file mode 100644
index 0000000..8d3ab27
--- /dev/null
+++ b/src/bin/makebootable/platform/efi/makebootable.cpp
@@ -0,0 +1,6 @@
+int
+main()
+{
+ return 0;
+}
+
diff --git a/src/system/boot/Jamfile b/src/system/boot/Jamfile
index e23eac3..67b618b 100644
--- a/src/system/boot/Jamfile
+++ b/src/system/boot/Jamfile
@@ -317,6 +317,9 @@
switch $(TARGET_BOOT_PLATFORM) {
case efi :
BuildEFILoader
haiku_loader.$(TARGET_BOOT_PLATFORM) : boot_loader_$(TARGET_BOOT_PLATFORM) ;
+ if $(TARGET_ARCH) = arm || $(TARGET_ARCH) =
arm64 {
+ BuildUImageScript boot.scr :
$(HAIKU_MMC_UBOOT_SCRIPT) ;
+ }
case bios_ia32 :
BuildBiosLoader
haiku_loader.$(TARGET_BOOT_PLATFORM) : boot_loader_$(TARGET_BOOT_PLATFORM) ;
diff --git a/src/tools/makebootable/platform/efi/Jamfile
b/src/tools/makebootable/platform/efi/Jamfile
new file mode 100644
index 0000000..1aa97cc
--- /dev/null
+++ b/src/tools/makebootable/platform/efi/Jamfile
@@ -0,0 +1,13 @@
+SubDir HAIKU_TOP src tools makebootable platform efi ;
+
+SEARCH_SOURCE
+ += [ FDirName $(HAIKU_TOP) src bin makebootable platform efi ] ;
+
+BuildPlatformMain <build>makebootable :
+ makebootable.cpp
+ $(hostPlatformSources)
+ :
+ # $(HOST_LIBBE)
+ $(HOST_LIBSTDC++) $(HOST_LIBSUPC++)
+;
+
--
To view, visit https://review.haiku-os.org/c/haiku/+/2938
To unsubscribe, or for help writing mail filters, visit
https://review.haiku-os.org/settings
Gerrit-Project: haiku
Gerrit-Branch: master
Gerrit-Change-Id: I563ebd77422d9e5dfcfeeedadcbc60471e8a57f4
Gerrit-Change-Number: 2938
Gerrit-PatchSet: 1
Gerrit-Owner: Alex von Gluck IV <kallisti5@xxxxxxxxxxx>
Gerrit-MessageType: newchange