re-creating boot images and partitions

Hello,

I’m trying to create an image on L4t 32.1 for Jetson TX2 from scratch without using the flasher.sh. I’m creating an image I can dd directly to /dev/mmcblk0 on the tx2.

Currently I’m doing using parted, with

# parted -s myimg.img mklabel gpt
# parted -s myimg.img unit s mkpart ${PART_NAME} ${START} ${END}
# dd if=${SIGNED_BINARY} of=myimg.img conv=notrunc seek=${START} bs=512
# START=expr($END+1)

where PART_NAME, START and END are calculated starting from mts-bootpack which starts at 4097 sectors, is 8192s in length so on and so forth. In it, the signed binaries are written with dd, as provided by yocto bsp.

And this works OK as long as the mbr and primary gpt were ALREADY written by the flashing tools, like this:

[  16.8394 ] Erasing sdmmc_user: 3 ......... [Done]
[  17.6722 ] Writing partition master_boot_record with mbr_1_3.bin
[  17.6738 ] [................................................] 100%
[  17.6775 ] Writing partition primary_gpt with gpt_primary_1_3.bin
[  17.6790 ] [................................................] 100%

If I use just only parted to create myimg.img and dd it to the TX2 emmc I’m getting:

[0[0000.242] I> Welcome to MB2(TBoot-BPMP)(version: 01.00.160913-t186-M-00.00-mobile-1b47d5d9)
[0000.250] I> bit @ 0xd480000
[0000.253] I> Boot-device: eMMC
[0000.257] I> sdmmc bdev is already initialized
[0000.261] I> pmic: reset reason (nverc)        : 0x0
[b][0000.268] I> Found 16 partitions in SDMMC_BOOT (instance 3)
[0000.277] W> Cannot find any partition table for 00010003[/b]

like the MB2 cannot parse the protective mbr & primary_gpt created by “parted” tool.

Is there any way I could generate the protective mbr and gpt for SDMMC_USER and dd them? I’ve looked into the Linux_for_Tegra directory during flashing but can’t find mbr_1_3.bin and gpt_primary_1_3.bin.

Any flags maybe that could be added with “parted” so that MB2 can read the SDMMC_USER partition table? I’ve tried adding msftdata but doesn’t help.

Any help is appreciated!

Solved, looks like parted doesn’t quite create the expected gpt header.