Kernel rebuild in jetson nano 4Gb dev kit B01-version

Hi!
I have the same problem as in the topic

I have a modem Quectel EG25-G. For it to work correctly, you need to install its driver. To do this, make changes to the system files that are not currently available.

[KERNEL]/drivers/usb/serial/option.c
[KERNEL]/drivers/usb/serial/qcserial.c
[KERNEL]/drivers/net/usb/qmi_wwan.c
[KERNEL]/drivers/usb/serial/usb_wwan.c

Please, help me to “download the full source from our download center.”

On the host computer installed Ubuntu20.04 LTS. SDK manager not support.

FYI, you can compile natively on the Jetson. The host PC version won’t “normally” matter, but if you compile with too new of a compiler, then the kernel may not work. The download content and docs will mention compiler versions, but you can mostly ignore that if you can compile directly on the Nano. The biggest problem would be if you don’t have enough disk space (and it is painful if you accidentally fill your disk).

First, this is a general URL for document downloads:
https://developer.nvidia.com/embedded/downloads

However, you should always go first to the exact L4T release you are working with. On the Nano you can run this command to find the L4T release:
head -n 1 /etc/nv_tegra_release

The location for finding each L4T release downloadables:
https://developer.nvidia.com/linux-tegra

Once you reach your specific release, then downloads can be found there (there is also a git download, but I don’t know if the tags are current for all releases). Just for the sake of illustration I will assume L4T is R32.5.1. In that case you’d end up here:
https://developer.nvidia.com/embedded/linux-tegra-r3251

There will be different downloads with a label for the specific platform. Make sure to look first if there is a 2GB Nano specific version. If not (and in many cases all releases will have some common content), then just use what you find. Here is a list of what some of those download URLs are for:

  • L4T Driver Package is the actual flash software. If you used SDK Manager/JetPack, then this is downloaded for you automatically.
  • Sample Root Filesystem is the “Linux_for_Tegra/rootfs/” content before any NVIDIA content is added. Basically this is purely Ubuntu, and is the main source of content for generating a rootfs image for flash.
  • L4T Driver Package (BSP) Sources: This is what you want. This contains a number of other packages. The only package within this which you want will extract as “kernel_src.tbz2” (and the sha1sum if interested). Extract the final kernel_src.tbz2 and you will have the source known to work with that release.
  • Under the “Tools” section there is a GCC BSP. This will be the correct gcc to use for building that kernel, and should be a “cross compiler” for an Ubuntu 18.04 host PC. This might work from an Ubuntu 20.04 PC, don’t know. Since kernel builds are “bare metal” you shouldn’t need any special libraries for kernel cross compile. You can try to compile natively instead directly on the Nano.

There are also documents there. Cross compile is not particularly hard, and this is what the docs show. Native compile is a bit simpler since you don’t have to set up the cross compile environment.

Hi,

Can you share me the result of lsusb command?

Hi!
Output of a command without a modem:
Bus 002 Device 002: ID 0bda:0411 Realtek Semiconductor Corp.
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 8087:0a2b Intel Corp.
Bus 001 Device 008: ID 09da:9090 A4Tech Co., Ltd. XL-730K / XL-750BK / XL-755BK Mice
Bus 001 Device 007: ID 05d5:6782 Super Gate Technology Co., Ltd
Bus 001 Device 005: ID 1a40:0101 Terminus Technology Inc. Hub
Bus 001 Device 006: ID 222a:0001
Bus 001 Device 004: ID 05e3:0608 Genesys Logic, Inc. Hub
Bus 001 Device 002: ID 0bda:5411 Realtek Semiconductor Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Output of the command with the modem:
Bus 002 Device 002: ID 0bda:0411 Realtek Semiconductor Corp.
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 8087:0a2b Intel Corp.
Bus 001 Device 008: ID 09da:9090 A4Tech Co., Ltd. XL-730K / XL-750BK / XL-755BK Mice
Bus 001 Device 007: ID 05d5:6782 Super Gate Technology Co., Ltd
Bus 001 Device 005: ID 1a40:0101 Terminus Technology Inc. Hub
Bus 001 Device 006: ID 222a:0001
Bus 001 Device 004: ID 05e3:0608 Genesys Logic, Inc. Hub
Bus 001 Device 009: ID 2c7c:0125
Bus 001 Device 002: ID 0bda:5411 Realtek Semiconductor Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

I downloaded and flashed the sd card image, installed it in nano, and started ubuntu on board nano. I connected a monitor, keyboard, and mouse. Further work was done on nano.

  1. From Jetson Downloads Center i download “L4T Driver Package (BSP) Sources” as public_sources.tbz2
  2. Make dir ~/nvidia/ and copied tbz2-file here.
  3. tar -xjf public_sources.tbz2
  4. cd ~/nvidia/Linux_for_Tegra/source/public
  5. tar -xjf kernel_src.tbz2
  6. sudo apt install build-essential bc
  7. TEGRA_KERNEL_OUT=~/nvidia/mykernel
  8. cd ~/nvidia/Linux_for_Tegra/source/public/kernel/kernel-4.9/
  9. mkdir -p $TEGRA_KERNEL_OUT
  10. sudo make ARCH=arm64 O=$TEGRA_KERNEL_OUT tegra_defconfig
  11. sudo make ARCH=arm64 O=$TEGRA_KERNEL_OUT menuconfig
  12. sudo make ARCH=arm64 O=$TEGRA_KERNEL_OUT -j4
    And i get an error.

Аnd more. I do not know what to do next with the received files?

