Hello,
- Jetson Nano Developer Kit with JetPack 4.6.1
I am trying to configure GPIO pins within the device tree, and I am unable to get a wakeup pin working. The sources I have been reading off of are:
- Jetson/FAQ/BSP/Nano Wakeup Pin - eLinux.org
- Jetson/Device Tree - eLinux.org
- How to determine the hexadecimal encoding of GPIO?
Below are the changes I have made to the device tree in attempt to configure GPIO wakeup Pin 36.
sudo apt update
sudo apt install device-tree-compiler
cd /boot
dtc -I dtb -O dts -o extracted.dts tegra210-p3448-0000-p3449-0000-b00.dtb
gedit extracted.dts
In extracted.dts, I added the wakeup_key node to gpio-keys:
gpio-keys {
compatible = "gpio-keys";
gpio-keys,name = "gpio-keys";
status = "okay";
disable-on-recovery-kernel;
power {
label = "Power";
gpios = <0x5b 0xbd 0x1>;
linux,code = <0x74>;
gpio-key,wakeup;
debounce-interval = <0x1e>;
nvidia,pmc-wakeup = <0x3c 0x0 0x18 0x0>;
};
forcerecovery {
label = "Forcerecovery";
gpios = <0x5b 0xbe 0x1>;
linux,code = <0x74>;
gpio-key,wakeup;
debounce-interval = <0x1e>;
};
wakeup_key {
label = "wakeup_key";
gpios = <0x5b 0xd1 0x1>;
linux,code = <0x74>;
gpio-key,wakeup;
debounce-interval = <0x1e>;
nvidia,pmc-wakeup = <0x3c 0x0 0x6 0x0>;
};
};
How I determined the hexidecimal values for the fields of wakeup_key:
For gpios = <0x5b 0xd1 0x1>;
I determined from source #3 from above, the values should be <pin_field pin_number pin_state>
0x5b
comes from the phandle field of thegpio@6000d000
node in extracted.dts0xd1
comes from me determining that Pin 36 has Name “UART_2_CTS” from the Jetson Nano GPIO Header PINOUT, and I then found UART2_CTS in the Jetson Nano Pinmux Spreadsheet in row 153, and in column B, UART2_CTS has B01 SODIMM value of 209 which is 0xd1 in hexidecmal0x1
is state 1 for the pin
gpio@6000d000
in extracted.dts:
gpio@6000d000 {
compatible = "nvidia,tegra210-gpio", "nvidia,tegra124-gpio", "nvidia,tegra30-gpio";
reg = <0x0 0x6000d000 0x0 0x1000>;
interrupts = <0x0 0x20 0x4 0x0 0x21 0x4 0x0 0x22 0x4 0x0 0x23 0x4 0x0 0x37 0x4 0x0 0x57 0x4 0x0 0x59 0x4 0x0 0x7d 0x4>;
#gpio-cells = <0x2>;
gpio-controller;
#interrupt-cells = <0x2>;
interrupt-controller;
gpio-ranges = <0x40 0x0 0x0 0xf6>;
status = "okay";
gpio-init-names = "default";
gpio-init-0 = <0x41>;
gpio-line-names = [00 00 00 00 00 00 00 00 00 00 00 00 53 50 49 31 5f 4d 4f 53 49 00 53 50 49 31 5f 4d 49 53 4f 00 53 50 49 31 5f 53 43 4b 00 53 50 49 31 5f 43 53 30 00 53 50 49 30 5f 4d 4f 53 49 00 53 50 49 30 5f 4d 49 53 4f 00 53 50 49 30 5f 53 43 4b 00 53 50 49 30 5f 43 53 30 00 53 50 49 30 5f 43 53 31 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 47 50 49 4f 31 33 00 00 00 00 00 00 00 00 00 00 00 00 55 41 52 54 31 5f 52 54 53 00 55 41 52 54 31 5f 43 54 53 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 49 32 53 30 5f 46 53 00 49 32 53 30 5f 44 49 4e 00 49 32 53 30 5f 44 4f 55 54 00 49 32 53 30 5f 53 43 4c 4b 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 47 50 49 4f 30 31 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 47 50 49 4f 30 37 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 47 50 49 4f 31 32 00 00 00 00 00 00 47 50 49 4f 31 31 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 47 50 49 4f 30 39 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 53 50 49 31 5f 43 53 31 00 00 00 00 00 00 00 00];
linux,phandle = <0x5b>;
phandle = <0x5b>;
For linux,code = <0x74>;
I found that <KEY_POWER> is 0x74 from Key Code Values for Linux. I am not sure if it should be <KEY_WAKEUP> which is 0x8f.
For debounce-interval = <0x1e>;
, I just took the 0x1e value from the power and forcerecovery nodes above wakeup_key
For nvidia,pmc-wakeup = <0x3c 0x0 0x6 0x0>;
I determined from source #3 from above, the values should be <pmc_handle event_type event_offset trigger_type>
0x3c
comes from the phandle of thepmc@7000e400
node of extracted.dts0x0
comes from the options of0 = PMC_WAKE_TYPE_GPIO
and1 = PMC_WAKE_TYPE_EVENT
. I chose PMC_WAKE_TYPE_GPIO because of source #1 from above.0x6
comes row 153, column Y (UART2_CTS, Wake) of the Jetson Nano Pinmux Spreadsheet having the value of wake6. This is a value I am unsure about.0x0
comes from0 = PMC_TRIGGER_TYPE_NONE
pmc@7000e400
in extracted.dts:
pmc@7000e400 {
compatible = "nvidia,tegra210-pmc";
reg = <0x0 0x7000e400 0x0 0x400>;
#padcontroller-cells = <0x1>;
status = "okay";
clocks = <0x26 0x125>;
clock-names = "pclk";
nvidia,secure-pmc;
clear-all-io-pads-dpd;
pinctrl-names = "default";
pinctrl-0 = <0x7d>;
nvidia,restrict-voltage-switch;
#nvidia,wake-cells = <0x3>;
nvidia,invert-interrupt;
nvidia,suspend-mode = <0x0>;
nvidia,cpu-pwr-good-time = <0x0>;
nvidia,cpu-pwr-off-time = <0x0>;
nvidia,core-pwr-good-time = <0x11eb 0xf24>;
nvidia,core-pwr-off-time = <0x9899>;
nvidia,core-pwr-req-active-high;
nvidia,sys-clock-req-active-high;
linux,phandle = <0x3c>;
phandle = <0x3c>;
After adding the wakeup_key node to gpio-keys in extracted.dts
cd /boot
dtc -I dts -O dtb -o tegra194-p3668-all-p3509-0000.dtb extracted.dts
cd /boot/extlinux
gedit extlinux.conf
I added the following line to the primary label in /boot/extlinux/extlinux.conf:
FDT /boot/tegra210-p3448-0000-p3449-0000-b00.dtb
Below is waht /boot/extlinux/extlinux.conf now looks like. I am unsure if this configuration is correct:
TIMEOUT 30
DEFAULT JetsonIO
MENU TITLE L4T boot options
LABEL primary
MENU LABEL primary kernel
LINUX /boot/Image
FDT /boot/tegra210-p3448-0000-p3449-0000-b00.dtb
INITRD /boot/initrd
APPEND ${cbootargs} quiet root=/dev/mmcblk0p1 rw rootwait rootfstype=ext4 console=ttyS0,115200n8 console=tty0 fbcon=map:0 net.ifnames=0
# When testing a custom kernel, it is recommended that you create a backup of
# the original kernel and add a new entry to this file so that the device can
# fallback to the original kernel. To do this:
#
# 1, Make a backup of the original kernel
# sudo cp /boot/Image /boot/Image.backup
#
# 2, Copy your custom kernel into /boot/Image
#
# 3, Uncomment below menu setting lines for the original kernel
#
# 4, Reboot
# LABEL backup
# MENU LABEL backup kernel
# LINUX /boot/Image.backup
# INITRD /boot/initrd
# APPEND ${cbootargs}
LABEL JetsonIO
MENU LABEL Custom Header Config: <CSI Camera IMX219 Dual>
LINUX /boot/Image
FDT /boot/kernel_tegra210-p3448-0000-p3449-0000-b00-user-custom.dtb
INITRD /boot/initrd
APPEND ${cbootargs} quiet root=/dev/mmcblk0p1 rw rootwait rootfstype=ext4 console=ttyS0,115200n8 console=tty0 fbcon=map:0 net.ifnames=0
I then rebooted the system
sudo reboot
Note: GPIO Pin 36 is gpio51 in the Jetson Nano GPIO Header PINOUT
After reboot:
echo 51 > /sys/class/gpio/export
echo in > /sys/class/gpio/gpio51/direction
sudo systemctl suspend
I then connect a wire to Pin 36 and Pin 2 (5V Pin), and then I short the wires to try to wakeup the Jetson Nano. Unfortunately, this does work with all the above configuration. If I am missing any steps or have incorrect configuration and anyone is able to help or provide insight, that would be very greatly appreciated!