SDCARD-RAW-TOOLS: extend script support
Change-Id: I0187e879bfcf1544d406c78a33dfbcee0070e0ca
This commit is contained in:
parent
c9e37af629
commit
2fbe4ce39c
|
|
@ -17,6 +17,22 @@ inherit deploy
|
|||
|
||||
SCRIPT_DEPLOYDIR ?= "scripts"
|
||||
|
||||
do_configure() {
|
||||
if [ -e ${WORKDIR}/create_sdcard_from_flashlayout.sh ]; then
|
||||
bbnote "Update DEFAULT_ROOTFS_PARTITION_SIZE to ${ROOTFS_PARTITION_SIZE}"
|
||||
sed 's/^DEFAULT_ROOTFS_PARTITION_SIZE=.*$/DEFAULT_ROOTFS_PARTITION_SIZE='"${ROOTFS_PARTITION_SIZE}"'/' -i ${WORKDIR}/create_sdcard_from_flashlayout.sh
|
||||
if [ ${ROOTFS_PARTITION_SIZE} -gt 1572864 ]; then
|
||||
# rootfs > 1.5GB then put sdcard raw size = ROOTFS_PARTITION_SIZE + 1.5GB
|
||||
raw_size=$(expr ${ROOTFS_PARTITION_SIZE} / 1024 )
|
||||
raw_size=$(expr $raw_size + 1536)
|
||||
sed 's/^DEFAULT_RAW_SIZE=.*$/DEFAULT_RAW_SIZE='"$raw_size"'/' -i ${WORKDIR}/create_sdcard_from_flashlayout.sh
|
||||
fi
|
||||
|
||||
bbnote "Update DEFAULT_SDCARD_PARTUUID to ${DEVICE_PARTUUID_ROOTFS_SDCARD}"
|
||||
sed 's/^DEFAULT_SDCARD_PARTUUID=.*$/DEFAULT_SDCARD_PARTUUID='"${DEVICE_PARTUUID_ROOTFS_SDCARD}"'/' -i ${WORKDIR}/create_sdcard_from_flashlayout.sh
|
||||
fi
|
||||
}
|
||||
|
||||
do_install() {
|
||||
install -d ${D}/${bindir}
|
||||
install -m 0755 ${WORKDIR}/create_sdcard_from_flashlayout.sh ${D}/${bindir}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,10 @@
|
|||
# CREATED: 11/22/2017 15:03
|
||||
# REVISION: ---
|
||||
#===============================================================================
|
||||
#TODO: Pre-requisite tools
|
||||
# sgdisk
|
||||
# du
|
||||
# dd
|
||||
|
||||
unset FLASHLAYOUT_data
|
||||
unset FLASHLAYOUT_filename
|
||||
|
|
@ -40,6 +44,8 @@ DEFAULT_ROOTFS_PARTITION_SIZE=768432
|
|||
# 32 MB of Padding on B
|
||||
DEFAULT_PADDING_SIZE=33554432
|
||||
|
||||
DEFAULT_SDCARD_PARTUUID=e91c4e10-16e6-4c0e-bd0e-77becf4a3582
|
||||
|
||||
# Columns name on FLASHLAYOUT_data
|
||||
COL_SELECTED_OPT=0
|
||||
COL_PARTID=1
|
||||
|
|
@ -90,7 +96,7 @@ function read_flash_layout() {
|
|||
debug "Number of line: $FLASHLAYOUT_number_of_line"
|
||||
while read -ra flashlayout_data; do
|
||||
selected=${flashlayout_data[0]}
|
||||
if [ "$selected" == "P" ] || [ "$selected" == "E" ];
|
||||
if [ "$selected" == "P" ] || [ "$selected" == "E" ] || [ "$selected" == "PD" ] || [ "$selected" == "DP" ];
|
||||
then
|
||||
# Selected=
|
||||
FLASHLAYOUT_data[$i,$COL_SELECTED_OPT]=${flashlayout_data[0]}
|
||||
|
|
@ -142,7 +148,7 @@ function get_last_image_path() {
|
|||
if [ "$ip" == "$SDCARD_TOKEN" ];
|
||||
then
|
||||
case "$selected" in
|
||||
1|P)
|
||||
1|P|D|PD|DP)
|
||||
if [ "$partName" == 'rootfs' ];
|
||||
then
|
||||
last_image=$bin2flash
|
||||
|
|
@ -186,7 +192,7 @@ function calculate_number_of_partition() {
|
|||
ip=${FLASHLAYOUT_data[$i,$COL_IP]}
|
||||
if [ "$ip" == "$SDCARD_TOKEN" ]
|
||||
then
|
||||
if [ "$selected" == "P" ] || [ "$selected" == "E" ];
|
||||
if [ "$selected" == "P" ] || [ "$selected" == "E" ] || [ "$selected" == "PD" ] || [ "$selected" == "DP" ];
|
||||
then
|
||||
num=$(($num+1))
|
||||
fi
|
||||
|
|
@ -210,7 +216,7 @@ function move_partition_offset() {
|
|||
|
||||
if [ "$ip" == "$SDCARD_TOKEN" ]
|
||||
then
|
||||
if [ "$selected" == "P" ] || [ "$selected" == "E" ] ;
|
||||
if [ "$selected" == "P" ] || [ "$selected" == "E" ] || [ "$selected" == "PD" ] || [ "$selected" == "DP" ];
|
||||
then
|
||||
#calculate actual size of partition (before update)
|
||||
# in case of last partition, we doesn't take care of tmp_next_offset
|
||||
|
|
@ -257,20 +263,27 @@ function generate_gpt_partition_table_from_flash_layout() {
|
|||
debug "DUMP Process for $partName partition"
|
||||
|
||||
case "$selected" in
|
||||
P|E|1)
|
||||
P|E|1|PD|DP)
|
||||
# partition are present and must be created
|
||||
;;
|
||||
*)
|
||||
continue
|
||||
;;
|
||||
esac
|
||||
# add boot flags on gpt parition
|
||||
if [ "$partName" == "bootfs" ];
|
||||
then
|
||||
bootfs_param=" -A $j:set:2"
|
||||
else
|
||||
bootfs_param=""
|
||||
fi
|
||||
|
||||
case "$partName" in
|
||||
boot)
|
||||
# add boot flags on gpt parition
|
||||
extrafs_param=" -A $j:set:2"
|
||||
;;
|
||||
rootfs)
|
||||
# add rootfs PARTUUID flags
|
||||
extrafs_param=" -u $j:${DEFAULT_SDCARD_PARTUUID}"
|
||||
;;
|
||||
*)
|
||||
extrafs_param=""
|
||||
;;
|
||||
esac
|
||||
|
||||
# get size of image to put on partition
|
||||
if [ -n "$bin2flash" ];
|
||||
|
|
@ -359,7 +372,7 @@ function generate_gpt_partition_table_from_flash_layout() {
|
|||
debug " DUMP image size $image_size"
|
||||
debug " DUMP partition size $partition_size"
|
||||
debug " DUMP free size $free_size "
|
||||
if [ "$selected" == "P" ] || [ "$selected" == "E" ];
|
||||
if [ "$selected" == "P" ] || [ "$selected" == "E" ] || [ "$selected" == "PD" ] || [ "$selected" == "DP" ];
|
||||
then
|
||||
if [ $free_size -lt 0 ];
|
||||
then
|
||||
|
|
@ -414,7 +427,7 @@ function generate_gpt_partition_table_from_flash_layout() {
|
|||
fi
|
||||
|
||||
printf "part %d: %8s ..." $j "$partName"
|
||||
exec_print "sgdisk -a 1 -n $j:$offset:$next_offset -c $j:$partName -t $j:$gpt_code $bootfs_param $FLASHLAYOUT_rawname"
|
||||
exec_print "sgdisk -a 1 -n $j:$offset:$next_offset -c $j:$partName -t $j:$gpt_code $extrafs_param $FLASHLAYOUT_rawname"
|
||||
partition_size=$(sgdisk -p $FLASHLAYOUT_rawname | grep $partName | awk '{ print $4}')
|
||||
partition_size_type=$(sgdisk -p $FLASHLAYOUT_rawname | grep $partName | awk '{ print $5}')
|
||||
printf "\r[CREATED] part %d: %8s [partition size %s %s]\n" $j "$partName" "$partition_size" "$partition_size_type"
|
||||
|
|
@ -466,7 +479,7 @@ function populate_gpt_partition_table_from_flash_layout() {
|
|||
#debug " DUMP ip $ip"
|
||||
#debug " DUMP offset $offset "
|
||||
#debug " DUMP bin2flash $bin2flash"
|
||||
if [ "$selected" == "P" ];
|
||||
if [ "$selected" == "P" ] || [ "$selected" == "PD" ] || [ "$selected" == "DP" ];
|
||||
then
|
||||
# Populate only the partition in "P"
|
||||
if [ -e $FLASHLAYOUT_prefix_image_path/$bin2flash ];
|
||||
|
|
@ -506,7 +519,7 @@ function print_shema_on_infofile() {
|
|||
ip=${FLASHLAYOUT_data[$i,$COL_IP]}
|
||||
if [ "$ip" == "$SDCARD_TOKEN" ];
|
||||
then
|
||||
if [ "$selected" == "P" ] || [ "$selected" == "E" ];
|
||||
if [ "$selected" == "P" ] || [ "$selected" == "E" ] || [ "$selected" == "PD" ] || [ "$selected" == "DP" ];
|
||||
then
|
||||
echo -n "=============" >> $FLASHLAYOUT_infoname
|
||||
fi
|
||||
|
|
@ -521,7 +534,7 @@ function print_shema_on_infofile() {
|
|||
ip=${FLASHLAYOUT_data[$i,$COL_IP]}
|
||||
if [ "$ip" == "$SDCARD_TOKEN" ];
|
||||
then
|
||||
if [ "$selected" == "P" ] || [ "$selected" == "E" ];
|
||||
if [ "$selected" == "P" ] || [ "$selected" == "E" ] || [ "$selected" == "PD" ] || [ "$selected" == "DP" ];
|
||||
then
|
||||
echo -n "= " >> $FLASHLAYOUT_infoname
|
||||
fi
|
||||
|
|
@ -536,7 +549,7 @@ function print_shema_on_infofile() {
|
|||
partName=${FLASHLAYOUT_data[$i,$COL_PARTNAME]}
|
||||
if [ "$ip" == "$SDCARD_TOKEN" ];
|
||||
then
|
||||
if [ "$selected" == "P" ] || [ "$selected" == "E" ];
|
||||
if [ "$selected" == "P" ] || [ "$selected" == "E" ] || [ "$selected" == "PD" ] || [ "$selected" == "DP" ];
|
||||
then
|
||||
printf "= %08s " "$partName" >> $FLASHLAYOUT_infoname
|
||||
fi
|
||||
|
|
@ -550,7 +563,7 @@ function print_shema_on_infofile() {
|
|||
ip=${FLASHLAYOUT_data[$i,$COL_IP]}
|
||||
if [ "$ip" == "$SDCARD_TOKEN" ];
|
||||
then
|
||||
if [ "$selected" == "P" ] || [ "$selected" == "E" ];
|
||||
if [ "$selected" == "P" ] || [ "$selected" == "E" ] || [ "$selected" == "PD" ] || [ "$selected" == "DP" ];
|
||||
then
|
||||
echo -n "= " >> $FLASHLAYOUT_infoname
|
||||
fi
|
||||
|
|
@ -564,7 +577,7 @@ function print_shema_on_infofile() {
|
|||
ip=${FLASHLAYOUT_data[$i,$COL_IP]}
|
||||
if [ "$ip" == "$SDCARD_TOKEN" ];
|
||||
then
|
||||
if [ "$selected" == "P" ] || [ "$selected" == "E" ];
|
||||
if [ "$selected" == "P" ] || [ "$selected" == "E" ] || [ "$selected" == "PD" ] || [ "$selected" == "DP" ];
|
||||
then
|
||||
printf "= %08s%-2d " "mmcblk0p" $j>> $FLASHLAYOUT_infoname
|
||||
j=$(($j+1))
|
||||
|
|
@ -579,7 +592,7 @@ function print_shema_on_infofile() {
|
|||
ip=${FLASHLAYOUT_data[$i,$COL_IP]}
|
||||
if [ "$ip" == "$SDCARD_TOKEN" ];
|
||||
then
|
||||
if [ "$selected" == "P" ] || [ "$selected" == "E" ];
|
||||
if [ "$selected" == "P" ] || [ "$selected" == "E" ] || [ "$selected" == "PD" ] || [ "$selected" == "DP" ];
|
||||
then
|
||||
printf "= (%-2d) " $j>> $FLASHLAYOUT_infoname
|
||||
j=$(($j+1))
|
||||
|
|
@ -593,7 +606,7 @@ function print_shema_on_infofile() {
|
|||
ip=${FLASHLAYOUT_data[$i,$COL_IP]}
|
||||
if [ "$ip" == "$SDCARD_TOKEN" ];
|
||||
then
|
||||
if [ "$selected" == "P" ] || [ "$selected" == "E" ];
|
||||
if [ "$selected" == "P" ] || [ "$selected" == "E" ] || [ "$selected" == "PD" ] || [ "$selected" == "DP" ];
|
||||
then
|
||||
echo -n "= " >> $FLASHLAYOUT_infoname
|
||||
fi
|
||||
|
|
@ -606,7 +619,7 @@ function print_shema_on_infofile() {
|
|||
ip=${FLASHLAYOUT_data[$i,$COL_IP]}
|
||||
if [ "$ip" == "$SDCARD_TOKEN" ];
|
||||
then
|
||||
if [ "$selected" == "P" ] || [ "$selected" == "E" ];
|
||||
if [ "$selected" == "P" ] || [ "$selected" == "E" ] || [ "$selected" == "PD" ] || [ "$selected" == "DP" ];
|
||||
then
|
||||
echo -n "=============" >> $FLASHLAYOUT_infoname
|
||||
fi
|
||||
|
|
@ -623,7 +636,7 @@ function print_shema_on_infofile() {
|
|||
bin2flash=${FLASHLAYOUT_data[$i,$COL_BIN2FLASH]}
|
||||
if [ "$ip" == "$SDCARD_TOKEN" ];
|
||||
then
|
||||
if [ "$selected" == "P" ] || [ "$selected" == "E" ];
|
||||
if [ "$selected" == "P" ] || [ "$selected" == "E" ] || [ "$selected" == "PD" ] || [ "$selected" == "DP" ];
|
||||
then
|
||||
echo "($j):" >> $FLASHLAYOUT_infoname
|
||||
echo " Device: /dev/mmcblk0p$j" >> $FLASHLAYOUT_infoname
|
||||
|
|
@ -650,7 +663,7 @@ function print_populate_on_infofile() {
|
|||
bin2flash=${FLASHLAYOUT_data[$i,$COL_BIN2FLASH]}
|
||||
if [ "$ip" == "$SDCARD_TOKEN" ];
|
||||
then
|
||||
if [ "$selected" == "P" ] || [ "$selected" == "E" ];
|
||||
if [ "$selected" == "P" ] || [ "$selected" == "E" ] || [ "$selected" == "PD" ] || [ "$selected" == "DP" ];
|
||||
then
|
||||
if [ "$selected" == "E" ];
|
||||
then
|
||||
|
|
@ -698,15 +711,15 @@ cat >> $FLASHLAYOUT_infoname << EOF
|
|||
|
||||
3. How to update the kernel/devicetree
|
||||
--------------------------------------
|
||||
The kernel and devicetree are present on "bootfs" partition.
|
||||
The kernel and devicetree are present on "boot" partition.
|
||||
To change kernel and devicetree, you can copy the file on this partitions:
|
||||
- plug SDCARD on your PC
|
||||
- copy kernel uImage on SDCARD
|
||||
sudo cp uImage /media/\$USER/bootfs/
|
||||
sudo cp uImage /media/\$USER/boot/
|
||||
- copy devicetree uImage on SDCARD
|
||||
sudo cp stm32mp1*.dtb /media/\$USER/bootfs/
|
||||
sudo cp stm32mp1*.dtb /media/\$USER/boot/
|
||||
- umount partitions of SDCARD
|
||||
sudo umount /media/\$USER/bootfs/
|
||||
sudo umount /media/\$USER/boot/
|
||||
(dont't forget to umount the other partitions of SDCARD:
|
||||
sudo umount \`lsblk --list | grep mmcblk0 | grep part | gawk '{ print \$7 }' | tr '\\n' ' '\`
|
||||
)
|
||||
|
|
@ -756,11 +769,6 @@ function print_warning() {
|
|||
fi
|
||||
}
|
||||
|
||||
function check_if_command_exists() {
|
||||
command -v $1 >/dev/null 2>&1 \
|
||||
|| { echo "Cannot continue. Please install $1 first."; exit 1; }
|
||||
}
|
||||
|
||||
function usage() {
|
||||
echo ""
|
||||
echo "Help:"
|
||||
|
|
@ -778,12 +786,6 @@ then
|
|||
echo ""
|
||||
usage
|
||||
else
|
||||
# Pre-requisite tools
|
||||
for i in sgdisk du dd;
|
||||
do
|
||||
check_if_command_exists $i
|
||||
done
|
||||
|
||||
FLASHLAYOUT_filename=$1
|
||||
FLASHLAYOUT_filename_path=$(dirname $FLASHLAYOUT_filename)
|
||||
FLASHLAYOUT_filename_name=$(basename $FLASHLAYOUT_filename)
|
||||
|
|
@ -839,9 +841,6 @@ else
|
|||
read answer
|
||||
if [[ "$answer" =~ ^[Yy]+[ESes]* ]]; then
|
||||
rm -f $FLASHLAYOUT_rawname $FLASHLAYOUT_infoname
|
||||
else
|
||||
echo "Cannot continue."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue