Overclocking - Q-engineering
Q-engineering
Q-engineering
Go to content
images/empty-GT_imagea-1-.png
Overclocking the Jetson Nano

Overclocking Jetson Nano CPU to 2 GHz and GPU to 1 GHz

Last updated: July 19, 2022

Introduction.

In this tutorial, the overclocking of the Jetson Nano is discussed. Overclocking your Nano is not so easy as a Raspberry Pi where only a simple line in a file will do all the work. If you want to overclock the Jetson Nano, a large part of the operating system (the Terga kernel) need to be rebuild. A job even advanced users will not lightly do.
Warnings.
First, please read the theory of overclocking in the Raspberry Pi guide here. It demonstrates why your overclocked Nano may work on Monday but not on Fryday. It also explains how much the life span of your Jetson Nano will shorten when overclocked.

The second warning is about the procedure. As said before, a part of your operating system is replaced. When not done right, you end up with a dead Jetson Nano, not booting any more. Take precautions by backing up all your software. Or even better, use a brand new SD-card with the latest Jetpack. Please, follow the procedure by the letter.

Last warning. Although written with the utmost care and thoroughly tested, we do not accept any responsibility whatsoever. It's your adventure.
Showstopper.
noneThe Updater can replace the entire kernel. Obviously, it will completely undo your overclocking! Be careful and check the downloads in advance. The same goes for the $ sudo apt-get upgrade command. Once NVIDIA releases a new L4T kernel, you will be forced to either ignore the update or recompile the core after backing up all your work first.
Software Updater
Sudo upgrade

Hardware.

There are some system requirements before we start with the overclocking.
Your power supply must be more than 10 Watt. We use a 20 Watt supply. Once overclocked, your Nano will certainly crash when sudden power drops occur due to heavy power demands.
Cooling the Jetson Nano with a fan is never a bad idea. Although already proper cooled with a heatsink, it will generate a lot of heat when running at its maximum speed. And, as mentioned before, a high temperature will shorter the life span of your Nano. We use a simple PWM controlled fan.

PWM Fan

The procedure is written and tested on a Jetson Nano with a JetPack 4.4, 4.5 and 4.6.1 [L4T 32.7.1]. Please check your version with jtop. Notice also the actual temperature of the Jetson Nano and the free space on the disk.
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install python-pip
$ sudo -H pip install -U jetson-stats
$ sudo reboot
none

Since we are going to build the operating system from scratch, we will need a lot of disk space to store all the compiled files. You must have 9 GB free on your disk. With less, it will crash. Once the new overclocked OS is running on your Jetson Nano, the memory is released. So it is only for temporary use.

Checklist.
  • Your software has been backed up.
  • You have a 10 W or more power supply.
  • You have L4T version 32.4.3 on your Nano.
  • You have more than 9 GB of free disk space.

Installing the source code.

You must first install the source code. It can be found on the NVIDIA development page. You must have an account with NIVIA to gain access. This takes a few extra steps.

JetPack download centre

Do not use the 34.1.1 version. This is the new JetPack 5.1, unfortunately not suitable for the Jetson Nano.

Download JetPack 4.6.1 source


Download the file. It will most likely stored in ~/Downloads. Move it to home and unzip the tarball with the following commands.
# move to HOME if the file is located in Downloads
$ cd ~
$ mv ~/Downloads/public_sources.tbz2 public_sources.tbz2
# unpack
$ tar -xvf public_sources.tbz2
$ cd Linux_for_Tegra/source/public
$ tar -xf kernel_src.tbz2
Now that the source code is loaded we can replace two files. Both define the clock frequency in different code blocks. Along with two scripts that will be used later, they can all be downloaded from our GitHub page.
If your folder happens to be named kernel/kernel-5.10, you downloaded the wrong version. As mentioned earlier, JetPack 5.1 is not suitable for the Jetson Nano. Please download the correct version before continuing.
# download the code
$ cd ~
$ git clone https://github.com/Qengineering/Jover.git
# replace both files
$ cd ~/Linux_for_Tegra/source/public
$ cp ~/Jover/clk-tegra124-dfll-fcpu.c kernel/kernel-4.9/drivers/clk/tegra/clk-tegra124-dfll-fcpu.c
$ cp ~/Jover/tegra210-dvfs.c kernel/kernel-4.9/drivers/soc/tegra/tegra210-dvfs.c
To be clear, screen dumps of both folders.

Clk_tegra124_over

Soc_tegra124_over

Rebuilding the kernel.

The next action is to actually rebuild the operating system. It will happen in three stages. We give screen dumps after each phase so that you can see if everything is going according to plan.
In folder ~/Linux_for_Tegra/source/public you find the nvbuild.sh script. That's the first phase. Run it with the following command.

none
# assuming your still in ~/Linux_for_Tegra/source/public
$ sudo ./nvbuild.sh
The compilation is ready after more than an hour. Meanwhile, about 7 GByte of space on your disk has been used by intermediate files.

Stage1_rdy

The next stage is the building of the modules. This is been done with the actions below.
# assuming your still in ~/Linux_for_Tegra/source/public
$ cd kernel/kernel-4.9
$ sudo make modules
The action takes about 13 minutes and generates another 1 GByte on your disk.

Make_Modules_Rdy

Now, install the modules.
$ sudo make modules_install
After successfully installing the modules, your screen will look like this.

Install_Modules_Rdy

The last action is to build some additional kernel drivers.
$ sudo make
$ sudo make install
Install_Rdy_3

Once all the building is done, you will find an image file in ~/Linux_for_Tegra/source/public/kernel/kernel-4.9/arch/arm64/boot/.

LocationImage

