Commit a079a64a authored by Grant Likely's avatar Grant Likely
Browse files

Create an ESP on the SD image

Adds an esp.img target for creating an ESP filesystem with the UEFI
shell on the SD card image. The ESP is first created by copying the
wanted files into the esp.tree directory, and then using mtools to put
the files into a fat filesystem image.

Signed-off-by: Grant Likely's avatarGrant Likely <>
parent 37d7093c
......@@ -46,7 +46,10 @@ UBOOT_EXTRA ?= EXT_DTB=$(DT_PATH)/$(DTB_TARGET)
FLASH_IMAGE ?= $(TFA_PATH)/build/$(TFA_PLAT)/release/flash-image.bin
.PHONY: dtb u-boot clean
ESP_SIZE ?= $$((64*1024*1024))
ESP_OFFSET ?= $$((4*1024*1024))
.PHONY: dtb u-boot clean
......@@ -72,3 +75,30 @@ sd.img: $(SD_IMG)
flash-sd: $(SD_IMG)
sudo dd if=${SD_IMG} of=${FLASH_DEVICE} conv=fdatasync status=progress
unzip -f $(SCT_VERSION).zip
unzip -f
touch $@
esp.tree/.done: scripts/ Shell.efi $(SCT_VERSION).zip
mkdir -p esp.tree/efi/boot
mkdir -p esp.tree/UEFISCT
cp Shell.efi \
$(UBOOT_OUTPUT)/lib/efi_selftest/efi_selftest_miniapp_return.efi \
$(UBOOT_OUTPUT)/lib/efi_selftest/efi_selftest_miniapp_exception.efi \
$(UBOOT_OUTPUT)/lib/efi_selftest/efi_selftest_miniapp_exit.efi \
$(UBOOT_OUTPUT)/lib/efi_loader/helloworld.efi esp.tree/
cp -r UEFISCT/SctPackageAARCH64/* esp.tree/UEFISCT
touch $@
esp.img: scripts/ Shell.efi esp.tree/.done
dd if=/dev/zero of=esp.img count=$$(($(ESP_SIZE) >> 9))
/sbin/mkfs.fat esp.img
mcopy -i esp.img -s esp.tree/* ::
......@@ -9,7 +9,9 @@ TFA_EXTRA += SCP_BL2=${CURDIR}/binaries-marvell/mrvl_scp_bl2.img
$(SD_IMG): u-boot
dd if=/dev/zero of=$(SD_IMG) seek=32M count=0
echo "label: dos" | /sbin/sfdisk $(SD_IMG)
dd if=${FLASH_IMAGE} of=$(SD_IMG) seek=1
$(SD_IMG): u-boot esp.img scripts/*.mk
dd if=/dev/zero of=$(SD_IMG) count=$$((128*1024*1024>>9))
#echo "label: dos" | /sbin/sfdisk $(SD_IMG)
echo "label: dos\n$$(($(ESP_OFFSET)>>9)) - 0xef -" | /sbin/sfdisk $(SD_IMG)
dd if=${FLASH_IMAGE} of=$(SD_IMG) seek=1 conv=notrunc
dd if=esp.img of=$(SD_IMG) seek=$$(($(ESP_OFFSET)>>9)) conv=notrunc
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment