In this post, I will discuss how to connect FLIR Lepton module with NVIDIA Jetson TK1.If you are new to Jetson TK1 and struggling on how to kick off the development with that , you can refer to my previous post to get to know about how to get started with NVIDIA Jetson TK1.In this post I assume, you have already installed Operating system(Ubuntu 14.04) using Jetpack or any other way. There is an excellent guide on how to enable SPI with Jetson TK1 and connect to Arduino Due, It helped me a lot understanding the hardware capabilities of Jetson TK1 to enable SPI communication , and how kernel device drivers and device tree helps to allow communication with SPI hardware in TK1 with programmers in Operating system level.It is better to first to go through that article up to part 3.My Jetson TK1 setup is Ubuntu 14.04 installed with Jetpack R21.5 and update the kernel with Grinch 21.3.4 for Jetson TK1.If you have already installed jetpack and running the OS following topic will cover how to install Grinch 21.3.4 kernel, and configure to use SPI.
I actually wanted to connect Lepton with Jetson without doing any Kernal modification , so I tried building official kernel enabling the SPI module but It didn't work and ended up with hanging the OS after few seconds of booting. So re-flash the Jetson and tried with latest Grinch kernel.As the steps mention here updating the stock kernel with Grinch kernel is easy.If you have fresh Jetpack installation(In my case Jetpack 21.5). Then run the following commands to update the kernel.
Download required firmware,kernel modules and boot zimage files
wget http://www.jarzebski.pl/files/jetsontk1/grinch-21.3.4/zImage
wget http://www.jarzebski.pl/files/jetsontk1/grinch-21.3.4/jetson-tk1-grinch-21.3.4-modules.tar.bz2
wget http://www.jarzebski.pl/files/jetsontk1/grinch-21.3.4/jetson-tk1-grinch-21.3.4-firmware.tar.bz2
Make sure you check the MD5 hash with following (It sometimes download 135K junk file, nothing in it)
a4a4ea10f2fe74fbb6b10eb2a3ad5409 zImage
3f84d425a13930af681cc463ad4cf3e6 jetson-tk1-grinch-21.3.4-modules.tar.bz2
f80d37ca6ae31d03e86707ce0943eb7f jetson-tk1-grinch-21.3.4-firmware.tar.bz2
Then extract and copy the files to system
sudo tar -C /lib/modules -vxjf jetson-tk1-grinch-21.3.4-modules.tar.bz2
sudo tar -C /lib -vxjf jetson-tk1-grinch-21.3.4-firmware.tar.bz2
sudo cp zImage /boot/zImage
If you are following original NVIDIA dev post sofa , stop here and the coping DTB file into /boot directory, Because we have to make some changes before copying the device tree blob file into /boot
spi0_0 {
#address-cells = <0x1>;
#size-cells = <0x0>;
compatible = "spidev";
reg = <0x0>;
spi-max-frequency = <0xF42400>;
spi-cpha;
nvidia,enable-hw-based-cs;
nvidia,cs-setup-clk-count = <0x1e>;
nvidia,cs-hold-clk-count = <0x1e>;
nvidia,rx-clk-tap-delay = <0x1f>;
nvidia,tx-clk-tap-delay = <0x0>;
};
};
I have only change the original <strong>0x17D7840 </strong>value to <strong>0xF42400</strong>, setting the max frequency value from 25MHz to 16MHz</li>
<li>Then compile the device tree source file again and copy it to <strong>/boot</strong> directory, to do that use the following command
```shell
./dtc -I dts -O dtb -o /boot/tegra124-jetson_tk1-pm375-000-c00-00.dtb tegra124-jetson_tk1-pm375-000-c00-00.dts
spi-tegra114 spi-tegra114.0: chipselect 0 already in use
spi_master spi0: spi_device register error /spi@7000d400/spi0_0
But it was quite confident that , I haven't using that port for any reason,So I further look for what could use this port other than spidev, and finally was able to find the answer from this post
This is because the touch controller fails to start up, becuase MCP251x has taken it already. This can be ignored, or you can disable the touch controller by editing /boot/extlinux/extlinux.conf and setting "touch_id=3@3"So simply open the /boot/extlinux/extlinux.conf file and change the touch_id value from 0@0 to 3@3, And that's it.Now restart the jetson and check whether the /dev/spidev0.0 is there , and most probably you should be able to locate it now.
So let's discuss how to connect the FLIR wire connections physically into Jetson TK1 GPIO adapter.
When I tried to connect the Lepton breakout board to Jetson , the harder part was to find the correct pins for SPI0 in Jetson J3A1 pad, Luckily descriptive explanation about all the GPIO port in Jetson was here. Then it was just a matter of picking up the correct pin from Jetson and connect to Lepton via a jumper cable, To make the process easy I have marked the correct pin number and it's named from above elinux wiki and the pin name appear in breakout board along with the pin number from right to left starting from SCL.
Before start connecting the lines , Make sure you have power off the jetson and unplug it from the power supply.
Now connect the cables and start the jetson TK1 to proceed with the next step, Capturing the data.
BTW Is I2C connections missing ? , No you can simply connect the SCL and SDA lines from Lepton breakout board to 18 GEN2I2CSCL3.3V and 20 GEN2I2CSDA3.3V and get the I2C working, But I haven't tested this yet.
One thing is we need to change the SPEED constant value in Lepton.py to SPEED = 16000000 to make it comply with the maxfrequency value we specified in device tree source, And also we need to change the MODE constant value to MODE = SPIMODE0 Because according to Jetson TK1 technical reference manual(TRM) ,SPI0 in jetson works in SPI mode0. After making those changes run the <a href="https://github.com/groupgets/pylepton/blob/master/pyleptoncapture">pylepton_capture script with sudo permission and you wold be able to take a thermal grayscale image from Lepton.
Here you can find some raw sample jpg images along with the value received from the Lepton before converting the values to 0-255 range.
References :