Change SPI speed on IMX8 with TorizonCore

Hello,

I’m new in using Toradex and TorizonCore, so sorry for refreshing the topic, but need to go to the source. I’m using Apalis IMX8 on Ixora Carrier Board connected to MCT070HDMI-B-CTP touch screen via HDMI. Before I used Apalis TK1 on Ixora. I have made both Quickstart Guides – with building image on TK1 with Yocto, and using containers and Torizon OTA on IMX8 (thank you for them). At this moment I’ve got two different images on my IMX8 boards – one of them is Reference Multimedia Image on IMX8 build with Yocto, and second is .yaml file from your tutorial consisting of two containers – Weston-vivante and kiosk-mode-browser uploaded via Torizon OTA.

In spite of customizing image I’d like to customize hardware – the SPI speed. As you mentioned before (Enable SPI iMX8QM) SPI on IMX8 is implemented as kernel module. Exploring device-trees for my board I found only option to set SPI max speed, should I add to option “assigned-clock-rates = value;” to device-tree? Why fsl-imx8qm-apalis.dts file is absent in device-tree and overlays repository after running :


torizoncore-builder dt-checkout

Should I use TorizonCore Builder to customize it? I’m not sure how to do this – changing device tree, customize kernel arguments or building external kernel module? What is interesting SPI working properly on image build on Yocto, with speed of 500kB and I can check this out with spidev_test. Unfortunately, spidev_test command can’t be found on second board, where image is based on .yaml file. How can I add it also to this image? On both boards there are spidev in /dev localization. Or, maybe I should resort directly to kernel using spi_ioc_transfer (Linux Kernel: spi_ioc_transfer Struct Reference) ?

Hi @ml_man ,

Thank you for reaching out to Toradex.

It would be easier for us if you could split your questions into different posts here in the community. I see that there are questions about SPI, Device Tree and OTA.

Could you please create posts for each question separately?

In the meantime, we’re already having a first look.

Best Regards
Kevin

Hi @kevin.tx ,
SPI and speed customization is connected with Device Tree, so I’ve moved problem with OTA to new post.

Hi @ml_man,

The fsl-imx8qm-apalis.dts device tree was used in an older Kernel version. The current file that has the lpspiX node declaration along with the assigned-clock-rates property is imx8-ss-dma.dtsi. Which is located in device-trees/dts-arm64/ if you use torizoncore-builder dt-checkout. You can also find it in our git repo: imx8-ss-dma.dtsi « freescale « dts « boot « arm64 « arch - linux-toradex.git - Linux kernel for Apalis, Colibri and Verdin modules.

About changing the device tree, that depends of the actual SPI clock speed you want to set. In our device tree by default assigned-clock-rates= <60000000>; (60 MHz) and in imx8-apalis-v1.1.dtsi (imx8-apalis-v1.1.dtsi « freescale « dts « boot « arm64 « arch - linux-toradex.git - Linux kernel for Apalis, Colibri and Verdin modules) spi-max-frequency = <4000000>; (4 MHz), so you should be able to increase the SPI clock up to 4 MHz without altering the device tree. If you want higher frequencies then you will have to change the device tree, which you could do using TorizonCore Builder. You can use the topics that you’ve linked as a reference to set up the frequencies.

I hope this helps clear up some of the confusion. With all that said, what is your target speed here for SPI? As I said above you may not need to change much at all.

Best Regards,
Jeremias

1 Like

Hi @jeremias.tx,
thank you for your answer, it helped me clear some confusions up.
I need just 2 MHz SPI frequency. To test if my container communicating properly with IMX’s GPIO’s I have added spidev_test from source:

https://github.com/rm-hull/spidev-test

and run the test with different speed. Everything seems to be fine. If I need more than 4 MHz I need to change device tree with TorizonCore Builder - I’ll try to do it if it will be necessary. Thank you for your help!

Seems like then everything is more or less good for your use-case. I’m glad I could be of assistance.

Best Regards,
Jeremias

1 Like