0、联系nvidia FAE打上相关补丁
I modified it earlier:https://forums.developer.nvidia.com/t/failed-to-sparse-the-raw-to-img-due-to-the-size-of-system-img-raw-is-not-mulple-of-4096/215526/25
diff --git a/rfs/usr/lib/nvidia/resizefs/nvresizefs.sh b/rfs/usr/lib/nvidia/resizefs/nvresizefs.sh
index 37d3ad3..cd36266 100755
--- a/rfs/usr/lib/nvidia/resizefs/nvresizefs.sh
+++ b/rfs/usr/lib/nvidia/resizefs/nvresizefs.sh
@@ -1,6 +1,6 @@
#!/bin/bash
-# Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved.
+# Copyright (c) 2019-2022, NVIDIA CORPORATION. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
@@ -103,13 +103,19 @@
done
support_resizefs="${is_last}"
fi
+
+ if [ "${is_last}" == "true" ]; then
+ get_app_size
+ max_available_app_size
+ size="+${max_app_size}M"
+ fi
}
function get_app_size()
{
# shellcheck disable=SC2086
partition_size="$(cat /sys/block/${block_dev}/${root_dev}/size)"
- echo "$((partition_size/2/1024))"
+ cur_app_size="$((partition_size/2/1024))"
}
function max_available_app_size()
@@ -123,7 +129,7 @@
grep "last usable sector" | \
awk '{print $10}')"
- echo "$(((last_usable_sector - app_start_sector + 1)/2/1024))"
+ max_app_size="$(((last_usable_sector - app_start_sector + 1)/2/1024))"
}
function parse_args()
@@ -143,7 +149,7 @@
echo "ERROR: ${script_name} doesn't support this platform."
exit 1
fi
- get_app_size
+ echo "${cur_app_size}"
exit 0
;;
-m | --max)
@@ -151,7 +157,7 @@
echo "ERROR: ${script_name} doesn't support this platform."
exit 1
fi
- max_available_app_size
+ echo "${max_app_size}"
exit 0
;;
-s | --size)
@@ -170,6 +176,8 @@
script_name="$(basename "${
0}")"
support_resizefs="false"
size="0"
+cur_app_size="0"
+max_app_size="0"
root_dev=""
block_dev=""
1、modify the following in Linux_for_Tegra/flash.sh and clone again
echo -e -n "\tConverting RAW image to Sparse image... ";
mv -f ${
target_partfile} ${
target_partfile}.raw;
- ./mksparse --fillpattern=0 ${
target_partfile}.raw ${
target_partfilile};
+ ./mksparse -b 512 --fillpattern=0 ${
target_partfile}.raw ${
target_partfilile};
2、Clone:
$sudo ./flash.sh -r -k APP -G clone.img jetson-agx-orin-devkit mmcblk0p1
There’s an error, but it’s not a big deal:
[ 8.2651 ] tegradevflash_v2 --read APP /home/chenweiqian/udi_nvidia/nvidia/r35.1/Linux_for_Tegra/clone.img
[ 8.2661 ] Bootloader version 01.00.0000
[ 8.3270 ] [................................................] 100%
*** The [APP] has been read successfully. ***
Converting RAW image to Sparse image...
Usage: ./mksparse [options] <source file> <target file>
where
<options> are:
-b|--blocksize<=r/w block size> ---------- default = 4096
-f|--fillpattern[=numeric byte pattern] -- default = 0
-V|--Verbose[=verbose level] ------------- default = Quiet
<source file> is:
raw image input file name.
<target file> is:
sparse image output file name.
3、check the size of clone.img.raw
chenweiqian@chenweiqian-virtual-machine:~/udi_nvidia/nvidia/r35.1/Linux_for_Tegra$ ls -l ./clone.img.raw
-rw-r--r-- 1 root root 62091112960 6月 13 12:51 ./clone.img.raw
4、手动将稀疏文件生成.img文件
Manually generate.img from.raw files
chenweiqian@chenweiqian-virtual-machine:~/udi_nvidia/nvidia/r35.1/Linux_for_Tegra$ cd bootloader/
chenweiqian@chenweiqian-virtual-machine:~/udi_nvidia/nvidia/r35.1/Linux_for_Tegra/bootloader$ sudo ./mksparse -b 512 --fillpattern=0 ../clone.img.raw clone.img
5、check the size of clone.img.raw
chenweiqian@chenweiqian-virtual-machine:~/udi_nvidia/nvidia/r35.1/Linux_for_Tegra/bootloader$ ls -l clone.img
-rwxr-xr-x 1 root root 27950983312 6月 13 13:58 clone.img
6、备份原始文件
Back up your original files
chenweiqian@chenweiqian-virtual-machine:~/udi_nvidia/nvidia/r35.1/Linux_for_Tegra/bootloader$ mv system.img system.img-bak
7、替换system.img
Replacing system.img
刷机时,加-r后将直接刷入system.img文件到Orin
chenweiqian@chenweiqian-virtual-machine:~/udi_nvidia/nvidia/r35.1/Linux_for_Tegra/bootloader$ mv clone.img system.img
8、如果此时直接加-r刷写,可能会报错Error: Return value 3
There is an error when flushing directly:Error: Return value 3
chenweiqian@chenweiqian-virtual-machine:~/udi_nvidia/nvidia/r35.1/Linux_for_Tegra$ sudo ./flash.sh -r jetson-agx-orin-devkit mmcblk0p1
[ 466.5250 ] Writing partition esp with esp.img [ 67108864 bytes ]
[ 466.5569 ] [................................................] 100%
[ 475.6980 ] Writing partition APP with system.img [ 27950983312 bytes ]
Error: Return value 3 ] 000%
Command tegradevflash_v2 --pt flash.xml.bin --create
Failed flashing t186ref.
9、为程序打上补丁
Patch the program:
modify allocation_attribute of APP from 0x8 to 0x808:https://forums.developer.nvidia.com/t/failure-to-flash-orin-with-cloned-system-img/236555/8
Linux_for_Tegra/bootloader/t186ref/cfg/flash_t234_qspi_sdmmc.xml
<partition name="APP" id="1" type="data">
<allocation_policy> sequential </allocation_policy>
<filesystem_type> basic </filesystem_type>
<size> APPSIZE </size>
<file_system_attribute> 0 </file_system_attribute>
- <allocation_attribute> 0x8 </allocation_attribute>
+ <allocation_attribute> 0x808 </allocation_attribute>
The “allocatio_atribute” can be 0x8 or 0x808.
The 0x808 should be used on the partition immediately preceding the secondary GPT on the non-boot device. Once “allocatio_atribute” is set to 0x808, the partition will occupy the remaining the free space in on the device; otherwise, it only occupies the space defined the its size.
It is introduced at:Partition Configuration — Child Elements10
10、And flash again with -r parameter
chenweiqian@chenweiqian-virtual-machine:~/udi_nvidia/nvidia/r35.1/Linux_for_Tegra$ sudo ./flash.sh -r jetson-agx-orin-devkit mmcblk0p1
11、Success!
[ 467.3835 ] Writing partition esp with esp.img [ 67108864 bytes ]
[ 467.4133 ] [................................................] 100%
[ 476.3526 ] Writing partition APP with system.img [ 27950983312 bytes ]
[ 476.3875 ] [................................................] 100%
[ 5087.8283 ] tegradevflash_v2 --write secondary_gpt_backup gpt_secondary_3_0.bin
[ 5087.8349 ] Bootloader version 01.00.0000
[ 5087.9229 ] Writing partition secondary_gpt_backup with gpt_secondary_3_0.bin [ 16896 bytes ]
[ 5087.9234 ] [................................................] 100%
[ 5088.2436 ] tegradevflash_v2 --write BCT br_bct_BR.bct
[ 5088.2453 ] Bootloader version 01.00.0000
[ 5088.3058 ] Writing partition BCT with br_bct_BR.bct [ 8192 bytes ]
[ 5088.3061 ] [................................................] 100%
[ 5094.9535 ] tegradevflash_v2 --write BCT-boot-chain_backup bct_backup.img
[ 5094.9547 ] Bootloader version 01.00.0000
[ 5095.0134 ] Writing partition BCT-boot-chain_backup with bct_backup.img [ 32768 bytes ]
[ 5095.0137 ] [................................................] 100%
[ 5095.5793 ] tegradevflash_v2 --write A_MB1_BCT mb1_cold_boot_bct_MB1_sigheader.bct.encrypt
[ 5095.5983 ] Bootloader version 01.00.0000
[ 5095.6527 ] Writing partition A_MB1_BCT with mb1_cold_boot_bct_MB1_sigheader.bct.encrypt [ 17344 bytes ]
[ 5095.6532 ] [................................................] 100%
[ 5095.9604 ] tegradevflash_v2 --write B_MB1_BCT mb1_cold_boot_bct_MB1_sigheader.bct.encrypt
[ 5095.9616 ] Bootloader version 01.00.0000
[ 5096.0160 ] Writing partition B_MB1_BCT with mb1_cold_boot_bct_MB1_sigheader.bct.encrypt [ 17344 bytes ]
[ 5096.0163 ] [................................................] 100%
[ 5096.3055 ] tegradevflash_v2 --write A_MEM_BCT mem_coldboot_sigheader.bct.encrypt
[ 5096.3068 ] Bootloader version 01.00.0000
[ 5096.3642 ] Writing partition A_MEM_BCT with mem_coldboot_sigheader.bct.encrypt [ 243712 bytes ]
[ 5096.3645 ] [................................................] 100%
[ 5099.4593 ] tegradevflash_v2 --write B_MEM_BCT mem_coldboot_sigheader.bct.encrypt
[ 5099.4604 ] Bootloader version 01.00.0000
[ 5099.5231 ] Writing partition B_MEM_BCT with mem_coldboot_sigheader.bct.encrypt [ 243712 bytes ]
[ 5099.5255 ] [................................................] 100%
[ 5102.6069 ] Flashing completed
[ 5102.6225 ] Coldbooting the device
[ 5102.6457 ] tegrarcm_v2 --chip 0x23 0 --ismb2
[ 5102.6475 ] MB2 version 01.00.0000
[ 5102.7267 ] Coldbooting the device
[ 5102.7285 ] tegrarcm_v2 --chip 0x23 0 --reboot coldboot
[ 5102.7297 ] MB2 version 01.00.0000
*** The target t186ref has been flashed successfully. ***
Reset the board to boot from internal eMMC.