Jetson Nano - Control SPI CS through GPIO

Is there any one here who successfully tried controlling SPI CS using a GPIO ?

When I set SPI_NO_CS option, it throws error “Error: Invalid argument”.

I do:

unsigned mode = 0x3 | SPI_NO_CS;
ioctl(spi_fd, SPI_IOC_WR_MODE, &mode);

Is there a way to resolve this ? Thanks.

This is part of my bigger issue where one of my custom board having STM32F4 properly does SPI communication with nano using Jetpack 4.3, but doesn’t work with Jetpack 4.4 or 4.5.

Same SPI test and board on 2 different Jetpack!.
The issue is repeatable always!

I wanted to try some debugging steps by trying to manually control CS.

You may need cs-gpios like below to the device tree.

cs-gpios = <&gpio TEGRA_GPIO(C, 3) GPIO_ACTIVE_LOW>, <&gpio TEGRA_GPIO(C, 4) GPIO_ACTIVE_LOW>;

1 Like

Thanks Shane. I wanted this for SPI1 too. So I downloaded pin-mux excel sheet from downloads centre to figure out those pins: CS0=TEGRA_GPIO(B, 7) and CS1=TEGRA_GPIO(DD, 0).

Is there a way to add this as DT overlay without changing the current DTB ?
Will be helpful for deployment in the future ?

Do have idea for it now, but I think you can use dtc to decompile the dtb the add those context the compile it to dtb by dtc again.

Seems like i cannot use macros TEGRA_GPIO() and GPIO_ACTIVE_LOW in the dts files decompiled from dtb files. It throws parse error when used.