Closed jschoch closed 11 months ago
the whole rio.c part needs to be rewritten, but unfortunately we have too many other things to do at the moment.
CS1 is used for SPI communication and CS0 was intended for flashing. However, there is probably a bug in the SPI, so I can't use CS1 in the normal way and have to set it manually.
I can make a PR to fix make CS a define for variable and to fix the issue with the crash, just let me know if you are ok and I'll submit it for review.
PR's are always welcome
is this the template for the rio header? tests/data/tangnano9k_1/rio.h
no, the header is build by this python script:
generators/linuxcnc_component/linuxcnc_component.py
do you want the PR against master, or should I make a branch?
main (is the master) is ok
I wonder if you've considered using a template library like mako or something for the header generation. I'm not really much of a python programmer but it seems like it maybe would be worthwhile for readability.
also, you may not need to do anything to MISO/MOSI since the RPI overlay seems to be setting all that up (including CLK) It may be cleaner to just toggle the CS pin and ignore the rest...
I wonder if you've considered using a template library like mako or something for the header generation. I'm not really much of a python programmer but it seems like it maybe would be worthwhile for readability.
the python code generates a little bit more then only the header file and there is not realy a benefit to use an extra template system for it
also, you may not need to do anything to MISO/MOSI since the RPI overlay seems to be setting all that up (including CLK) It may be cleaner to just toggle the CS pin and ignore the rest...
I would be happy if someone could clean up the code :)
the c-code is copied from the remora project and i'm glad that it works. as i said, everything needs to be reworked.
is merged and worked, man thanks !!!
but can not see you as a contributor :( https://github.com/multigcs/LinuxCNC-RIO/graphs/contributors
sorry for that, maybe because i merged it via the console and over the github button, or i have changed to much :(
Through some trials and tribulations I will skip here I discovered that if linuxcnc crashes then the SPI setup of my pi 4 would get into some strange state and I could no longer connect to the tang 9k.
The naive fix was to reboot, the less hair pulling fix is to remove and restart the spi module
This seems to have something to do with the set_pud command here
https://github.com/multigcs/LinuxCNC-RIO/blob/2507c97df8856cc6f45211df77ebed181ab243cc/generators/linuxcnc_component/rio.c#L282
Also, noticed that this is hard coded to CE0 in the initialization but elsewhere it is using a CE1 pin
https://github.com/multigcs/LinuxCNC-RIO/blob/2507c97df8856cc6f45211df77ebed181ab243cc/generators/linuxcnc_component/rio.c#L1175
this manifests as per below
In the unstuck state GPIO 7 doens't have the SPI alt state and a crashing linuxcnc doesn't lock SPI up. The other way to see the stuck state is with qt_spitest.py where all the rx values are the same and modprobe remove/restart the spi module allows the qt_spitest.py to work again.
I can do a PR to make the CS pin a define or variable if you are open to it, may also be worthwhile to make the other pins easier to update with some notes on how to set the overlay to enable spi1..4