Tx2 cloning and partitioning

I am cloning a image for Tx2 board following the guide
https://elinux.org/Jetson/TX2_Cloning which works as intended.
But I also need to create separate partitions as /data mnt point. I found following thread for flashing clone image with user specified rootfs and later use gparted to create partition. Tip: Rootfs Partition Resizing

But I am facing problem in doing so. Let me describe the steps I followed. First I Installed the Jetpack 4.3 using sdkmanager and installed all my dependencies to get a final image. df -h output shows total used space as 12GB
I used the first thread mentioned above to clone the image which created two files as system.img.raw (28GB) and system.img (12GB). Using system.img.raw file and flashing on other device works fine. But since I also need to create partitions I followed second thread for partitioning. I couldn’t understand how to truncate and resize system.img.raw file since it is already 28GB, I tried with some experiment and truncate it to 16GB (Since the actual img is only of 12GB + 4 GB extra buffer).
flash.sh script successfully write the image on the device but it stuck on Nvidia logo after flashing and does not proceed to login screen even after pressing reset button as suggested in the logs attached below. I also repeated the same steps with sparsed system.img (12GB) file, trucated to 16GB and followed the step of losetup and gparted, flashing success but still device stuck on nvidia logo on bootup.

Below are flashing logs

sudo ./flash.sh -r -S 16GiB jetson-tx2 mmcblk0p1
###############################################################################
# L4T BSP Information:
# R32 , REVISION: 4.3
###############################################################################
# Target Board Information:
# Name: jetson-tx2, Board Family: t186ref, SoC: Tegra 186, 
# OpMode: production, Boot Authentication: NS, 
###############################################################################
./tegraflash.py --chip 0x18 --applet "/home/suhail/Documents/nvidia/nvidia_sdk/JetPack_4.4_Linux_JETSON_TX2/Linux_for_Tegra/bootloader/mb1_recovery_prod.bin" --skipuid --cmd "dump eeprom boardinfo cvm.bin" 
Welcome to Tegra Flash
version 1.0.0
Type ? or help for help and q or quit to exit
Use ! to execute system commands
 
[   0.0136 ] Generating RCM messages
[   0.0170 ] tegrarcm_v2 --listrcm rcm_list.xml --chip 0x18 0 --download rcm /home/suhail/Documents/nvidia/nvidia_sdk/JetPack_4.4_Linux_JETSON_TX2/Linux_for_Tegra/bootloader/mb1_recovery_prod.bin 0 0
[   0.0196 ] RCM 0 is saved as rcm_0.rcm
[   0.0221 ] RCM 1 is saved as rcm_1.rcm
[   0.0222 ] List of rcm files are saved in rcm_list.xml
[   0.0222 ] 
[   0.0222 ] Signing RCM messages
[   0.0257 ] tegrasign_v2 --key None --list rcm_list.xml --pubkeyhash pub_key.key
[   0.0283 ] Assuming zero filled SBK key
[   0.0422 ] 
[   0.0423 ] Copying signature to RCM mesages
[   0.0454 ] tegrarcm_v2 --chip 0x18 0 --updatesig rcm_list_signed.xml
[   0.0507 ] 
[   0.0509 ] Boot Rom communication
[   0.0542 ] tegrarcm_v2 --chip 0x18 0 --rcm rcm_list_signed.xml --skipuid
[   0.0569 ] RCM version 0X180001
[   0.0591 ] Boot Rom communication completed
[   1.0657 ] 
[   2.0698 ] tegrarcm_v2 --isapplet
[   2.0724 ] Applet version 01.00.0000
[   2.0913 ] 
[   2.0923 ] Retrieving EEPROM data
[   2.0924 ] tegrarcm_v2 --oem platformdetails eeprom cvm /home/suhail/Documents/nvidia/nvidia_sdk/JetPack_4.4_Linux_JETSON_TX2/Linux_for_Tegra/bootloader/cvm.bin
[   2.0931 ] Applet version 01.00.0000
[   2.1314 ] Saved platform info in /home/suhail/Documents/nvidia/nvidia_sdk/JetPack_4.4_Linux_JETSON_TX2/Linux_for_Tegra/bootloader/cvm.bin
[   2.2055 ] 
Board ID(3310) version(B02) sku(1000) revision(E.0)
Copy /home/suhail/Documents/nvidia/nvidia_sdk/JetPack_4.4_Linux_JETSON_TX2/Linux_for_Tegra/kernel/dtb/tegra186-quill-p3310-1000-c03-00-base.dtb to /home/suhail/Documents/nvidia/nvidia_sdk/JetPack_4.4_Linux_JETSON_TX2/Linux_for_Tegra/kernel/dtb/tegra186-quill-p3310-1000-c03-00-base.dtb.rec
copying bctfile(/home/suhail/Documents/nvidia/nvidia_sdk/JetPack_4.4_Linux_JETSON_TX2/Linux_for_Tegra/bootloader/t186ref/BCT/P3310_A00_8GB_lpddr4_A02_l4t.cfg)... done.
copying misc_config(/home/suhail/Documents/nvidia/nvidia_sdk/JetPack_4.4_Linux_JETSON_TX2/Linux_for_Tegra/bootloader/t186ref/BCT/tegra186-mb1-bct-misc-si-l4t.cfg)... done.
copying pinmux_config(/home/suhail/Documents/nvidia/nvidia_sdk/JetPack_4.4_Linux_JETSON_TX2/Linux_for_Tegra/bootloader/t186ref/BCT/tegra186-mb1-bct-pinmux-quill-p3310-1000-c03.cfg)... done.
copying pmic_config(/home/suhail/Documents/nvidia/nvidia_sdk/JetPack_4.4_Linux_JETSON_TX2/Linux_for_Tegra/bootloader/t186ref/BCT/tegra186-mb1-bct-pmic-quill-p3310-1000-c04.cfg)... done.
copying pmc_config(/home/suhail/Documents/nvidia/nvidia_sdk/JetPack_4.4_Linux_JETSON_TX2/Linux_for_Tegra/bootloader/t186ref/BCT/tegra186-mb1-bct-pad-quill-p3310-1000-c03.cfg)... done.
copying prod_config(/home/suhail/Documents/nvidia/nvidia_sdk/JetPack_4.4_Linux_JETSON_TX2/Linux_for_Tegra/bootloader/t186ref/BCT/tegra186-mb1-bct-prod-quill-p3310-1000-c03.cfg)... done.
copying scr_config(/home/suhail/Documents/nvidia/nvidia_sdk/JetPack_4.4_Linux_JETSON_TX2/Linux_for_Tegra/bootloader/t186ref/BCT/minimal_scr.cfg)... done.
copying scr_cold_boot_config(/home/suhail/Documents/nvidia/nvidia_sdk/JetPack_4.4_Linux_JETSON_TX2/Linux_for_Tegra/bootloader/t186ref/BCT/mobile_scr.cfg)... done.
copying bootrom_config(/home/suhail/Documents/nvidia/nvidia_sdk/JetPack_4.4_Linux_JETSON_TX2/Linux_for_Tegra/bootloader/t186ref/BCT/tegra186-mb1-bct-bootrom-quill-p3310-1000-c03.cfg)... done.
copying dev_params(/home/suhail/Documents/nvidia/nvidia_sdk/JetPack_4.4_Linux_JETSON_TX2/Linux_for_Tegra/bootloader/t186ref/BCT/emmc.cfg)... done.
Existing bootloader(/home/suhail/Documents/nvidia/nvidia_sdk/JetPack_4.4_Linux_JETSON_TX2/Linux_for_Tegra/bootloader/nvtboot_cpu.bin) reused.
copying initrd(/home/suhail/Documents/nvidia/nvidia_sdk/JetPack_4.4_Linux_JETSON_TX2/Linux_for_Tegra/bootloader/l4t_initrd.img)... done.
	populating kernel to rootfs... done.
	populating initrd to rootfs... done.
	populating /home/suhail/Documents/nvidia/nvidia_sdk/JetPack_4.4_Linux_JETSON_TX2/Linux_for_Tegra/kernel/dtb/tegra186-quill-p3310-1000-c03-00-base.dtb to rootfs... done.
Making Boot image... done.
20+0 records in
20+0 records out
20 bytes copied, 0.000423414 s, 47.2 kB/s
Existing sosfile(/home/suhail/Documents/nvidia/nvidia_sdk/JetPack_4.4_Linux_JETSON_TX2/Linux_for_Tegra/bootloader/mb1_recovery_prod.bin) reused.
copying tegraboot(/home/suhail/Documents/nvidia/nvidia_sdk/JetPack_4.4_Linux_JETSON_TX2/Linux_for_Tegra/bootloader/t186ref/nvtboot.bin)... done.
Existing cpu_bootloader(/home/suhail/Documents/nvidia/nvidia_sdk/JetPack_4.4_Linux_JETSON_TX2/Linux_for_Tegra/bootloader/nvtboot_cpu.bin) reused.
Existing mb2blfile(/home/suhail/Documents/nvidia/nvidia_sdk/JetPack_4.4_Linux_JETSON_TX2/Linux_for_Tegra/bootloader/nvtboot_recovery.bin) reused.
Existing mtspreboot(/home/suhail/Documents/nvidia/nvidia_sdk/JetPack_4.4_Linux_JETSON_TX2/Linux_for_Tegra/bootloader/preboot_d15_prod_cr.bin) reused.
Existing mts(/home/suhail/Documents/nvidia/nvidia_sdk/JetPack_4.4_Linux_JETSON_TX2/Linux_for_Tegra/bootloader/mce_mts_d15_prod_cr.bin) reused.
Existing mb1file(/home/suhail/Documents/nvidia/nvidia_sdk/JetPack_4.4_Linux_JETSON_TX2/Linux_for_Tegra/bootloader/mb1_prod.bin) reused.
Existing bpffile(/home/suhail/Documents/nvidia/nvidia_sdk/JetPack_4.4_Linux_JETSON_TX2/Linux_for_Tegra/bootloader/bpmp.bin) reused.
copying bpfdtbfile(/home/suhail/Documents/nvidia/nvidia_sdk/JetPack_4.4_Linux_JETSON_TX2/Linux_for_Tegra/bootloader/t186ref/tegra186-a02-bpmp-quill-p3310-1000-c04-00-te770d-ucm2.dtb)... done.
Existing scefile(/home/suhail/Documents/nvidia/nvidia_sdk/JetPack_4.4_Linux_JETSON_TX2/Linux_for_Tegra/bootloader/camera-rtcpu-sce.img) reused.
Existing spefile(/home/suhail/Documents/nvidia/nvidia_sdk/JetPack_4.4_Linux_JETSON_TX2/Linux_for_Tegra/bootloader/spe.bin) reused.
Existing drameccfile(/home/suhail/Documents/nvidia/nvidia_sdk/JetPack_4.4_Linux_JETSON_TX2/Linux_for_Tegra/bootloader/dram-ecc.bin) reused.
Existing badpagefile(/home/suhail/Documents/nvidia/nvidia_sdk/JetPack_4.4_Linux_JETSON_TX2/Linux_for_Tegra/bootloader/badpage.bin) reused.
copying wb0boot(/home/suhail/Documents/nvidia/nvidia_sdk/JetPack_4.4_Linux_JETSON_TX2/Linux_for_Tegra/bootloader/t186ref/warmboot.bin)... done.
Existing tosfile(/home/suhail/Documents/nvidia/nvidia_sdk/JetPack_4.4_Linux_JETSON_TX2/Linux_for_Tegra/bootloader/tos-trusty.img) reused.
Existing eksfile(/home/suhail/Documents/nvidia/nvidia_sdk/JetPack_4.4_Linux_JETSON_TX2/Linux_for_Tegra/bootloader/eks.img) reused.
copying dtbfile(/home/suhail/Documents/nvidia/nvidia_sdk/JetPack_4.4_Linux_JETSON_TX2/Linux_for_Tegra/kernel/dtb/tegra186-quill-p3310-1000-c03-00-base.dtb)... done.
Copying nv_boot_control.conf to rootfs
Reusing existing system.img... 
done.
Existing tbcfile(/home/suhail/Documents/nvidia/nvidia_sdk/JetPack_4.4_Linux_JETSON_TX2/Linux_for_Tegra/bootloader/cboot.bin) reused.
copying tbcdtbfile(/home/suhail/Documents/nvidia/nvidia_sdk/JetPack_4.4_Linux_JETSON_TX2/Linux_for_Tegra/kernel/dtb/tegra186-quill-p3310-1000-c03-00-base.dtb)... done.
copying cfgfile(/home/suhail/Documents/nvidia/nvidia_sdk/JetPack_4.4_Linux_JETSON_TX2/Linux_for_Tegra/bootloader/t186ref/cfg/flash_l4t_t186.xml) to flash.xml... done.
Existing flasher(/home/suhail/Documents/nvidia/nvidia_sdk/JetPack_4.4_Linux_JETSON_TX2/Linux_for_Tegra/bootloader/nvtboot_recovery_cpu.bin) reused.
Existing flashapp(/home/suhail/Documents/nvidia/nvidia_sdk/JetPack_4.4_Linux_JETSON_TX2/Linux_for_Tegra/bootloader/tegraflash.py) reused.
./tegraflash.py --bl nvtboot_recovery_cpu.bin --sdram_config P3310_A00_8GB_lpddr4_A02_l4t.cfg --odmdata 0x1090000 --applet mb1_recovery_prod.bin --cmd "flash; reboot"  --cfg flash.xml --chip 0x18 --misc_config tegra186-mb1-bct-misc-si-l4t.cfg --pinmux_config tegra186-mb1-bct-pinmux-quill-p3310-1000-c03.cfg --pmic_config tegra186-mb1-bct-pmic-quill-p3310-1000-c04.cfg --pmc_config tegra186-mb1-bct-pad-quill-p3310-1000-c03.cfg --prod_config tegra186-mb1-bct-prod-quill-p3310-1000-c03.cfg --scr_config minimal_scr.cfg --scr_cold_boot_config mobile_scr.cfg --br_cmd_config tegra186-mb1-bct-bootrom-quill-p3310-1000-c03.cfg --dev_params emmc.cfg  --bins "mb2_bootloader nvtboot_recovery.bin; mts_preboot preboot_d15_prod_cr.bin; mts_bootpack mce_mts_d15_prod_cr.bin; bpmp_fw bpmp.bin; bpmp_fw_dtb tegra186-a02-bpmp-quill-p3310-1000-c04-00-te770d-ucm2.dtb; tlk tos-trusty.img; eks eks.img; bootloader_dtb tegra186-quill-p3310-1000-c03-00-base.dtb"   
saving flash command in /home/suhail/Documents/nvidia/nvidia_sdk/JetPack_4.4_Linux_JETSON_TX2/Linux_for_Tegra/bootloader/flashcmd.txt
saving Windows flash command to /home/suhail/Documents/nvidia/nvidia_sdk/JetPack_4.4_Linux_JETSON_TX2/Linux_for_Tegra/bootloader/flash_win.bat
*** Flashing target device started. ***
Welcome to Tegra Flash
version 1.0.0
Type ? or help for help and q or quit to exit
Use ! to execute system commands
 
[   0.0009 ] tegrasign_v2 --key None --getmode mode.txt
[   0.0016 ] Assuming zero filled SBK key
[   0.0017 ] 
[   0.0017 ] Generating RCM messages
[   0.0023 ] tegrarcm_v2 --listrcm rcm_list.xml --chip 0x18 0 --download rcm mb1_recovery_prod.bin 0 0
[   0.0029 ] RCM 0 is saved as rcm_0.rcm
[   0.0032 ] RCM 1 is saved as rcm_1.rcm
[   0.0032 ] List of rcm files are saved in rcm_list.xml
[   0.0032 ] 
[   0.0032 ] Signing RCM messages
[   0.0038 ] tegrasign_v2 --key None --list rcm_list.xml --pubkeyhash pub_key.key
[   0.0044 ] Assuming zero filled SBK key
[   0.0071 ] 
[   0.0072 ] Copying signature to RCM mesages
[   0.0079 ] tegrarcm_v2 --chip 0x18 0 --updatesig rcm_list_signed.xml
[   0.0089 ] 
[   0.0089 ] Parsing partition layout
[   0.0105 ] tegraparser_v2 --pt flash.xml.tmp
[   0.0131 ] 
[   0.0131 ] Creating list of images to be signed
[   0.0152 ] tegrahost_v2 --chip 0x18 0 --partitionlayout flash.xml.bin --list images_list.xml zerosbk
[   0.0554 ] 
[   0.0555 ] Generating signatures
[   0.0576 ] tegrasign_v2 --key None --list images_list.xml --pubkeyhash pub_key.key
[   0.0590 ] Assuming zero filled SBK key
[   0.3716 ] 
[   0.3717 ] Generating br-bct
[   0.3735 ] Updating dev and MSS params in BR BCT
[   0.3736 ] tegrabct_v2 --dev_param emmc.cfg --sdram P3310_A00_8GB_lpddr4_A02_l4t.cfg --brbct br_bct.cfg --chip 0x18 0
[   0.4136 ] 
[   0.4136 ] Updating bl info
[   0.4145 ] tegrabct_v2 --brbct br_bct_BR.bct --chip 0x18 0 --updateblinfo flash.xml.bin --updatesig images_list_signed.xml
[   0.4159 ] 
[   0.4159 ] Updating smd info
[   0.4165 ] tegrabct_v2 --brbct br_bct_BR.bct --chip 0x18 --updatesmdinfo flash.xml.bin
[   0.4175 ] 
[   0.4175 ] Updating Odmdata
[   0.4183 ] tegrabct_v2 --brbct br_bct_BR.bct --chip 0x18 0 --updatefields Odmdata =0x1090000
[   0.4191 ] 
[   0.4192 ] Get Signed section of bct
[   0.4199 ] tegrabct_v2 --brbct br_bct_BR.bct --chip 0x18 0 --listbct bct_list.xml
[   0.4207 ] 
[   0.4213 ] tegrasign_v2 --key None --list bct_list.xml --pubkeyhash pub_key.key
[   0.4221 ] Assuming zero filled SBK key
[   0.4223 ] 
[   0.4223 ] Updating BCT with signature
[   0.4229 ] tegrabct_v2 --brbct br_bct_BR.bct --chip 0x18 0 --updatesig bct_list_signed.xml
[   0.4238 ] 
[   0.4239 ] Generating coldboot mb1-bct
[   0.4245 ] tegrabct_v2 --chip 0x18 0 --mb1bct mb1_cold_boot_bct.cfg --sdram P3310_A00_8GB_lpddr4_A02_l4t.cfg --misc tegra186-mb1-bct-misc-si-l4t.cfg --scr mobile_scr.cfg --pinmux tegra186-mb1-bct-pinmux-quill-p3310-1000-c03.cfg --pmc tegra186-mb1-bct-pad-quill-p3310-1000-c03.cfg --pmic tegra186-mb1-bct-pmic-quill-p3310-1000-c04.cfg --brcommand tegra186-mb1-bct-bootrom-quill-p3310-1000-c03.cfg --prod tegra186-mb1-bct-prod-quill-p3310-1000-c03.cfg
[   0.4252 ] MB1-BCT version: 0xf
[   0.4254 ] Packing sdram param for instance[0]
[   0.4509 ] Packing sdram param for instance[1]
[   0.4511 ] Packing sdram param for instance[2]
[   0.4513 ] Packing sdram param for instance[3]

[   0.4516 ] Parsing config file :tegra186-mb1-bct-pinmux-quill-p3310-1000-c03.cfg 
[   0.4521 ] Appending platform config data of size :- 3032

[   0.4524 ] Parsing config file :mobile_scr.cfg 
[   0.4526 ] Appending platform config data of size :- 12240

[   0.4531 ] Parsing config file :tegra186-mb1-bct-pad-quill-p3310-1000-c03.cfg 
[   0.4535 ] Appending platform config data of size :- 24
[   0.4535 ] 
[   0.4535 ] Parsing config file :tegra186-mb1-bct-pmic-quill-p3310-1000-c04.cfg 
[   0.4535 ] Appending platform config data of size :- 672
[   0.4535 ] 
[   0.4535 ] Parsing config file :tegra186-mb1-bct-bootrom-quill-p3310-1000-c03.cfg 
[   0.4535 ] Appending platform config data of size :- 64
[   0.4535 ] 
[   0.4535 ] Parsing config file :tegra186-mb1-bct-prod-quill-p3310-1000-c03.cfg 
[   0.4535 ] Appending platform config data of size :- 1628
[   0.4535 ] 
[   0.4536 ] Updating mb1-bct with firmware information
[   0.4545 ] tegrabct_v2 --chip 0x18 --mb1bct mb1_cold_boot_bct_MB1.bct --updatefwinfo flash.xml.bin
[   0.4552 ] MB1-BCT version: 0xf
[   0.4557 ] 
[   0.4557 ] Updating mb1-bct with storage information
[   0.4565 ] tegrabct_v2 --chip 0x18 --mb1bct mb1_cold_boot_bct_MB1.bct --updatestorageinfo flash.xml.bin
[   0.4573 ] MB1-BCT version: 0xf
[   0.4578 ] 
[   0.4585 ] tegrahost_v2 --chip 0x18 --align mb1_cold_boot_bct_MB1.bct
[   0.4592 ] 
[   0.4600 ] tegrahost_v2 --appendsigheader mb1_cold_boot_bct_MB1.bct zerosbk
[   0.4609 ] 
[   0.4626 ] tegrasign_v2 --key None --list mb1_cold_boot_bct_MB1_sigheader.bct_list.xml --pubkeyhash pub_key.key
[   0.4644 ] Assuming zero filled SBK key
[   0.4664 ] 
[   0.4675 ] tegrahost_v2 --updatesigheader mb1_cold_boot_bct_MB1_sigheader.bct.encrypt mb1_cold_boot_bct_MB1_sigheader.bct.hash zerosbk
[   0.4683 ] 
[   0.4684 ] Generating recovery mb1-bct
[   0.4691 ] tegrabct_v2 --chip 0x18 0 --mb1bct mb1_bct.cfg --sdram P3310_A00_8GB_lpddr4_A02_l4t.cfg --misc tegra186-mb1-bct-misc-si-l4t.cfg --scr minimal_scr.cfg --pinmux tegra186-mb1-bct-pinmux-quill-p3310-1000-c03.cfg --pmc tegra186-mb1-bct-pad-quill-p3310-1000-c03.cfg --pmic tegra186-mb1-bct-pmic-quill-p3310-1000-c04.cfg --brcommand tegra186-mb1-bct-bootrom-quill-p3310-1000-c03.cfg --prod tegra186-mb1-bct-prod-quill-p3310-1000-c03.cfg
[   0.4697 ] MB1-BCT version: 0xf
[   0.4698 ] Packing sdram param for instance[0]
[   0.4949 ] Packing sdram param for instance[1]
[   0.4956 ] Packing sdram param for instance[2]
[   0.4960 ] Packing sdram param for instance[3]

[   0.4964 ] Parsing config file :tegra186-mb1-bct-pinmux-quill-p3310-1000-c03.cfg 
[   0.4974 ] Appending platform config data of size :- 3032

[   0.4982 ] Parsing config file :minimal_scr.cfg 
[   0.4984 ] Appending platform config data of size :- 12240
[   0.4984 ] 
[   0.4984 ] Parsing config file :tegra186-mb1-bct-pad-quill-p3310-1000-c03.cfg 
[   0.4984 ] Appending platform config data of size :- 24
[   0.4984 ] 
[   0.4984 ] Parsing config file :tegra186-mb1-bct-pmic-quill-p3310-1000-c04.cfg 
[   0.4984 ] Appending platform config data of size :- 672
[   0.4984 ] 
[   0.4984 ] Parsing config file :tegra186-mb1-bct-bootrom-quill-p3310-1000-c03.cfg 
[   0.4984 ] Appending platform config data of size :- 64
[   0.4984 ] 
[   0.4984 ] Parsing config file :tegra186-mb1-bct-prod-quill-p3310-1000-c03.cfg 
[   0.4984 ] Appending platform config data of size :- 1628
[   0.4984 ] 
[   0.4984 ] Updating mb1-bct with firmware information
[   0.4993 ] tegrabct_v2 --chip 0x18 --mb1bct mb1_bct_MB1.bct --updatefwinfo flash.xml.bin
[   0.5000 ] MB1-BCT version: 0xf
[   0.5005 ] 
[   0.5005 ] Updating mb1-bct with storage information
[   0.5012 ] tegrabct_v2 --chip 0x18 --mb1bct mb1_bct_MB1.bct --updatestorageinfo flash.xml.bin
[   0.5018 ] MB1-BCT version: 0xf
[   0.5022 ] 
[   0.5029 ] tegrahost_v2 --chip 0x18 --align mb1_bct_MB1.bct
[   0.5036 ] 
[   0.5043 ] tegrahost_v2 --appendsigheader mb1_bct_MB1.bct zerosbk
[   0.5051 ] 
[   0.5059 ] tegrasign_v2 --key None --list mb1_bct_MB1_sigheader.bct_list.xml --pubkeyhash pub_key.key
[   0.5066 ] Assuming zero filled SBK key
[   0.5079 ] 
[   0.5088 ] tegrahost_v2 --updatesigheader mb1_bct_MB1_sigheader.bct.encrypt mb1_bct_MB1_sigheader.bct.hash zerosbk
[   0.5097 ] 
[   0.5098 ] Copying signatures
[   0.5104 ] tegrahost_v2 --chip 0x18 0 --partitionlayout flash.xml.bin --updatesig images_list_signed.xml
[   0.5559 ] 
[   0.5560 ] Boot Rom communication
[   0.5576 ] tegrarcm_v2 --chip 0x18 0 --rcm rcm_list_signed.xml
[   0.5589 ] BootRom is not running
[   5.6978 ] 
[   6.7018 ] tegrarcm_v2 --isapplet
[   6.7044 ] Applet version 01.00.0000
[   6.7246 ] 
[   6.7247 ] Sending BCTs
[   6.7283 ] tegrarcm_v2 --download bct_bootrom br_bct_BR.bct --download bct_mb1 mb1_bct_MB1_sigheader.bct.encrypt
[   6.7293 ] Applet version 01.00.0000
[   6.7638 ] Sending bct_bootrom
[   6.7642 ] [................................................] 100%
[   6.7660 ] Sending bct_mb1
[   6.7666 ] [................................................] 100%
[   6.7842 ] 
[   6.7843 ] Generating blob
[   6.7877 ] tegrahost_v2 --chip 0x18 --align blob_nvtboot_recovery_cpu.bin
[   6.7909 ] 
[   6.7940 ] tegrahost_v2 --appendsigheader blob_nvtboot_recovery_cpu.bin zerosbk
[   6.7987 ] 
[   6.8033 ] tegrasign_v2 --key None --list blob_nvtboot_recovery_cpu_sigheader.bin_list.xml --pubkeyhash pub_key.key
[   6.8067 ] Assuming zero filled SBK key
[   6.8285 ] 
[   6.8324 ] tegrahost_v2 --updatesigheader blob_nvtboot_recovery_cpu_sigheader.bin.encrypt blob_nvtboot_recovery_cpu_sigheader.bin.hash zerosbk
[   6.8353 ] 
[   6.8369 ] tegrahost_v2 --chip 0x18 --align blob_nvtboot_recovery.bin
[   6.8380 ] 
[   6.8391 ] tegrahost_v2 --appendsigheader blob_nvtboot_recovery.bin zerosbk
[   6.8406 ] 
[   6.8420 ] tegrasign_v2 --key None --list blob_nvtboot_recovery_sigheader.bin_list.xml --pubkeyhash pub_key.key
[   6.8430 ] Assuming zero filled SBK key
[   6.8468 ] 
[   6.8483 ] tegrahost_v2 --updatesigheader blob_nvtboot_recovery_sigheader.bin.encrypt blob_nvtboot_recovery_sigheader.bin.hash zerosbk
[   6.8498 ] 
[   6.8510 ] tegrahost_v2 --chip 0x18 --align blob_preboot_d15_prod_cr.bin
[   6.8521 ] 
[   6.8534 ] tegrahost_v2 --appendsigheader blob_preboot_d15_prod_cr.bin zerosbk
[   6.8547 ] 
[   6.8564 ] tegrasign_v2 --key None --list blob_preboot_d15_prod_cr_sigheader.bin_list.xml --pubkeyhash pub_key.key
[   6.8579 ] Assuming zero filled SBK key
[   6.8610 ] 
[   6.8635 ] tegrahost_v2 --updatesigheader blob_preboot_d15_prod_cr_sigheader.bin.encrypt blob_preboot_d15_prod_cr_sigheader.bin.hash zerosbk
[   6.8649 ] 
[   6.8662 ] tegrahost_v2 --chip 0x18 --align blob_mce_mts_d15_prod_cr.bin
[   6.8672 ] 
[   6.8684 ] tegrahost_v2 --appendsigheader blob_mce_mts_d15_prod_cr.bin zerosbk
[   6.8739 ] 
[   6.8756 ] tegrasign_v2 --key None --list blob_mce_mts_d15_prod_cr_sigheader.bin_list.xml --pubkeyhash pub_key.key
[   6.8766 ] Assuming zero filled SBK key
[   6.9355 ] 
[   6.9367 ] tegrahost_v2 --updatesigheader blob_mce_mts_d15_prod_cr_sigheader.bin.encrypt blob_mce_mts_d15_prod_cr_sigheader.bin.hash zerosbk
[   6.9398 ] 
[   6.9407 ] tegrahost_v2 --chip 0x18 --align blob_bpmp.bin
[   6.9414 ] 
[   6.9422 ] tegrahost_v2 --appendsigheader blob_bpmp.bin zerosbk
[   6.9437 ] 
[   6.9446 ] tegrasign_v2 --key None --list blob_bpmp_sigheader.bin_list.xml --pubkeyhash pub_key.key
[   6.9454 ] Assuming zero filled SBK key
[   6.9577 ] 
[   6.9588 ] tegrahost_v2 --updatesigheader blob_bpmp_sigheader.bin.encrypt blob_bpmp_sigheader.bin.hash zerosbk
[   6.9600 ] 
[   6.9608 ] tegrahost_v2 --chip 0x18 --align blob_tegra186-a02-bpmp-quill-p3310-1000-c04-00-te770d-ucm2.dtb
[   6.9615 ] 
[   6.9621 ] tegrahost_v2 --appendsigheader blob_tegra186-a02-bpmp-quill-p3310-1000-c04-00-te770d-ucm2.dtb zerosbk
[   6.9635 ] 
[   6.9649 ] tegrasign_v2 --key None --list blob_tegra186-a02-bpmp-quill-p3310-1000-c04-00-te770d-ucm2_sigheader.dtb_list.xml --pubkeyhash pub_key.key
[   6.9657 ] Assuming zero filled SBK key
[   6.9788 ] 
[   6.9800 ] tegrahost_v2 --updatesigheader blob_tegra186-a02-bpmp-quill-p3310-1000-c04-00-te770d-ucm2_sigheader.dtb.encrypt blob_tegra186-a02-bpmp-quill-p3310-1000-c04-00-te770d-ucm2_sigheader.dtb.hash zerosbk
[   6.9813 ] 
[   6.9821 ] tegrahost_v2 --chip 0x18 --align blob_tos-trusty.img
[   6.9827 ] 
[   6.9833 ] tegrahost_v2 --appendsigheader blob_tos-trusty.img zerosbk
[   6.9844 ] 
[   6.9852 ] tegrasign_v2 --key None --list blob_tos-trusty_sigheader.img_list.xml --pubkeyhash pub_key.key
[   6.9858 ] Assuming zero filled SBK key
[   6.9940 ] 
[   6.9953 ] tegrahost_v2 --updatesigheader blob_tos-trusty_sigheader.img.encrypt blob_tos-trusty_sigheader.img.hash zerosbk
[   6.9968 ] 
[   6.9978 ] tegrahost_v2 --chip 0x18 --align blob_eks.img
[   6.9988 ] 
[   7.0000 ] tegrahost_v2 --appendsigheader blob_eks.img zerosbk
[   7.0010 ] 
[   7.0027 ] tegrasign_v2 --key None --list blob_eks_sigheader.img_list.xml --pubkeyhash pub_key.key
[   7.0034 ] Assuming zero filled SBK key
[   7.0036 ] 
[   7.0044 ] tegrahost_v2 --updatesigheader blob_eks_sigheader.img.encrypt blob_eks_sigheader.img.hash zerosbk
[   7.0052 ] 
[   7.0060 ] tegrahost_v2 --chip 0x18 --align blob_tegra186-quill-p3310-1000-c03-00-base.dtb
[   7.0066 ] 
[   7.0073 ] tegrahost_v2 --appendsigheader blob_tegra186-quill-p3310-1000-c03-00-base.dtb zerosbk
[   7.0083 ] 
[   7.0092 ] tegrasign_v2 --key None --list blob_tegra186-quill-p3310-1000-c03-00-base_sigheader.dtb_list.xml --pubkeyhash pub_key.key
[   7.0098 ] Assuming zero filled SBK key
[   7.0181 ] 
[   7.0191 ] tegrahost_v2 --updatesigheader blob_tegra186-quill-p3310-1000-c03-00-base_sigheader.dtb.encrypt blob_tegra186-quill-p3310-1000-c03-00-base_sigheader.dtb.hash zerosbk
[   7.0202 ] 
[   7.0210 ] tegrahost_v2 --chip 0x18 --generateblob blob.xml blob.bin
[   7.0218 ] number of images in blob are 9
[   7.0219 ] blobsize is 4335416
[   7.0220 ] Added binary blob_nvtboot_recovery_cpu_sigheader.bin.encrypt of size 221312
[   7.0235 ] Added binary blob_nvtboot_recovery_sigheader.bin.encrypt of size 90016
[   7.0238 ] Added binary blob_preboot_d15_prod_cr_sigheader.bin.encrypt of size 63104
[   7.0242 ] Added binary blob_mce_mts_d15_prod_cr_sigheader.bin.encrypt of size 2082144
[   7.0249 ] Added binary blob_bpmp_sigheader.bin.encrypt of size 533904
[   7.0257 ] Added binary blob_tegra186-a02-bpmp-quill-p3310-1000-c04-00-te770d-ucm2_sigheader.dtb.encrypt of size 605120
[   7.0263 ] Added binary blob_tos-trusty_sigheader.img.encrypt of size 366400
[   7.0266 ] Added binary blob_eks_sigheader.img.encrypt of size 1440
[   7.0269 ] Added binary blob_tegra186-quill-p3310-1000-c03-00-base_sigheader.dtb.encrypt of size 371824
[   7.0291 ] 
[   7.0291 ] Sending bootloader and pre-requisite binaries
[   7.0307 ] tegrarcm_v2 --download blob blob.bin
[   7.0316 ] Applet version 01.00.0000
[   7.0501 ] Sending blob
[   7.0505 ] [................................................] 100%
[   7.5500 ] 
[   7.5529 ] tegrarcm_v2 --boot recovery
[   7.5558 ] Applet version 01.00.0000
[   7.5733 ] 
[   8.5775 ] tegrarcm_v2 --isapplet
[   8.8761 ] 
[   8.8814 ] tegradevflash_v2 --iscpubl
[   8.8826 ] Cannot Open USB
[   9.4083 ] 
[  10.4120 ] tegrarcm_v2 --isapplet
[  10.4330 ] 
[  10.4341 ] tegradevflash_v2 --iscpubl
[  10.4350 ] Bootloader version 01.00.0000
[  10.4523 ] Bootloader version 01.00.0000
[  10.4540 ] 
[  10.4540 ] Retrieving storage infomation
[  10.4551 ] tegrarcm_v2 --oem platformdetails storage storage_info.bin
[  10.4560 ] Applet is not running on device. Continue with Bootloader
[  10.4905 ] 
[  10.4936 ] tegradevflash_v2 --oem platformdetails storage storage_info.bin
[  10.4962 ] Bootloader version 01.00.0000
[  10.5133 ] Saved platform info in storage_info.bin
[  10.5186 ] 
[  10.5187 ] Flashing the device
[  10.5221 ] tegraparser_v2 --storageinfo storage_info.bin --generategpt --pt flash.xml.bin
[  10.5260 ] 
[  10.5288 ] tegradevflash_v2 --pt flash.xml.bin --create
[  10.5315 ] Bootloader version 01.00.0000
[  10.5349 ] Erasing sdmmc_boot: 3 ......... [Done]
[  10.5699 ] Writing partition secondary_gpt with gpt_secondary_0_3.bin
[  10.5716 ] [................................................] 100%

