Loading...
首页专栏正文

xavier nx平台调试spi从模式2

 
1人已赏
free-jdx 发布于 2021-06-09 17:29:44 浏览 2521 点赞 84 收藏 6

1. 前言

承接上篇调试记录 https://www.ebaina.com/articles/140000012611

2. 修改如下

硬件连接:

SPI1_MOSI<-->SPI3_MISO, 
SPI1_CLK<-->SPI3_CLK, 
SP1_CS0 <--> SPI3_CS0  
SPI1_CS1->SPI3_CS1.

设备树:

SPI1 has to be configured as Master and SPI3 has to be configured as slave in the dt and pinmux settings have to be updated. 
SPI1 DT:    
spi@3210000 {
        status = "okay";
        compatible = "nvidia,tegra186-spi";
        spi@0 {
            compatible = "spidev";
            reg = <0>;
            spi-max-frequency = <65000000>;
            controller-data {
                nvidia,enable-hw-based-cs;
            };
        };
    };

SPI3 DT
    spi@3230000 {
        status = "okay";
        compatible = "nvidia,tegra186-spi-slave";
        spi@0 {
            compatible = "spidev";
            reg = <0>;
            spi-max-frequency = <65000000>;
            controller-data {
                nvidia,enable-hw-based-cs;
            };
        };
     };

PINMUX settings are listed below for SPI1 and SP13 for loopback. 
    (Note: SPI1 and SP3 have an internal loopback connection for Xavier)

pinmux:

SPI_1 pinmux settings:
PADCTL_UART_SPI1_MISO_0  (0x0243d020) =  0x440;
PADCTL_UART_SPI1_MOSI_0 (0x0243d058) =  0x440;
PADCTL_UART_SPI1_SCK_0 (0x0243d040) =  0x440;
PADCTL_UART_SPI1_CS0_0 (0x0243d010) =  0x448;
PADCTL_UART_SPI1_CS1_0 (0x0243d050) =  0x448;

SPI_3 pinmux settings:
PADCTL_UART_SPI3_MISO_0  (0x0243d008) =  0x440;
PADCTL_UART_SPI3_MOSI_0 (0x0243d060) =  0x440;
PADCTL_UART_SPI3_SCK_0 (0x0243d048) =  0x444;
PADCTL_UART_SPI3_CS0_0 (0x0243d018) =  0x448;
PADCTL_UART_SPI3_CS1_0 (0x0243d028) =  0x448;

3. 更新dtb方式

(1)反编译更新

这种方式无需搭建SDK环境,比较便捷

(1)在/opt/nvidia/jetson-io/jetson-io.py目录下激活spi1、spi3
(2) dtb反编译
sudo dtc -I dtb -O dts -o ~/ user-custom.dts / boot / tegra194-p3668-all- p3509-0000-user-custom.dtb
(3)打开~/ user-custom.dts 并将spi3(spi@3230000)更改为slave
(4) dts编译
→sudo dtc - i dts -o dtb -o /boot/tegra194-p3668-all- p3509-0000-user-custom.dts
(5)重新启动jetson
(6)使用devmem2 (temporary)修改reg值
(7)连接:
SPI1_MOSI<–>SPI3_MISO, SPI1_CLK<–>SPI3_CLK, SP1_CS0 <–> SPI3_CS0 and SPI1_CS1<–>SPI3_CS1
(8)测试

(2)依赖SDK编译dts刷机更新dtb

(1) Jetson_Xavier_NX_Pinmux_Configuration_Template_v1.06使用.xlsm设置pinmux并创建DT
(tegra19x-jetson_xavier_nx_module-gpio-default。dtsi tegra19x-jetson_xavier_nx_module-padvoltage-default。dtsi tegra19x-jetson_xavier_nx_module-pinmux.dtsi)
(2)在Linux主机PC上通过SDK Manager安装Linux_for_Tegra
3)进入“/Linux_for_Tegra/kernel/pinmux/t19x”目录
(4)导入dtsi
(tegra19x-jetson_xavier_nx_module-gpio-default.dtsi, 
tegra19x-jetson_xavier_nx_module-padvoltage-default.dtsi, 
tegra19x-jetson_xavier_nx_module-pinmux.dtsi)
文件拷贝到Linux主机PC上,生成cfg文件。
;Python pinmux-dts2cfg.py
pinmux addr_info.txtdtsi 
gpio_addr_info.txt 
por_val.txt 
tegra19x-jetson_xavier_nx_module-pinmux.dtsi 
tegra19x-jetson_xavier_nx_module-gpio-default.dtsi 1.0>galen.cfg
(5)修改“galen.cfg”为“/Linux_for_Tegra/bootloader/t186ref/BCT/tegra19x-mb1-pinmux-p3668-a01”
(6) Flash with sdk manager(或sudo ./ Flash .sh jetson-xavier-nx-devkit mmcblk0p1 .

3. 调试记录

(1)运行出错

先运行从服务器,然后再运行主服务器, 但是当我运行从服务器(/dev/spidev2.0)时,我得到一个错误。

can’t send spi message: Invalid argument
Aborted (core dumped)
<<<<< dmesg >>>>>>
spi-tegra124-slave 3230000.spi: Tx is not supported in mode 0
spi-tegra124-slave 3230000.spi: spi can not start transfer, err -22
spi_master spi2: failed to transfer one message from queue

(2)继续修改SDK文件

a. Modify dt to slave /boot/tegra194-p3668-all-p3509-0000-user-custom.dtb

b. 修改pin配置表

c. 硬件连接

SPI1 MOSI (pin 19) <-> SPI3 MOSI (pin 37), SPI1 MISO (pin 21) <-> SPI3 MISO (pin 22), SPI1 SCK (pin 23) <-> SPI3 SCK (pin 13), SPI1 CS0 (pin 24) <-> SPI3 CS0 (pin 18), SPI1 CS1 (pin 26) <-> SPI3 CS1 (pin 16)

仍然得到从模式的错误

*本文仅代表作者观点,不代表易百纳技术社区立场。系作者授权易百纳技术社区发表,未经许可不得转载。

精彩评论

内容存在敏感词
打赏
打赏作者
free-jdx
您的支持将鼓励我继续创作!
金额:
¥1 ¥5 ¥10 ¥50 ¥100
支付方式:
微信支付
支付宝支付
微信支付
打赏成功!

感谢您的打赏,如若您也想被打赏,可前往 发表专栏 哦~

易百纳技术社区
确定要删除此文章、专栏、评论吗?
确定
取消
易百纳技术社区