Yocto with i.MX287EVK board

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Yocto with i.MX287EVK board

Jump to solution
3,325 Views
drb55
Contributor III

Hi,

I have been trying for the better part of two weeks to add SPI functionality to the Yocto image for the i.MX287EVK board. The current setup:

             i.MX287EVK board   

             Ubuntu 64 bit 22.04 VM 

             Dunfell release of Yocto 

            core-image-full-cmdline 

The image builds with no errors and boots from an SD card.

Is the following a true statement for the i.MX287 board?

There are two ways of using the user mode SPI device driver. To be able to do that, you need to enable your device with the spidev driver. An example would be as follows:                                                           
   spidev@0x00 {
   compatible = "spidev";
   spi-max-frequency = <800000>; /* It depends on your device */
   reg = <0>; /* correspond to chip select 0 */
   };
You can call either the read/write functions or an ioctl(). By calling read/write, you can only read or write at a time. If you need full duplex read and write, you have to use the Input Output Control (ioctl) commands.  

I would like to use SPI in full duplex mode.

What specific modifications do I need to make (DTS files, kernel configuration or anything else) if any, to enable the SPI functionality using Input Output Control (ioctl) commands in the hardware.

If the Input Output Control (ioctl) commands are not usable how are the read/write commands implemented (specifics)?

A sample of the user application code in C++ would also be very appreciated.

iMX287 

Labels (1)
Tags (4)
0 Kudos
Reply
1 Solution
2,825 Views
Sanket_Parekh
NXP TechSupport
NXP TechSupport

Hi @drb55 

I hope you are doing well.
 
One can use the below commands to test spidev.
# spidev_test -h // to get help 
# spidev_test -D /dev/spidev1.1 -v
 
Additionally one can refer to test/mxc_spi_test.
 
As you are using a chip select 1 for spidev, pin mux definition for the same is not available in dts.
 
Thanks & Regards,
Sanket Parekh

View solution in original post

0 Kudos
Reply
9 Replies
3,281 Views
Sanket_Parekh
NXP TechSupport
NXP TechSupport

Hi @drb55 ,

I hope you are doing well. 
 
One can use ioctl with SPI_IOC_MESSAGE command for full duplex transfer example using spidev. 
Please refer to /tools/spi/spidev_fdx.c in the kernel source. 
 
Thanks & Regards,
Sanket Parekh
0 Kudos
Reply
3,105 Views
drb55
Contributor III

Hi,

Thanks for the response, but it didn't resolve the problem. What is the correct entry for the compatible field if the device is an i.MX287.

According to the Linux Kernel documentation "spidev" is no longer supported 

SPI userspace API — The Linux Kernel documentation

It used to be supported to define an SPI device using the “spidev” name. For example, as .modalias = “spidev” or compatible = “spidev”. But this is no longer supported by the Linux kernel and instead a real SPI device name as listed in one of the tables must be used.

Not having a real SPI device name will lead to an error being printed and the spidev driver failing to probe.

Thanks,

Dan

0 Kudos
Reply
3,060 Views
Sanket_Parekh
NXP TechSupport
NXP TechSupport

Hi @drb55 

I hope you are doing well.

In the latest version of spidev.c driver, support for the "spidev" compatible string is removed because of the below reason.

Since spidev is a detail of how Linux controls a device rather than a description of the hardware in the system we should never have a node

described as "spidev" in DT, any SPI device could be a spidev so this is just not a useful description.

One can use any of the compatible strings in device tree node from the below table or add a hardware-specific string in below list at spidev. c.

static const struct of_device_id spidev_dt_ids[] = {

{ .compatible = "rohm,dh2228fv" },

{ .compatible = "lineartechnology,ltc2488" },

{ .compatible = "ge,achc" },

{ .compatible = "semtech,sx1301" },

{ .compatible = "lwn,bk4" },

{ .compatible = "dh,dhcom-board" },

{ .compatible = "menlo,m53cpld" },

{},

};

Thanks & Regards,

Sanket Parekh

0 Kudos
Reply
3,055 Views
drb55
Contributor III

Hi,

Thank you for the response.

Is there an application note or document that describes all of the steps necessary (like a checklist) to add an interface (SPI, I2C etc.) to the hardware description files (Including dtsi, dts, spidev.c and other files) and then test that the interface is functional.

Having one document for future reference would be very helpful.

Thanks

Dan

 

0 Kudos
Reply
3,030 Views
Sanket_Parekh
NXP TechSupport
NXP TechSupport

Hi @drb55 

I hope you are doing well.
 
One can refer to below mentioned documents : 
1. AN5125 for device tree introduction.
2. Chapter - 11 Unit Tests in i.MX Linux Reference Manual
3. imx-test for unit test source code
 
Thanks & Regards,
Sanket Parekh

0 Kudos
Reply
3,007 Views
drb55
Contributor III

Hi,

Thank you for the documents, unfortunately the spidev is not working. I have spent many hours on this effort to no avail. I have included the dts and dtsi files as a reference, any suggestions to resolve this are greatly appreciated.                                                                                                                                                                                  

SPI user mode enabled in the kernel.  

drb55_0-1676050585258.png

ls /dev/spidev*
/dev/spidev1.1 /dev/spidev2.0

Symbols file/directory is not loaded for some reason.                                                                                   
ls -l /proc/device-tree/__symbols__ | grep spi
ls: cannot access '/proc/device-tree/__symbols__': No such file or directory

root@imx28evk:/# dmesg | grep spi
[ 5.288199] mxs-spi 80014000.spi: registered master spi1
[ 5.290709] spi spi1.0: setup mode 0, 8 bits/w, 40000000 Hz max --> 0
[ 5.299155] spi-nor spi1.0: unrecognized JEDEC id bytes: ff ff ff ff ff ff
[ 5.307742] mxs-spi 80014000.spi: registered child spi1.0
[ 5.308037] spi spi1.1: setup mode 0, 8 bits/w, 5000000 Hz max --> 0
[ 5.315865] mxs-spi 80014000.spi: registered child spi1.1
[ 5.320976] mxs-spi 80016000.spi: registered master spi2
[ 5.322298] spi spi2.0: setup mode 0, 8 bits/w, 5000000 Hz max --> 0
[ 5.327063] mxs-spi 80016000.spi: registered child spi2.0
[ 5.788912] mxs-mmc 80010000.spi: Got WP GPIO
[ 5.823180] mxs-mmc 80010000.spi: initialized

 Thanks,                                                                                                                                                                       Dan

0 Kudos
Reply
2,924 Views
Sanket_Parekh
NXP TechSupport
NXP TechSupport

Hi @drb55 

I hope you are doing well.

ls -l /proc/device-tree/__symbols__ | grep spi
ls: cannot access '/proc/device-tree/__symbols__': No such file or directory

 
The above error seems to be different than SPI
 
Please make sure the below-mentioned configurations are in the kernel configuration file.
CONFIG_PROC_DEVICETREE=y
CONFIG_PROC_FS=y
CONFIG_OF=y
 
From the previously mentioned logs, it seems that SPI is correctly initialized.
 
In imx28-evk.dts, spidev compatible sting seems incorrect.
 
spidev1: spi@1 {
                #address-cells = <1>;
                #size-cells = <1>;
                compatible = "nxp,evalspi";
                reg = <1>; /* CS #1 */
                spi-max-frequency = <5000000>;
        };
 
Please try to use any of the compatible strings in the device tree as mentioned in the previous reply.
 
Please try testing with /tools/spi/spidev_test.c
 
Thanks & Regards,
Sanket Parekh
0 Kudos
Reply
2,904 Views
drb55
Contributor III

Hi,

My apologies I uploaded an old dts file. I have attached the dts file I am using, spidev doesn't appear to be working.

I am using this command to test and see nothing on the scope. echo "hello" > /dev/spidev1.1

Please advise on how to use spidev_test.c. 

Thanks,

Dan

0 Kudos
Reply
2,826 Views
Sanket_Parekh
NXP TechSupport
NXP TechSupport

Hi @drb55 

I hope you are doing well.
 
One can use the below commands to test spidev.
# spidev_test -h // to get help 
# spidev_test -D /dev/spidev1.1 -v
 
Additionally one can refer to test/mxc_spi_test.
 
As you are using a chip select 1 for spidev, pin mux definition for the same is not available in dts.
 
Thanks & Regards,
Sanket Parekh

0 Kudos
Reply