Cross-Compilation in jetson orin nx board

Hi,
The command in document is to clone the image of target board. It doesn’t re-flash the target board.

The cloned image is in host PC.

Just some information you might find useful…

A clone is a bit-for-bit exact binary copy of the entire partition. A raw clone is every last bit, and won’t have any knowledge of the filesystem or content on the partition. A sparse clone knows about the ext4 format, and excludes the “empty” filesystem space. One can always restore from a binary raw clone. To restore from a sparse clone the tool involved must understand how ext4 and empty space works. One can loopback mount a raw clone, but you cannot loopback mount a sparse clone. Loopback makes a file look like a partition.

The clone will never fit on the Jetson; indeed, a raw clone is the size of the entire partition, so to put it on the Jetson as a file you’d have to double the size of the partition. Loopback mounted clones on the Linux host PC allow you to examine and modify the partition. The flash software on the host PC can use that raw clone to flash. In theory, if you were to clone, put it on the host PC, and then use the clone to flash, then nothing would have occurred (you would have replaced the existing bytes of data with the same exact bytes of data).

However, if you were to modify the cloned image on the desktop PC prior to flashing with it, then the flash would include those changes.

Cross compiling needs the environment of libraries that the destination system has. You could copy every library you need one at a time. However, if you have a clone (and we are not restoring with the clone), then loopback mounting gives you every single file and library of the exact layout as on the actual Jetson. This becomes what is called the “sysroot”. You still need cross tools, and all of this is on your host PC, but any library needed for linking is now there (even better yet, that library is guaranteed to be the same exact version as on the actual Jetson).

Can you please give me a clear steps to clone a jetson board? for cross compiling

yes, i have mounted the system.img.raw and completed all the steps now how to compile ? can u give me the steps after mounting?

If and only if the Jetson itself has libraries (and maybe header files) needed for a compile of your software, then just check your cross compile or build software configuration to name the library locations inside of the mounted loopback image as the sysroot. The host PC won’t know the difference between a loopback image and any other content, it is “just there and will work” (other than being 64-bit ARM). Your software build for cross compile needs libraries to link against, and although the tools for cross linking differ (and thus any Makefile or other configuration), you need more or less the same linking as you would perform manually. However you tell the build to find and link to libraries just update it for the cross linker to the 64-bit ARM libraries in the mounted clone (the “sysroot” in documentation).

this error is producing while running that commands
Error: Invalid target board - -G.

Usage: sudo ./flash.sh [options] <target_board>
Where,
target board: Valid target board name.
rootdev: Proper root device.
options:
-c ---------- Flash partition table config file.
-d ---------- device tree file.
-f --------- Path to flash application (tegraflash.py)
-h -------------------- print this message.
-i – key for disk encryption support.

I would have to recreate your entire cross compile build and have your clone in order to be able to answer. However, cross compile does not use flash.sh. flash.sh is used for flashing. It is true that some of the code for preparing for flash uses QEMU emulation, but this is not cross compiling, which is a separate topic from flashing.

What is it that you specifically want to accomplish? Maybe if we know more about what it is you are trying to do it would be easier to give a useful answer.

sudo ./flash.sh -r -k APP -G mmcblk0p1 for this which partition i want to give to copy system.img file from file system partiton

i have run sudo ./flash.sh -r -k APP -G jetson-orin-nano-devkit nvmeon1
and still from last 3 hrs still running like this

[ 1024.0219 ] tegrarcm_v2 --chip 0x23 0 --ismb2
[ 2040.8314 ] tegrarcm_v2 --chip 0x23 0 --ismb2applet
[ 3055.6380 ] tegrarcm_v2 --chip 0x23 0 --ismb2
[ 4072.4474 ] tegrarcm_v2 --chip 0x23 0 --ismb2applet
[ 5087.2541 ] tegrarcm_v2 --chip 0x23 0 --ismb2
[ 6104.0634 ] tegrarcm_v2 --chip 0x23 0 --ismb2applet
[ 7118.8700 ] tegrarcm_v2 --chip 0x23 0 --ismb2
[ 8135.6794 ] tegrarcm_v2 --chip 0x23 0 --ismb2applet
[ 9150.4860 ] tegrarcm_v2 --chip 0x23 0 --ismb2
[ 10167.2954 ] tegrarcm_v2 --chip 0x23 0 --ismb2applet
[ 11182.1017 ] tegrarcm_v2 --chip 0x23 0 --ismb2
[ 12198.9114 ] tegrarcm_v2 --chip 0x23 0 --ismb2applet
[ 13213.7180 ] tegrarcm_v2 --chip 0x23 0 --ismb2
[ 14230.5274 ] tegrarcm_v2 --chip 0x23 0 --ismb2applet
[ 15245.3341 ] tegrarcm_v2 --chip 0x23 0 --ismb2
[ 16262.1434 ] tegrarcm_v2 --chip 0x23 0 --ismb2applet

I suspect the flash command is not quite correct. Using an external device probably requires an initrd flash instead of a regular flash, but I have no external NVMe to try so I am not certain of what the correct command would be.

Would someone from NVIDIA be able to comment on a correct initrd flash for this NVMe? Or at least confirm that the command is or is not correct?

Then what is the working command for this step?

Error: None of the bootloaders are running on device. Check the UART log.
*** The [APP] has been read successfully. ***
Converting RAW image to Sparse image… mv: cannot stat ‘/home/ubuntu/nvidia/nvidia_sdk/JetPack_6.0_Linux_JETSON_ORIN_NX_TARGETS/Linux_for_Tegra/jetson-orin-nano-devkit’: No such file or directory
open input file /home/ubuntu/nvidia/nvidia_sdk/JetPack_6.0_Linux_JETSON_ORIN_NX_TARGETS/Linux_for_Tegra/jetson-orin-nano-devkit.raw failed.

i am geting like this at last

I have not worked on external device flash as I don’t have anything suitable for it. Someone else will need to give specifics, but what you are looking for would be at:
Linux_for_Tegra/tools/kernel/flash/

Then check out the README_initrd_flash.txt.

A short explanation is that the bootloader target will normally be stored in the Jetson itself. The boot chain must then have the ability (in terms of drivers) to access all hardware and filesystems before Linux can boot. With the external device you will tend to need a kind of “adapter”, an initial ramdisk. That initrd is just a very simple filesystem that all bootloaders can understand, and you put the initial Linux boot specs there. At that point the Linux kernel itself loads, and via content on the initrd, the bootloader does not need to know how to access the NVMe or other external drive; Linux knows how since it has the drivers in the initrd. So I suspect you need an initrd flash, but in JetPack 6 there might be some changes I have not looked at.

Hi,
Please check this section and follow the steps:

Flashing Support — NVIDIA Jetson Linux Developer Guide 1 documentation

Note
To clone the rootfs partition of the external storage device, for example, the NVMe
storage device, see [Cloning rootfs with initrd]

helllo, can you please provide a steps for cross-complation for jetson from x86 linux system

Hi,
The steps in document are clear. Please take a look. You need to make sure the environment is good on target device, clone the image out, and mount the image to host PC.

its unable to clone the system.image and it was stucking as last time said. there is any another way, i have backup images of all partitions through that we cant generate raw.image file?

Whenever you flash normally these files will be generated on the host PC:

  • Linux_for_Tegra/bootloader/system.img
  • Linux_for_Tegra/bootloader/system.img.raw

The one you are interested in is system.img.raw. The other is a sparse file.

If you were to clone a system after flash, then you’d almost see the same exact files. I say “almost” because at the end of the flash the Jetson would have rebooted and attempted first boot account setup.

Incidentally, cloning an eMMC model is different than cloning from an external device or SD card. What is your exact description of if this is a dev kit, if it uses an SD card, if it uses SSD, so on?

Hi,
Please let the Orin NX board enter recovery mode and run the command:

$ sudo ./tools/kernel_flash/l4t_initrd_flash.sh --initrd jetson-orin-nano-devkit external

After the command is done, you can login the board through ssh and run dd to clone the image. Detail of steps is in developer guide. If you hit issues, please set up the UART debug port to check the UART log.

i have generated a system.img.raw and mounted in my host pc. And then i am trying to compile the qt code using aarch qmake i am getting this error-
/home/ubuntu/jetson/home/ubuntu/Qt/6.7.2/gcc_arm64/mkspecs/features/toolchain.prf:76: Variable QMAKE_CXX.COMPILER_MACROS is not defined.
Project ERROR: failed to parse default include paths from compiler output