[  10.6202 ] Erasing sdmmc_user: 3 ......... [Done]
[  14.0954 ] Writing partition master_boot_record with mbr_1_3.bin
[  14.0960 ] [................................................] 100%
[  14.1003 ] Writing partition primary_gpt with gpt_primary_1_3.bin
[  14.1079 ] [................................................] 100%
[  14.1135 ] Writing partition secondary_gpt with gpt_secondary_1_3.bin
[  14.1222 ] [................................................] 100%

[  14.1334 ] Writing partition mb1 with mb1_prod.bin.encrypt
[  14.1337 ] [................................................] 100%
[  14.1421 ] Writing partition mb1_b with mb1_prod.bin.encrypt
[  14.1680 ] [................................................] 100%
[  14.1768 ] Writing partition dram-ecc-fw with dram-ecc_sigheader.bin.encrypt
[  14.2006 ] [................................................] 100%
[  14.2079 ] Writing partition badpage-fw with badpage_sigheader.bin.encrypt
[  14.2416 ] [................................................] 100%
[  14.2468 ] Writing partition badpage-fw_b with badpage_sigheader.bin.encrypt
[  14.3006 ] [................................................] 100%
[  14.3059 ] Writing partition spe-fw with spe_sigheader.bin.encrypt
[  14.3602 ] [................................................] 100%
[  14.3685 ] Writing partition spe-fw_b with spe_sigheader.bin.encrypt
[  14.4251 ] [................................................] 100%
[  14.4334 ] Writing partition mb2 with nvtboot_sigheader.bin.encrypt
[  14.4650 ] [................................................] 100%
[  14.4736 ] Writing partition mb2_b with nvtboot_sigheader.bin.encrypt
[  14.5148 ] [................................................] 100%
[  14.5233 ] Writing partition mts-preboot with preboot_d15_prod_cr_sigheader.bin.encrypt
[  14.5696 ] [................................................] 100%
[  14.5759 ] Writing partition mts-preboot_b with preboot_d15_prod_cr_sigheader.bin.encrypt
[  14.6284 ] [................................................] 100%
[  14.6362 ] Writing partition SMD with slot_metadata.bin
[  14.6919 ] [................................................] 100%
[  14.7004 ] Writing partition SMD_b with slot_metadata.bin
[  14.7066 ] [................................................] 100%
[  14.7117 ] Writing partition VER_b with emmc_bootblob_ver.txt
[  14.7141 ] [................................................] 100%
[  14.7186 ] Writing partition VER with emmc_bootblob_ver.txt
[  14.7666 ] [................................................] 100%
[  14.7714 ] Writing partition master_boot_record with mbr_1_3.bin
[  14.7749 ] [................................................] 100%
[  14.7789 ] Writing partition APP with system.img
[  14.7803 ] [................................................] 100%
[ 902.6988 ] Writing partition mts-bootpack with mce_mts_d15_prod_cr_sigheader.bin.encrypt
[ 902.7289 ] [................................................] 100%
[ 902.8439 ] Writing partition mts-bootpack_b with mce_mts_d15_prod_cr_sigheader.bin.encrypt
[ 902.8784 ] [................................................] 100%
[ 902.9839 ] Writing partition cpu-bootloader with cboot_sigheader.bin.encrypt
[ 903.0169 ] [................................................] 100%
[ 903.0376 ] Writing partition cpu-bootloader_b with cboot_sigheader.bin.encrypt
[ 903.0575 ] [................................................] 100%
[ 903.0741 ] Writing partition bootloader-dtb with tegra186-quill-p3310-1000-c03-00-base_sigheader.dtb.encrypt
[ 903.0949 ] [................................................] 100%
[ 903.1172 ] Writing partition bootloader-dtb_b with tegra186-quill-p3310-1000-c03-00-base_sigheader.dtb.encrypt
[ 903.1389 ] [................................................] 100%
[ 903.1567 ] Writing partition secure-os with tos-trusty_sigheader.img.encrypt
[ 903.1728 ] [................................................] 100%
[ 903.1959 ] Writing partition secure-os_b with tos-trusty_sigheader.img.encrypt
[ 903.2178 ] [................................................] 100%
[ 903.2356 ] Writing partition eks with eks_sigheader.img.encrypt
[ 903.2543 ] [................................................] 100%
[ 903.2629 ] Writing partition adsp-fw with adsp-fw_sigheader.bin.encrypt
[ 903.2667 ] [................................................] 100%
[ 903.2767 ] Writing partition adsp-fw_b with adsp-fw_sigheader.bin.encrypt
[ 903.2911 ] [................................................] 100%
[ 903.2994 ] Writing partition bpmp-fw with bpmp_sigheader.bin.encrypt
[ 903.3048 ] [................................................] 100%
[ 903.3305 ] Writing partition bpmp-fw_b with bpmp_sigheader.bin.encrypt
[ 903.3464 ] [................................................] 100%
[ 903.3700 ] Writing partition bpmp-fw-dtb with tegra186-a02-bpmp-quill-p3310-1000-c04-00-te770d-ucm2_sigheader.dtb.encrypt
[ 903.3805 ] [................................................] 100%
[ 903.4118 ] Writing partition bpmp-fw-dtb_b with tegra186-a02-bpmp-quill-p3310-1000-c04-00-te770d-ucm2_sigheader.dtb.encrypt
[ 903.4252 ] [................................................] 100%
[ 903.4516 ] Writing partition sce-fw with camera-rtcpu-sce_sigheader.img.encrypt
[ 903.4637 ] [................................................] 100%
[ 903.4773 ] Writing partition sce-fw_b with camera-rtcpu-sce_sigheader.img.encrypt
[ 903.4839 ] [................................................] 100%
[ 903.4929 ] Writing partition sc7 with warmboot_wbheader.bin.encrypt
[ 903.4988 ] [................................................] 100%
[ 903.5045 ] Writing partition sc7_b with warmboot_wbheader.bin.encrypt
[ 903.5073 ] [................................................] 100%
[ 903.5124 ] Writing partition BMP with bmp.blob
[ 903.5170 ] [................................................] 100%
[ 903.5242 ] Writing partition BMP_b with bmp.blob
[ 903.5286 ] [................................................] 100%
[ 903.5362 ] Writing partition kernel-bootctrl with kernel_bootctrl.bin
[ 903.5428 ] [................................................] 100%
[ 903.5486 ] Writing partition kernel-bootctrl_b with kernel_bootctrl.bin
[ 903.5504 ] [................................................] 100%
[ 903.5559 ] Writing partition kernel with boot_sigheader.img.encrypt
[ 903.5578 ] [................................................] 100%
[ 903.5827 ] Writing partition kernel_b with boot_sigheader.img.encrypt
[ 903.5927 ] [................................................] 100%
[ 903.6157 ] Writing partition kernel-dtb with tegra186-quill-p3310-1000-c03-00-base_sigheader.dtb.encrypt
[ 903.6261 ] [................................................] 100%
[ 903.6444 ] Writing partition kernel-dtb_b with tegra186-quill-p3310-1000-c03-00-base_sigheader.dtb.encrypt
[ 903.6546 ] [................................................] 100%
[ 903.6809 ] 
[ 903.6879 ] tegradevflash_v2 --write BCT br_bct_BR.bct
[ 903.6908 ] Bootloader version 01.00.0000
[ 903.6945 ] Writing partition BCT with br_bct_BR.bct
[ 903.6956 ] [................................................] 100%
[ 903.7549 ] 
[ 903.7761 ] tegradevflash_v2 --write MB1_BCT mb1_cold_boot_bct_MB1_sigheader.bct.encrypt
[ 903.7788 ] Bootloader version 01.00.0000
[ 903.7820 ] Writing partition MB1_BCT with mb1_cold_boot_bct_MB1_sigheader.bct.encrypt
[ 903.7832 ] [................................................] 100%
[ 903.8512 ] 
[ 903.8552 ] tegradevflash_v2 --write MB1_BCT_b mb1_cold_boot_bct_MB1_sigheader.bct.encrypt
[ 903.8588 ] Bootloader version 01.00.0000
[ 903.8619 ] Writing partition MB1_BCT_b with mb1_cold_boot_bct_MB1_sigheader.bct.encrypt
[ 903.8633 ] [................................................] 100%
[ 903.9196 ] 
[ 903.9197 ] Flashing completed

