Skip to content

Commit 979ccb4

Browse files
authored
Merge pull request #29 from kairos-io/agx
AGX Orin instructions
2 parents a42650c + 7fc778f commit 979ccb4

File tree

2 files changed

+1029
-0
lines changed

2 files changed

+1029
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,253 @@
1+
---
2+
title: "Nvidia AGX Orin"
3+
linkTitle: "Nvidia AGX Orin"
4+
weight: 4
5+
date: 2022-11-13
6+
description: >
7+
Install Kairos on Nvidia AGX Orin
8+
---
9+
10+
This page describes how to install Kairos on [Nvidia AGX Orin](https://www.nvidia.com/en-us/autonomous-machines/embedded-systems/jetson-orin/) in the eMMC.
11+
12+
13+
## Prerequisites
14+
15+
- [Nvidia AGX Orin](https://www.nvidia.com/en-us/autonomous-machines/embedded-systems/jetson-orin/)
16+
- An USB type-C cable
17+
- A Linux host used to flash the Nvidia AGX Orin board
18+
- Jetson linux SDK [download](https://developer.nvidia.com/embedded/jetson-linux)
19+
20+
You can find debugging information here: https://developer.ridgerun.com/wiki/index.php/NVIDIA_Jetson_Orin/In_Board/Getting_in_Board/Serial_Console
21+
22+
## Flashing
23+
24+
We are going to write the partitions in the eMMC. In order to do this we will use the Nvidia SDK configured with a custom partitioning layout.
25+
26+
The partitions are:
27+
- OEM for storing cloud config files (`/oem`)
28+
- COS_STATE for storing the active/passive images to boot the system
29+
- EFI for storing the efi shell and grub to boot the system
30+
- RECOVERY - to store the recovery system
31+
- PERSISTENT - this is an optional partition to store the persistent data of the system. you can either write this in the eMMC or, for instance, to an external storage. It is enough to create a partition and label it as `COS_PERSISTENT`. There can be only one partition with such label, the first that matches wins.
32+
33+
### Prepare the SDK
34+
35+
The Jetson Linux SDK is used to perform the flashing process.
36+
37+
Download the Jetson Linux SDK:
38+
39+
```bash
40+
wget https://developer.nvidia.com/downloads/embedded/l4t/r35_release_v3.1/release/jetson_linux_r35.3.1_aarch64.tbz2 -O tegra.bz2
41+
tar xvf tegra.bz2
42+
```
43+
44+
Now, we are going to prepare the rootfs and the bootloader. The Jetson Linux SDK requires the rootfs to generate the `system.img` file and continue the flashing process however, we will not use the image generated by the SDK as we will use a different set of images (see below). Here we also disable extlinux as Kairos uses GRUB:
45+
46+
```bash
47+
cd Linux_for_Tegra
48+
# Drop extlinux
49+
echo "" > ./bootloader/extlinux.conf
50+
# This is needed so the SDK doesn't complain of missing files (not really used in the flash process)
51+
IMAGE=quay.io/kairos/core-ubuntu-20-lts-arm-nvidia-jetson-agx-orin:latest
52+
docker run -ti --rm -v $PWD/rootfs:/rootfs quay.io/luet/base util unpack "$IMAGE" /rootfs
53+
# workaround needed (SDK writes to the symlink)
54+
rm rootfs/boot/initrd
55+
# Extlinux is required by the SDK - so we fake it in our root (it will not be there eventually)
56+
mkdir -p rootfs/boot/extlinux/
57+
echo "" > rootfs/boot/extlinux/extlinux.conf
58+
```
59+
60+
### Prepare the images
61+
62+
You can either download pre-built Kairos images, or build your own from a container image. You can find Kairos core ubuntu images based on Ubuntu `20.04` here: https://quay.io/repository/kairos/core-ubuntu-20-lts-arm-nvidia-jetson-agx-orin.
63+
64+
{{< tabpane text=true >}}
65+
{{% tab header="Download pre-built partition images from a container image" %}}
66+
67+
We will download pre-built images from a container image. Pre-built images are using https://quay.io/repository/kairos/core-ubuntu-20-lts-arm-nvidia-jetson-agx-orin and contains `.img` files that can be used for flashing. Img files are pushed automatically by the Kairos CI in https://quay.io/repository/kairos/core-ubuntu-20-lts-arm-nvidia-jetson-agx-orin.
68+
69+
```bash
70+
KAIROS_VERSION=v2.2.0-rc3
71+
IMAGE=quay.io/kairos/core-ubuntu-20-lts-arm-nvidia-jetson-agx-orin-img:$KAIROS_VERSION
72+
docker run -ti --rm -v $PWD/bootloader:/rootfs quay.io/luet/base util unpack "$IMAGE" /rootfs
73+
mv bootloader/build/*.img bootloader
74+
```
75+
76+
{{% /tab %}}
77+
{{% tab header="Build partition images from a container image" %}}
78+
79+
If you are customizing the image, or either modifying the default partition sizes you can build the images by running:
80+
```bash
81+
IMAGE=quay.io/kairos/core-ubuntu-20-lts-arm-nvidia-jetson-agx-orin:latest
82+
docker run --privileged \
83+
-e container=$IMAGE \
84+
-e STATE_SIZE="6200" \
85+
-e RECOVERY_SIZE="4200" \
86+
-e DEFAULT_ACTIVE_SIZE="2000" \
87+
-v $PWD/bootloader:/bootloader --entrypoint /prepare_arm_images.sh -ti --rm quay.io/kairos/osbuilder-tools
88+
```
89+
90+
{{% /tab %}}
91+
{{% tab header="Build partition images from a directory" %}}
92+
93+
If you have instead the rootfs as a directory, you can create the required partitions with:
94+
```bash
95+
PATH=/rootfs/path
96+
docker run --privileged \
97+
-e directory=$PATH \
98+
-e STATE_SIZE="6200" \
99+
-e RECOVERY_SIZE="4200" \
100+
-e DEFAULT_ACTIVE_SIZE="2000" \
101+
-v $PWD/bootloader:/bootloader --entrypoint /prepare_arm_images.sh -ti --rm quay.io/kairos/osbuilder-tools
102+
```
103+
104+
{{% /tab %}}
105+
{{< /tabpane >}}
106+
107+
After running any of the commands above, the generated images files required for flashing will be inside the `bootloader` directory (`bootloader/efi.img`, `bootloader/recovery_partition.img`, `bootloader/state_partition.img`, `bootloader/oem.img`, `bootloader/persistent.img` ).
108+
109+
{{% alert title="Note" %}}
110+
The persistent image is optional, as you can store the system persistent data rather in an SD card or an NVME disk. The default `persistent.img` is of 2GB size. To create a persistent image manually of the size you prefer instead you can run:
111+
112+
```
113+
# Create a 2GB filesystem for COS_PERSISTENT volume
114+
truncate -s $((2048*1024*1024)) bootloader/persistent.img
115+
mkfs.ext2 -L "COS_PERSISTENT" bootloader/persistent.img
116+
```
117+
118+
Note that the size of the partitions you modify should be duly reported in the partition layout (see below).
119+
{{% /alert %}}
120+
121+
### Edit the parition layout
122+
123+
We are going now to modify the partition layout in `bootloader/t186ref/cfg/flash_t234_qspi_sdmmc.xml` which corresponds to the partitioning of the AGX Orin board. An example config file can be found in [here](https://kairos.io/examples/images/flash_t234_qspi_sdmmc.xml).
124+
125+
```bash
126+
wget 'https://kairos.io/examples/images/flash_t234_qspi_sdmmc.xml' -O bootloader/t186ref/cfg/flash_t234_qspi_sdmmc.xml
127+
```
128+
If you are editing the partition sizes and generating the images manually, use the example config file as a baseline and edit the `size` accordingly to the corresponding partitions (find the respective `filename` and compare the file size, see the notes below). Otherwise, if you want to use the original file, identify the "APP" partition ( `<partition name="APP" id="1" type="data">` ), remove it , and add the following instead:
129+
130+
```xml
131+
<partition name="esp" type="data">
132+
<allocation_policy> sequential </allocation_policy>
133+
<filesystem_type> basic </filesystem_type>
134+
<size> 20971520 </size>
135+
<file_system_attribute> 0 </file_system_attribute>
136+
<partition_type_guid> C12A7328-F81F-11D2-BA4B-00A0C93EC93B </partition_type_guid>
137+
<allocation_attribute> 0x8 </allocation_attribute>
138+
<percent_reserved> 0 </percent_reserved>
139+
<filename> efi.img </filename>
140+
<description> **Required.** Contains a redundant copy of CBoot. </description>
141+
</partition>
142+
143+
<partition name="COS_RECOVERY" type="data">
144+
<allocation_policy> sequential </allocation_policy>
145+
<filesystem_type> basic </filesystem_type>
146+
<size> 2298478592 </size>
147+
<allocation_attribute> 0x8 </allocation_attribute>
148+
<filename> recovery_partition.img </filename>
149+
<description> </description>
150+
</partition>
151+
<partition name="COS_STATE" type="data">
152+
<allocation_policy> sequential </allocation_policy>
153+
<filesystem_type> basic </filesystem_type>
154+
<size> 5234491392 </size>
155+
<allocation_attribute> 0x8 </allocation_attribute>
156+
<filename> state_partition.img </filename>
157+
<description> </description>
158+
</partition>
159+
<partition name="COS_OEM" type="data">
160+
<allocation_policy> sequential </allocation_policy>
161+
<filesystem_type> basic </filesystem_type>
162+
<size> 67108864 </size>
163+
<allocation_attribute> 0x8 </allocation_attribute>
164+
<filename> oem.img </filename>
165+
<description> </description>
166+
</partition>
167+
<partition name="COS_PERSISTENT" type="data">
168+
<allocation_policy> sequential </allocation_policy>
169+
<filesystem_type> basic </filesystem_type>
170+
<size> 2147483648 </size>
171+
<allocation_attribute> 0x8 </allocation_attribute>
172+
<filename> persistent.img </filename>
173+
<description> </description>
174+
</partition>
175+
```
176+
177+
{{% alert title="Note" %}}
178+
The `COS_PERSISTENT` partition is optional. You can also use an SD card, or an nvme drive instead. The only requirement is to have the partition labeled as `COS_PERSISTENT`.
179+
{{% /alert %}}
180+
181+
{{% alert title="Note" %}}
182+
If modifiying the parition sizes, you need to replace `<size>` of each partition in the XML:
183+
184+
```
185+
stat -c %s bootloader/efi.img
186+
stat -c %s bootloader/recovery_partition.img
187+
stat -c %s bootloader/state_partition.img
188+
stat -c %s bootloader/oem.img
189+
stat -c %s bootloader/persistent.img
190+
```
191+
{{% /alert %}}
192+
193+
### Flash
194+
195+
To flash the images to the Orin board
196+
197+
1. Put the board in [recovery mode](https://developer.nvidia.com/embedded/learn/jetson-agx-orin-devkit-user-guide/howto.html#force-recovery-mode)
198+
2. Run:
199+
200+
```
201+
sudo ./flash.sh jetson-agx-orin-devkit mmcblk0p1
202+
```
203+
204+
### Booting
205+
206+
The Orin board now should boot. If you are connected over the serial you can login with: `kairos/kairos`, similarly if you have plugged it to the network you should be able to SSH in as well.
207+
208+
## Notes
209+
210+
## USB Timeout error
211+
212+
It is possible that during flashing on certain kernel versions to see an error message:
213+
214+
```
215+
[ 0.3623 ] tegrarcm_v2 --new_session --chip 0x23 --uid --download bct_br br_bct_BR.bct --download mb1 mb1_t234_prod_aligned_sigheader.bin.encrypt --download psc_bl1 psc_bl1_t234_prod_aligned_sigheader.bin.encrypt --download bct_mb1 mb1_bct_MB1_sigheader.bct.encrypt
216+
[ 0.3630 ] BR_CID: 0x80012344705DD25D1C00000019028240
217+
[ 0.3932 ] Sending bct_br
218+
[ 0.4409 ] ERROR: might be timeout in USB write.
219+
[ 5.5325 ]
220+
```
221+
222+
See also the relevant Nvidia discussions in the forum:
223+
- https://forums.developer.nvidia.com/t/usb-timeout-when-flashing-agx-orin/235600
224+
- https://forums.developer.nvidia.com/t/cannot-flash-jetson-os-image-to-jetson-agx-orin-devkit-via-sdk-manager/219489/2
225+
226+
The solution here is trying with a different kernel version, as suggested in the Nvidia threads.
227+
228+
### Default configuration
229+
230+
To customize the default cloud config of the board, generate the images mounting the cloud config you want in the images in `/defaults.yaml`:
231+
232+
```bash
233+
IMAGE=quay.io/kairos/core-ubuntu-20-lts-arm-nvidia-jetson-agx-orin:latest
234+
CLOUD_CONFIG=/cloud/config.yaml
235+
docker run -v $CLOUD_CONFIG:/defaults.yaml --privileged \
236+
-e container=$IMAGE \
237+
-e STATE_SIZE="6200" \
238+
-e RECOVERY_SIZE="4200" \
239+
-e DEFAULT_ACTIVE_SIZE="2000" \
240+
-v $PWD/bootloader:/bootloader --entrypoint /prepare_arm_images.sh -ti --rm quay.io/kairos/osbuilder-tools
241+
```
242+
243+
### Debugging
244+
245+
Use the micro USB as debug serial port with minicom to debug any booting issues.
246+
247+
```
248+
sudo minicom -D /dev/ttyACM0 -8 -b 115200
249+
```
250+
251+
### Flashing port
252+
253+
In order to flash the Nvidia AGX Orin you will need to use the USB Type-C ports. The Micro USB port is reserved only for debugging over the serial console.

0 commit comments

Comments
 (0)