The procedure described here is based on the following. Thanks!
Jetson Nano devkit works with resistive 4" Waveshare touchscreen - success story
(1) Initial setup
Follow the official procedure to set up and update to the latest version.
JetPack SDK | NVIDIA Developer
(2) Install the kernel driver.
(a) git clone GitHub - JetsonHacksNano/buildKernelAndModules: Build the Linux Kernel and Modules on board the NVIDIA Jetson Nano Developer Kit
(b) cd buildKernelAndModules
(c) . /getKernelSources.sh
(d) . /editConfig.sh
In Device drivers - Input device suppiort - Touchscreens select âADS7846/TSC2046/AD7873 and AD(S)7843 based touchscreensâ and mark it with asterisk (driver built into kernel). Exit, exit, exit, exit, yes. Way too boring :)
(e) . /makeKernel.sh
It takes about 70 minutes.
(f) . /copyImage.sh
(g) reboot
(3) Enable SPI and get the device tree file.
(a) Connect to Jetson via SSH. (The display is too small to work with a 5" LCD)
(b) Enable SPI using jetson-io.py. Note that you will edit the custom device tree file later, so make sure you check the file name carefully.
(i) sudo /opt/nvidia/jetson-io/jetson-io.py
Configure 40-pin expansion header
Mark âspi1â with asterisk
Back
Save and exit without rebooting
At this step copy the resulting file location.
(You may want to copy this file name to an editor or something to make it easier later)
Example: /boot/kernel_tegra210-p3448-0003-p3542-0000-user-custom.dtb
(4) Edit the device tree to register the touchscreen.
(a) Create a working folder and move to it.
mkdir SPI
cd SPI
(b) Copy the device tree file and decompile it.
cp /boot/kernel_tegra210-p3448-0003-p3542-0000-user-custom.dtb .
mv kernel_tegra210-p3448-0003-p3542-0000-user-custom.dtb kernel_tegra210-p3448-0003-p3542-0000-user-custom.dtb.orig
dtc -O dts -o tegra.dts kernel_tegra210-p3448-0003-p3542-0000-user-custom.dtb.orig
(c) Open tegra.dts in an editor and edit the device tree.
In the spi@7000d400 section, rewrite spi@1.
Before the change
spi@1 {
compatible = "tegra-spidev";
reg = <0x1>;
spi-max-frequency = <0x1f78a40>;
controller-data {
nvidia,enable-hw-based-cs;
nvidia,rx-clk-tap-delay = <0x7>;
};
};
After the change
spi@1 {
// 5" 800x600 LCD for Raspi
// SKU:6320629805
// XPT2046 Controller (ADS7846)
// Speed = 50000
// pmax = 255, xohms = 150
// xmin = 200, xmax = 3900
// ymin = 200, ymax = 3900
// compatible = "ti,ads
compatible = "ti,ads7846";
reg = <0x1>; // CS1 of SPI
spi-max-frequency = <50000>; // 50000
nvidia,enable-hw-based-cs;
nvidia,rx-clk-tap-delay = <0x7>;
interrupt-parent = <0x5a>; // phandle of "gpio@6000d000"
interrupts = <13 0>; // pin 22 is gpio13 for IRQ
pendown-gpio = <0x5a 13 0>;
vcc-supply = <0x4b>; // phandle of "regulator@2"
//ti,swap-xy = <0x1>; // uncomment to swap axes
ti,x-min = [00 c8]; // 200
ti,x-max = [0f 3c]; // 3900
ti,y-min = [00 c8]; // 200
ti,y-max = [0f 3c]; // 3900
ti,x-plate-ohms = [00 96]; // 150
ti,pressure-max = [00 ff]; // 255
wakeup-source;
controller-data {
nvidia,cs-setup-clk-count = <0x1e>;
nvidia,cs-hold-clk-count = <0x1e>;
nvidia,rx-clk-tap-delay = <0x1f>;
nvidia,tx-clk-tap-delay = <0x0>;
};
};
(d) Compile tegra.dts and write it to /boot. You will get a lot of warnings, but ignore them.
dtc -O dtb tegra.dts -o kernel_tegra210-p3448-0003-p3542-0000-user-custom.dtb
sudo cp tegra210-p3448-0000-p3449-0000-b00-user-custom.dtb /boot
(e) reboot and you are done.
(4) Reference: dmesg | grep -i spi
[ 0.425327] iommu: Adding device 7000d400.spi to group 7
[ 0.425614] iommu: Adding device 7000d600.spi to group 8
[ 0.425890] iommu: Adding device 70410000.spi to group 9
[ 1.110122] tegra-qspi 70410000.spi: Prod settings list not found
[ 1.111344] qspi_mtd spi32766.0: MX25U3235F (4096 Kbytes)
[ 1.111354] qspi_mtd spi32766.0: mtd .name = spi32766.0, .size = 0x400000 (4MiB) .erasesize = 0x00001000 (4KiB) .numeraseregions = 0
[ 1.131749] ads7846 spi0.1: touchscreen, irq 110
[ 1.135700] input: ADS7846 Touchscreen as /devices/7000d400.spi/spi_master/spi0/spi0.1/input/input0
Thatâs all.
Translated with DeepL/Translator (free version)