-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathflash.sh
More file actions
executable file
·78 lines (70 loc) · 2.12 KB
/
flash.sh
File metadata and controls
executable file
·78 lines (70 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash
# Defaults: NVMe + super (ARK PAB carrier)
STORAGE_DEV="nvme0n1p1"
USE_INITRD=true
FLASH_TARGET="jetson-orin-nano-devkit-super"
while [[ $# -gt 0 ]]; do
case $1 in
--sdcard)
STORAGE_DEV="mmcblk0p1"
USE_INITRD=false
shift ;;
--usb)
STORAGE_DEV="sda"
shift ;;
--no-super)
FLASH_TARGET="jetson-orin-nano-devkit"
shift ;;
*)
echo "Unknown option: $1"
echo "Usage: ./flash.sh [--sdcard] [--usb] [--no-super]"
exit 1 ;;
esac
done
# Log output to file while keeping terminal output
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
exec > >(tee "$SCRIPT_DIR/flash.log.txt") 2>&1
# Pre-flash target confirmation
LAST_TARGET_FILE="$SCRIPT_DIR/source_build/LAST_BUILT_TARGET"
if [ -f "$LAST_TARGET_FILE" ]; then
LAST_TARGET=$(cat "$LAST_TARGET_FILE")
echo "========================================="
echo " Built target: $LAST_TARGET"
echo "========================================="
read -p "Flash this target? (y/N): " confirm
if [ "$confirm" != "y" ] && [ "$confirm" != "Y" ]; then
echo "Flash aborted."
exit 0
fi
else
echo "WARNING: No LAST_BUILT_TARGET file found — cannot confirm which target was built."
read -p "Continue anyway? (y/N): " confirm
if [ "$confirm" != "y" ] && [ "$confirm" != "Y" ]; then
echo "Flash aborted."
exit 0
fi
fi
sudo -v
echo "Waiting for device..."
while true; do
for pid in 7323 7423 7523 7623; do
if lsusb -d 0955:${pid} > /dev/null 2>&1; then
break 2
fi
done
sleep 1
done
pushd .
cd prebuilt/Linux_for_Tegra/
if [ "$USE_INITRD" = true ]; then
# NVMe flash
sudo ./tools/kernel_flash/l4t_initrd_flash.sh --external-device "$STORAGE_DEV" \
-p "-c ./bootloader/generic/cfg/flash_t234_qspi.xml" \
-c ./tools/kernel_flash/flash_l4t_t234_nvme.xml \
--erase-all --showlogs --network usb0 \
"$FLASH_TARGET" "$STORAGE_DEV"
else
# SD card flash
sudo ./flash.sh "$FLASH_TARGET" "$STORAGE_DEV"
fi
popd