-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LAN865x not working with RT1170 & RT1064 (likely caused by LPSPI issues) #69658
Comments
CC @decsny @lmajewski |
If you can narrow down if it is an LPSPI issue or LAN865 issue that would be helpful because I don't have a LAN865, and the author of the driver most likely does not have a platform with LPSPI. Since you said it works on other platforms, maybe you can compare the SPI signals with a signal analyzer between those platforms and the RT1064 to see where is the difference as your next step in debugging. |
@mariopaja - I only had the Nucleo Devel board for T1S development. I've tried to use the Zephyr kernel's well defined APIs, so I assume that semaphores shall work in the same way cross platform. From the above comment - Could you share which HW revision of LAN8651 do your have? (B0 or B1) Just a side note - I shall have come back to this driver in short time, as the full duplex transmission needs to be finished (now it is a very simple, working half-duplex driver). |
with RISK-V yes. I would definitely have to do a second test round with all the MCUs. I am also suspicious on the driver itself because I have faced issues with the chip select, and there are other developers that are mentioning that they are facing difficulties like #69692 (comment). These made me a bit suspicious and confused because these two issues are not directly related to each other. I will be able to provide the SPI signals for STM, NXP, & ESP32-S3/C3 by the end of the next working week. |
There is this issue with the LPSPI CS tracked here: #16544 , maybe consider if this is a cause |
@lmajewski @decsny
|
I was able to point the error to: zephyr/drivers/ethernet/oa_tc6.c Line 309 in ca527d9
before getting the following error: and is is either transmitting the first 3 bytes of the header and then the SPI stops transmitting or the SPI doesnt start the transmittion at all like the image below: @decsny It also seems like the SPI is transmitting 16 bytes at a time without any delay between each byte transmission (image below). Maybe this is creating a bottleneck. Is there a possibility to lower the transmission speed between the bytes and make it look more like the behaviour of STM32 H563 (image below)? |
@lmajewski for further testing I added the following code to zephyr/drivers/ethernet/oa_tc6.c Line 272 in ca527d9
|
@lmajewski I finished the patch today for the rt1064 and I could get the expected behaviour and transmit & recevie packets. @decsny Is there any particular reason why it would work with one and not with the other?
|
@mariopaja - Am I correct, that you need to delay the transmission start between sending first byte and the CS being low? As well as your's CPU (to talk with LAN965x) requires some time between sending each byte?
The SPI transmission shall not impact the TC6 driver - it shall be tuned in the CPU setup code. It looks like the issue is either with the way LAN8651 is communicating via SPI or with the NXP's RT1170 HAL's SPI driver. Could you check if LAN8651 documentation has any requirements for it? Maybe you's SPI setup (like polarity or CLK frequency) is different than that required? Could you also check if lowering the SPI frequency helps with the communication stability on your setup? |
@lmajewski I think it has to do with the MCUX SPI HAL, because the issue arises as TC6 tries to transmit 4 bytes of the header.
For this reason I circumvented this issue with the patch here: #69658 (comment). Instead of providing two buffers at different lengths I give one big buffer to SPI. As a solution it may be enough for our case but it is at no means a good solution. |
@mariopaja - I do have an impression that the patch you mentioned would we OK only for some short time.... In the long term IMHO it would be better to have this issue investigated and correctly fixed in the HAL. Maybe NXP's maintainers (especially for HAL) shall be informed about the issue? Maybe they could look on this problem? |
This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time. |
@mariopaja I have been looking into the lpspi driver lately because of various other issues, and I have a feeling they are related to your issue with this. For example, the chip select is not remaining asserted throughout the whole transfer, that could be the issue, or a host of other ones that I am finding. Basically, the lpspi driver is not even implementing the zephyr api correctly in my opinion at all. I am doing a major rework of this driver that probably will not show up until after LTS because it is too major of a change for this current release cycle. |
This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time. |
This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time. |
Hi @decsny, |
@mariopaja it is WIP but might be interesting to try #82877 version of the lpspi driver which I have working on RT series. To be clear I do not know what is the actual issue on this ticket, that PR is addressing another issue but it totally rewrites the driver from scratch so maybe it has as different behavior for you. And it should remove the HAL from the equation. |
This PR is more robust now so I highly recommend to try it. In addition to that, there are these three configuration options of the LPSPI hardware that are currently supported in the binding: zephyr/dts/bindings/spi/nxp,lpspi.yaml Lines 17 to 34 in 3df9b5f
I think you should try configuring those how you need, especially the |
Hi @decsny, I tried your suggestions on mimxrt1064_evk and the issue is still persistant.
|
looking at the datasheet for the LAN8650, you need to set |
Hi @decsny, I was finaly able to make the lan865x work. The initialization seems succesful without any errors. However, at the moment I am not able to test it further. BTW, something that I noticed: Will this PR be backported to v3.7 LTS? MIMXRT1064_EVK Overlay:
|
It's not clear to me what fixed the issue for you, was it those two properties I mentioned, or that PR, Or the frequency being limited to 2 MHz? Or all of them together? We should make sure this is clear before considering this closed. Also, if the frequency has to be limited to 2 MHz, that still seems like another kind of bug And no , sadly the PR probably cannot be justified for any backports, as it's not just that one PR but a collection, with thousands of lines of changes, and the driver completely rewritten from scratch... although technically it was all in pursuit of fixing bugs, I think release team would not allow it.... |
@decsny The frequency when set above 2MHz becomes unstable. The higher it is set the more it fluctuates. |
Is it possibly a sampling rate issue ? |
@mariopaja @decsny - The reduction of SPI frequency to 2MHz seems to me like just papering over the real issue. |
@decsny I doubt that, in such cases the measurement fails or I get an error. In general I am not expecting to reach 20MHz clock frequency, because none of the other boards tested before did but it should reach a certain frequency and then be more or less stable. As I remember, when set to 10MHZ I could see variations from 2MHz to 10MHz. This pushed me to lower the frequency. |
Absolute maximum frequency of LPSPI on RT1064 is 30 MHz. This can be lower depending on the clock source provided to the peripheral, so maybe that is something to look at. Otherwise, there should be no logical/software reason that the LPSPI generates an unstable clock, so only other thing I can think to check is all the electrical specifications of the LAN865 and RT1064 , and pinctrl settings. |
@decsny what clock configuration/source changes would you recommend to test? Were there changes on the clock sources between v3.7 & this PR? As I remember on v3.7 the clock was more or less stable compared to now. |
I'm still unclear what was the thing that fixed the issue here. There was no mention of a regression in SCK stability from 3.7 until now. So far there are 3 variables here:
Can you please isolate each variable here and clarify which one(s) are actually having any effect |
@decsny I did the following tests
|
@mariopaja I'm assuming this is with current main? It seems like the issue is resolved for the LAN functioning so maybe we can close this issue? Except why is the SCK only 4 MHz when set otherwise ? is this another issue ? and does it only happen for the RT parts? |
I was using #82877 for the tests.
It seems like this PR has already addressed the issue seen on v3.7. I think we can close this issue.
The clock would be nice to know why it has such behaviour. However, I will try to do some more tests on RT parts but also on other MCUs. Afterwards, I might open onether issue addressing it |
@mariopaja @decsny Just for the record - on STM32 based system - the SPI frequecy: I'm just concerned, that 2MHz is way too slow and there must have been issue with the NXP's SPI driver. |
@lmajewski I will also do some more tests with u575 and rt1064 with other measurement devices to determine if the issue was the used logic analyser. I will also post the results in this issue and then open another issue just for the RT part SCK |
We have been testing the LAN865x driver and we have had problems with RT1064 and RT1170.
Our main focus was NXP RT1064 but we were not able to implement LAN865x and therefore ended up testing it with several MCU to see what is going wrong.
From the table below it seems that LAN865x works totally fine with other ARM, RISK-V & XTENSA MCUs but not with RT1064 & RT1170
XIAO ESP32C3
![esp32c3](https://private-user-images.githubusercontent.com/28357816/312459958-7289807b-597e-4a07-a8ae-1176283327f4.JPG?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxNTk2MTEsIm5iZiI6MTczOTE1OTMxMSwicGF0aCI6Ii8yODM1NzgxNi8zMTI0NTk5NTgtNzI4OTgwN2ItNTk3ZS00YTA3LWE4YWUtMTE3NjI4MzMyN2Y0LkpQRz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEwVDAzNDgzMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWJmMjcxN2QxMGM1NTUwOTIyNzBkNmMyMGMzN2EyNDRlZWJkYzQzNzllMmEyOTI5OGIwNmVmOTBjZGNkYWFjMTgmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.fcmOB69yrFqIk6ycSvvBcw4c_3I73fry_36BoGqBFu0)
XIAO ESP32S3
![xiao_esp32s3](https://private-user-images.githubusercontent.com/28357816/312464307-eacc64e0-63fa-47df-8dd3-73b5fdf7d18e.JPG?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxNTk2MTEsIm5iZiI6MTczOTE1OTMxMSwicGF0aCI6Ii8yODM1NzgxNi8zMTI0NjQzMDctZWFjYzY0ZTAtNjNmYS00N2RmLThkZDMtNzNiNWZkZjdkMThlLkpQRz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEwVDAzNDgzMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTQ3NjMxYjI1NTkxNmYxZDE0OWMxZjMxNjExMTI4YTExYjBiOGViZThiYjkwZDM2NDA5NzY2ZjQ2N2E1MmYwZWUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.u0kkPxTRkvrhr_oapqzH5F5lX4yv28n4Bqds9Qs9id4)
NUCLEO H563
![h563](https://private-user-images.githubusercontent.com/28357816/312460114-5cc36e69-7a47-4807-8983-12570c614f0b.JPG?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxNTk2MTEsIm5iZiI6MTczOTE1OTMxMSwicGF0aCI6Ii8yODM1NzgxNi8zMTI0NjAxMTQtNWNjMzZlNjktN2E0Ny00ODA3LTg5ODMtMTI1NzBjNjE0ZjBiLkpQRz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEwVDAzNDgzMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTQzOGNjYjYzOGRhM2JkNTUyNTlkMmQ5NDY5YWM4YWUxNWZkODU3MGYzNjNmMzAzNzk5NzQwNzFhMDYxYzU2MzYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.yzejGINeVadsB7o1Wx1MwI_BioKkQ8Q2jWyXvoeZiSE)
RT1170 LAN865x
![rt1170_lan865x](https://private-user-images.githubusercontent.com/28357816/312460252-d5f57142-beff-4f29-96c0-255b2a6fd25a.JPG?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxNTk2MTEsIm5iZiI6MTczOTE1OTMxMSwicGF0aCI6Ii8yODM1NzgxNi8zMTI0NjAyNTItZDVmNTcxNDItYmVmZi00ZjI5LTk2YzAtMjU1YjJhNmZkMjVhLkpQRz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEwVDAzNDgzMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTU1Yjg4OTE4NTY2N2RjODFhMTQwNDJhYWU2NjFhMDY5ODUwOGFmOWFmMDFmOGE1N2EyNTZjYjE1M2U1NTMzM2ImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.laN4SLH9NbxdSJNj06FMXsLIYtCj_fccI6zwrVb4BTI)
RT1064
![rt1064](https://private-user-images.githubusercontent.com/28357816/313683904-a3c479fe-a103-4370-9002-3dd1d8cd05fd.JPG?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxNTk2MTEsIm5iZiI6MTczOTE1OTMxMSwicGF0aCI6Ii8yODM1NzgxNi8zMTM2ODM5MDQtYTNjNDc5ZmUtYTEwMy00MzcwLTkwMDItM2RkMWQ4Y2QwNWZkLkpQRz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEwVDAzNDgzMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTc0Y2QwOTk4M2MyYjI1MDM2ZGNiNDIyMmIwN2ZmZWJjOGUyMmI5NjllNGVlYWM2ODViODgwMTdiMGVlMzRhYzImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.CP5lIymb5WC5Xhvlj6F0U40IIDJ4wx1Th-jRcATHut8)
Additionally a test with W5500 module
![rt1170_w5500](https://private-user-images.githubusercontent.com/28357816/312460997-cfc2bad8-3db1-46ba-aaa2-2592a90e0824.JPG?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxNTk2MTEsIm5iZiI6MTczOTE1OTMxMSwicGF0aCI6Ii8yODM1NzgxNi8zMTI0NjA5OTctY2ZjMmJhZDgtM2RiMS00NmJhLWFhYTItMjU5MmE5MGUwODI0LkpQRz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEwVDAzNDgzMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTQ3NDcxNDIzODJjMTdmNDYxZTIzNDU2MDAwYzAxMzQwYmM5ODE5MTE2YTQwOGFjMjVlMjJlNWFhZTBlMDhkNzQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.fC6yi9Hn24oE8iHz0iawXdSf6vypkiUXKhuxKyL9kJ0)
RT1170 W5500
The text was updated successfully, but these errors were encountered: