Enable hardware SPI on Xillinux

时间:2016-08-31 18:49:30

标签: embedded-linux fpga xilinx vivado zynq

I have a MicroZed board with Xillinux 1.3 running on it. I wanted to interface an external SPI ADC to it, and write an application in linux to read values from the ADC. Zynq device's hardware SPI interface isn't enabled in Xillinux. How can I go about enabling it, I would have to recompile the FSBL and U-boot, but I don't know where to start. Can I just modify the Xillinux's Vivado design and proceed from there or will I have to start from scratch?

2 个答案:

答案 0 :(得分:0)

您不必修改FSBL或U-boot。您只需将SPI控制器添加到器件树并更新可编程逻辑,以便SPI引脚连接到ADC。

Xilinx SDK具有创建设备树文件的工具,如https://developers.google.com/protocol-buffers/docs/cpptutorial页面所述。

我通常手动编辑.dts文件,但您仍需要运行dtc将其转换为二进制格式,如该页所述。

例如,这是一个Build Device Tree Blob板的.dts片段,使SPI连接到闪存芯片:

&spi0 {
    status = "okay";
    num-cs = <4>;
    is-decoded-cs = <0>;
    eeprom: at25@0 {
        at25,byte-len = <8192>;
        at25,addr-mode = <2>;
        at25,page-size = <32>;

        compatible = "atmel,at25";
        reg = <2>;
        spi-max-frequency = <1000000>;
    };
};

答案 1 :(得分:0)

你必须做两步。

1-修改内核源代码中主板的硬件描述符文件(.h)并添加spi设备。首先,看看电路板的原理图和processo的数据表,确保使用正确名称的正确设备

2-在你的内核配置上添加spidev

现在构建并启动内核,如果你检查/ dev /你应该找到spidev **。