[ 903.9198 ] Coldbooting the device
[ 903.9228 ] tegradevflash_v2 --reboot coldboot
[ 903.9258 ] Bootloader version 01.00.0000
[ 903.9340 ] 
*** The target t186ref has been flashed successfully. ***
Reset the board to boot from internal eMMC.

Cloning with raw img without resizing/truncate works fine but doing resizing for partitioning purposes I getting stuck with both sparse and raw image. Could somebody point out what I am doing wrong here.

hello suhail.m,

may I know what’s your use-case?
you should NOT trucated the back-up (cloned) raw image for flashing.
thanks

@JerryChang, Yes it make sense not to truncate the original raw file. But same also did not worked while I trucate the sparse img file from 12GB to 16GB.
My use case is as follows :

  1. I want to clone a image to multiple devices with a fix rootfs partition (16GB).
  2. Remaining space I want to create two additional partitions to mount at /data and /opt of different sizes for user specific contents.
  3. Later I want to set rootfs partition to ro-mode for which I am following this thread and it seems with #R32.1 overlay works with some modification on kernerl module (Though this step comes later as I am stuck right now with the 1 and 2 step).
    Any alternate way you would like to recommend would be very helpful?

Some information about partition sizes may help…

You can ignore the sparse image, it cannot be edited. It’s only use is to restore a system which was cloned by this image. The smaller sparse image is faster to flash, but you need the raw image for any kind of editing. Both would end up working as a flash image.

