Error about Enabling SPI/SPIDev on 28.1

I tried the tutorial following Jetson/TX2 SPI - eLinux.org on real TX2. However, all those steps had passed, except

sudo ./flash.sh -r -k kernel-dtb jetson-tx2 mmcblk0p1

there is no flash.sh in TX2.

So I tried the tutorial on host machine. However, the errors occurred when i run the command

$ git clone http://github.com/jetsonhacks/buildJetsonTX2Kernel.git

 $ cd buildJetsonTX2Kernel
 $ ./getKernelSources.sh

This one

$ ./getKernelSources.sh

the errors:

Get:8 file:/var/visionworks-tracking-repo  Release [2,008 B]                   
Hit:13 http://us.archive.ubuntu.com/ubuntu xenial InRelease                    
Get:14 http://security.ubuntu.com/ubuntu xenial-security InRelease [107 kB] 
Get:15 http://us.archive.ubuntu.com/ubuntu xenial-updates InRelease [109 kB]
Get:16 http://us.archive.ubuntu.com/ubuntu xenial-backports InRelease [107 kB] 
Fetched 323 kB in 2s (144 kB/s)                               
Reading package lists... Done
Reading package lists... Done
Building dependency tree       
Reading state information... Done
pkg-config is already the newest version (0.29.1-0ubuntu1).
qt5-default is already the newest version (5.5.1+dfsg-16ubuntu7.5).
The following packages were automatically installed and are no longer required:
  linux-headers-4.13.0-36 linux-headers-4.13.0-36-generic
  linux-headers-4.13.0-45 linux-headers-4.13.0-45-generic
  linux-headers-4.15.0-30 linux-headers-4.15.0-30-generic
  linux-image-4.13.0-36-generic linux-image-4.13.0-45-generic
  linux-image-4.15.0-30-generic linux-image-extra-4.13.0-36-generic
  linux-image-extra-4.13.0-45-generic linux-modules-4.15.0-30-generic
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 166 not upgraded.
--2018-08-25 03:21:58--  http://developer.download.nvidia.com/embedded/L4T/r28_Release_v2.0/GA/BSP/tx2_sources.tbz2

Resolving developer.download.nvidia.com (developer.download.nvidia.com)... 58.216.33.87, 58.216.33.88, 58.223.168.55, ...
Connecting to developer.download.nvidia.com (developer.download.nvidia.com)|58.216.33.87|:80... connected.
HTTP request sent, awaiting response... 304 Not Modified
File ‘tx2_sources.tbz2’ not modified on server. Omitting download.

bzip2: (stdin) is not a bzip2 file.
tar: Child returned status 2
tar: Error is not recoverable: exiting now
tar: public_release/kernel_src.tbz2: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now
rm: cannot remove 'public_release': No such file or directory
./scripts/getKernelSources.sh: line 11: cd: kernel/kernel-4.4: No such file or directory
gzip: /proc/config.gz: No such file or directory
make: *** No rule to make target 'xconfig'.  Stop.<li></li>

the command can run on target TX2, but can not on host machine.

can anyone help me ? Plz.

After you run the JetPack-L4T-xxxx-linux-x64_b23.run the 64_TX2/Linux_for_Tegra folder should be gen and the flash.sh must be there.

Right, the file ‘flash.sh’ is on the host machine, but not on the target TX2.

Yes, you have to update the DTB from host instead of tegra device.

However, when I run the commands on host machine, this one can not work.

$ ./getKernelSources.sh

The errors occur like my fist posted.

Resolving developer.download.nvidia.com (developer.download.nvidia.com)... 58.216.33.87, 58.216.33.88, 58.223.168.55, ...
Connecting to developer.download.nvidia.com (developer.download.nvidia.com)|58.216.33.87|:80... connected.
HTTP request sent, awaiting response... 304 Not Modified
File ‘tx2_sources.tbz2’ not modified on server. Omitting download.

bzip2: (stdin) is not a bzip2 file.
tar: Child returned status 2
tar: Error is not recoverable: exiting now
tar: public_release/kernel_src.tbz2: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now
rm: cannot remove 'public_release': No such file or directory
./scripts/getKernelSources.sh: line 11: cd: kernel/kernel-4.4: No such file or directory
gzip: /proc/config.gz: No such file or directory
make: *** No rule to make target 'xconfig'.  Stop.<li></li>

If you want to get the kernel source to build on your host device please check the l4t-document in download center.

Hi~

I download the files manually.

Finally, the command runs without errors.

However, my host machine is X86, and the TX2 is ARM64.

when i run the command https://elinux.org/Jetson/TX2_SPI

$ cd /usr/src/kernel/kernel-4.4
 $ sudo make tegra18_defconfig

It does not work on host X86.

m@ubuntu:/usr/src/kernel/kernel-4.4$ sudo make tegra18_defconfig
  HOSTCC  scripts/kconfig/conf.o
  HOSTLD  scripts/kconfig/conf
***
*** Can't find default configuration "arch/x86/configs/tegra18_defconfig"!
***
scripts/kconfig/Makefile:111: recipe for target 'tegra18_defconfig' failed
make[1]: *** [tegra18_defconfig] Error 1
Makefile:542: recipe for target 'tegra18_defconfig' failed
make: *** [tegra18_defconfig] Error 2

Your compile thinks it is compiling for a desktop PC. Note this:

*** Can't find default configuration "arch/<u><b>x86</b></u>/configs/tegra18_defconfig"!

Are you trying to cross compile from a PC? If so, have you set up the environment with the cross tools? Here are some notes on this:
https://devtalk.nvidia.com/default/topic/1038175/jetson-tx2/tx2i-wifi-support/post/5274619/#5274619