Difference between revisions of "Nvidia Jetson: Flashing Custom Firmware"

From Humanoid Robots Wiki
Jump to: navigation, search
(Created page with "= Developing Custom Firmware = == For the Jetson Orin Nano == = Flashing = = Notes: - Current Design constraints: - Based off of the availability of parts in JLCPCB....")
 
(Flashing the Kernel)
 
(17 intermediate revisions by 3 users not shown)
Line 1: Line 1:
= Developing Custom Firmware =  
+
= Flashing Standard Firmware =
== For the Jetson Orin Nano ==  
+
== SDKManager ==
 +
SDKManager is available only on Linux, and can be installed here: <code>https://developer.nvidia.com/sdk-manager</code>
 +
# Start up the SDKManager
 +
# Put the Jetson into recovery mode. For the AGX, this can be done by pressing the recovery button while powering on the device. For the Nano and NX, however, a jumper will be required.
 +
# Connect the Target Jetson to the host device and ensure that the target device is recognized.
 +
# Follow the instructions on the application, choosing configurations as necessary.
 +
 +
= Flashing Custom Firmware (For Jetson 36.3) =
 +
== Pre-requisites ==
 +
# Please install required packages with the command <code>sudo apt install build-essential bc && sudo apt install build-essential bc</code>.
 +
=== Downloading the Toolchain ===
 +
# Download the Toolchain binaries located in <code>https://developer.nvidia.com/embedded/jetson-linux</code>.
 +
# From there, <code>mkdir $HOME/l4t-gcc</code>, <code>cd $HOME/l4t-gcc</code> and extract the installed toolchain into this newly created directory using the <code>tar</code> command.
  
= Flashing =
+
== Downloading the Kernel ==
=
+
# Follow steps 1 to 3 as mentioned in Flashing Standard Firmware.
 +
# Proceed to the second step of the SDKManager, where the respective individual dependencies and Jetson Images are listed and are to be installed. Proceed with the installation.
 +
# When prompted to actually flash the Jetson, opt to skip. This will install the <code>nvidia</code> folder on your home directory, in which the <code>rootfs</code>, <code>kernel</code>, and <code>bootloader</code> are located.
 +
# Navigate to <code>nvidia</code> and <code>cd</code> through its subdirectories, until <code>Linux for Tegra</code> is reached.
 +
# Inside <code>Linux for Tegra</code>, <code>cd</code> into the <code>sources</code> folder. It should be unpopulated with the exception of some bash scripts. Run the <code>source_sync.sh</code> script and when asked to specify the release tag of the downloadable sources, enter <code>jetson_36.3</code>. This will install the sources for the respective Jetson version as necessary. To find the release tag of future iterations of the Jetson firmware, please refer to its respective release notes.
 +
# Once sources have been synced, the <code>sources</code> directory should now be populated with the required files.
  
 +
== Customizing Kernel ==
 +
# Within <code>source</code>, enter the <code>kernel</code> eventually navigate to the <code>kernel-jammy-src</code> folder and run <code>make menuconfig ARCH=arm64</code>. This will bring up a UI with configurable drivers and peripherals. Select desired configurations and save.
 +
# The configurations can be found within a <code>.config</code> file located within the same directory. Copy the contents and locate the <code>defconfig</code> file in <code>./arch/arm64/configs/</code>, overwriting it with the copied contents.
  
Notes:
+
== Building Custom Kernel and Installing Modules ==
- Current Design constraints:
+
# Navigate back out to <code>sources</code>.
  - Based off of the availability of parts in JLCPCB. Possibility of parts not being found or existing.  
+
# Define the Cross-compilation toolchain with the commands <code>export CROSS_COMPILE=<toolchain-path>/bin/aarch64-buildroot-linux-gnu-</code>. If installation was done correctly as per the pre-requisites section, the command <code>export CROSS_COMPILE=$HOME/l4t-gcc/aarch64--glibc--stable-2022.08-1/bin/aarch64-buildroot-linux-gnu-</code> should work. 
  -  
+
# Define the Cross-compilation toolchain with the commands <code>export CROSS_COMPILE_AARCH64_PATH=</code>, and <code>export CROSS_COMPILE_AARCH64=/bin/aarch64-buildroot-linux-gnu-</code>. (Potentially deprecated)
 +
# Inside the sources, directory, make an output directory for built kernel files using <code>mkdir kernel_out</code>.
 +
# Build the modules using the command <code>./nvbuild.sh -o kernel_out</code>. This will compile the drivers and device trees for the new kernel.
 +
# Navigate out from the <code>sources</code> directory into the <code>Linux for Tegra</code>.
 +
# Use the <code>cp</code> to overwrite <code>./rootfs/usr/lib/modules/5.15.136-tegra/updates/nvgpu.ko</code> with <code>./source/kernel_out/nvgpu/drivers/gpu/nvgpu/nvgpu.ko</code>.
 +
# Repeat the previous step to replace <code>Linux_for_Tegra/kernel/dtb/</code> with </code>source/kernel_out/kernel/kernel-jammy-src/arch/arm64/boot/dts/nvidia</code>. Ensure that instead of overwriting the directory, only the files are copied over.
 +
# Overwrite the Image file in <code>./kernel</code> with <code>./source/kernel_out/kernel/kernel-jammy-src/arch/arm64/boot/Image
 +
</code>.
 +
# To specify the installation path for the compiled modules, use the command <code>export INSTALL_MOD_PATH=$HOME/nvidia/nvidia_sdk/JetPack_6.0_Linux_JETSON_AGX_ORIN_TARGETS/Linux_for_Tegra/rootfs/</code>.  
 +
# Install modules using the command <code>./nvbuild -i</code>. The Jetson is now ready to be flashed.
  
- Flashing is done with the flash.sh script through the following command
+
== Flashing the Kernel ==
$ sudo ./flash.sh <board> <rootdev>
+
Ensure that the target Jetson is connected to the host device and is in recovery mode. Navigate to the <code>Linux for Tegra</code> directory and run <code>sudo ./nvsdkmanager_flash.sh</code>. When prompted, disconnect the Jetson from host device and allow it to boot. Congratulations, you have successfully flashed your Jetson with custom firmware.
where board is the actual board (Jetson-Nano-XX, etc.)
 
rootdev determines what type of device is being flahed. Use mmcblk0pc1 to flash a local storage device (eMMC or SD card)
 
- TO begin flashing, put the device into force recovery mode and then press reset.  
 
- Run the flash script using the previous command specified.
 
 
 
Flash using a convenient script:
 
- To avoid having to specify the rootdev andthe board configurations, can use the custom flashing script:
 
  -
 
 
 
Using GPIO Pins to program protocol:
 
- you can use the rasberry pi libraries to interface with the pins, configuring them to whatever layout that is needed.
 
  - Example: it is possible to direclty interface with the i2c system in the nano by using the
 

Latest revision as of 19:56, 30 August 2024

Flashing Standard Firmware[edit]

SDKManager[edit]

SDKManager is available only on Linux, and can be installed here: https://developer.nvidia.com/sdk-manager

  1. Start up the SDKManager
  2. Put the Jetson into recovery mode. For the AGX, this can be done by pressing the recovery button while powering on the device. For the Nano and NX, however, a jumper will be required.
  3. Connect the Target Jetson to the host device and ensure that the target device is recognized.
  4. Follow the instructions on the application, choosing configurations as necessary.

Flashing Custom Firmware (For Jetson 36.3)[edit]

Pre-requisites[edit]

  1. Please install required packages with the command sudo apt install build-essential bc && sudo apt install build-essential bc.

Downloading the Toolchain[edit]

  1. Download the Toolchain binaries located in https://developer.nvidia.com/embedded/jetson-linux.
  2. From there, mkdir $HOME/l4t-gcc, cd $HOME/l4t-gcc and extract the installed toolchain into this newly created directory using the tar command.

Downloading the Kernel[edit]

  1. Follow steps 1 to 3 as mentioned in Flashing Standard Firmware.
  2. Proceed to the second step of the SDKManager, where the respective individual dependencies and Jetson Images are listed and are to be installed. Proceed with the installation.
  3. When prompted to actually flash the Jetson, opt to skip. This will install the nvidia folder on your home directory, in which the rootfs, kernel, and bootloader are located.
  4. Navigate to nvidia and cd through its subdirectories, until Linux for Tegra is reached.
  5. Inside Linux for Tegra, cd into the sources folder. It should be unpopulated with the exception of some bash scripts. Run the source_sync.sh script and when asked to specify the release tag of the downloadable sources, enter jetson_36.3. This will install the sources for the respective Jetson version as necessary. To find the release tag of future iterations of the Jetson firmware, please refer to its respective release notes.
  6. Once sources have been synced, the sources directory should now be populated with the required files.

Customizing Kernel[edit]

  1. Within source, enter the kernel eventually navigate to the kernel-jammy-src folder and run make menuconfig ARCH=arm64. This will bring up a UI with configurable drivers and peripherals. Select desired configurations and save.
  2. The configurations can be found within a .config file located within the same directory. Copy the contents and locate the defconfig file in ./arch/arm64/configs/, overwriting it with the copied contents.

Building Custom Kernel and Installing Modules[edit]

  1. Navigate back out to sources.
  2. Define the Cross-compilation toolchain with the commands export CROSS_COMPILE=<toolchain-path>/bin/aarch64-buildroot-linux-gnu-. If installation was done correctly as per the pre-requisites section, the command export CROSS_COMPILE=$HOME/l4t-gcc/aarch64--glibc--stable-2022.08-1/bin/aarch64-buildroot-linux-gnu- should work.
  3. Define the Cross-compilation toolchain with the commands export CROSS_COMPILE_AARCH64_PATH=, and export CROSS_COMPILE_AARCH64=/bin/aarch64-buildroot-linux-gnu-. (Potentially deprecated)
  4. Inside the sources, directory, make an output directory for built kernel files using mkdir kernel_out.
  5. Build the modules using the command ./nvbuild.sh -o kernel_out. This will compile the drivers and device trees for the new kernel.
  6. Navigate out from the sources directory into the Linux for Tegra.
  7. Use the cp to overwrite ./rootfs/usr/lib/modules/5.15.136-tegra/updates/nvgpu.ko with ./source/kernel_out/nvgpu/drivers/gpu/nvgpu/nvgpu.ko.
  8. Repeat the previous step to replace Linux_for_Tegra/kernel/dtb/ with source/kernel_out/kernel/kernel-jammy-src/arch/arm64/boot/dts/nvidia. Ensure that instead of overwriting the directory, only the files are copied over.
  9. Overwrite the Image file in ./kernel with ./source/kernel_out/kernel/kernel-jammy-src/arch/arm64/boot/Image

.

  1. To specify the installation path for the compiled modules, use the command export INSTALL_MOD_PATH=$HOME/nvidia/nvidia_sdk/JetPack_6.0_Linux_JETSON_AGX_ORIN_TARGETS/Linux_for_Tegra/rootfs/.
  2. Install modules using the command ./nvbuild -i. The Jetson is now ready to be flashed.

Flashing the Kernel[edit]

Ensure that the target Jetson is connected to the host device and is in recovery mode. Navigate to the Linux for Tegra directory and run sudo ./nvsdkmanager_flash.sh. When prompted, disconnect the Jetson from host device and allow it to boot. Congratulations, you have successfully flashed your Jetson with custom firmware.