Project

General

Profile

spidev loopback testing not working

Added by Sandeep Sivadas about 1 year ago

Hi,

We tried to configure SPI4 in the devkit by following the guidelines in the below link "(https://support.criticallink.com/redmine/projects/mitysom_am57x/wiki/Linux_Application_Using_spidev)".
As per the link we changed mux_data.h file and the "am57xx-mitysom-baseboard.dtsi" file , then flashed the MLO and u-boot.img in to the sd-card and also copied zImage, /rootfs/lib/modules/4.19<rest_of_name> and other .dtb files so as to built the kernel.
spidev4.0 and spidev4.1 are listed in /dev. But SPI fails the loopback test when we tried spidev_test.c application
Kindly look in to it.

with regards
Sandeep S


Replies (9)

RE: spidev loopback testing not working - Added by Michael Williamson about 1 year ago

Hi Sandeep,

Are you trying to loop spidev4.0 to spidev4.1? Or are you looping back one of the two devices onto themselves (e.g., SPI4_D0 connected to SPI4_D1 on same SPI channel)?

The example you linked to does not perform a loopback, it just demonstrates transmitting data (the received data is all zeros).

Have you scoped the CLK or output data to confirm you have the pin mux setup correctly?

Can you provide the output of the spidev_test command (in verbose mode) so we can see what the failure mode is?

With regards,
Mike

RE: spidev loopback testing not working - Added by Sandeep Sivadas about 1 year ago

Hi Mike,

Output of the spidev_test obtained is

root@mitysom-am57x:~# ./spidev_test -D /dev/spidev4.0 -v
spi mode: 0x0
bits per word: 8
max speed: 500000 Hz (500 KHz)
TX | FF FF FF FF FF FF 40 00 00 00 00 95 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF F0 0D | ......@....�.................
RX | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | .............................

I scoped the CLK and SPI4_D0, there is no CLK or data signal is coming. I followed the same steps as in the wiki page.
Also when i updated the Kernel and uboot images, USB, 2 Ethernet and HDMI functionalities also not working

With regards
Sandeep S

RE: spidev loopback testing not working - Added by Jonathan Cormier about 1 year ago

Sandeep Sivadas wrote in RE: spidev loopback testing not working:

Hi Mike,

Output of the spidev_test obtained is

root@mitysom-am57x:~# ./spidev_test -D /dev/spidev4.0 -v
spi mode: 0x0
bits per word: 8
max speed: 500000 Hz (500 KHz)
TX | FF FF FF FF FF FF 40 00 00 00 00 95 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF F0 0D | ......@....�.................
RX | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | .............................

I scoped the CLK and SPI4_D0, there is no CLK or data signal is coming. I followed the same steps as in the wiki page.

If there was no output seen on the CLK or D0 then it is very likely that the pinmux was not updated.
I added a troubleshooting section to the wiki page, to step you through printing out the pinmux so we can verify it was set correctly.
https://support.criticallink.com/redmine/projects/mitysom_am57x/wiki/Linux_Application_Using_spidev#Verify-pinmux-change-in-u-boot-was-done-correctly

Also when i updated the Kernel and uboot images, USB, 2 Ethernet and HDMI functionalities also not working

This is concerning, are you able to build the kernel and u-boot without any changes and get these devices to function?
Can you share what commands you are running to build and copy the files to the devkit? As well as a boot log?

With regards
Sandeep S

RE: spidev loopback testing not working - Added by Sandeep Sivadas about 1 year ago

Hi,

I tried the devmem2 commands.The output got as follows

root@mitysom-am57x:/dev# devmem2 0x4A003460
/dev/mem opened.
Memory mapped at address 0xb6f15000.
Read at address 0x4A003460 (0xb6f15460): 0x0004000E

Then i updated the mux_data.h file for SPI4 pinmux and followed the step as in link https://support.criticallink.com/redmine/projects/mitysom_am57x/wiki/U-Boot_Setup_Pinmux
But instead of changing contents of core_padconf_array_essential_mitysom_devkit , i changed in core_padconf_array_essential_mitysom_nonfpga_devkit located at /boards/cl/mitysom57x/mux_data.h

and then followed the steps in link https://support.criticallink.com/redmine/projects/mitysom_am57x/wiki/U-Boot_Building_for_MitySOM-AM57X
Copied MLO and u-boot.img to the SD card. Now the SPI4 loop back is working. (Kernel building is already performed as in the wiki page)

the output obtained are

root@mitysom-am57x:/opt# devmem2 0x4A003460
/dev/mem opened.
Memory mapped at address 0xb6fec000.
Read at address 0x4A003460 (0xb6fec460): 0x00050008
root@mitysom-am57x:/opt# ./spidev_test -D /dev/spidev4.0 -v
spi mode: 0x0
bits per word: 8
max speed: 500000 Hz (500 KHz)
TX | FF FF FF FF FF FF 40 00 00 00 00 95 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF F0 0D | ..........�.................
RX | FF FF FF FF FF FF 40 00 00 00 00 95 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF F0 0D | ......
....�.................

Bootlog file also attaching here. PRU ethernet,HDMI etc are still disabled.

RE: spidev loopback testing not working - Added by Jonathan Cormier about 1 year ago

Sandeep Sivadas wrote in RE: spidev loopback testing not working:

Hi,

I tried the devmem2 commands.The output got as follows

