1#!/vendor/bin/sh
2#
3# The script belongs to the feature of UFS FFU via OTA: go/p23-ffu-ota
4# Its purpose is to copy the corresponding firmware into partition for UFS FFU.
5
6ufs_dev="/dev/sys/block/bootdevice"
7fw_dir="/vendor/firmware"
8blk_dev="/dev/block/by-name/fips"
9
10vendor=$(cat ${ufs_dev}/vendor | tr -d "[:space:]")
11model=$(cat ${ufs_dev}/model | tr -d "[:space:]")
12rev=$(cat ${ufs_dev}/rev | tr -d "[:space:]")
13
14file=$(find ${fw_dir} -name "*${vendor}${model}${rev}*" | head -n 1)
15if [ -n "$file" ]; then
16	# The first 4KB block at fips partition has been occupied, and unused space begins from 4 KB
17	# Refer to: go/pixel-mp-ffu-ota-1p
18	dd if="$file" of=$blk_dev bs=4k seek=1
19fi
20