# short-description: Create SDCard installer image
# long-description: Create SDCard installer image

# offset 1S => 1 sector (1x512 byte)
# The bootloader can be at 5 different position: 1S, 34S, 4096S, 8192S, 12288S
# MBR disk use only the sector 0, so 1S is free
# GPT disk use sector 0-33S, so first free slot is 34S

# Current bootloader is about 1.8MB, so if we put it at 4096S and 12288S we
# have 4MiB between the first bootloader and the second copy of it

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# Don't name partition in the installer disk image, otherwise the installer may not work as it rely on partition label!
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
part --offset 4096S --source rawcopy --sourceparams="file=flash-image.bin" --ondisk mmcblk1 --fixed-size 4M
part --offset 12288S --source rawcopy --sourceparams="file=flash-image.bin" --ondisk mmcblk1 --fixed-size 4M
part --source bootimg-partition --part-type=EF00 --ondisk mmcblk1 --offset 20480S --fixed-size 125M
bootloader --ptable gpt
