XU4 SPI speed

Post Reply
hebere
Posts: 28
Joined: Wed Feb 27, 2013 2:56 pm
languages_spoken: english
ODROIDs: Odroid-x2, XU3-Lite
Has thanked: 0
Been thanked: 0
Contact:

XU4 SPI speed

Post by hebere »

Hi,
We are using XU4 as a central computing unit in our device. SPI port of XU4 is used for communication with our MCU. Up to now we were communicating around 18.75Mhz. We need to increase it to a value up to 25Mhz. When we change the frequency in our code, we can not get the required frequency. I made list for the requested frequency and observed frequency.

Requested Observed
10 MHz 9.375 MHz
12.5 MHz 12.5 MHz
15 MHz 12.5 MHz
20 MHz 18.75 MHz
25 MHz 18.75 MHz
30 MHz 18.75 MHz
35 MHz 18.75 MHz
40 MHz 37.5 MHz
50 MHz 37.5 MHz

Is is possible to modify the clk driver or clk source of spi to get the requested output frequency like 22-23 MHz or at least 25 MHz. We have good experience with XU4 formerly with X2. We do not want to change our design.

Best Regards.

User avatar
odroid
Site Admin
Posts: 34849
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean, Japanese
ODROIDs: ODROID
Has thanked: 927 times
Been thanked: 758 times
Contact:

Re: XU4 SPI speed

Post by odroid »

We will check it.
Can you tell me which OS image do you use?
What is your current running Kernel version?

hebere
Posts: 28
Joined: Wed Feb 27, 2013 2:56 pm
languages_spoken: english
ODROIDs: Odroid-x2, XU3-Lite
Has thanked: 0
Been thanked: 0
Contact:

Re: XU4 SPI speed

Post by hebere »

Hi.
OS version is
Ubuntu 18.04.3 (20190910) (MINIMAL, BARE OS)

Kernel version is
Kernel 4.14.176

Best regards.

User avatar
odroid
Site Admin
Posts: 34849
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean, Japanese
ODROIDs: ODROID
Has thanked: 927 times
Been thanked: 758 times
Contact:

Re: XU4 SPI speed

Post by odroid »

I think the clock source divider or PLL flexibility seems to be very limited to generate near 25Mhz.
But we will try to find any possible ways.

User avatar
odroid
Site Admin
Posts: 34849
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean, Japanese
ODROIDs: ODROID
Has thanked: 927 times
Been thanked: 758 times
Contact:

Re: XU4 SPI speed

Post by odroid »

After changing the SPI clock source configuration(80Mhz to 100Mhz) in the Kernel device tree file, we could get the following results.
It is far from the perfection but it looks better than previous one.

10Mhz 10Mhz
12.5Mhz 12.5Mhz
15Mhz 12.5Mhz
20Mhz 16.67Mhz
25Mhz 25Mhz
30Mhz 25Mhz
40Mhz 25Mhz
50Mhz 50Mhz

We will release a Kernel update package within a couple of days.

hebere
Posts: 28
Joined: Wed Feb 27, 2013 2:56 pm
languages_spoken: english
ODROIDs: Odroid-x2, XU3-Lite
Has thanked: 0
Been thanked: 0
Contact:

Re: XU4 SPI speed

Post by hebere »

Thank you for your effort. We are waiting for the update.
Best regards.

User avatar
odroid
Site Admin
Posts: 34849
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean, Japanese
ODROIDs: ODROID
Has thanked: 927 times
Been thanked: 758 times
Contact:

Re: XU4 SPI speed

Post by odroid »

Update the kernel to 4.14.180-176.
It also fixed the annoying SPI warning message in dmesg output.

hebere
Posts: 28
Joined: Wed Feb 27, 2013 2:56 pm
languages_spoken: english
ODROIDs: Odroid-x2, XU3-Lite
Has thanked: 0
Been thanked: 0
Contact:

Re: XU4 SPI speed

Post by hebere »

Again thanks for your effort. We will update the kernel and check.
Best regards.

hebere
Posts: 28
Joined: Wed Feb 27, 2013 2:56 pm
languages_spoken: english
ODROIDs: Odroid-x2, XU3-Lite
Has thanked: 0
Been thanked: 0
Contact:

Re: XU4 SPI speed

Post by hebere »

Hi,

We have made some tests for SPI update based on kernel 4.14.180+ and the results are:

1. Up to and including 16.67Mhz 32-bit SPI transfers seem to be OK.
2. 25Mhz 32-bit SPI transfers has gaps in the communication frame. Please see the image. Maybe DMA can not catch up with SPI?
3. 8-bit and 16-bit SPI transfers always have gaps.
4. 32-bit frames seems to have byte order reversed with compared to kernel 3.10.104+

We can handle byte order reversing but gaps break make our communication.
It is possible to fix the gaps for 25Mhz?

Best Regards.

Image

User avatar
odroid
Site Admin
Posts: 34849
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean, Japanese
ODROIDs: ODROID
Has thanked: 927 times
Been thanked: 758 times
Contact:

Re: XU4 SPI speed

Post by odroid »

Was there no gap before updating the kernel with 18.75Mhz clock speed?

hebere
Posts: 28
Joined: Wed Feb 27, 2013 2:56 pm
languages_spoken: english
ODROIDs: Odroid-x2, XU3-Lite
Has thanked: 0
Been thanked: 0
Contact:

Re: XU4 SPI speed

Post by hebere »

We did the test again. We can confirm that with 18.75Mhz, there is no gap.

User avatar
odroid
Site Admin
Posts: 34849
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean, Japanese
ODROIDs: ODROID
Has thanked: 927 times
Been thanked: 758 times
Contact:

Re: XU4 SPI speed

Post by odroid »

We will check whether we can reduce the gap or not with 25Mhz transfer speed.
But we may need two weeks due to some urgent problems.

hebere
Posts: 28
Joined: Wed Feb 27, 2013 2:56 pm
languages_spoken: english
ODROIDs: Odroid-x2, XU3-Lite
Has thanked: 0
Been thanked: 0
Contact:

Re: XU4 SPI speed

Post by hebere »

Any news?

User avatar
odroid
Site Admin
Posts: 34849
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean, Japanese
ODROIDs: ODROID
Has thanked: 927 times
Been thanked: 758 times
Contact:

Re: XU4 SPI speed

Post by odroid »

Sorry for late reply.
We tried many different ways to reduced the gap.
But there were always some gaps if the SPI clock speed is higher than 17Mhz.

To avoid this problem, we have to use the PIO mode instead of the DMA mode.
But the SPI PIO mode causes a very high CPU load.
DMA = 4%, PIO = 100%.

Do you need to transfer tons of data via SPI always?
If not, we will try to make a guide how to use the PIO mode after disabling the DMA.

hebere
Posts: 28
Joined: Wed Feb 27, 2013 2:56 pm
languages_spoken: english
ODROIDs: Odroid-x2, XU3-Lite
Has thanked: 0
Been thanked: 0
Contact:

Re: XU4 SPI speed

Post by hebere »

Unfortunately we are making near real-time continuous data acquisition. In 2014 we did some tests on xu3-Lite using PIO mode and we could not achieve uninterrupted data acquisition at that time.
Thanks for your effort.

User avatar
odroid
Site Admin
Posts: 34849
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean, Japanese
ODROIDs: ODROID
Has thanked: 927 times
Been thanked: 758 times
Contact:

Re: XU4 SPI speed

Post by odroid »

