# short-description: Create SD card image with a boot partition
# long-description: Creates a partitioned SD card image for STM32MP1 OpenSTLinux BSP
#
#  - -------- ----- ------------ -------- ---------- -------- --------
# | | TFA(2) | FIP | U-BOOT ENV | bootfs | vendorfs | rootfs | userfs |
#  - -------- ----- ------------ -------- ---------- -------- --------
# ^ ^
# | |
# 0 17kB
#
# Partition sizes are defined throught the machine settings (or can be changed manually on this file).
#
# Warning: the first stage of boot (here fsbl1, fsbl2, fip) MUST be on GPT partition to be detected.
#

# FSBL partitions (TF-A BL2)
part fsbla --source rawcopy --fstype=ext4 --fsoptions "noauto" --part-name=fsbla --sourceparams="file=/home/automatix/stm/b/rb/build-openstlinuxweston-stm32mp25x-phyflex-libra-rdk-3/tmp-glibc/deploy/images/stm32mp25x-phyflex-libra-rdk-3/arm-trusted-firmware/tf-a-stm32mp257f-phyflex-fpsc-g-som-optee-sdcard.stm32" --ondisk mmcblk --part-type 0x8301 --fixed-size 256K --align 17
part fsbla2 --source rawcopy --fstype=ext4 --fsoptions "noauto" --part-name=fsbla2 --sourceparams="file=/home/automatix/stm/b/rb/build-openstlinuxweston-stm32mp25x-phyflex-libra-rdk-3/tmp-glibc/deploy/images/stm32mp25x-phyflex-libra-rdk-3/arm-trusted-firmware/tf-a-stm32mp257f-phyflex-fpsc-g-som-optee-sdcard.stm32" --ondisk mmcblk --part-type 0x8301 --fixed-size 256K

# Fip partition
part fip   --source rawcopy --fstype=ext4 --fsoptions "noauto" --part-name=fip --sourceparams="file=/home/automatix/stm/b/rb/build-openstlinuxweston-stm32mp25x-phyflex-libra-rdk-3/tmp-glibc/deploy/images/stm32mp25x-phyflex-libra-rdk-3/fip/fip-stm32mp257f-phyflex-fpsc-g-som-optee-sdcard.bin" --ondisk mmcblk --part-type 0x8301 --fixed-size 4096K

# U-BOOT env
part u-boot-env --source empty --part-name=u-boot-env --ondisk mmcblk --part-type 0x8301 --fixed-size 512K

# Bootfs
part /boot --source rootfs --rootfs-dir=/home/automatix/stm/b/rb/build-openstlinuxweston-stm32mp25x-phyflex-libra-rdk-3/tmp-glibc/work/stm32mp25x_phyflex_libra_rdk_3-ostl-linux/st-image-weston/1.0/rootfs/boot --ondisk mmcblk --fstype=ext4 --part-name bootfs --active --fixed-size 65536K
# Vendorfs
part /vendor --source rootfs --rootfs-dir=/home/automatix/stm/b/rb/build-openstlinuxweston-stm32mp25x-phyflex-libra-rdk-3/tmp-glibc/work/stm32mp25x_phyflex_libra_rdk_3-ostl-linux/st-image-weston/1.0/rootfs/vendor --ondisk mmcblk --fstype=ext4 --part-name vendorfs --fixed-size 49152K
# Rootfs
part / --source rootfs --ondisk mmcblk --fstype=ext4 --part-name rootfs --extra-space 1024M --uuid e91c4e10-16e6-4c0e-bd0e-77becf4a3582
# Userfs
part /usr/local --source rootfs --rootfs-dir=/home/automatix/stm/b/rb/build-openstlinuxweston-stm32mp25x-phyflex-libra-rdk-3/tmp-glibc/work/stm32mp25x_phyflex_libra_rdk_3-ostl-linux/st-image-weston/1.0/rootfs/usr/local --ondisk mmcblk --fstype=ext4 --part-name userfs --fixed-size 131072K

bootloader --ptable gpt