This image replaces the original one in /boot/. After a reboot, your Jetson Nano is overclocked! One remark, you cannot copy the image to another Nano, hoping to overclock this one with only a simple replacement. You have to replace much more kernel files, all already done by the sudo make install and sudo make modules_install commands.
Let see what the original frequencies are before rebooting.

Freq_Before
# assuming your still in ~/Linux_for_Tegra/source/public/kernel/kernel-4.9
$ sudo cp arch/arm64/boot/Image /boot/Image
$ sudo reboot
After reboot hopefully you get the next clock freqencies with the command $ sudo /usr/bin/jetson_clocks --show.

Freq_after

Cleaning.

When you are satisfied with the result, the disc cleaning can begin. If you delete all temporary files that are no longer in use, you will free up about 9 GByte of your disk. Follow the following commands.
$ cd ~
$ sudo rm -rf Linux_for_Tegra
$ rm public_sources.tbz2

Max frequency.

As explained here, overclocking does not have a strict upper limit. Light tasks can still work even at 2.2 GHz. Heavy AI applications are bound to crash at that speed. Most will operate at up to 1.9 GHz. You will have to experiment to find a suitable frequency on which your app will still run stably. On our Jetson Nano we have the CPU at 1.9 GHz and the GPU at 0.95 GHz.

To set the upper limit of the clocks, there are two simple scripts in the GitHub repo. You have overclock.sh where the actual frequencies are declared. And rc.local which will run overclock.sh on startup.
overclock.sh

#!/bin/bash

sleep 15
echo 1900000 > /sys/devices/system/cpu/cpu1/cpufreq/scaling_max_freq
echo 950000000 > /sys/devices/57000000.gpu/devfreq/57000000.gpu/max_freq
The first line (#!/bin/bash) is a so-called shebang which let the script executed as bash shell.

The next line (sleep 15) holds the execution for 15 seconds. It turns out that the boot sequence first calls the rc.local script, which in its turn, call the overclock script. Next, the boot continues with filling the PLL's of the clock hardware and setup the clock governer. This action will cancel any previous instructions to the clock. In other words, the settings in overclock.sh has no bearing. The 15 second delay allows the boot sequence to set the clock registers first, where after the script can set the maximum clock speed permanently.

The third line defines the maximum CPU clock frequency, here 1900000 (kHz) or 1.9 GHz.
The last line dictates the maximum GPU frequency. In this case, 950000000 (Hz), which gives a clock rate of 950 MHz.
rc.local

#!/bin/bash

sudo /etc/init.d/overclock.sh &
For those unfamiliar with rc.local, this script always runs at startup automatically when present in the /etc folder.
The first line is the shebang which let the script executed as bash shell. This line must be present if you expand an already existing rc.local on your Jetson Nano.
The next line calls the overclock script. Note the ampersand at the end of the line, which is crucial. It let the overclock script execute in a separate thread while continuing the execution. Remember, the overclock script expects within 15 seconds that the boot sequence is ready with the clock registers so it can set maximum frequency. Without the ampersand, rc.local will wait until the overclock script has finished before continuing.
$ cd ~
# copy the overclock script
$ sudo cp ~/Jover/overclock.sh /etc/init.d/overclock.sh
$ sudo chmod 755 /etc/init.d/overclock.sh
# check if you have rc.local on your Nano
$ sudo find /etc -name "rc.local"
# if found, merge the contents. if not, continue by copying
$ sudo cp ~/Jover/rc.local /etc/rc.local
$ sudo chmod 755 /etc/rc.local
$ sudo reboot
After the restart, your maximum clock frequencies are activated, as you can see below.

Max_1G9

Again, these maxima are not strict limits. It is more trail and error. With a simple text editor like nano, boundaries easily are altered.
# install nano if you like
$ sudo apt-get update
$ sudo apt-get install nano
# edit the script
$ sudo nano /etc/init.d/overclock.sh
# run the script to set the new limits
$ sudo /etc/init.d/overclock.sh
Alter max frequency

Again, these maxima are not strict limits. It is more trail and error. With a simple text editor like nano, boundaries easily are altered. Please give reasonable figures.
# final cleaning
$ sudo rm -rf ~/Jover

Additional information.

You can find additional information on this NVIDIA page, Another source we used was the eLinux.org page.

Some last remarks. In the text, you read that the jetson_clocks script also can store and reload settings.
That's correct. Unfornuality the maximum clock speed is not supported.

The clock frequency on a Jetson Nano is very dynamic. In contrast to a Raspberry Pi where there are only two speeds (min and max), the Nano has lots of possible frequencies. Which one used depends on the task on hand and will be set by the so-called governer, all to keep power consumption as low as possible. Below the possible frequencies before overclocking.

availible_before

And these are the frequencies after overclocking.

availible_after

Note the commands. These are slightly different compared to the documentation.

By the way, the paragraph about making settings stick, does not apply in our case. The text refers to the governor, not the maximum clock frequency.

Somewhat confusing is the lscpu command. It gives you the maximum governer clock frequency found with the command cat /sys/.../scaling_available_frequencies. Not the actual limited value set by sys/.../scaling_max_freq, as can be seen below.

lscpu_jetson

Final remark.

Use a new SD card. Old and worn out cards cause problems when the Jetson Nano is overclocked. They can crash the system when writes are stacked due to slow processing.
Thanks.
We like to thank <skrilax@gmail.com> for all the hard work modifying tegra210-dvfs.c and clk-tegra124-dfll-fcpu.c. Without his work, this guide would not have been possible.
images/GithubSmall.png
images/YouTubeSmall.png
images/SDcardSmall.png
Back to content