# short-description: Create SD card image with a boot partition (1GB)
# long-description: Creates a partitioned SD card image (1GB)
#
#  - ----- --------- -------------- ---------------------------------
# | | TFA | u-boot  |     bootfs   |    vendorfs | rootfs  | userfs |
#  - ----- --------- -------------- ---------------------------------
# ^ ^     ^         ^              ^             ^         ^        ^
# | |     |         |              |             |         |        |
# 0 17kB 529kB     4MB           66.5MB        82.5MB   850.5Mb  1024MB
#
# Warning: the first stage of boot (here fsbl1, fsbl2, fip) MUST be on GPT partition to be detected.
#

part fsbl1 --source rawcopy --fstype=ext4 --fsoptions "noauto" --part-name=fsbl1 --sourceparams="file=${DEPLOY_DIR_IMAGE}/arm-trusted-firmware/tf-a-stm32mp157c-dk2-sdcard.stm32" --ondisk mmcblk --part-type 0x8301 --fixed-size 256K --align 17
part fsbl2 --source rawcopy --fstype=ext4 --fsoptions "noauto" --part-name=fsbl2 --sourceparams="file=${DEPLOY_DIR_IMAGE}/arm-trusted-firmware/tf-a-stm32mp157c-dk2-sdcard.stm32" --ondisk mmcblk --part-type 0x8301 --fixed-size 256K
part fip   --source rawcopy --fstype=ext4 --fsoptions "noauto" --part-name=fip --sourceparams="file=${DEPLOY_DIR_IMAGE}/fip/fip-stm32mp157c-dk2-trusted.bin" --ondisk mmcblk --part-type 0x8301 --fixed-size 4096K

part bootfs --source rawcopy --sourceparams="file=st-image-bootfs-${DISTRO}-${MACHINE}.ext4" --ondisk mmcblk --fstype=ext4 --label bootfs --active --fixed-size 64M
part / --source rootfs --ondisk mmcblk --fstype=ext4 --label rootfs --fixed-size 768M --uuid e91c4e10-16e6-4c0e-bd0e-77becf4a3582
part usrfs --source rawcopy --sourceparams="file=st-image-userfs-${DISTRO}-${MACHINE}.ext4" --ondisk mmcblk --fstype=ext4 --label userfs --active --fixed-size 173M

bootloader --ptable gpt