I see. :(
We will try a similar test with the ODROID-N2 to find a maximum clock frequency with minimum data intervals.

User avatar
odroid
Site Admin
Posts: 34849
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean, Japanese
ODROIDs: ODROID
Has thanked: 927 times
Been thanked: 758 times
Contact:

Re: XU4 SPI speed

Post by odroid »

We could archive 50Mbps transfer speed on the N2 board SPI port.
But the packet size must have been a multiple of 60. This signal capture shows 240 bytes continuous transmitting.
scope_1.png
scope_1.png (101.64 KiB) Viewed 371 times

If we send 256 bytes, we could see a gap of several micro seconds.
scope_0.png
scope_0.png (105.3 KiB) Viewed 371 times
Since the example code max buffer size is 256, it should be modified to a multiple of 60 with kernel driver parameter together probably.

hebere
Posts: 28
Joined: Wed Feb 27, 2013 2:56 pm
languages_spoken: english
ODROIDs: Odroid-x2, XU3-Lite
Has thanked: 0
Been thanked: 0
Contact:

Re: XU4 SPI speed

Post by hebere »

Thank you for your effort again.

In our device we initiate spi reads in every 50msec using gpio interrupt. We are reading nearly 82200 (this is the nearest multiple of 60 to our transfer buffer) bytes of data in each read. We need SPI speed of 25MHz.
Is it possible to achieve these requirements with ODROID-N2 (gpio interrupt, SPI with speed 25MHz, 2xUART (we are using debug port of xu4 as the second UART interface)).
Another option may be is it possible to have 2 SPI ports at 18.75 MHz with XU4?

Best Regards.

User avatar
odroid
Site Admin
Posts: 34849
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean, Japanese
ODROIDs: ODROID
Has thanked: 927 times
Been thanked: 758 times
Contact:

Re: XU4 SPI speed

Post by odroid »

It seems to be possible even withe much cheaper ODROID-C4. C4 has the exactly same SPI block in the N2.
How many GPIO interrupt inputs do you need? C4/N2 can use only 4 at the same time.

I don't think any ODROID boards can handle multiple SPI ports at that speed.

BTW, can you please tell me what you are making briefly?
We can help you more efficiently if we know your application.

hebere
Posts: 28
Joined: Wed Feb 27, 2013 2:56 pm
languages_spoken: english
ODROIDs: Odroid-x2, XU3-Lite
Has thanked: 0
Been thanked: 0
Contact:

Re: XU4 SPI speed

Post by hebere »

Thanks for your effort.

We are designing and manufacturing an analyzer which reads analog data collected by an MCU at every 50msec and makes analysis on the data. Data ready indication is given as a gpio interrupt generated from MCU and XU4reads data from SPI.
As our data is continuous, we can not tolerate missing interrupt or delayed SPI read. We started our design with X2 and switched to XU4. We have more than 550 analyzer working in the field some of which are working more than 6 years. Now we need to increase data size but we are stuck at SPI speed. We can not use 50Mhz because our MCU can work up to 25Mhz in theory. It is working at 18.75Mhz now. As we will change our design, we can also use two SPI at slower rate also. We need at least 2 gpio with interrupt.

Best Regards.

User avatar
odroid
Site Admin
Posts: 34849
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean, Japanese
ODROIDs: ODROID
Has thanked: 927 times
Been thanked: 758 times
Contact:

Re: XU4 SPI speed

Post by odroid »

I see.
ODROID-C4 can use up to 8 GPIO interrupts at the same time if the slave devices use rising or falling edges.
If the slave devices use rising and falling together, the number of GPIO interrupts is limited at 4.
Also note that the C4/N2 GPIO voltage level is 3.3Volt while the X2/XU4 is 1.8Volt.
It seems to be another benefit for interfacing a MCU device.

We will try connecting a SPI flash memory to the ODROID-C4 board to evaluate the actual maximum data reading transfer rate at 25Mhz frequency.
If the actual data transfer rate is over 20Mbps or 2.5M Byte/sec, ODROID-C4 can be a solution for your application.
Let me know whether that approach is acceptable or not.

hebere
Posts: 28
Joined: Wed Feb 27, 2013 2:56 pm
languages_spoken: english
ODROIDs: Odroid-x2, XU3-Lite
Has thanked: 0
Been thanked: 0
Contact:

Re: XU4 SPI speed

Post by hebere »

Thanks for your effort,

We were using level shifter for X2 and XU4 which would also limit our SPI speed for 25Mhz. 3.3V level will be a great achievement.
If your tests for 25Mhz pass successfully, we will get one C4 or N2 and test our application.

Best regards.

User avatar
odroid
Site Admin
Posts: 34849
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean, Japanese
ODROIDs: ODROID
Has thanked: 927 times
Been thanked: 758 times
Contact:

Re: XU4 SPI speed

Post by odroid »

Ok. we will order a couple of SPI flash memory chips for testing soon.

Post Reply

Return to “Hardware and peripherals”

Who is online

Users browsing this forum: No registered users and 2 guests