root@mitysom-am57x:/dev# devmem2 0x4A003460
/dev/mem opened.
Memory mapped at address 0xb6f15000.
Read at address 0x4A003460 (0xb6f15460): 0x0004000E

Then i updated the mux_data.h file for SPI4 pinmux and followed the step as in link https://support.criticallink.com/redmine/projects/mitysom_am57x/wiki/U-Boot_Setup_Pinmux
But instead of changing contents of core_padconf_array_essential_mitysom_devkit , i changed in core_padconf_array_essential_mitysom_nonfpga_devkit located at /boards/cl/mitysom57x/mux_data.h

Aw okay I didn't know you were using the nonfpga variant, this makes sense. I'll add a note to the wiki.

and then followed the steps in link https://support.criticallink.com/redmine/projects/mitysom_am57x/wiki/U-Boot_Building_for_MitySOM-AM57X
Copied MLO and u-boot.img to the SD card. Now the SPI4 loop back is working. (Kernel building is already performed as in the wiki page)

the output obtained are

root@mitysom-am57x:/opt# devmem2 0x4A003460
/dev/mem opened.
Memory mapped at address 0xb6fec000.
Read at address 0x4A003460 (0xb6fec460): 0x00050008
root@mitysom-am57x:/opt# ./spidev_test -D /dev/spidev4.0 -v
spi mode: 0x0
bits per word: 8
max speed: 500000 Hz (500 KHz)
TX | FF FF FF FF FF FF 40 00 00 00 00 95 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF F0 0D | ..........�.................
RX | FF FF FF FF FF FF 40 00 00 00 00 95 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF F0 0D | ......
....�.................

Bootlog file also attaching here. PRU ethernet,HDMI etc are still disabled.

There are several kernel modules which are built outside of the kernel source directory and included in the sdcard by yocto. These need to be copied to the new kernel modules directory or video (pvrsrvkm.ko) and the pru stuff will stop working.

It is enough to copy the extra folder from the original kernel modules directory to the new one

root@mitysom-am57x:~# ls /lib/modules/4.19.94-g913a232ac5/extra/
cmemk.ko            debugss_kmodule.ko  gdbserverproxy.ko   uio_module_drv.ko
cryptodev.ko        galcore.ko          pvrsrvkm.ko
root@mitysom-am57x:~# cp -R  /lib/modules/4.19.94-g913a232ac5/extra  /lib/modules/<new build directory>

Note in the 57x mitysom-linux-4.19 branch, there is a push.sh script which tried to auto handle this while copying the kernel and modules to a running devkit.

I'll update the wiki to make this more clear.

RE: spidev loopback testing not working - Added by Jonathan Cormier about 1 year ago

This doesn't explain why USB isn't coming up though. Your log doesn't show any USB log statements, the most likely reason would be if the USB kernel modules aren't loaded either.

The following modules should have been auto-loaded for USB to function.

root@mitysom-am57x:~# lsmod | grep -E usb\|dwc
dwc3                   73728  0
udc_core               28672  1 dwc3
extcon_usb_gpio        16384  0
phy_omap_usb2          16384  3
dwc3_omap              16384  0
usbserial              36864  1 ftdi_sio
usbcore               217088  4 ftdi_sio,usbserial,xhci_plat_hcd,xhci_hcd
usb_common             16384  3 udc_core,usbcore,dwc3

I suspect if you run lsmod, you won't have any modules loaded. This would mean you need to copy the modules from the INSTALL_MOD_PATH mentioned in the linux wiki.

The build.sh and push.sh scripts should handle this nicely.

./build.sh && ./push.sh root@IPADDRESS

RE: spidev loopback testing not working - Added by Sandeep Sivadas about 1 year ago

Hi,
I tried the kernel and u-boot building as suggested and included the "extra" folder. Now SPI communication, Ethernet,USB etc are working fine. Only one difficulty faced in the Kernel building and copying to /lib/module portion. There I have to create a kernel folder and copied the contents from my PC to SD card. Otherwise kernel modules are pasted inside the module folder.

cd ../rootfs/lib/modules/4.19<rest_of_name>
rsync -r kernel modules* root@${TARGIP}:/lib/modules

Please take a look at this command.

Thank you for your support
Sandeep S

RE: spidev loopback testing not working - Added by Jonathan Cormier about 1 year ago

Sandeep Sivadas wrote in RE: spidev loopback testing not working:

Hi,
I tried the kernel and u-boot building as suggested and included the "extra" folder. Now SPI communication, Ethernet,USB etc are working fine. Only one difficulty faced in the Kernel building and copying to /lib/module portion. There I have to create a kernel folder and copied the contents from my PC to SD card. Otherwise, kernel modules are pasted inside the module folder.

cd ../rootfs/lib/modules/4.19<rest_of_name>
rsync -r kernel modules* root@${TARGIP}:/lib/modules

Please take a look at this command.

You are right that's a little more work than needed. I updated the wiki to simplify the copy commands. The following command should be sufficient to create and copy the files a bit easier.

TARGET=root@10.0.103.50
cd ../rootfs/
rsync -avr lib ${TARGET}:/

RE: spidev loopback testing not working - Added by Jonathan Cormier about 1 year ago

Hint: as long as your changes are only in the device tree file, if you only copy the changed dtb and leave out the zImage, then the kernel version string won't change and you won't have to copy all the kernel modules and copy the extra folder.

    (1-9/9)
    Go to top
    Add picture from clipboard (Maximum size: 1 GB)