From the message above, I modified the option.c b usb_wwan.c files before executing steps 10, 11, and 12. Therefore, an error occurred when executing make.
WITHOUT changing these files, after creating the .config with command
sudo make ARCH = arm64 O = $ TEGRA_KERNEL_OUT tegra_defconfig
i run
sudo make ARCH=arm64 O=$TEGRA_KERNEL_OUT -j4
compilation is complete.

if i set
TEGRA_KERNEL_OUT=/usr/src/linux-headers-4.9.201-tegra-ubuntu18.04_aarch64/kernel-4.9/
i get an error

Is this natively on the Jetson? If cross compiled, then there is more to set up, but your basics look correct for a native compile.

You could try cross compile just to see if the cross compiler (available at the same download location) version helps. The native compiler will be a different version than the cross compiler, and although I could not give you any specifics, there are times when the compiler version matters.

However, since those are for wireless drivers, there is also a possibility that some firmware might be required. Is your menuconfig step enabling a WiFi driver?

Oops, just noticed the failure of the “make tegra_defconfig”. That should not fail (conceivably it could fail with the wrong compiler release, but not likely). This makes me wonder if you have the out of tree content. Normally, when NVIDIA ships kernel source, it has a tree like this for the source install:

sources
├── hardware
│   └── nvidia
├── kernel
│   ├── kernel-4.9
│   ├── nvgpu
│   └── nvidia
└── u-boot

The kernel source itself would be in the “kernel-4.9” location, and if you “cd ..”, then some out of tree content is visible for u-boot, hardware, and nvidia. Perhaps if the out of tree content is missing, then tegra_defconfig could fail to build.

I don’t have a U-BOOT folder

I got this structure

You are missing the out of tree content. When certain features are enabled in the kernel build it looks for that content via relative path. The “..” in a relative path is the parent directory to the current directory and the “.” is the current directory. There are places where there are enough “../” that it goes outside of the main kernel source code.

I won’t guarantee it, but there is a chance the issue you are running into is from not having that external code. I don’t know why the average kernel config would need U-Boot code, but possibly this would be required for cases when device tree is required…device tree can be used in both boot stages and the Linux kernel starting up.

I do notice that your output location is probably not valid (the “TEGRA_KERNEL_OUT=/usr/src/linux-headers-4.9.201-tegra-ubuntu18.04_aarch64/kernel-4.9/” is a privileged location and if it is truly for headers, then it probably modifies this in some unexpected way. Try instead to compile from pristine source without any modification (and everything in the above linux-headers... is no longer pristine) and output to a completely empty directory. For example (this assumes your user name is “ubuntu”, adjust as needed):

mkdir /home/ubuntu/kernel_out
cd /where/ever/pristine/source/is
sudo -s
make mrproper
export TEGRA_KERNEL_OUT=/home/ubuntu/kernel_out
make O=$TEGRA_KERNEL_OUT tegra_defconfig
exit

Does this work? If not, what do you see in the build log?

Hi!
I tried several different options. The last successful one is:
I downloaded the sd card image from the Jetson Download Center and flashed it using BalenaEtcher. After that, I plugged it into the jetson nano socket, connected the monitor, keyboard and mouse. All further work on board the JETSON NANO.

  1. From https://developer.nvidia.com/embedded/linux-tegra-r3251
  2. download public_sources.tbz2
  3. copy to ~/nvidia/
  4. tar -xjf public_sources.tbz2
  5. cd Linux_for_Tegra/source/public
  6. tar -xjf kernel_src.tbz2
  7. tar -xjf u-boot_src.tbz2
  8. sudo apt install build-essential bc libncurses5-dev libncursesw5-dev
  9. TEGRA_KERNEL_OUT=~/nvidia/mykernel
  10. cd ~/nvidia/Linux_for_Tegra/source/public/kernel/kernel-4.9/
  11. mkdir -p $TEGRA_KERNEL_OUT
  12. sudo make ARCH=arm64 O=$TEGRA_KERNEL_OUT tegra_defconfig
  13. sudo make ARCH=arm64 O=$TEGRA_KERNEL_OUT -j4

I ended up with a folder with files similar to the existing kernel files. I haven’t made any modifications to the files for the modem yet.
What should I do next?

If you are compiling natively, you’d skip the “ARCH=...”, but during cross compile, not only would you use that, you’d also have to name the toolchain. An example (change depending on release and toolchain):

export TEGRA_KERNEL_OUT=~/nvidia/mykernel
export CROSS_COMPILE=/usr/bin/aarch64-linux-gnu-
export ARCH=arm64

If you are cross compiling, did you skip CROSS_COMPILE=? If you are native compiling, be sure to not use ARCH=.

This is old and a bit out of date, but here is a long and detailed talk on compiling the kernel:
https://forums.developer.nvidia.com/t/tx2i-wifi-support/63839/2

Keep in mind that if this works, then you can save your “$TEGRA_KERNEL_OUT/.config”, completely wipe out the “$TEGRA_KERNEL_OUT” content, recreate this, copy your saved “.config” to “$TEGRA_KERNEL_OUT”, and start again, but use an editor to then make your modifications. The trick is to know that the tegra_defconfig worked once, and after modification of that config, to use a clean output directory (other than your starting .config).

If tegra_defconfig fails again, and if you are using the supplied toolchain in cross compile without any config modifications, then post the full compile log.

Note that if you use three backquote characters (the “`” character at the upper left of the keyboard) on a forum line, add content below this, and then add three more backquote characters, that it will preserve whitespace and add scrollbars even for long quotes. Like:
```
…log paste…
```
(I escaped the backquotes, but if you paste a log between those two lines without escape characters, then it will format nicely)