A formatted (ext4) filesystem on an image must be correctly manipulated if the image is to be reduced in size. If you were to use the “truncate” command to enlarge the raw file, then the actual filesystem would itself not be changed in any way. At this point you could take a loopback mounted image (in which the underlying file size has been enlarged) and use an application such as “gparted” to expand the formatted size to include the new added file size.

If you wanted to take a raw image and reduce the size, then you would have to first reduce the amount of space consumed by ext4 formatting. An application such as gparted could be used to reduce this size. Following this, the end of the file could be cut off. Examples of ways to do this would be either via the truncate command or just copying the relevant size to a new file using dd.

Speculating (I did not test this), if you did not reduce the actual raw image file size, but did reduce the ext4 formatting via some tool such as gparted, then I am guessing the flashed unit would work correctly, and that the size of the reported rootfs partition would match the size of the gparted reduced ext4. There would be extra space left on the eMMC which could be used for other partitions via the running system, e.g., via gdisk. However, I am not positive about this, and the reason is that the flash software might incorrectly set the layout for the other partitions…don’t know. You can bet that the flash of the image treats that image as binary data and will in no way care about the part of this image which is ext4 versus unused file space. It is the running Jetson which cares about the amount consumed by ext4.

If it turns out that the gparted reduced ext4 is unable to run correctly due to layout of other partitions, then you would find it mandatory to use a tool such as truncate or dd to match the image size to the ext4 formatted size. As long as you save an unmodified backup image, then there is no harm in trying to just reduce the ext4 via gparted and flashing without truncating the tail of the file which is no longer ext4.

When you do change sizes, be certain that the size is an allowed size which is an even multiple of the MiB or GiB. If you flash an image which has the ext4 reduced through gparted, and you want that extra space to become available for later addition of a new partition, then be certain to name the entire raw file size as the size, and not the reduced ext4 size. It is worth emphasizing again that the flash process, when “reusing” an image, has no knowledge of what part of the file is ext4 versus empty file. It is the running Jetson which knows the size of the ext4 portion.

Any time your flashed image is not the exact default size, then you should specify with the “-S size” option.

You can get a better explanation of the truncate command via man truncate. You can also search Google for “linux truncate examples” or “linux truncate tutorial”.

There are also ways to edit the “.conf” file of a flash to customize partition layout. That information is available in the official docs for that particular release.

Thanks I will try these things out and update.

@linuxdev it worked flawlessly. The only point I was missing was that I truncate the raw file before resizing it using gparted on loop mount, Thanks for such a detailed answer.