how to flash kernel and dts

hi
i have some question about flash
1、how to using flash.sh to flash kernel image file,i using this cmd,but is not work

sudo ./flash.sh -k kernel jetson-tx2 mmcblk0p1

2、how to clone all the TX2 system,the following cmd can not colone dtb file,can like the kernel image,
copy the dtb file to /etc/XXX path?

sudo ./flash.sh -r -k APP -G clone.img jetson-tx2 mmcblk0p1

Flash and clone instructions depend upon which release is used. What is the exact version you are using (e.g., “head -n 1 /etc/nv_tegra_release” if you don’t know)? In the case of flashing the kernel image did you first replace “Linux_for_Tegra/kernel/Image”?

Clone currently is for clone of rootfs. A running system can use dd to clone other partitions. Which do you want to clone?

Device tree is somewhat complicated, but from a running system:

dtc -I fs -O dts -o extracted.dts /proc/device-tree

The reason I say “complicated” is that boot stages prior to U-Boot now need device tree access, and so the ext4 file system can’t provide this and any device tree in “/boot” is now invalid. The dtb is a signed binary partition (at the moment), and early stages read this, edit this, and then pass it on to U-Boot (which in turn passes it on to Linux). Thus the “kernel-dtb” partition and what you get from extracting from “/proc/device-tree/” will be slightly different. Without a correct signature the extracted version wouldn’t work, but you could use dd to copy the kernel-dtb partition (only the APP/rootfs partition changes on a running system, the others are only accessed during boot and thus you can use dd to copy any of them).

As an example you can list partitions via:

sudo gdisk -l /dev/mmcblk0

You will see mmcblk0p26 has label “kernel-dtb”, and if you want a copy of this:

dd if=/dev/mmcblk0p26 of=clone_kernel-dtb.img